/* Multiply a number by a small integer in range -185861411 .. 185861411.
The output is in reduced form, the input x need not be.  x and xy may point
to the same buffer.
333085
private static final long10 mul_small(long10 xy, long10 x, long y) {
		long t;
		t = (x._8*y);
		xy._8 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._9*y);
		xy._9 = (t & ((1 << 25) - 1));
		t = 19 * (t >> 25) + (x._0*y);
		xy._0 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._1*y);
		xy._1 = (t & ((1 << 25) - 1));
		t = (t >> 25) + (x._2*y);
		xy._2 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._3*y);
		xy._3 = (t & ((1 << 25) - 1));
		t = (t >> 25) + (x._4*y);
		xy._4 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._5*y);
		xy._5 = (t & ((1 << 25) - 1));
		t = (t >> 25) + (x._6*y);
		xy._6 = (t & ((1 << 26) - 1));
		t = (t >> 26) + (x._7*y);
		xy._7 = (t & ((1 << 25) - 1));
		t = (t >> 25) + xy._8;
		xy._8 = (t & ((1 << 26) - 1));
		xy._9 += (t >> 26);
		return xy;
	}
193864
function uint16BEtoNumber(bytes) {
  var n = 0;
  for (var i = 0; i < 1; i++) {
    n |= bytes[i];
    n <<= 8;
  }
  n |= bytes[1];
  return n;
}
1358952
static public double xy(double[] x, double[] y) {
    double result = 0.0;
    for (int i = 0; i < x.length; i++) {
      result += (x[i] * y[i]);
    }

    return (result);
  }
1261993
public static int toInt(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return (b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8) |
					((b[off + 2] & 0xFF) << 16) | ((b[off + 3] & 0xFF) << 24);
		}
		return ((b[off] & 0xFF) << 24) | ((b[off + 1] & 0xFF) << 16) |
				((b[off + 2] & 0xFF) << 8) | (b[off + 3] & 0xFF);
	}
1181854
public void putUnsignedInt(long i) {
        _buffer[_offset++] = (byte) (i >>> 24 & 0xff);
        _buffer[_offset++] = (byte) (i >> 16);
        _buffer[_offset++] = (byte) (i >> 8);
        _buffer[_offset++] = (byte) i;
    }
455495
function amf3encUI29(num) {
    var len = 0;
    if (num < 0x80) len = 1;
    if (num < 0x4000) len = 2;
    if (num < 0x200000) len = 3;
    if (num >= 0x200000) len = 4;
    var buf = new Buffer(len);
    switch (len) {
        case 1:
            buf.writeUInt8(num, 0);
            break;
        case 2:
            buf.writeUInt8(num & 0x7F, 0);
            buf.writeUInt8((num >> 7) | 0x80, 1);
            break;
        case 3:
            buf.writeUInt8(num & 0x7F, 0);
            buf.writeUInt8((num >> 7) & 0x7F, 1);
            buf.writeUInt8((num >> 14) | 0x80, 2);
            break;
        case 4:
            buf.writeUInt8(num & 0xFF, 0);
            buf.writeUInt8((num >> 8) & 0x7F, 1);
            buf.writeUInt8((num >> 15) | 0x7F, 2);
            buf.writeUInt8((num >> 22) | 0x7F, 3);
            break;
    }
    return buf;
}
1212050
function(number, precision) {

    const multiplier = !!precision ? Math.pow(10, precision) : 1;

    return Math.ceil(number * multiplier) / multiplier;
  }
105778
function (x, y) {
    var i, j, xi, Zi, Vi, lsb_Vi, w=sjcl.bitArray, xor=w._xor4;

    Zi = [0,0,0,0];
    Vi = y.slice(0);

    // Block size is 128 bits, run 128 times to get Z_128
    for (i=0; i<128; i++) {
      xi = (x[Math.floor(i/32)] & (1 << (31-i%32))) !== 0;
      if (xi) {
        // Z_i+1 = Z_i ^ V_i
        Zi = xor(Zi, Vi);
      }

      // Store the value of LSB(V_i)
      lsb_Vi = (Vi[3] & 1) !== 0;

      // V_i+1 = V_i >> 1
      for (j=3; j>0; j--) {
        Vi[j] = (Vi[j] >>> 1) | ((Vi[j-1]&1) << 31);
      }
      Vi[0] = Vi[0] >>> 1;

      // If LSB(V_i) is 1, V_i+1 = (V_i >> 1) ^ R
      if (lsb_Vi) {
        Vi[0] = Vi[0] ^ (0xe1 << 24);
      }
    }
    return Zi;
  }
1258977
public static long multiplyExact(long x, long y) {
        long r = x * y;
        long ax = Math.abs(x);
        long ay = Math.abs(y);
        if (((ax | ay) >>> 31 != 0)) {
            // Some bits greater than 2^31 that might cause overflow
            // Check the result using the divide operator
            // and check for the special case of Long.MIN_VALUE * -1
           if (((y != 0) && (r / y != x)) ||
               (x == Long.MIN_VALUE && y == -1)) {
                throw new ArithmeticException("long overflow");
            }
        }
        return r;
    }
339353
public int multiply(int x, int y) {
    assert(x >= 0 && x < getFieldSize() && y >= 0 && y < getFieldSize());
    return mulTable[x][y];
  }
284761
function() {
    var b = this.buffer, o = this.offset, carry = 1;
    for (var i = o + 7; i >= o; i--) {
      var v = (b[i] ^ 0xff) + carry;
      b[i] = v & 0xff;
      carry = v >> 8;
    }
  }
966467
public static int toShort(byte[] b, int off, boolean littleEndian) {
		if (littleEndian) {
			return ((b[off] & 0xFF) | ((b[off + 1] & 0xFF) << 8));
		}
		return (((b[off] & 0xFF) << 8) | (b[off + 1] & 0xFF));
	}
358955
static int getInt (ByteBuffer buffer) {
        int v = buffer.get();
        int value = v & 0x7F;
        if ((v & 0x80) != 0) {
            v = buffer.get();
            value |= (v & 0x7F) << 7;
            if ((v & 0x80) != 0) {
                v = buffer.get();
                value |= (v & 0x7F) << 14;
                if ((v & 0x80) != 0) {
                    v = buffer.get();
                    value |= (v & 0x7F) << 21;
                    if ((v & 0x80) != 0) {
                        v = buffer.get();
                        value |= (v & 0x7F) << 28;
                    }
                }
            }
        }
        value = (value >>> 1) ^ (-(value & 1));
        return value;
    }
1135095
function () {
        _gpfBinZ = 36969 * (_gpfBinZ & 65535) + (_gpfBinZ >> 16) & _gpfMax32;
        _gpfBinW = 18000 * (_gpfBinW & 65535) + (_gpfBinW >> 16) & _gpfMax32;
        return ((_gpfBinZ << 16) + _gpfBinW & _gpfMax32) + _gpfMax31;
    }
1371493
function ( n, buffer, bytes ) {
                var s = ( n % k ) * slen
                    // how many bytes to read/consume from the input buffer [1 to 4]
                    , rbytes = bytes >>> 0 ? abs( bytes ) % 5 : ibytes
                    , blen = buffer.length - rbytes
                    , bruint = null
                    , sum = 0
                    , b = 0
                    ;
                /*
                 * NOTE: js is not capable to handle integers larger than ~2^53,
                 * when the sum exceeds this limit, we expect to get get biased
                 * results, or in other words, more collisions. It will happens
                 * when we are using large primes as range, or with long buffer
                 * in input. If sum === sum + 1, we could break the for cycle.
                 */
                if ( rbytes === 1 ) {
                    // use [] notation when reading input, 1 byte at the time.
                    if ( ibytes === 1 ) {
                        // read input and seed 1 byte at the time
                        for ( ; b <= blen && s <= rlen; ++b, ++s )
                            sum += buffer[ b ] * result[ s ];
                        return sum % prange;
                    }
                    for ( ; b <= blen && s <= rlen; ++b, s += ibytes )
                        sum += buffer[ b ] * result[ ruint ]( s );
                    return sum % prange;
                }
                // build string for read method (16, 24 or 32 bits unsigned integers)
                bruint =  bruint = 'readUInt' + ( rbytes << 3 ) + 'BE';
                for ( ; b <= blen && s <= rlen; b += rbytes, s += ibytes ) {
                    sum += buffer[ bruint ]( b ) * result[ ruint ]( s );
                    sum %= prange;
                }
                return sum;
            }
762058
static public double EScafferF6NonCont(double[] x) {

    double sum = 0.0;
    double prevX, currX;

    currX = myXRound(x[0]);
    for (int i = 1; i < x.length; i++) {
      prevX = currX;
      currX = myXRound(x[i]);
      sum += ScafferF6(prevX, currX);
    }
    prevX = currX;
    currX = myXRound(x[0]);
    sum += ScafferF6(prevX, currX);

    return (sum);
  }
821209
private static int merging3_2(int[] buffer, int x) {
		int cnt1;
		int cnt2;
		int cnt = 0;
		for (int i = x; i < x + 48; i += 6) {
			cnt1 = buffer[i + 1];
			cnt2 = buffer[i + 3];
			final int w = buffer[i + 5];
			cnt1 = cnt1 - ((cnt1 >>> 1) & 0x55555555) + (w & 0x55555555);
			cnt2 = cnt2 - ((cnt2 >>> 1) & 0x55555555) + ((w >>> 1) & 0x55555555);
			cnt1 = (cnt1 & 0x33333333) + ((cnt1 >>> 2) & 0x33333333);
			cnt1 += (cnt2 & 0x33333333) + ((cnt2 >>> 2) & 0x33333333);
			cnt += (cnt1 & 0x0F0F0F0F) + ((cnt1 >>> 4) & 0x0F0F0F0F);
		}
		cnt = (cnt & 0x00FF00FF) + ((cnt >>> 8) & 0x00FF00FF);
		cnt += cnt >>> 16;
		return cnt & 0x00000FFFF;
	}