diff options
Diffstat (limited to 'contrib/bc/tests/fuzzing/bc_inputs1/len.bc')
-rw-r--r-- | contrib/bc/tests/fuzzing/bc_inputs1/len.bc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/contrib/bc/tests/fuzzing/bc_inputs1/len.bc b/contrib/bc/tests/fuzzing/bc_inputs1/len.bc new file mode 100644 index 000000000000..ec931f2386a5 --- /dev/null +++ b/contrib/bc/tests/fuzzing/bc_inputs1/len.bc @@ -0,0 +1,48 @@ +define fast_gcd(a, b) { + + if (a == b) return a; + if (a > b) return fast_gcd(a - b, b) + + return fast_gcd(a, b - a); +} + +define void r_reduce(*r[]) { + + auto g,s; + + if (length(r[]) != 2) sqrt(-1); + if (scale(r[0])) 2^r[0]; + if (scale(r[1])) 2^r[1]; + + if (r[0] >= 0 && r[1] >= 0) g = fast_gcd(r[0], r[1]); + else g = gcd(r[0], r[1]); + + s = scale; + scale = 0; + + r[0] /= g; + r[1] /= g; + + scale = s; +} + +define void r_init(*r[], a, b) { + r[0] = a; + r[1] = b; + r_reduce(r[]); +} + +define void r_initi(*r[], i, a, b) { + + length(r[]); + + r[0] = i * b + a; + r[1] = b; + + length(r[]); + + r_reduce(r[]); +} + +length(a[]) +r_initi(a[], 5, 63, 94); |