static long clampedMultiply(final long a, final long b) {
    long r = a * b;
    long ax = Math.abs(a);
    long ay = Math.abs(b);
    if (((ax | ay) >>> 31 != 0)
        && (((b != 0) && (r / b != a)) || (a == Long.MIN_VALUE && b == -1))) {
      // out of bounds, clamp it!
      return ((a ^ b) < 0) ? Long.MIN_VALUE : Long.MAX_VALUE;
    } else {
      return r;
    }
  }
Multiplies a and b, but if an underflow/overflow occurs return the Long max/min value

@param a first value
@param b second value
@return value of a times b if no over/underflows or Long.MAX_VALUE/Long.MIN_VALUE otherwise
evm/src/main/java/org/hyperledger/besu/evm/internal/Words.java