41 [[nodiscard]]
inline uint32_t
divInC(uint64_t dividend)
const
43 uint64_t t1 = uint64_t(uint32_t(dividend)) * uint32_t(m);
44 uint64_t t2 = (dividend >> 32) * uint32_t(m);
45 uint64_t t3 = uint32_t(dividend) * (m >> 32);
46 uint64_t t4 = (dividend >> 32) * (m >> 32);
48 uint64_t s1 = uint64_t(uint32_t(a)) + uint32_t(t1);
49 uint64_t s2 = (s1 >> 32) + (a >> 32) + (t1 >> 32) + t2;
50 uint64_t s3 = uint64_t(uint32_t(s2)) + uint32_t(t3);
51 uint64_t s4 = (s3 >> 32) + (s2 >> 32) + (t3 >> 32) + t4;
53 uint64_t result = s4 >> s;
56 assert(result == uint32_t(result));
58 return uint32_t(result);