def S32.divmod.if
import bend-kit-int@0.2.0.0/int.bend as Intimport Base
606# x / 0 is 0 and x % 0 is x, as in Base's U32. MIN / -1 wraps to MIN.
607def S32.divmod.if(z: Bool, +a: U32, +b: U32) -> U32 & U32:
608 match z:
609 case True{}:
610 (0, a)
611 case False{}:
612 (S32.neg_if(Bool.xor(S32.is_neg(a), S32.is_neg(b)),
613 U32.div(S32.abs(a), S32.abs(b))),
614 S32.neg_if(S32.is_neg(a), U32.mod(S32.abs(a), S32.abs(b))))