Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function ediv_rem$prime$1(_a, _b, _cum) {
while(true) {
var cum = _cum;
var b = _b;
var a = _a;
var a$1 = Int32.abs(a);
var b$1 = Int32.abs(b);
var r = a$1 - b$1 | 0;
if (Caml_primitive.caml_int32_compare(a$1, b$1) === 1) {
_cum = cum + Int32.one | 0;
_b = b$1;
_a = r;
continue ;
} else {
return /* tuple */[
cum + Int32.one | 0,
r
];
}
};
}
function ediv_rem$prime$1(_a, _b, _cum) {
while(true) {
var cum = _cum;
var b = _b;
var a = _a;
var a$1 = Int32.abs(a);
var b$1 = Int32.abs(b);
var r = a$1 - b$1 | 0;
if (Caml_primitive.caml_int32_compare(a$1, b$1) === 1) {
_cum = cum + Int32.one | 0;
_b = b$1;
_a = r;
continue ;
} else {
return /* tuple */[
cum + Int32.one | 0,
r
];
}
};
}
function ediv_rem$1(a, b) {
if (gt$1(a, Int32.minus_one)) {
return div_rem$1(a, b);
} else {
var match = ediv_rem$prime$1(a, b, Int32.zero);
return /* tuple */[
-match[0] | 0,
Int32.abs(match[1])
];
}
}