// Generated by ReScript, PLEASE EDIT WITH CARE


function gray_encode(b) {
  return b ^ (b >>> 1);
}

function gray_decode(n) {
  let _p = n;
  let _n = (n >>> 1);
  while (true) {
    let n$1 = _n;
    let p = _p;
    if (n$1 === 0) {
      return p;
    }
    _n = (n$1 >>> 1);
    _p = p ^ n$1;
    continue;
  };
}

function next_power(v) {
  let v$1 = v - 1 | 0;
  let v$2 = (v$1 >>> 1) | v$1;
  let v$3 = (v$2 >>> 2) | v$2;
  let v$4 = (v$3 >>> 4) | v$3;
  let v$5 = (v$4 >>> 8) | v$4;
  let v$6 = (v$5 >>> 16) | v$5;
  return v$6 + 1 | 0;
}

export {
  gray_encode,
  gray_decode,
  next_power,
}
/* No side effect */
