adc static method

(Uint64, Uint64) adc(
  1. Uint64 a,
  2. Uint64 b,
  3. Uint64 carry
)

Add-with-carry: a + b + carry. Returns (result, carryOut) where carryOut is the numeric carry (0, 1, or 2 — matches Rust's adc, which accepts a full-width carry-in from a preceding mac).

Implementation

static (Uint64 result, Uint64 carryOut) adc(
  Uint64 a,
  Uint64 b,
  Uint64 carry,
) {
  final s1 = a + b;
  final c1 = s1 < a ? Uint64.one : Uint64.zero;
  final s2 = s1 + carry;
  final c2 = s2 < s1 ? Uint64.one : Uint64.zero;
  return (s2, c1 + c2);
}