{"abstract":"Code after a failed conditional branch computes with an extra zero on the stack.","category":"Bytecode virtual machines","checks":8,"contract":"WebAssembly-style structured control over a value stack. block k / loop / end nest; each block or loop pushes a label recording its operand height and arity (block: k result values, loop: 0). br d targets the d-th enclosing label counting outward from 0; the branch keeps the top arity values, discards operands down to the label height, then for a block pops that label and continues after its end, for a loop keeps the loop label and continues at the first instruction inside the loop. br_if pops a condition and branches when it is non-zero. Other ops: const v, add, sub, eqz, get k, set k, drop. Each instruction costs one fuel. Return status (done/fuel/trap), stack and locals.","contract_signature":"code, locals_, fuel","evaluation_group":"w2-bytecode-virtual-machines-structured-control-labels","failed_approach":"Popping but inverting the test branches exactly when the condition is zero.","family":"w2-bytecode-virtual-machines-structured-control-labels-br-if-condition-consumption","id":"FA-90121","implementations":{"attempt":{"sha256":"cd19fd0428ed312eca5ef2748155e2bb9d0a8525f6add8f6ce72410233188c8e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(code, locals_, fuel):\n    match = {}\n    opens = []\n    for i, ins in enumerate(code):\n        if ins[0] in ('block', 'loop'):\n            opens.append(i)\n        elif ins[0] == 'end':\n            match[opens.pop()] = i\n    loc = list(locals_)\n    stack = []\n    labels = []\n    pc = 0\n    steps = 0\n    try:\n        while pc < len(code):\n            if steps == fuel:\n                return {'status': 'fuel', 'stack': stack, 'locals': loc}\n            steps += 1\n            ins = code[pc]\n            op = ins[0]\n            if op in ('block', 'loop'):\n                labels.append({'kind': op, 'pc': pc, 'end': match[pc], 'height': len(stack),\n                               'arity': ins[1] if op == 'block' else 0})\n                pc += 1\n            elif op == 'end':\n                labels.pop()\n                pc += 1\n            elif op in ('br', 'br_if'):\n                if op == 'br_if' and stack.pop() != 0:\n                    pc += 1\n                    continue\n                target = labels[len(labels) - 1 - ins[1]]\n                keep = stack[len(stack) - target['arity']:] if target['arity'] else []\n                del stack[target['height']:]\n                stack.extend(keep)\n                if target['kind'] == 'loop':\n                    del labels[len(labels) - ins[1]:]\n                    pc = target['pc'] + 1\n                else:\n                    del labels[len(labels) - 1 - ins[1]:]\n                    pc = target['end'] + 1\n            elif op == 'const':\n                stack.append(ins[1])\n                pc += 1\n            elif op in ('add', 'sub'):\n                b = stack.pop()\n                a = stack.pop()\n                stack.append(a + b if op == 'add' else a - b)\n                pc += 1\n            elif op == 'eqz':\n                stack.append(1 if stack.pop() == 0 else 0)\n                pc += 1\n            elif op == 'get':\n                stack.append(loc[ins[1]])\n                pc += 1\n            elif op == 'set':\n                loc[ins[1]] = stack.pop()\n                pc += 1\n            else:\n                stack.pop()\n                pc += 1\n    except IndexError:\n        return {'status': 'trap', 'stack': stack, 'locals': loc}\n    return {'status': 'done', 'stack': stack, 'locals': loc}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [2, 0],\n    500),\n   {'locals': [0, 3], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [2, 0],\n    500),\n   {'locals': [0, 4], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [4, 0],\n    900),\n   {'locals': [0, 8], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 41], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [41, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 1], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 10], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [13], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 1], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    21),\n   {'locals': [49, 99], 'stack': [], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [3, 0],\n    500),\n   {'locals': [0, 6], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [3, 0],\n    500),\n   {'locals': [0, 6], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [5, 0],\n    900),\n   {'locals': [0, 10], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 42], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [42, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 2], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 20], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [23], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 2], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    22),\n   {'locals': [49, 99], 'stack': [49], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [4, 0],\n    500),\n   {'locals': [0, 10], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [4, 0],\n    500),\n   {'locals': [0, 8], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [6, 0],\n    900),\n   {'locals': [0, 12], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 43], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [43, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 3], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 30], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [33], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 3], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    23),\n   {'locals': [49, 99], 'stack': [49, 1], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [5, 0],\n    500),\n   {'locals': [0, 15], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [5, 0],\n    500),\n   {'locals': [0, 10], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [7, 0],\n    900),\n   {'locals': [0, 14], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 44], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [44, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 4], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 40], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [43], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 4], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    24),\n   {'locals': [49, 99], 'stack': [48], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [6, 0],\n    500),\n   {'locals': [0, 21], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [6, 0],\n    500),\n   {'locals': [0, 12], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [8, 0],\n    900),\n   {'locals': [0, 16], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 45], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [45, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 5], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 50], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [53], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 5], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    25),\n   {'locals': [48, 99], 'stack': [], 'status': 'fuel'})]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"0eff6f476f00a23971bb17920a0418e92a60c2f583bd5b364b20aabb53530677","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(code, locals_, fuel):\n    match = {}\n    opens = []\n    for i, ins in enumerate(code):\n        if ins[0] in ('block', 'loop'):\n            opens.append(i)\n        elif ins[0] == 'end':\n            match[opens.pop()] = i\n    loc = list(locals_)\n    stack = []\n    labels = []\n    pc = 0\n    steps = 0\n    try:\n        while pc < len(code):\n            if steps == fuel:\n                return {'status': 'fuel', 'stack': stack, 'locals': loc}\n            steps += 1\n            ins = code[pc]\n            op = ins[0]\n            if op in ('block', 'loop'):\n                labels.append({'kind': op, 'pc': pc, 'end': match[pc], 'height': len(stack),\n                               'arity': ins[1] if op == 'block' else 0})\n                pc += 1\n            elif op == 'end':\n                labels.pop()\n                pc += 1\n            elif op in ('br', 'br_if'):\n                if op == 'br_if' and stack[-1] == 0:\n                    pc += 1\n                    continue\n                target = labels[len(labels) - 1 - ins[1]]\n                keep = stack[len(stack) - target['arity']:] if target['arity'] else []\n                del stack[target['height']:]\n                stack.extend(keep)\n                if target['kind'] == 'loop':\n                    del labels[len(labels) - ins[1]:]\n                    pc = target['pc'] + 1\n                else:\n                    del labels[len(labels) - 1 - ins[1]:]\n                    pc = target['end'] + 1\n            elif op == 'const':\n                stack.append(ins[1])\n                pc += 1\n            elif op in ('add', 'sub'):\n                b = stack.pop()\n                a = stack.pop()\n                stack.append(a + b if op == 'add' else a - b)\n                pc += 1\n            elif op == 'eqz':\n                stack.append(1 if stack.pop() == 0 else 0)\n                pc += 1\n            elif op == 'get':\n                stack.append(loc[ins[1]])\n                pc += 1\n            elif op == 'set':\n                loc[ins[1]] = stack.pop()\n                pc += 1\n            else:\n                stack.pop()\n                pc += 1\n    except IndexError:\n        return {'status': 'trap', 'stack': stack, 'locals': loc}\n    return {'status': 'done', 'stack': stack, 'locals': loc}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [2, 0],\n    500),\n   {'locals': [0, 3], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [2, 0],\n    500),\n   {'locals': [0, 4], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [4, 0],\n    900),\n   {'locals': [0, 8], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 41], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [41, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 1], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 10], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [13], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 1], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    21),\n   {'locals': [49, 99], 'stack': [], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [3, 0],\n    500),\n   {'locals': [0, 6], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [3, 0],\n    500),\n   {'locals': [0, 6], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [5, 0],\n    900),\n   {'locals': [0, 10], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 42], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [42, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 2], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 20], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [23], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 2], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    22),\n   {'locals': [49, 99], 'stack': [49], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [4, 0],\n    500),\n   {'locals': [0, 10], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [4, 0],\n    500),\n   {'locals': [0, 8], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [6, 0],\n    900),\n   {'locals': [0, 12], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 43], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [43, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 3], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 30], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [33], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 3], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    23),\n   {'locals': [49, 99], 'stack': [49, 1], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [5, 0],\n    500),\n   {'locals': [0, 15], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [5, 0],\n    500),\n   {'locals': [0, 10], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [7, 0],\n    900),\n   {'locals': [0, 14], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 44], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [44, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 4], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 40], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [43], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 4], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    24),\n   {'locals': [49, 99], 'stack': [48], 'status': 'fuel'})],\n [('regression: counted loop exits through outer block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [6, 0],\n    500),\n   {'locals': [0, 21], 'stack': [], 'status': 'done'}),\n  ('continue from inside a nested block',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [6, 0],\n    500),\n   {'locals': [0, 12], 'stack': [], 'status': 'done'}),\n  ('continue loop with more iterations',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['block', 0],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['get', 1],\n     ['const', 2],\n     ['add'],\n     ['set', 1],\n     ['br', 1],\n     ['end'],\n     ['const', 999],\n     ['set', 1],\n     ['end'],\n     ['end']],\n    [8, 0],\n    900),\n   {'locals': [0, 16], 'stack': [], 'status': 'done'}),\n  ('block result keeps one value above outer operand',\n   ([['const', 45], ['block', 1], ['const', 5], ['const', 7], ['br', 0], ['const', 99], ['end']], [], 50),\n   {'locals': [], 'stack': [45, 7], 'status': 'done'}),\n  ('void block branch discards operands',\n   ([['block', 0], ['const', 1], ['const', 5], ['br', 0], ['end'], ['const', 3]], [], 50),\n   {'locals': [], 'stack': [3], 'status': 'done'}),\n  ('untaken br_if consumes its condition',\n   ([['const', 50], ['block', 0], ['const', 0], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [53], 'status': 'done'}),\n  ('taken br_if exits the block',\n   ([['const', 10], ['block', 0], ['const', 5], ['br_if', 0], ['const', 3], ['add'], ['end']], [], 50),\n   {'locals': [], 'stack': [10], 'status': 'done'}),\n  ('control: fuel exhaustion',\n   ([['block', 0],\n     ['loop', 0],\n     ['get', 0],\n     ['eqz'],\n     ['br_if', 1],\n     ['get', 1],\n     ['get', 0],\n     ['add'],\n     ['set', 1],\n     ['get', 0],\n     ['const', 1],\n     ['sub'],\n     ['set', 0],\n     ['br', 0],\n     ['end'],\n     ['end']],\n    [50, 0],\n    25),\n   {'locals': [48, 99], 'stack': [], 'status': 'fuel'})]]\nfor label, args, expected in cases[N - 1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"A deterministic, bounded teaching model of one bytecode virtual machine mechanism with a stipulated instruction encoding; it is not a production VM and claims no conformance to any real specification. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-bytecode-virtual-machines-structured-control-labels-br-if-condition-consumption","generated_at":"2026-09-29T14:51:23.867163+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Label-depth branching is the core of structured bytecode interpreters.","root_cause":"The condition is peeked instead of popped when the branch is not taken.","sha256":"3b4471fd034a2132784807cc2fbab0d1bba274e5195e2c1b850ef9d0a11a3177","title":"Structured control: untaken br_if leaves its condition behind · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":40.749,"exit_code":1,"observations":[{"actual":{"locals":[2,0],"stack":[],"status":"done"},"check":"regression: counted loop exits through outer block","expected":{"locals":[0,3],"stack":[],"status":"done"},"passed":false},{"actual":{"locals":[2,0],"stack":[],"status":"done"},"check":"continue from inside a nested block","expected":{"locals":[0,4],"stack":[],"status":"done"},"passed":false},{"actual":{"locals":[4,0],"stack":[],"status":"done"},"check":"continue loop with more iterations","expected":{"locals":[0,8],"stack":[],"status":"done"},"passed":false},{"actual":{"locals":[],"stack":[41,7],"status":"done"},"check":"block result keeps one value above outer operand","expected":{"locals":[],"stack":[41,7],"status":"done"},"passed":true},{"actual":{"locals":[],"stack":[3],"status":"done"},"check":"void block branch discards operands","expected":{"locals":[],"stack":[3],"status":"done"},"passed":true},{"actual":{"locals":[],"stack":[10],"status":"done"},"check":"untaken br_if consumes its condition","expected":{"locals":[],"stack":[13],"status":"done"},"passed":false},{"actual":{"locals":[],"stack":[13],"status":"done"},"check":"taken br_if exits the block","expected":{"locals":[],"stack":[10],"status":"done"},"passed":false},{"actual":{"locals":[50,0],"stack":[],"status":"done"},"check":"control: fuel exhaustion","expected":{"locals":[49,99],"stack":[],"status":"fuel"},"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: counted loop exits through outer block\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [2, 0]}, \"expected\": {\"locals\": [0, 3], \"stack\": [], \"status\": \"done\"}, \"passed\": false}, {\"check\": \"continue from inside a nested block\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [2, 0]}, \"expected\": {\"locals\": [0, 4], \"stack\": [], \"status\": \"done\"}, \"passed\": false}, {\"check\": \"continue loop with more iterations\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [4, 0]}, \"expected\": {\"locals\": [0, 8], \"stack\": [], \"status\": \"done\"}, \"passed\": false}, {\"check\": \"block result keeps one value above outer operand\", \"actual\": {\"status\": \"done\", \"stack\": [41, 7], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [41, 7], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"void block branch discards operands\", \"actual\": {\"status\": \"done\", \"stack\": [3], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [3], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"untaken br_if consumes its condition\", \"actual\": {\"status\": \"done\", \"stack\": [10], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [13], \"status\": \"done\"}, \"passed\": false}, {\"check\": \"taken br_if exits the block\", \"actual\": {\"status\": \"done\", \"stack\": [13], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [10], \"status\": \"done\"}, \"passed\": false}, {\"check\": \"control: fuel exhaustion\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [50, 0]}, \"expected\": {\"locals\": [49, 99], \"stack\": [], \"status\": \"fuel\"}, \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.19,"exit_code":1,"observations":[{"actual":{"locals":[0,3],"stack":[],"status":"done"},"check":"regression: counted loop exits through outer block","expected":{"locals":[0,3],"stack":[],"status":"done"},"passed":true},{"actual":{"locals":[0,4],"stack":[],"status":"done"},"check":"continue from inside a nested block","expected":{"locals":[0,4],"stack":[],"status":"done"},"passed":true},{"actual":{"locals":[0,8],"stack":[],"status":"done"},"check":"continue loop with more iterations","expected":{"locals":[0,8],"stack":[],"status":"done"},"passed":true},{"actual":{"locals":[],"stack":[41,7],"status":"done"},"check":"block result keeps one value above outer operand","expected":{"locals":[],"stack":[41,7],"status":"done"},"passed":true},{"actual":{"locals":[],"stack":[3],"status":"done"},"check":"void block branch discards operands","expected":{"locals":[],"stack":[3],"status":"done"},"passed":true},{"actual":{"locals":[],"stack":[10,3],"status":"done"},"check":"untaken br_if consumes its condition","expected":{"locals":[],"stack":[13],"status":"done"},"passed":false},{"actual":{"locals":[],"stack":[10],"status":"done"},"check":"taken br_if exits the block","expected":{"locals":[],"stack":[10],"status":"done"},"passed":true},{"actual":{"locals":[49,99],"stack":[0],"status":"fuel"},"check":"control: fuel exhaustion","expected":{"locals":[49,99],"stack":[],"status":"fuel"},"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: counted loop exits through outer block\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [0, 3]}, \"expected\": {\"locals\": [0, 3], \"stack\": [], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"continue from inside a nested block\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [0, 4]}, \"expected\": {\"locals\": [0, 4], \"stack\": [], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"continue loop with more iterations\", \"actual\": {\"status\": \"done\", \"stack\": [], \"locals\": [0, 8]}, \"expected\": {\"locals\": [0, 8], \"stack\": [], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"block result keeps one value above outer operand\", \"actual\": {\"status\": \"done\", \"stack\": [41, 7], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [41, 7], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"void block branch discards operands\", \"actual\": {\"status\": \"done\", \"stack\": [3], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [3], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"untaken br_if consumes its condition\", \"actual\": {\"status\": \"done\", \"stack\": [10, 3], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [13], \"status\": \"done\"}, \"passed\": false}, {\"check\": \"taken br_if exits the block\", \"actual\": {\"status\": \"done\", \"stack\": [10], \"locals\": []}, \"expected\": {\"locals\": [], \"stack\": [10], \"status\": \"done\"}, \"passed\": true}, {\"check\": \"control: fuel exhaustion\", \"actual\": {\"status\": \"fuel\", \"stack\": [0], \"locals\": [49, 99]}, \"expected\": {\"locals\": [49, 99], \"stack\": [], \"status\": \"fuel\"}, \"passed\": false}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}