#[inline]
const fn u128_mulhi(x: u128, y: u128) -> u128 {
let x_lo = x as u64;
let x_hi = (x >> 64) as u64;
let y_lo = y as u64;
let y_hi = (y >> 64) as u64;
let carry = (x_lo as u128 * y_lo as u128) >> 64;
let m = x_lo as u128 * y_hi as u128 + carry;
let high1 = m >> 64;
let m_lo = m as u64;
let high2 = (x_hi as u128 * y_lo as u128 + m_lo as u128) >> 64;
x_hi as u128 * y_hi as u128 + high1 + high2
}
#[inline]
pub(super) fn udivmod_1e19(n: u128) -> (u128, u64) {
let d = 10_000_000_000_000_000_000_u64;
let quot = if n < 1 << 83 {
((n >> 19) as u64 / (d >> 19)).into()
} else {
u128_mulhi(n, 156927543384667019095894735580191660403) >> 62
};
let rem = (n - quot * u128::from(d)) as u64;
debug_assert_eq!(quot, n / u128::from(d));
debug_assert_eq!(u128::from(rem), n % u128::from(d));
(quot, rem)
}