broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(a // b))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(-q if a < 0 else q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Negative quotients are one lower than the bytecode semantics require (-9 / 2 gives -5).

Each op is [name, a, b] over 32-bit two's complement ints: iadd/imul wrap; idiv truncates toward zero and MIN_VALUE / -1 wraps to MIN_VALUE; irem has the sign of the dividend; ishl/ishr/iushr use only the low five bits of the shift count, iushr shifts in zeros; ineg wraps. Division by zero yields "ArithmeticException", an unknown op "VerifyError".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(q if (a < 0) == (b < 0) else -q)
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(min(q, 2147483647) if (a < 0) == (b < 0) else -q)
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Dividing MIN_VALUE by -1 yields 2147483648, a value no int slot can hold.

Each op is [name, a, b] over 32-bit two's complement ints: iadd/imul wrap; idiv truncates toward zero and MIN_VALUE / -1 wraps to MIN_VALUE; irem has the sign of the dividend; ishl/ishr/iushr use only the low five bits of the shift count, iushr shifts in zeros; ineg wraps. Division by zero yields "ArithmeticException", an unknown op "VerifyError".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(q if (a < 0) == (b < 0) else -q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(a % b)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(q if (a < 0) == (b < 0) else -q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if b >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Remainders of negative dividends come out positive (-10 % 3 gives 2).

Each op is [name, a, b] over 32-bit two's complement ints: iadd/imul wrap; idiv truncates toward zero and MIN_VALUE / -1 wraps to MIN_VALUE; irem has the sign of the dividend; ishl/ishr/iushr use only the low five bits of the shift count, iushr shifts in zeros; ineg wraps. Division by zero yields "ArithmeticException", an unknown op "VerifyError".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(q if (a < 0) == (b < 0) else -q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << b))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(q if (a < 0) == (b < 0) else -q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << min(b, 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Shifting by 32 clears the value instead of leaving it unchanged.

Each op is [name, a, b] over 32-bit two's complement ints: iadd/imul wrap; idiv truncates toward zero and MIN_VALUE / -1 wraps to MIN_VALUE; irem has the sign of the dividend; ishl/ishr/iushr use only the low five bits of the shift count, iushr shifts in zeros; ineg wraps. Division by zero yields "ArithmeticException", an unknown op "VerifyError".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(q if (a < 0) == (b < 0) else -q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap(a >> (b & 31)))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(ops):
    def wrap(v):
        v &= 0xFFFFFFFF
        return v - 0x100000000 if v >= 0x80000000 else v
    out = []
    for op, a, b in ops:
        if op == 'iadd':
            out.append(wrap(a + b))
        elif op == 'imul':
            out.append(wrap(a * b))
        elif op == 'idiv':
            if b == 0:
                out.append('ArithmeticException')
            else:
                q = abs(a) // abs(b)
                out.append(wrap(q if (a < 0) == (b < 0) else -q))
        elif op == 'irem':
            if b == 0:
                out.append('ArithmeticException')
            else:
                r = abs(a) % abs(b)
                out.append(r if a >= 0 else -r)
        elif op == 'ishl':
            out.append(wrap(a << (b & 31)))
        elif op == 'ishr':
            out.append(a >> (b & 31))
        elif op == 'iushr':
            out.append(wrap((a & 0xFFFFFFFF) >> b))
        elif op == 'ineg':
            out.append(wrap(-a))
        else:
            out.append('VerifyError')
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483646, 1], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -8, 2], ['idiv', 9, -2]],), [-4, -4]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483647, -1]],),
   [-2147483648, 2147483647]),
  ('irem takes the sign of the dividend', ([['irem', -10, 3], ['irem', 11, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 2, 32], ['ishl', 3, 34]],), [2, 12]),
  ('iushr is a logical shift with masking', ([['iushr', -16, 28], ['iushr', -16, 37]],), [15, 134217727]),
  ('division by zero', ([['idiv', 1, 0], ['irem', 1, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65537], ['ishr', -8, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [65536, -2, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483645, 2], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -9, 2], ['idiv', 11, -2]],), [-4, -5]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483646, -1]],),
   [-2147483648, 2147483646]),
  ('irem takes the sign of the dividend', ([['irem', -13, 3], ['irem', 14, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 3, 32], ['ishl', 3, 35]],), [3, 24]),
  ('iushr is a logical shift with masking', ([['iushr', -32, 28], ['iushr', -16, 38]],), [15, 67108863]),
  ('division by zero', ([['idiv', 2, 0], ['irem', 2, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65538], ['ishr', -16, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [131072, -4, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483644, 3], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -10, 2], ['idiv', 13, -2]],), [-5, -6]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483645, -1]],),
   [-2147483648, 2147483645]),
  ('irem takes the sign of the dividend', ([['irem', -16, 3], ['irem', 17, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 4, 32], ['ishl', 3, 36]],), [4, 48]),
  ('iushr is a logical shift with masking', ([['iushr', -48, 28], ['iushr', -16, 39]],), [15, 33554431]),
  ('division by zero', ([['idiv', 3, 0], ['irem', 3, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65539], ['ishr', -24, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [196608, -6, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483643, 4], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -11, 2], ['idiv', 15, -2]],), [-5, -7]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483644, -1]],),
   [-2147483648, 2147483644]),
  ('irem takes the sign of the dividend', ([['irem', -19, 3], ['irem', 20, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 5, 32], ['ishl', 3, 37]],), [5, 96]),
  ('iushr is a logical shift with masking', ([['iushr', -64, 28], ['iushr', -16, 40]],), [15, 16777215]),
  ('division by zero', ([['idiv', 4, 0], ['irem', 4, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65540], ['ishr', -32, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [262144, -8, -2147483648, 'VerifyError'])],
 [('regression: iadd reaching MAX_VALUE',
   ([['iadd', 2147483642, 5], ['iadd', 2147483647, 1]],),
   [2147483647, -2147483648]),
  ('idiv truncates toward zero', ([['idiv', -12, 2], ['idiv', 17, -2]],), [-6, -8]),
  ('idiv MIN_VALUE by -1 overflows to MIN_VALUE',
   ([['idiv', -2147483648, -1], ['idiv', -2147483643, -1]],),
   [-2147483648, 2147483643]),
  ('irem takes the sign of the dividend', ([['irem', -22, 3], ['irem', 23, -3]],), [-1, 2]),
  ('ishl masks the shift count to five bits', ([['ishl', 6, 32], ['ishl', 3, 38]],), [6, 192]),
  ('iushr is a logical shift with masking', ([['iushr', -80, 28], ['iushr', -16, 41]],), [15, 8388607]),
  ('division by zero', ([['idiv', 5, 0], ['irem', 5, 0]],), ['ArithmeticException', 'ArithmeticException']),
  ('controls: imul wrap, ishr, ineg MIN',
   ([['imul', 65536, 65541], ['ishr', -40, 2], ['ineg', -2147483648, 0], ['bogus', 1, 1]],),
   [327680, -10, -2147483648, 'VerifyError'])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Unsigned right shifts of negative ints stay negative.

Each op is [name, a, b] over 32-bit two's complement ints: iadd/imul wrap; idiv truncates toward zero and MIN_VALUE / -1 wraps to MIN_VALUE; irem has the sign of the dividend; ishl/ishr/iushr use only the low five bits of the shift count, iushr shifts in zeros; ineg wraps. Division by zero yields "ArithmeticException", an unknown op "VerifyError".

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(code):
    effects = {'push': (0, 1), 'pop': (1, -1), 'dup': (1, 1), 'dup_x1': (1, 1), 'swap': (2, 0),
               'add': (2, -1), 'ifeq': (1, -1), 'goto': (0, 0), 'return': (1, -1)}
    def verify():
        depth = {0: 0}
        work = [0]
        maxd = 0
        while work:
            i = work.pop()
            op, arg = code[i]
            need, delta = effects[op]
            d = depth[i]
            if d < need:
                return ['underflow', i]
            nd = d + delta
            maxd = max(maxd, nd)
            if op == 'goto':
                succ = [arg]
            elif op == 'ifeq':
                succ = [i + 1, arg]
            elif op == 'return':
                succ = []
            else:
                succ = [i + 1]
            for s in succ:
                if s < 0 or s >= len(code):
                    return ['falls-off', i]
                if s in depth:
                    if depth[s] != nd:
                        return ['inconsistent', s]
                else:
                    depth[s] = nd
                    work.append(s)
        return ['ok', maxd]
    try:
        return verify()
    except (IndexError, KeyError):
        return ['vm-crash']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('dup_x1 with one item underflows', ([['push', 1], ['dup_x1', None], ['return', None]],), ['underflow', 1]),
  ('dup_x1 with two items is legal',
   ([['push', 1], ['push', 2], ['dup_x1', None], ['add', None], ['add', None], ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1], ['goto', 3], ['add', None], ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 0], ['ifeq', 4], ['push', 5], ['goto', 5], ['push', 7], ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows', ([['ifeq', 1], ['push', 1], ['return', None]],), ['underflow', 0]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1], ['push', 0], ['ifeq', 4], ['pop', None], ['return', None]],),
   ['inconsistent', 4]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1], ['ifeq', 3], ['push', 9], ['push', 1], ['return', None]],),
   ['inconsistent', 3]),
  ('execution falling off the end', ([['push', 1], ['push', 1]],), ['falls-off', 1]),
  ('negative branch target', ([['push', 1], ['goto', -1], ['return', None]],), ['falls-off', 1]),
  ('swap with one item underflows', ([['push', 1], ['swap', None], ['return', None]],), ['underflow', 1])],
 [('dup_x1 with one item underflows',
   ([['push', 1], ['pop', None], ['push', 1], ['dup_x1', None], ['return', None]],),
   ['underflow', 3]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1], ['pop', None], ['push', 1], ['goto', 5], ['add', None], ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 0],
     ['ifeq', 6],
     ['push', 5],
     ['goto', 7],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1], ['pop', None], ['ifeq', 3], ['push', 1], ['return', None]],),
   ['underflow', 2]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1], ['pop', None], ['push', 1], ['push', 0], ['ifeq', 6], ['pop', None], ['return', None]],),
   ['inconsistent', 6]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1], ['pop', None], ['push', 1], ['ifeq', 5], ['push', 9], ['push', 1], ['return', None]],),
   ['inconsistent', 5]),
  ('execution falling off the end', ([['push', 1], ['pop', None], ['push', 1]],), ['falls-off', 2]),
  ('negative branch target',
   ([['push', 1], ['pop', None], ['push', 1], ['goto', -1], ['return', None]],),
   ['falls-off', 3]),
  ('swap with one item underflows',
   ([['push', 1], ['pop', None], ['push', 1], ['swap', None], ['return', None]],),
   ['underflow', 3])],
 [('dup_x1 with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['dup_x1', None],
     ['return', None]],),
   ['underflow', 5]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['goto', 7],
     ['add', None],
     ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 0],
     ['ifeq', 8],
     ['push', 5],
     ['goto', 9],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['ifeq', 5], ['push', 1], ['return', None]],),
   ['underflow', 4]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['push', 0],
     ['ifeq', 8],
     ['pop', None],
     ['return', None]],),
   ['inconsistent', 8]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['ifeq', 7],
     ['push', 9],
     ['push', 1],
     ['return', None]],),
   ['inconsistent', 7]),
  ('execution falling off the end',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 1], ['push', 1]],),
   ['falls-off', 5]),
  ('negative branch target',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 1], ['goto', -1], ['return', None]],),
   ['falls-off', 5]),
  ('swap with one item underflows',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 1], ['swap', None], ['return', None]],),
   ['underflow', 5])],
 [('dup_x1 with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['dup_x1', None],
     ['return', None]],),
   ['underflow', 7]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['goto', 9],
     ['add', None],
     ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 0],
     ['ifeq', 10],
     ['push', 5],
     ['goto', 11],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['ifeq', 7],
     ['push', 1],
     ['return', None]],),
   ['underflow', 6]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['push', 0],
     ['ifeq', 10],
     ['pop', None],
     ['return', None]],),
   ['inconsistent', 10]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['ifeq', 9],
     ['push', 9],
     ['push', 1],
     ['return', None]],),
   ['inconsistent', 9]),
  ('execution falling off the end',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 3], ['pop', None], ['push', 1]],),
   ['falls-off', 6]),
  ('negative branch target',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['goto', -1],
     ['return', None]],),
   ['falls-off', 7]),
  ('swap with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['swap', None],
     ['return', None]],),
   ['underflow', 7])],
 [('dup_x1 with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['dup_x1', None],
     ['return', None]],),
   ['underflow', 9]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['goto', 11],
     ['add', None],
     ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 0],
     ['ifeq', 12],
     ['push', 5],
     ['goto', 13],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['ifeq', 9],
     ['push', 1],
     ['return', None]],),
   ['underflow', 8]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['push', 0],
     ['ifeq', 12],
     ['pop', None],
     ['return', None]],),
   ['inconsistent', 12]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['ifeq', 11],
     ['push', 9],
     ['push', 1],
     ['return', None]],),
   ['inconsistent', 11]),
  ('execution falling off the end',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['push', 1]],),
   ['falls-off', 9]),
  ('negative branch target',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['goto', -1],
     ['return', None]],),
   ['falls-off', 9]),
  ('swap with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['swap', None],
     ['return', None]],),
   ['underflow', 9])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(code):
    effects = {'push': (0, 1), 'pop': (1, -1), 'dup': (1, 1), 'dup_x1': (3, 1), 'swap': (2, 0),
               'add': (2, -1), 'ifeq': (1, -1), 'goto': (0, 0), 'return': (1, -1)}
    def verify():
        depth = {0: 0}
        work = [0]
        maxd = 0
        while work:
            i = work.pop()
            op, arg = code[i]
            need, delta = effects[op]
            d = depth[i]
            if d < need:
                return ['underflow', i]
            nd = d + delta
            maxd = max(maxd, nd)
            if op == 'goto':
                succ = [arg]
            elif op == 'ifeq':
                succ = [i + 1, arg]
            elif op == 'return':
                succ = []
            else:
                succ = [i + 1]
            for s in succ:
                if s < 0 or s >= len(code):
                    return ['falls-off', i]
                if s in depth:
                    if depth[s] != nd:
                        return ['inconsistent', s]
                else:
                    depth[s] = nd
                    work.append(s)
        return ['ok', maxd]
    try:
        return verify()
    except (IndexError, KeyError):
        return ['vm-crash']
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('dup_x1 with one item underflows', ([['push', 1], ['dup_x1', None], ['return', None]],), ['underflow', 1]),
  ('dup_x1 with two items is legal',
   ([['push', 1], ['push', 2], ['dup_x1', None], ['add', None], ['add', None], ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1], ['goto', 3], ['add', None], ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 0], ['ifeq', 4], ['push', 5], ['goto', 5], ['push', 7], ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows', ([['ifeq', 1], ['push', 1], ['return', None]],), ['underflow', 0]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1], ['push', 0], ['ifeq', 4], ['pop', None], ['return', None]],),
   ['inconsistent', 4]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1], ['ifeq', 3], ['push', 9], ['push', 1], ['return', None]],),
   ['inconsistent', 3]),
  ('execution falling off the end', ([['push', 1], ['push', 1]],), ['falls-off', 1]),
  ('negative branch target', ([['push', 1], ['goto', -1], ['return', None]],), ['falls-off', 1]),
  ('swap with one item underflows', ([['push', 1], ['swap', None], ['return', None]],), ['underflow', 1])],
 [('dup_x1 with one item underflows',
   ([['push', 1], ['pop', None], ['push', 1], ['dup_x1', None], ['return', None]],),
   ['underflow', 3]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1], ['pop', None], ['push', 1], ['goto', 5], ['add', None], ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 0],
     ['ifeq', 6],
     ['push', 5],
     ['goto', 7],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1], ['pop', None], ['ifeq', 3], ['push', 1], ['return', None]],),
   ['underflow', 2]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1], ['pop', None], ['push', 1], ['push', 0], ['ifeq', 6], ['pop', None], ['return', None]],),
   ['inconsistent', 6]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1], ['pop', None], ['push', 1], ['ifeq', 5], ['push', 9], ['push', 1], ['return', None]],),
   ['inconsistent', 5]),
  ('execution falling off the end', ([['push', 1], ['pop', None], ['push', 1]],), ['falls-off', 2]),
  ('negative branch target',
   ([['push', 1], ['pop', None], ['push', 1], ['goto', -1], ['return', None]],),
   ['falls-off', 3]),
  ('swap with one item underflows',
   ([['push', 1], ['pop', None], ['push', 1], ['swap', None], ['return', None]],),
   ['underflow', 3])],
 [('dup_x1 with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['dup_x1', None],
     ['return', None]],),
   ['underflow', 5]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['goto', 7],
     ['add', None],
     ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 0],
     ['ifeq', 8],
     ['push', 5],
     ['goto', 9],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['ifeq', 5], ['push', 1], ['return', None]],),
   ['underflow', 4]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['push', 0],
     ['ifeq', 8],
     ['pop', None],
     ['return', None]],),
   ['inconsistent', 8]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 1],
     ['ifeq', 7],
     ['push', 9],
     ['push', 1],
     ['return', None]],),
   ['inconsistent', 7]),
  ('execution falling off the end',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 1], ['push', 1]],),
   ['falls-off', 5]),
  ('negative branch target',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 1], ['goto', -1], ['return', None]],),
   ['falls-off', 5]),
  ('swap with one item underflows',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 1], ['swap', None], ['return', None]],),
   ['underflow', 5])],
 [('dup_x1 with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['dup_x1', None],
     ['return', None]],),
   ['underflow', 7]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['goto', 9],
     ['add', None],
     ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 0],
     ['ifeq', 10],
     ['push', 5],
     ['goto', 11],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['ifeq', 7],
     ['push', 1],
     ['return', None]],),
   ['underflow', 6]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['push', 0],
     ['ifeq', 10],
     ['pop', None],
     ['return', None]],),
   ['inconsistent', 10]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['ifeq', 9],
     ['push', 9],
     ['push', 1],
     ['return', None]],),
   ['inconsistent', 9]),
  ('execution falling off the end',
   ([['push', 1], ['pop', None], ['push', 2], ['pop', None], ['push', 3], ['pop', None], ['push', 1]],),
   ['falls-off', 6]),
  ('negative branch target',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['goto', -1],
     ['return', None]],),
   ['falls-off', 7]),
  ('swap with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 1],
     ['swap', None],
     ['return', None]],),
   ['underflow', 7])],
 [('dup_x1 with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['dup_x1', None],
     ['return', None]],),
   ['underflow', 9]),
  ('dup_x1 with two items is legal',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['push', 2],
     ['dup_x1', None],
     ['add', None],
     ['add', None],
     ['return', None]],),
   ['ok', 3]),
  ('regression: dead code after goto is not verified',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['goto', 11],
     ['add', None],
     ['return', None]],),
   ['ok', 1]),
  ('if/else arms merge at equal depth',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 0],
     ['ifeq', 12],
     ['push', 5],
     ['goto', 13],
     ['push', 7],
     ['return', None]],),
   ['ok', 1]),
  ('ifeq on empty stack underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['ifeq', 9],
     ['push', 1],
     ['return', None]],),
   ['underflow', 8]),
  ('deeper arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['push', 0],
     ['ifeq', 12],
     ['pop', None],
     ['return', None]],),
   ['inconsistent', 12]),
  ('shallower arm reaching merge first is inconsistent',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['ifeq', 11],
     ['push', 9],
     ['push', 1],
     ['return', None]],),
   ['inconsistent', 11]),
  ('execution falling off the end',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['push', 1]],),
   ['falls-off', 9]),
  ('negative branch target',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['goto', -1],
     ['return', None]],),
   ['falls-off', 9]),
  ('swap with one item underflows',
   ([['push', 1],
     ['pop', None],
     ['push', 2],
     ['pop', None],
     ['push', 3],
     ['pop', None],
     ['push', 4],
     ['pop', None],
     ['push', 1],
     ['swap', None],
     ['return', None]],),
   ['underflow', 9])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A method using dup_x1 on a single-item stack verifies and later corrupts the frame.

code is a list of [op, arg]. Stack effects (required, delta): push (0,+1), pop (1,-1), dup (1,+1), dup_x1 (2,+1), swap (2,0), add (2,-1), ifeq (1,-1; successors fallthrough and arg), goto (0,0; only arg), return (1,-1; none). Dataflow from index 0 with depth 0: report ["underflow", i], ["falls-off", i] for a successor outside the code, ["inconsistent", s] when a merge sees two depths, else ["ok", max depth]. Unreachable code is never examined.

split: open-access