/* eslint-enable no-shadow /* eslint-disable no-bitwise
507250
function f32(k64Cnt, x, k32 ) {

        var lB0 = b0(x)
          , lB1 = b1(x)
          , lB2 = b2(x)
          , lB3 = b3(x)
          , k0 = k32[0] || 0
          , k1 = k32[1] || 0
          , k2 = k32[2] || 0
          , k3 = k32[3] || 0
          , result = 0;

        switch (k64Cnt & 3) {
          case 1:
            result = MDS[0][P[P_01][lB0] & 0xFF ^ b0(k0)] ^
                     MDS[1][P[P_11][lB1] & 0xFF ^ b1(k0)] ^
                     MDS[2][P[P_21][lB2] & 0xFF ^ b2(k0)] ^
                     MDS[3][P[P_31][lB3] & 0xFF ^ b3(k0)];
            break;

          case 0:  // same as 4
            lB0 = P[P_04][lB0] & 0xFF ^ b0(k3);
            lB1 = P[P_14][lB1] & 0xFF ^ b1(k3);
            lB2 = P[P_24][lB2] & 0xFF ^ b2(k3);
            lB3 = P[P_34][lB3] & 0xFF ^ b3(k3);
            /* falls through */

          case 3:
            lB0 = P[P_03][lB0] & 0xFF ^ b0(k2);
            lB1 = P[P_13][lB1] & 0xFF ^ b1(k2);
            lB2 = P[P_23][lB2] & 0xFF ^ b2(k2);
            lB3 = P[P_33][lB3] & 0xFF ^ b3(k2);
            /* falls through */

          case 2:
            result = MDS[0][P[P_01][P[P_02][lB0] & 0xFF ^ b0(k1)] & 0xFF ^ b0(k0)] ^
                     MDS[1][P[P_11][P[P_12][lB1] & 0xFF ^ b1(k1)] & 0xFF ^ b1(k0)] ^
                     MDS[2][P[P_21][P[P_22][lB2] & 0xFF ^ b2(k1)] & 0xFF ^ b2(k0)] ^
                     MDS[3][P[P_31][P[P_32][lB3] & 0xFF ^ b3(k1)] & 0xFF ^ b3(k0)];
            break;

          default:
        }

        return result;
      }
47314
function blockEncrypt(input, inOffset, sessionKey) {

        if (input &&
          sessionKey &&
          utils.isAnArray(sessionKey) &&
          utils.isAnArray(input)) {

          input = new Uint8Array(input);
          var sBox = sessionKey[0]
            , sKey = sessionKey[1]

            /*eslint-disable no-plusplus*/
            , x0 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24

            , x1 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24

            , x2 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24

            , x3 = input[inOffset++] & 0xFF |
                   (input[inOffset++] & 0xFF) << 8 |
                   (input[inOffset++] & 0xFF) << 16 |
                   (input[inOffset++] & 0xFF) << 24
            /*eslint-enable no-plusplus*/

            , t0
            , t1
            , k = ROUND_SUBKEYS
            , R = 0;

          x0 ^= sKey[INPUT_WHITEN];
          x1 ^= sKey[INPUT_WHITEN + 1];
          x2 ^= sKey[INPUT_WHITEN + 2];
          x3 ^= sKey[INPUT_WHITEN + 3];
          for (R = 0; R < ROUNDS; R += 2) {

            t0 = fe32(sBox, x0, 0);
            t1 = fe32(sBox, x1, 3);
            /*eslint-disable no-plusplus*/
            x2 ^= t0 + t1 + sKey[k++];
            /*eslint-enable no-plusplus*/
            x2 = x2 >>> 1 | x2 << 31;
            x3 = x3 << 1 | x3 >>> 31;
            /*eslint-disable no-plusplus*/
            x3 ^= t0 + 2 * t1 + sKey[k++];
            /*eslint-enable no-plusplus*/

            t0 = fe32(sBox, x2, 0);
            t1 = fe32(sBox, x3, 3);
            /*eslint-disable no-plusplus*/
            x0 ^= t0 + t1 + sKey[k++];
            /*eslint-enable no-plusplus*/
            x0 = x0 >>> 1 | x0 << 31;
            x1 = x1 << 1 | x1 >>> 31;
            /*eslint-disable no-plusplus*/
            x1 ^= t0 + 2 * t1 + sKey[k++];
            /*eslint-enable no-plusplus*/
          }

          x2 ^= sKey[OUTPUT_WHITEN];
          x3 ^= sKey[OUTPUT_WHITEN + 1];
          x0 ^= sKey[OUTPUT_WHITEN + 2];
          x1 ^= sKey[OUTPUT_WHITEN + 3];

          return new Uint8Array([x2, x2 >>> 8, x2 >>> 16, x2 >>> 24,
             x3, x3 >>> 8, x3 >>> 16, x3 >>> 24,
             x0, x0 >>> 8, x0 >>> 16, x0 >>> 24,
             x1, x1 >>> 8, x1 >>> 16, x1 >>> 24]);
        }

        throw 'input block is not an array or sessionKey is incorrect';
      }
603028
function getbit(key, bitoffset, req) {
  var buf = this.getValueBuffer(key, req)
    , byte = bitoffset >> 3
    , bit = 7 - (bitoffset & 0x7)
    , bitval = 0;
  if(buf === undefined) return 0;
  if(byte < buf.length) {
    bitval = buf[byte] & (1 << bit);
  }
  return bitval ? 1 : 0;
}
134585
function base32DecodeLastCharacter(chunk, characterIndex, buffer, index) {
    const byteIndex = Math.floor(index + (characterIndex * 5) / 8);
    const offset = characterIndex % 8;
    switch (offset) {
        case 1:
            buffer[byteIndex] |= chunk >>> 2;
            break;
        case 3:
            buffer[byteIndex] |= chunk >>> 4;
            break;
        case 4:
            buffer[byteIndex] |= chunk >>> 1;
            break;
        case 6:
            buffer[byteIndex] |= chunk >>> 3;
            break;
        case 7:
            buffer[byteIndex] |= chunk;
            break;
    }
}
876697
function encode(events) {
  if(!Array.isArray(events)) {
    return '00';
  }
  let bitmask = 0;
  for(event in events) {
    let index = events[event];
    bitmask += (1 << index);
  }
  return ('00' + bitmask.toString(16)).substr(-2);
}
1166260
function bits( x ) {
	var b;

	// Convert the input value to a bit string:
	b = div2( x );

	// Left pad the bit string to ensure 8 bits are represented:
	b = lpad( b, NBITS, '0' );

	return b;
}
1031723
function makeLisIndices(a) {
		var p = a.slice()
		var result = []
		result.push(0)
		var u
		var v
		for (var i = 0, il = a.length; i < il; ++i) {
			if (a[i] === -1) {
				continue
			}
			var j = result[result.length - 1]
			if (a[j] < a[i]) {
				p[i] = j
				result.push(i)
				continue
			}
			u = 0
			v = result.length - 1
			while (u < v) {
				var c = ((u + v) / 2) | 0 // eslint-disable-line no-bitwise
				if (a[result[c]] < a[i]) {
					u = c + 1
				}
				else {
					v = c
				}
			}
			if (a[i] < a[result[u]]) {
				if (u > 0) {
					p[i] = result[u - 1]
				}
				result[u] = i
			}
		}
		u = result.length
		v = result[u - 1]
		while (u-- > 0) {
			result[u] = v
			v = p[v]
		}
		return result
	}
294622
function divide(buf, n) {
  /* eslint-disable no-bitwise */
  var i = 0, l, t, rem;

  t = buf[i];
  rem = t % n;
  buf[i] = Math.floor(t / n);

  for (i = 1, l = buf.length; i < l; i++) {
    t = rem * 256 + buf[i];
    rem = t % n;
    buf[i] = Math.floor(t / n);
  }

  return rem;
}
785649
function asciifyImage( canvasRenderer, oAscii ) {

		oCtx.clearRect( 0, 0, iWidth, iHeight );
		oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
		var oImgData = oCtx.getImageData( 0, 0, iWidth, iHeight ).data;

		// Coloring loop starts now
		var strChars = "";

		// console.time('rendering');

		for ( var y = 0; y < iHeight; y += 2 ) {

			for ( var x = 0; x < iWidth; x ++ ) {

				var iOffset = ( y * iWidth + x ) * 4;

				var iRed = oImgData[ iOffset ];
				var iGreen = oImgData[ iOffset + 1 ];
				var iBlue = oImgData[ iOffset + 2 ];
				var iAlpha = oImgData[ iOffset + 3 ];
				var iCharIdx;

				var fBrightness;

				fBrightness = ( 0.3 * iRed + 0.59 * iGreen + 0.11 * iBlue ) / 255;
				// fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255;

				if ( iAlpha == 0 ) {

					// should calculate alpha instead, but quick hack :)
					//fBrightness *= (iAlpha / 255);
					fBrightness = 1;

				}

				iCharIdx = Math.floor( ( 1 - fBrightness ) * ( aCharList.length - 1 ) );

				if ( bInvert ) {

					iCharIdx = aCharList.length - iCharIdx - 1;

				}

				// good for debugging
				//fBrightness = Math.floor(fBrightness * 10);
				//strThisChar = fBrightness;

				var strThisChar = aCharList[ iCharIdx ];

				if ( strThisChar === undefined || strThisChar == " " )
					strThisChar = "&nbsp;";

				if ( bColor ) {

					strChars += "<span style='"
						+ "color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");"
						+ ( bBlock ? "background-color:rgb(" + iRed + "," + iGreen + "," + iBlue + ");" : "" )
						+ ( bAlpha ? "opacity:" + ( iAlpha / 255 ) + ";" : "" )
						+ "'>" + strThisChar + "</span>";

				} else {

					strChars += strThisChar;

				}

			}
			strChars += "<br/>";

		}

		oAscii.innerHTML = "<tr><td>" + strChars + "</td></tr>";

		// console.timeEnd('rendering');

		// return oAscii;

	}
519374
function setBit (buffer, pos, bit) {
  const byte = Math.floor(pos / 8)
  const bitPos = pos % 8

  if (bit === 0) {
    const mask = 255 - (1 << bitPos)
    buffer[byte] &= mask
  } else {
    const mask = (1 << bitPos)
    buffer[byte] |= mask
  }
}
1173519
function FFT() {
  
  var _n = 0,          // order
      _bitrev = null,  // bit reversal table
      _cstb = null;    // sin/cos table
  var _tre, _tim;
  
  this.init = function (n) {
    if(n !== 0 && (n & (n - 1)) === 0) {
      _n = n;
      _setVariables();
      _makeBitReversal();
      _makeCosSinTable();
    } else {
      throw new Error("init: radix-2 required");
    }
  };
    
  // 1D-FFT
  this.fft1d = function (re, im) {
    fft(re, im, 1);
  };
    
  // 1D-IFFT
  this.ifft1d = function (re, im) {
    var n = 1/_n;
    fft(re, im, -1);
    for(var i=0; i<_n; i++) {
      re[i] *= n;
      im[i] *= n;
    }
  };
  
  // 2D-FFT
  this.fft2d = function (re, im) {
    var i = 0;
    // x-axis
    for(var y=0; y<_n; y++) {
      i = y*_n;
      for(var x1=0; x1<_n; x1++) {
        _tre[x1] = re[x1 + i];
        _tim[x1] = im[x1 + i];
      }
      this.fft1d(_tre, _tim);
      for(var x2=0; x2<_n; x2++) {
        re[x2 + i] = _tre[x2];
        im[x2 + i] = _tim[x2];
      }
    }
    // y-axis
    for(var x=0; x<_n; x++) {
      for(var y1=0; y1<_n; y1++) {
        i = x + y1*_n;
        _tre[y1] = re[i];
        _tim[y1] = im[i];
      }
      this.fft1d(_tre, _tim);
      for(var y2=0; y2<_n; y2++) {
        i = x + y2*_n;
        re[i] = _tre[y2];
        im[i] = _tim[y2];
      }
    }
  };
  
  // 2D-IFFT
  this.ifft2d = function (re, im) {
    var i = 0;
    // x-axis
    for(var y=0; y<_n; y++) {
      i = y*_n;
      for(var x1=0; x1<_n; x1++) {
        _tre[x1] = re[x1 + i];
        _tim[x1] = im[x1 + i];
      }
      this.ifft1d(_tre, _tim);
      for(var x2=0; x2<_n; x2++) {
        re[x2 + i] = _tre[x2];
        im[x2 + i] = _tim[x2];
      }
    }
    // y-axis
    for(var x=0; x<_n; x++) {
      for(var y1=0; y1<_n; y1++) {
        i = x + y1*_n;
        _tre[y1] = re[i];
        _tim[y1] = im[i];
      }
      this.ifft1d(_tre, _tim);
      for(var y2=0; y2<_n; y2++) {
        i = x + y2*_n;
        re[i] = _tre[y2];
        im[i] = _tim[y2];
      }
    }
  };
  
  // core operation of FFT
  function fft(re, im, inv) {
    var d, h, ik, m, tmp, wr, wi, xr, xi,
        n4 = _n >> 2;
    // bit reversal
    for(var l=0; l<_n; l++) {
      m = _bitrev[l];
      if(l < m) {
        tmp = re[l];
        re[l] = re[m];
        re[m] = tmp;
        tmp = im[l];
        im[l] = im[m];
        im[m] = tmp;
      }
    }
    // butterfly operation
    for(var k=1; k<_n; k<<=1) {
      h = 0;
      d = _n/(k << 1);
      for(var j=0; j<k; j++) {
        wr = _cstb[h + n4];
        wi = inv*_cstb[h];
        for(var i=j; i<_n; i+=(k<<1)) {
          ik = i + k;
          xr = wr*re[ik] + wi*im[ik];
          xi = wr*im[ik] - wi*re[ik];
          re[ik] = re[i] - xr;
          re[i] += xr;
          im[ik] = im[i] - xi;
          im[i] += xi;
        }
        h += d;
      }
    }
  }
  
  // set variables
  function _setVariables() {
    if(typeof Uint8Array !== 'undefined') {
      _bitrev = new Uint8Array(_n);
    } else {
      _bitrev = new Array(_n);
    }
    if(typeof Float64Array !== 'undefined') {
      _cstb = new Float64Array(_n*1.25);
      _tre = new Float64Array(_n*_n);
      _tim = new Float64Array(_n*_n);
    } else {
      _cstb = new Array(_n*1.25);
      _tre = new Array(_n*_n);
      _tim = new Array(_n*_n);
    }
  }
  
  // make bit reversal table
  function _makeBitReversal() {
    var i = 0,
        j = 0,
        k = 0;
    _bitrev[0] = 0;
    while(++i < _n) {
      k = _n >> 1;
      while(k <= j) {
        j -= k;
        k >>= 1;
      }
      j += k;
      _bitrev[i] = j;
    }
  }
  
  // make trigonometric function table
  function _makeCosSinTable() {
    var n2 = _n >> 1,
        n4 = _n >> 2,
        n8 = _n >> 3,
        n2p4 = n2 + n4,
        t = Math.sin(Math.PI/_n),
        dc = 2*t*t,
        ds = Math.sqrt(dc*(2 - dc)),
        c = _cstb[n4] = 1,
        s = _cstb[0] = 0;
    t = 2*dc;
    for(var i=1; i<n8; i++) {
      c -= dc;
      dc += t*c;
      s += ds;
      ds -= t*s;
      _cstb[i] = s;
      _cstb[n4 - i] = c;
    }
    if(n8 !== 0) {
      _cstb[n8] = Math.sqrt(0.5);
    }
    for(var j=0; j<n4; j++) {
      _cstb[n2 - j]  = _cstb[j];
    }
    for(var k=0; k<n2p4; k++) {
      _cstb[k + n2] = -_cstb[k];
    }
  }
}
1048932
function _makeBitReversalTable() {
    var i = 0,
        j = 0,
        k = 0;
    _bitrev[0] = 0;
    while (++i < _n) {
        k = _n >> 1;
        while (k <= j) {
            j -= k;
            k >>= 1;
        }
        j += k;
        _bitrev[i] = j;
    }
}
308411
function(obj) {
    console.log(`trained in ${ obj.iterations } iterations with error: ${ obj.error }`);

    const result01 = net.run([0, 1]);
    const result00 = net.run([0, 0]);
    const result11 = net.run([1, 1]);
    const result10 = net.run([1, 0]);

    assert(result01[0] > 0.9);
    assert(result00[0] < 0.1);
    assert(result11[0] < 0.1);
    assert(result10[0] > 0.9);

    console.log('0 XOR 1: ', result01);  // 0.987
    console.log('0 XOR 0: ', result00);  // 0.058
    console.log('1 XOR 1: ', result11);  // 0.087
    console.log('1 XOR 0: ', result10);  // 0.934
  }
93856
function findPmiChordsToHighlight() {
      const {
        group: param,
        bin,
        highlight,
        mode: oneBinAllVarsMode,
      } = model.renderState.pmiHighlight;
      if (highlight) {
        svg
          .select('g.pmiChords')
          .selectAll('path.pmiChord')
          .classed('highlight-pmi', false);
      }

      const binMap = {};

      function addBin(pName, bIdx) {
        if (!binMap[pName]) {
          binMap[pName] = [];
        }
        if (binMap[pName].indexOf(bIdx) === -1) {
          binMap[pName].push(bIdx);
        }
      }

      if (oneBinAllVarsMode) {
        svg
          .select('g.pmiChords')
          .selectAll(`path[data-source-name="${param}"]:not(.fade)`)
          .classed('highlight-pmi', highlight)
          .each(function highlightPMI(d, i) {
            const elt = d3.select(this);
            addBin(param, bin);
            addBin(
              elt.attr('data-target-name'),
              Number.parseInt(elt.attr('data-target-bin'), 10)
            );
          });

        svg
          .select('g.pmiChords')
          .selectAll(`path[data-target-name="${param}"]:not(.fade)`)
          .each(function inner(d, i) {
            const elt = d3.select(this);
            addBin(param, Number.parseInt(elt.attr('data-target-bin'), 10));
            addBin(
              elt.attr('data-source-name'),
              Number.parseInt(elt.attr('data-source-bin'), 10)
            );
          });

        if (binMap[param] && binMap[param].indexOf(bin) >= 0) {
          binMap[param] = [bin];
        }

        svg
          .select('g.pmiChords')
          .selectAll(`path[data-target-name="${param}"]:not(.fade)`)
          .classed('highlight-pmi', function inner(d, i) {
            const elt = d3.select(this);
            return (
              binMap[param].indexOf(
                Number.parseInt(elt.attr('data-target-bin'), 10)
              ) >= 0
            );
          });
      } else {
        svg
          .select('g.pmiChords')
          .selectAll(
            `path[data-source-name="${param}"][data-source-bin="${bin}"]:not(.fade)`
          )
          .classed('highlight-pmi', highlight)
          .each(function highlightPMI(d, i) {
            const elt = d3.select(this);
            addBin(param, bin);
            addBin(
              elt.attr('data-target-name'),
              Number.parseInt(elt.attr('data-target-bin'), 10)
            );
          });

        svg
          .select('g.pmiChords')
          .selectAll(
            `path[data-target-name="${param}"][data-target-bin="${bin}"]:not(.fade)`
          )
          .classed('highlight-pmi', highlight)
          .each(function highlightPMI(d, i) {
            const elt = d3.select(this);
            addBin(param, bin);
            addBin(
              elt.attr('data-source-name'),
              Number.parseInt(elt.attr('data-source-bin'), 10)
            );
          });
      }

      return binMap;
    }
355934
function _toInteger (value) {
    var n = +value;

    if (n !== n) { // eslint-disable-line no-self-compare
        return 0;
    } else if (n % 1 === 0) {
        return n;
    } else {
        return Math.floor(Math.abs(n)) * (n < 0 ? -1 : 1);
    }
}
147301
function float(val, bit) {
    var ret = parseFloat(val);
    return isNaN(ret) ? 0 : bit != null ? ret.toFixed(bit) : ret;
  }
1328910
function parseModifiers(packet, bits) {
  /* eslint-disable no-bitwise */
  /* eslint-disable no-param-reassign */
  packet.modifiers.l_control = ((bits & 1) !== 0);
  packet.modifiers.l_shift = ((bits & 2) !== 0);
  packet.modifiers.l_alt = ((bits & 4) !== 0);
  packet.modifiers.l_meta = ((bits & 8) !== 0);
  packet.modifiers.r_control = ((bits & 16) !== 0);
  packet.modifiers.r_shift = ((bits & 32) !== 0);
  packet.modifiers.r_alt = ((bits & 64) !== 0);
  packet.modifiers.r_meta = ((bits & 128) !== 0);
  /* eslint-enable no-bitwise */
  /* eslint-enable no-param-reassign */
}