For the above code, if the incoming data is 0x800000000000000, there seems to be a risk of overflow. In some compilers, the data of (int64_t)LONG_MIN may be converted to -2147483648:

When the incoming data is 0x800000000000000 it will go to the processing of -num and the number of -(-9,223,372,036,854,775,808) may be overflow in the range of int64_t (-9,223,372,036,854,775,808~9,223,372,036,854,775,807). And this might lead to the generation of undefined behaviors of the compiler.