#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
bool multiplyWillOverflow(uint64_t x, uint64_t y) {
if (x <= 1 || y <= 1) {
return false;
}
uint64_t d = x * y;
return d / y != x;
}
int main() {
uint64_t x = 3, y = 1472783642;
printf("%s\n", multiplyWillOverflow(x, y) ? "true" : "false");
x = 9223372036854775807;
y = 3;
printf("%s\n", multiplyWillOverflow(x, y) ? "true" : "false");
return 0;
}
/*
run:
false
true
*/