"""VERIFY PASS 1.

Hypothesis under attack: the D1/D2 agents' HIGH claims about deserializer shapes.
Method: print FULL decompiles with len(src) for every function whose contents an
absence claim depends on, so truncation can be ruled out by the reader.

Controls (must all resolve, else the batch is suspect):
  FutSquadSaveServerResponse   -> 0x180171a60
  FutSquadListServerResponse   -> 0x180172140
  FutCreateMatchServerResponse -> 0x180120380
"""
import traceback

OUT = "/tmp/claude-1000/-home-alex-Documents-OpenFUT/8e521ca1-ca3e-4138-bb96-df1744dd1d30/scratchpad/packres/v1_raw.txt"

try:
    lines = []
    def P(*a):
        s = " ".join(str(x) for x in a)
        print(s)
        lines.append(s)

    P("=" * 70)
    P("CONTROL BATCH: class_deser")
    for name in ["FutSquadSaveServerResponse", "FutSquadListServerResponse",
                 "FutCreateMatchServerResponse", "FutDiscardCardServerResponse",
                 "FutMoveCardServerResponse", "FutUserCreditsServerResponse",
                 "FutSBCSubmitChallengeServerResponse",
                 "FutGetPurchasedItemsServerResponse"]:
        try:
            P("  %-42s -> %s" % (name, [hex(x[0]) for x in class_deser(name)]))
        except Exception as e:
            P("  %-42s -> ERR %s" % (name, e))

    TARGETS = [
        (0x18014cc60, "D1-1 FutCreateUserServerResponse deser"),
        (0x18013ec10, "D1-2/D1-7 userInfo record deser"),
        (0x180138e10, "D2-1 duplicateItemIdList element parser"),
        (0x180127300, "D2-5 FutDiscardCardServerResponse deser"),
        (0x180128600, "D2-9 FutMoveCardServerResponse deser"),
        (0x180162880, "D2-2 createPackResponse deser"),
        (0x180126f40, "D2-10 bulk discard body builder"),
        (0x180127cc0, "D2-3 MoveCard request body builder"),
        (0x180142650, "D2-8 pile string->enum decoder"),
        (0x18013bd40, "D1-11 FutGetPurchasedItems body deser"),
        (0x180124ee0, "D1-11 FutGetPurchasedItems root deser"),
        (0x180127570, "D2-4 discard URL suffix builder"),
    ]
    for va, tag in TARGETS:
        f = func(va)
        src = dec(va)
        P("")
        P("=" * 70)
        P("### %s  @ %#x  fname=%s  entry=%s  len(src)=%d" %
          (tag, va, fname(va) if f else "?",
           hex(int(f.getEntryPoint().getOffset())) if f else "NONE", len(src)))
        P("=" * 70)
        P(src)

    with open(OUT, "w") as fh:
        fh.write("\n".join(lines))
    print("WROTE", OUT, len(lines), "lines")
except Exception:
    traceback.print_exc()
