"""Q: identify the CONSUMER of the item record's discard fields.

The parsed stack struct is local_188 (RBP+0x160) and it is handed to
`FUN_18011a830()->vtbl[0xa08](mgr, existingItem, &parsed)`. The heap records our
live probe walked have the SAME layout (discardValue at +0x38, client-computed at
+0x3c, both confirmed live), so a consumer reads [reg+0x38] / [reg+0x3c].

H1: no consumer reads +0x3c off an item; the display reads +0x38 only.
H2: some consumer reads +0x38 and falls back to +0x3c.

q3 found 40 "read 0x38 then read 0x3c off the same base" sites DLL-wide, three of
which sit in functions carrying an item fingerprint. Decompile those and decide.

CONTROL: FUN_18013fe00 is a known item handler and FUN_1800d8330 a known
cardsubtypeid mapper; both must decompile to something recognisable. Also resolve
FUN_18011a830's vtable slot 0xa08, which is the known sink, as a positive check
that vtable resolution works here at all.

Absence discipline: any "no consumer reads +0x3c" statement below is scoped to
CardsDLL's .text only. FIFA17.exe is Denuvo-packed and is NOT searched, so a
consumer living there cannot be excluded by this query.
"""
import traceback

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

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

    P("=== SINK: FUN_18011a830 and vtable slot 0xa08 ===")
    src = dec(0x18011A830)
    P("FUN_18011a830 decompile, len=%d" % len(src))
    P(src)

    for tgt in (0x1800AA440, 0x18007C5F0, 0x18007BF00, 0x1800D7920):
        s = dec(tgt)
        P("")
        P("=" * 100)
        P("=== FUN_%x FULL DECOMPILE, len=%d ===" % (tgt, len(s)))
        P(s)
        P("--- callers of %#x ---" % tgt)
        for frm, typ, fn, ent in xrefs_to(tgt):
            P("    %#x %-12s %s @ %#x" % (frm, typ, fn, ent))

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