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$2(_a, _b, _cum) {
while(true) {
var cum = _cum;
var b = _b;
var a = _a;
var a$1 = Int64.abs(a);
var b$1 = Int64.abs(b);
var r = Caml_int64.sub(a$1, b$1);
if (Caml_int64.compare(a$1, b$1) === 1) {
_cum = Caml_int64.add(cum, Int64.one);
_b = b$1;
_a = r;
continue ;
} else {
return /* tuple */[
Caml_int64.add(cum, Int64.one),
r
];
}
};
}
function ediv_rem$2(a, b) {
if (gt$2(a, Int64.minus_one)) {
return div_rem$2(a, b);
} else {
var match = ediv_rem$prime$2(a, b, Int64.zero);
return /* tuple */[
Caml_int64.neg(match[0]),
Int64.abs(match[1])
];
}
}
function ediv_rem$prime$2(_a, _b, _cum) {
while(true) {
var cum = _cum;
var b = _b;
var a = _a;
var a$1 = Int64.abs(a);
var b$1 = Int64.abs(b);
var r = Caml_int64.sub(a$1, b$1);
if (Caml_int64.compare(a$1, b$1) === 1) {
_cum = Caml_int64.add(cum, Int64.one);
_b = b$1;
_a = r;
continue ;
} else {
return /* tuple */[
Caml_int64.add(cum, Int64.one),
r
];
}
};
}