def div_fin
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as U64import Base
74# Long division in 32/12/12/8-bit digits: every partial remainder is below
75# d <= 2^20, so each candidate r * 2^12 + digit stays below 2^32.
76def div_fin(+lo: U32, +hi: U32, +d: U32, +t1: U32, +t2: U32, +t3: U32) -> U64:
77 U64{U32.add(U32.add(U32.mul(U32.div(t1, d), 1048576), U32.mul(U32.div(t2, d), 256)), U32.div(t3, d)), U32.div(hi, d)}