def red96_z
import bend-collections@1.0.0.0/src/math/w64.bend as W64import Base
import bend-collections@1.0.0.0/src/math/u64.bend as W
387# x mod m for x = xh * 2^32 + x0 with xh < m and m >= 2^32
388def red96_z(+xh: W.U64, +x0: U32, +m: W.U64, small: Bool) -> W.U64:
389 match small:
390 case True{}:
391 W.U64{x0, lo(xh)}
392 case False{}:
393 sub(W.U64{x0, lo(xh)}, fst_q(mul_32_64(q96(W.U64{x0, lo(xh)}, hi(xh), m, bitlen(hi(m))), m)))