{"abstract":"A backward loop branch jumps far forward out of the program.","category":"Instruction set emulation","checks":6,"contract":"Input [prog, limit]: word-indexed instructions at byte addresses 4*i: addi rt rs imm, beq/bne/beql rs rt off16, j index, nop, halt; 8 registers with r0 hardwired to 0. Branch target = branch address + 4 + (sign-extended off16 << 2). The instruction after a branch or jump (its delay slot) always executes before control transfers, except that a not-taken beql skips (annuls) its slot. j target = ((pc+4) & 0xF0000000) | (index << 2). Addresses outside the program behave as halt. Return [executed pcs, registers].","evaluation_group":"w2-instruction-set-emulation-delay-slot","failed_approach":"Subtracting 0x8000 produces the wrong negative distance.","family":"w2-instruction-set-emulation-delay-slot-offset-sign-extension","id":"FA-89716","implementations":{"attempt":{"sha256":"e3685a568e08fcb9e3bcf33750b93b674d1894e7914f2236a0cee8b1b934e007","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(*args):\n    prog, limit = args\n    r = [0] * 8\n    pc = 0\n    trace = []\n    pending = None\n    steps = 0\n    while steps < limit:\n        steps += 1\n        ins = prog[pc // 4] if 0 <= pc // 4 < len(prog) else ['halt']\n        trace.append(pc)\n        op = ins[0]\n        nxt = pc + 4\n        if op == 'halt':\n            break\n        if op == 'addi':\n            if ins[1]:\n                r[ins[1]] = r[ins[2]] + ins[3]\n        elif op in ('beq', 'bne', 'beql'):\n            taken = (r[ins[1]] == r[ins[2]]) == (op != 'bne')\n            off = ins[3] - 0x8000 if ins[3] & 0x8000 else ins[3]\n            tgt = pc + 4 + (off << 2)\n            if op == 'beql' and not taken:\n                nxt = pc + 8\n            else:\n                pending = tgt if taken else pc + 8\n        elif op == 'j':\n            pending = ((pc + 4) & 0xF0000000) | (ins[1] << 2)\n        if pending is not None and op not in ('beq', 'bne', 'beql', 'j'):\n            nxt = pending\n            pending = None\n        pc = nxt\n    return [trace, r]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 2], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 3], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 1], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 3], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 6, 3, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 4], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 4, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 2], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 3, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 4], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 8, 4, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 5], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 5, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 3], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 4, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 5], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 10, 5, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 6], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 6, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 4], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 5, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 6], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 12, 6, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 7], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 7, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 5], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 6, 0]])]]\nfor label, args, expected in fixtures[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":"de9837cdf296dc95214c29801f31975afb1865c793d9352a6c4d5b462c7862e4","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(*args):\n    prog, limit = args\n    r = [0] * 8\n    pc = 0\n    trace = []\n    pending = None\n    steps = 0\n    while steps < limit:\n        steps += 1\n        ins = prog[pc // 4] if 0 <= pc // 4 < len(prog) else ['halt']\n        trace.append(pc)\n        op = ins[0]\n        nxt = pc + 4\n        if op == 'halt':\n            break\n        if op == 'addi':\n            if ins[1]:\n                r[ins[1]] = r[ins[2]] + ins[3]\n        elif op in ('beq', 'bne', 'beql'):\n            taken = (r[ins[1]] == r[ins[2]]) == (op != 'bne')\n            off = ins[3]\n            tgt = pc + 4 + (off << 2)\n            if op == 'beql' and not taken:\n                nxt = pc + 8\n            else:\n                pending = tgt if taken else pc + 8\n        elif op == 'j':\n            pending = ((pc + 4) & 0xF0000000) | (ins[1] << 2)\n        if pending is not None and op not in ('beq', 'bne', 'beql', 'j'):\n            nxt = pending\n            pending = None\n        pc = nxt\n    return [trace, r]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 2], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 3], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 1], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 3], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 6, 3, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 4], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 4, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 2], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 3, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 4], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 8, 4, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 5], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 5, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 3], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 4, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 5], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 10, 5, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 6], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 6, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 4], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 5, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 6], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 12, 6, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 7], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 7, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 5], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 6, 0]])]]\nfor label, args, expected in fixtures[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"},"fixed":{"sha256":"1e2caedfb6642996cdeaf03ff48831d82f9e03b7a79d8a46d93687fbea5e8790","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(*args):\n    prog, limit = args\n    r = [0] * 8\n    pc = 0\n    trace = []\n    pending = None\n    steps = 0\n    while steps < limit:\n        steps += 1\n        ins = prog[pc // 4] if 0 <= pc // 4 < len(prog) else ['halt']\n        trace.append(pc)\n        op = ins[0]\n        nxt = pc + 4\n        if op == 'halt':\n            break\n        if op == 'addi':\n            if ins[1]:\n                r[ins[1]] = r[ins[2]] + ins[3]\n        elif op in ('beq', 'bne', 'beql'):\n            taken = (r[ins[1]] == r[ins[2]]) == (op != 'bne')\n            off = ins[3] - 0x10000 if ins[3] & 0x8000 else ins[3]\n            tgt = pc + 4 + (off << 2)\n            if op == 'beql' and not taken:\n                nxt = pc + 8\n            else:\n                pending = tgt if taken else pc + 8\n        elif op == 'j':\n            pending = ((pc + 4) & 0xF0000000) | (ins[1] << 2)\n        if pending is not None and op not in ('beq', 'bne', 'beql', 'j'):\n            nxt = pending\n            pending = None\n        pc = nxt\n    return [trace, r]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 2], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 3], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 1], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 3], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 6, 3, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 4], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 4, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 2], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 3, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 4], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 8, 4, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 5], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 5, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 3], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 4, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 5], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 10, 5, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 6], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 6, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 4], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 5, 0]])], [('forward taken beq', [[['addi', 1, 0, 3], ['beq', 0, 0, 2], ['addi', 2, 2, 1], ['addi', 3, 0, 9], ['halt']], 40], [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]]), ('backward counted loop', [[['addi', 1, 0, 6], ['addi', 2, 2, 2], ['addi', 1, 1, -1], ['bne', 1, 0, 65533], ['addi', 3, 3, 1], ['halt']], 60], [[0, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 12, 6, 0, 0, 0, 0]]), ('branch likely not taken annuls slot', [[['addi', 1, 0, 1], ['beql', 1, 0, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['halt']], 40], [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]]), ('branch likely taken runs slot', [[['addi', 1, 0, 1], ['beql', 1, 1, 2], ['addi', 2, 0, 7], ['addi', 3, 0, 4], ['addi', 4, 0, 5], ['halt']], 40], [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]]), ('zero register and jump', [[['addi', 1, 0, 7], ['addi', 0, 1, 5], ['addi', 4, 0, 1], ['j', 5], ['addi', 5, 4, 1], ['addi', 6, 0, 3], ['halt']], 40], [[0, 4, 8, 12, 16, 20, 24], [0, 7, 0, 0, 1, 2, 3, 0]]), ('bne with nop slot', [[['addi', 1, 0, 1], ['bne', 1, 0, 3], ['nop'], ['addi', 7, 0, 1], ['halt'], ['addi', 6, 1, 5], ['halt']], 40], [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 6, 0]])]]\nfor label, args, expected in fixtures[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 emulator rule; the instruction semantics are a stipulated contract inspired by common ISAs and are not a claim of cycle-exact or architectural conformance. 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-instruction-set-emulation-delay-slot-offset-sign-extension","generated_at":"2026-09-29T14:51:19.962986+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Emulating MIPS-style pipelines requires executing the architectural delay slot and computing targets from the slot address.","repair":"Sign-extend the 16-bit offset by subtracting 0x10000 when bit 15 is set.","root_cause":"The 16-bit offset field is used as an unsigned value.","sha256":"5348233458274af78ddf6d501a0f40bdf4b88f35912997afec31adbdbe8b83a6","title":"Backward branch offset not sign-extended · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":39.743,"exit_code":1,"observations":[{"actual":[[0,4,8,16],[0,3,1,0,0,0,0,0]],"check":"forward taken beq","expected":[[0,4,8,16],[0,3,1,0,0,0,0,0]],"passed":true},{"actual":[[0,4,8,12,16,131076],[0,1,2,1,0,0,0,0]],"check":"backward counted loop","expected":[[0,4,8,12,16,4,8,12,16,20],[0,0,4,2,0,0,0,0]],"passed":false},{"actual":[[0,4,12,16],[0,1,0,4,0,0,0,0]],"check":"branch likely not taken annuls slot","expected":[[0,4,12,16],[0,1,0,4,0,0,0,0]],"passed":true},{"actual":[[0,4,8,16,20],[0,1,7,0,5,0,0,0]],"check":"branch likely taken runs slot","expected":[[0,4,8,16,20],[0,1,7,0,5,0,0,0]],"passed":true},{"actual":[[0,4,8,12,16,20,24],[0,3,0,0,1,2,3,0]],"check":"zero register and jump","expected":[[0,4,8,12,16,20,24],[0,3,0,0,1,2,3,0]],"passed":true},{"actual":[[0,4,8,20,24],[0,1,0,0,0,0,2,0]],"check":"bne with nop slot","expected":[[0,4,8,20,24],[0,1,0,0,0,0,2,0]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"forward taken beq\", \"actual\": [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]], \"expected\": [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"backward counted loop\", \"actual\": [[0, 4, 8, 12, 16, 131076], [0, 1, 2, 1, 0, 0, 0, 0]], \"expected\": [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]], \"passed\": false}, {\"check\": \"branch likely not taken annuls slot\", \"actual\": [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]], \"expected\": [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"branch likely taken runs slot\", \"actual\": [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]], \"expected\": [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]], \"passed\": true}, {\"check\": \"zero register and jump\", \"actual\": [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]], \"expected\": [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]], \"passed\": true}, {\"check\": \"bne with nop slot\", \"actual\": [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]], \"expected\": [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.491,"exit_code":1,"observations":[{"actual":[[0,4,8,16],[0,3,1,0,0,0,0,0]],"check":"forward taken beq","expected":[[0,4,8,16],[0,3,1,0,0,0,0,0]],"passed":true},{"actual":[[0,4,8,12,16,262148],[0,1,2,1,0,0,0,0]],"check":"backward counted loop","expected":[[0,4,8,12,16,4,8,12,16,20],[0,0,4,2,0,0,0,0]],"passed":false},{"actual":[[0,4,12,16],[0,1,0,4,0,0,0,0]],"check":"branch likely not taken annuls slot","expected":[[0,4,12,16],[0,1,0,4,0,0,0,0]],"passed":true},{"actual":[[0,4,8,16,20],[0,1,7,0,5,0,0,0]],"check":"branch likely taken runs slot","expected":[[0,4,8,16,20],[0,1,7,0,5,0,0,0]],"passed":true},{"actual":[[0,4,8,12,16,20,24],[0,3,0,0,1,2,3,0]],"check":"zero register and jump","expected":[[0,4,8,12,16,20,24],[0,3,0,0,1,2,3,0]],"passed":true},{"actual":[[0,4,8,20,24],[0,1,0,0,0,0,2,0]],"check":"bne with nop slot","expected":[[0,4,8,20,24],[0,1,0,0,0,0,2,0]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"forward taken beq\", \"actual\": [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]], \"expected\": [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"backward counted loop\", \"actual\": [[0, 4, 8, 12, 16, 262148], [0, 1, 2, 1, 0, 0, 0, 0]], \"expected\": [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]], \"passed\": false}, {\"check\": \"branch likely not taken annuls slot\", \"actual\": [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]], \"expected\": [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"branch likely taken runs slot\", \"actual\": [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]], \"expected\": [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]], \"passed\": true}, {\"check\": \"zero register and jump\", \"actual\": [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]], \"expected\": [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]], \"passed\": true}, {\"check\": \"bne with nop slot\", \"actual\": [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]], \"expected\": [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.586,"exit_code":0,"observations":[{"actual":[[0,4,8,16],[0,3,1,0,0,0,0,0]],"check":"forward taken beq","expected":[[0,4,8,16],[0,3,1,0,0,0,0,0]],"passed":true},{"actual":[[0,4,8,12,16,4,8,12,16,20],[0,0,4,2,0,0,0,0]],"check":"backward counted loop","expected":[[0,4,8,12,16,4,8,12,16,20],[0,0,4,2,0,0,0,0]],"passed":true},{"actual":[[0,4,12,16],[0,1,0,4,0,0,0,0]],"check":"branch likely not taken annuls slot","expected":[[0,4,12,16],[0,1,0,4,0,0,0,0]],"passed":true},{"actual":[[0,4,8,16,20],[0,1,7,0,5,0,0,0]],"check":"branch likely taken runs slot","expected":[[0,4,8,16,20],[0,1,7,0,5,0,0,0]],"passed":true},{"actual":[[0,4,8,12,16,20,24],[0,3,0,0,1,2,3,0]],"check":"zero register and jump","expected":[[0,4,8,12,16,20,24],[0,3,0,0,1,2,3,0]],"passed":true},{"actual":[[0,4,8,20,24],[0,1,0,0,0,0,2,0]],"check":"bne with nop slot","expected":[[0,4,8,20,24],[0,1,0,0,0,0,2,0]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"forward taken beq\", \"actual\": [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]], \"expected\": [[0, 4, 8, 16], [0, 3, 1, 0, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"backward counted loop\", \"actual\": [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]], \"expected\": [[0, 4, 8, 12, 16, 4, 8, 12, 16, 20], [0, 0, 4, 2, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"branch likely not taken annuls slot\", \"actual\": [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]], \"expected\": [[0, 4, 12, 16], [0, 1, 0, 4, 0, 0, 0, 0]], \"passed\": true}, {\"check\": \"branch likely taken runs slot\", \"actual\": [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]], \"expected\": [[0, 4, 8, 16, 20], [0, 1, 7, 0, 5, 0, 0, 0]], \"passed\": true}, {\"check\": \"zero register and jump\", \"actual\": [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]], \"expected\": [[0, 4, 8, 12, 16, 20, 24], [0, 3, 0, 0, 1, 2, 3, 0]], \"passed\": true}, {\"check\": \"bne with nop slot\", \"actual\": [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]], \"expected\": [[0, 4, 8, 20, 24], [0, 1, 0, 0, 0, 0, 2, 0]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}