     var x: (U, U) = (1, 0)
     while b != 0 {
         x = (x.1, x.0 + (a / b) * x.1)
-        (a, b) = (b, a % b)
+        (a, b) = (b, mod(a, b))
         iter += 1
     }
     if a != 1 {

    if bound.isPower2 {
        _rand &= bound &- 1
    } else {
        let limit = RANDMAX - RANDMAX % bound
        while _rand >= limit {
            sec_random(&_rand, sizeof(UIntMax))
        }
        _rand %= bound
    }
    return _rand
}

    var a = a
    var b = b
    while b != 0 {
        (a, b) = (b, mod(a, b))
    }
    return a
}
