#include typedef struct { uint64_t hi; uint64_t lo; } uint128_t; void absd128(uint128_t, uint128_t, uint128_t *); void absd128(uint128_t a, uint128_t b, uint128_t *diff) { if ((int64_t)a.hi < (int64_t)b.hi || (a.hi == b.hi && a.lo < b.lo)) { if (b.lo < a.lo) a.hi++; diff->hi = b.hi - a.hi; diff->lo = b.lo - a.lo; } else { if (a.lo < b.lo) b.hi++; diff->hi = a.hi - b.hi; diff->lo = a.lo - b.lo; } }