Making res unsigned, and casting hi and lo to unsigned long long in the "res = hi + lo;" statement, and casting res back to long long in the two places it gets compared against 0, would be the obvious approach to avoid signed overflow.
Making res unsigned, and casting hi and lo to unsigned long long in the
"res = hi + lo;" statement, and casting res back to long long in the two
places it gets compared against 0, would be the obvious approach to avoid
signed overflow.