///////////////////////////////////////////////////////////////////////////////
// safe addition/subtraction
343560
func safeAdd(a, b int64) (int64, bool) {
	if b > 0 && a > math.MaxInt64-b {
		return -1, true
	} else if b < 0 && a < math.MinInt64-b {
		return -1, true
	}
	return a + b, false
}
840274
function unsafeRemove (i, a, l) {
  const b = new Array(l)
  let j
  for (j = 0; j < i; ++j) {
    b[j] = a[j]
  }
  for (j = i; j < l; ++j) {
    b[j] = a[j + 1]
  }

  return b
}
110183
function () {
		var a = array.cast( arguments ),
		    t = a.pop(),
		    P = array.chunk( a, 2 ),
		    n = P.length,
		    c, S0, Q0, Q1, Q2, C0, C1, C2, C3;

		if ( n < 2 || n > 4 ) {
			throw new Error( label.error.invalidArguments );
		}

		// Setting variables
		c  = [];
		S0 = 1 - t;
		Q0 = math.sqr( S0 );
		Q1 = 2 * S0 * t;
		Q2 = math.sqr( t );
		C0 = Math.pow( S0, 3 );
		C1 = 3 * Q0 * t;
		C2 = 3 * S0 * Q2;
		C3 = Math.pow( t, 3 );

		// Straight
		if ( n === 2 ) {
			c.push( ( S0 * P[0][0] ) + ( t * P[1][0] ) );
			c.push( ( S0 * P[0][1] ) + ( t * P[1][1] ) );
		}
		// Quadratic
		else if ( n === 3 ) {
			c.push( ( Q0 * P[0][0] ) + ( Q1 * P[1][0] ) + ( Q2 + P[2][0] ) );
			c.push( ( Q0 * P[0][1] ) + ( Q1 * P[1][1] ) + ( Q2 + P[2][1] ) );
		}
		// Cubic
		else if ( n === 4 ) {
			c.push( ( C0 * P[0][0] ) + ( C1 * P[1][0] ) + ( C2 * P[2][0] ) + ( C3 * P[3][0] ) );
			c.push( ( C0 * P[0][1] ) + ( C1 * P[1][1] ) + ( C2 * P[2][1] ) + ( C3 * P[3][1] ) );
		}

		return c;
	}
721965
function (plus, minus) {
    var out = {}, i;

    for (i in plus) {
      if (plus.hasOwnProperty(i) && plus[i] !== minus[i]) {
        out[i] = plus[i];
      }
    }

    return out;
  }
778271
function safe_multiply(x, y) {
  		/*
  			a = a00 + a16
  			b = b00 + b16
  			a*b = (a00 + a16)(b00 + b16)
  				= a00b00 + a00b16 + a16b00 + a16b16

  			a16b16 overflows the 32bits
  		 */
     var xlsw = (x & 0xFFFF)
     var xmsw = (x >> 16) +(xlsw >> 16);
     var ylsw = (y & 0xFFFF)
     var ymsw = (y >> 16) +(ylsw >> 16);
  		var a16 = xmsw
  		var a00 = xlsw
  		var b16 = ymsw
  		var b00 = ylsw
  		var c16, c00
  		c00 = a00 * b00
  		c16 = c00 >>> 16

  		c16 += a16 * b00
  		c16 &= 0xFFFF		// Not required but improves performance
  		c16 += a00 * b16

  		xlsw = c00 & 0xFFFF
  		xmsw= c16 & 0xFFFF

  		return (xmsw << 16) | (xlsw & 0xFFFF)
  	}
266332
function add(a, b, carryIn=0) {
  let result = a + b + carryIn;
  let fullResult = result;
  let carryOut = 0;

  // carryOut is 6th trit, truncate result to 5 trits
  if (result > MAX_TRYTE) {
    carryOut  = 1;
    result -= MAX_TRYTE * 2 + 1;
  } else if (result < MIN_TRYTE) {
    carryOut = -1; // underflow
    result += MAX_TRYTE * 2 + 1;
  }

  // overflow is set if sign is incorrect
  let overflow;
  if (Math.sign(fullResult) === Math.sign(result)) {
    overflow = 0;
  } else {
    overflow = Math.sign(fullResult) || Math.sign(result);
  }
  // note: for 5-trit + 5-trit + 1-trit will always V = C, but the logic above is generic
  if (overflow !== carryOut) throw new Error(`unexpected overflow calculation: ${overflow} !== ${carryOut}`);

  return {result, carryOut, fullResult, overflow};
}
305466
function safeParseInt(value, base)
{
	if (base && base != 10)
	{
		return unsafeParseInt(value, base);
	}
	return unsafeParseInt(value, 10);
}
1188724
public final void multiplicativeExpression() throws RecognitionException {
		int multiplicativeExpression_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 123) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1192:5: ( unaryExpression ( ( '*' | '/' | '%' ) unaryExpression )* )
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1192:9: unaryExpression ( ( '*' | '/' | '%' ) unaryExpression )*
			{
			pushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression5444);
			unaryExpression();
			state._fsp--;
			if (state.failed) return;
			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1192:25: ( ( '*' | '/' | '%' ) unaryExpression )*
			loop155:
			while (true) {
				int alt155=2;
				int LA155_0 = input.LA(1);
				if ( (LA155_0==31||LA155_0==38||LA155_0==49) ) {
					alt155=1;
				}

				switch (alt155) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:1192:27: ( '*' | '/' | '%' ) unaryExpression
					{
					if ( input.LA(1)==31||input.LA(1)==38||input.LA(1)==49 ) {
						input.consume();
						state.errorRecovery=false;
						state.failed=false;
					}
					else {
						if (state.backtracking>0) {state.failed=true; return;}
						MismatchedSetException mse = new MismatchedSetException(null,input);
						throw mse;
					}
					pushFollow(FOLLOW_unaryExpression_in_multiplicativeExpression5462);
					unaryExpression();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop155;
				}
			}

			}

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 123, multiplicativeExpression_StartIndex); }

		}
	}
1227879
function multiplyInteger(x, k) {
      var temp,
        carry = 0,
        i = x.length;

      for (x = x.slice(); i--;) {
        temp = x[i] * k + carry;
        x[i] = temp % BASE | 0;
        carry = temp / BASE | 0;
      }

      if (carry) x.unshift(carry);

      return x;
    }
200812
function ADD64AA(v, a, b) {
    var o0 = v[a] + v[b];
    var o1 = v[a + 1] + v[b + 1];
    if (o0 >= 0x100000000) {
        o1++;
    }
    v[a] = o0;
    v[a + 1] = o1;
}
454808
function multiply(x, k, base) {
        var m, temp, xlo, xhi,
          carry = 0,
          i = x.length,
          klo = k % SQRT_BASE,
          khi = k / SQRT_BASE | 0;

        for (x = x.slice(); i--;) {
          xlo = x[i] % SQRT_BASE;
          xhi = x[i] / SQRT_BASE | 0;
          m = khi * xlo + xhi * klo;
          temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry;
          carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi;
          x[i] = temp % base;
        }

        if (carry) x = [carry].concat(x);

        return x;
      }
674007
function unsafeDrop (n, a, l) {
  const b = new Array(l)
  for (let i = 0; i < l; ++i) {
    b[i] = a[n + i]
  }
  return b
}
379157
function (q, a, b, x, s, t) {
        return safe_add(bit_rol(safe_add(safe_add(a, q),safe_add(x, t)), s),b);
    }
950572
@Override
  public Double add11(Double arg1, Double arg2) {
    if (arg1 == null || arg2 == null) {
      return Double.NaN;
    } else {
      return arg1 + arg2;
    }
  }
56613
function getAndRemoveMiddle(numItemsToKeepAtEachEnd, array) {
    errorIfNotInteger_1.errorIfNotInteger(numItemsToKeepAtEachEnd);
    if (numItemsToKeepAtEachEnd < 1)
        throw new Error('The number of items to' +
            ' preserve at each end must be at least 1');
    if ((numItemsToKeepAtEachEnd * 2) > array.length) {
        throw new Error('The number of items to preserve multiplied by 2' +
            ' exceeds the length of the array. This is not allowed.');
    }
    var numToRemove = array.length - (numItemsToKeepAtEachEnd * 2);
    return getAndRemoveAdjacentAt_1.getAndRemoveAdjacentAt(numItemsToKeepAtEachEnd, numToRemove, array);
}
309948
public void subtractValue(int idx, double val) {
        int c = get1dConfigIdx(idx);
        values.set(c, s.minus(values.get(c), val));
    }
927638
public static int safeAdd(int val1, int val2) {
        int sum = val1 + val2;
        // If there is a sign change, but the two values have the same sign...
        if ((val1 ^ sum) < 0 && (val1 ^ val2) >= 0) {
            throw new ArithmeticException
                ("The calculation caused an overflow: " + val1 + " + " + val2);
        }
        return sum;
    }