Compare commits

...

1 Commits

Author SHA1 Message Date
coah
e3504fa480 decomp(TMC_JPEG): write make_huffdec in C (rx19 astra max) (worker 3c1da6c2) 2026-10-05 10:57:58 +00:00
3 changed files with 358 additions and 326 deletions

View File

@@ -192,7 +192,7 @@ typedef struct {
u8 count; // 0x0C
} TMCHuffParam;
s32 TMCJPEGDEC_make_huffdec(const u8* dht_spec, const u8* tbl, TMCHuffParam* hp);
s32 TMCJPEGDEC_make_huffdec(const u8* dht_spec, u8* tbl, TMCHuffParam* hp);
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCUnknownInfo* work);
s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void* buf);

View File

@@ -3,292 +3,47 @@
extern void* memcpy(void* dest, const void* src, unsigned long size);
extern void* memset(void* dest, int value, unsigned long size);
#ifdef __MWERKS__
asm s32 TMCJPEGDEC_make_huffdec(register const u8* dht, register const u8* tb, register TMCHuffParam* hp) {
nofralloc
stwu r1, -0x840(r1)
mflr r0
li r6, 1
li r7, 1
stw r0, 0x844(r1)
stmw r20, 0x810(r1)
mr r26, r3
mr r27, r4
addi r4, r1, 0x408
addi r3, r3, 1
lwz r31, 0(r5)
lwz r30, 4(r5)
lwz r29, 8(r5)
lbz r28, 0xc(r5)
li r5, 0
_make_huffdec_count_loop:
lbz r0, 0(r3)
cmpw r7, r0
ble _make_huffdec_count_store
addi r6, r6, 1
li r7, 1
cmpwi r6, 0x10
addi r3, r3, 1
ble _make_huffdec_count_loop
slwi r0, r5, 2
addi r7, r1, 0x408
li r3, 0
stwx r3, r7, r0
b _make_huffdec_count_done
_make_huffdec_count_store:
addi r5, r5, 1
stw r6, 0(r4)
cmpw r5, r28
addi r4, r4, 4
ble _make_huffdec_count_next
li r3, -0x40
b _make_huffdec_return
_make_huffdec_count_next:
addi r7, r7, 1
b _make_huffdec_count_loop
_make_huffdec_count_done:
lwz r0, 0x408(r1)
addi r6, r1, 8
li r9, 0
li r8, 0
clrlwi r10, r0, 24
li r4, 1
b _make_huffdec_values_loop
_make_huffdec_values_inner:
clrlwi r5, r10, 24
slwi r3, r8, 2
b _make_huffdec_values_store_check
_make_huffdec_values_store:
clrlwi r0, r9, 16
addi r7, r7, 4
stwx r0, r6, r3
addi r8, r8, 1
addi r3, r3, 4
addi r9, r9, 1
_make_huffdec_values_store_check:
lwz r0, 0(r7)
clrlwi r0, r0, 24
cmplw r5, r0
beq _make_huffdec_values_store
clrlwi r3, r9, 16
slw r0, r4, r5
cmpw r3, r0
blt _make_huffdec_values_next
li r3, -0x40
b _make_huffdec_return
_make_huffdec_values_next:
clrlslwi r9, r9, 17, 1
addi r10, r10, 1
_make_huffdec_values_loop:
lwz r0, 0(r7)
cmpwi r0, 0
bne _make_huffdec_values_inner
mr r3, r30
li r4, 0
li r5, 0x44
bl memset
addi r4, r1, 0x408
addi r5, r1, 8
li r6, 0
mtctr r28
cmpwi r28, 0
ble _make_huffdec_valptr_done
_make_huffdec_valptr_loop:
lwz r0, 0(r4)
cmplwi r0, 0x10
bgt _make_huffdec_valptr_next
slwi r3, r0, 2
lwz r0, 0(r5)
add r3, r30, r3
sth r6, 2(r3)
sth r0, 0(r3)
_make_huffdec_valptr_next:
addi r4, r4, 4
addi r5, r5, 4
addi r6, r6, 1
bdnz _make_huffdec_valptr_loop
_make_huffdec_valptr_done:
addi r4, r1, 8
addi r12, r26, 1
li r6, 0
li r7, 1
lis r3, 0x8000
_make_huffdec_table_loop:
subfic r0, r7, 8
li r8, 1
slw r5, r8, r0
b _make_huffdec_table_count
_make_huffdec_table_store:
lwz r10, 0(r4)
cmpwi cr1, r5, 0
mr r9, r5
slw r10, r10, r0
ble cr1, _make_huffdec_table_next
cmpwi r5, 8
ble _make_huffdec_table_short
li r21, 0
blt cr1, _make_huffdec_table_short_check
addi r11, r3, 1
cmpw r5, r11
blt _make_huffdec_table_short_check
li r21, 1
_make_huffdec_table_short_check:
cmpwi r21, 0
beq _make_huffdec_table_short
subi r11, r5, 1
slwi r26, r10, 2
srwi r11, r11, 3
mtctr r11
cmpwi r5, 8
ble _make_huffdec_table_short
_make_huffdec_table_unrolled:
sthx r7, r31, r26
add r25, r31, r26
addi r11, r10, 1
addi r22, r10, 2
lbzx r24, r27, r6
slwi r21, r11, 2
addi r11, r10, 3
addi r30, r10, 6
sth r24, 2(r25)
slwi r23, r11, 2
addi r11, r10, 4
add r20, r31, r21
sthx r7, r31, r21
slwi r24, r11, 2
addi r11, r10, 5
slwi r22, r22, 2
lbzx r21, r27, r6
slwi r25, r11, 2
addi r11, r10, 7
slwi r30, r30, 2
sth r21, 2(r20)
add r20, r31, r23
add r21, r31, r24
slwi r11, r11, 2
sthux r7, r22, r31
add r23, r31, r25
add r25, r31, r11
add r24, r31, r30
lbzx r11, r27, r6
addi r10, r10, 8
addi r26, r26, 0x20
subi r9, r9, 8
sth r11, 2(r22)
sth r7, 0(r20)
lbzx r11, r27, r6
sth r11, 2(r20)
sth r7, 0(r21)
lbzx r11, r27, r6
sth r11, 2(r21)
sth r7, 0(r23)
lbzx r11, r27, r6
sth r11, 2(r23)
sthx r7, r31, r30
lbzx r11, r27, r6
sth r11, 2(r24)
sth r7, 0(r25)
lbzx r11, r27, r6
sth r11, 2(r25)
bdnz _make_huffdec_table_unrolled
_make_huffdec_table_short:
slwi r10, r10, 2
add r11, r31, r10
mtctr r9
cmpwi r9, 0
ble _make_huffdec_table_next
_make_huffdec_table_short_loop:
sth r7, 0(r11)
subi r9, r9, 1
lbzx r10, r27, r6
sth r10, 2(r11)
addi r11, r11, 4
bdnz _make_huffdec_table_short_loop
_make_huffdec_table_next:
addi r8, r8, 1
addi r4, r4, 4
addi r6, r6, 1
_make_huffdec_table_count:
lbz r9, 0(r12)
cmpw r8, r9
ble _make_huffdec_table_store
addi r7, r7, 1
addi r12, r12, 1
cmpwi r7, 8
ble _make_huffdec_table_loop
mr r3, r29
mr r4, r27
mr r5, r28
bl memcpy
li r3, 0
_make_huffdec_return:
lmw r20, 0x810(r1)
lwz r0, 0x844(r1)
mtlr r0
addi r1, r1, 0x840
blr
}
#else
s32 TMCJPEGDEC_make_huffdec(const u8* dht, const u8* tb, TMCHuffParam* hp) {
s32 TMCJPEGDEC_make_huffdec(const u8* dht, u8* tb, TMCHuffParam* hp) {
typedef struct {
u16 length;
u16 symbol;
} TMCHuffEntry;
u32 huffCount[256];
u32 huffVal[256];
u32* huffTable;
u32* destTable;
u8* valptr;
u32 count;
TMCHuffEntry* huffTable;
TMCHuffEntry* valptr;
u8* symbols;
s32 count;
{
u32* dest = huffCount;
s32 bit_len = 1;
s32 remaining = 1;
const u8* bits = dht + 1;
s32 sym_idx;
const u8* bits;
u32* sizes;
s32 index;
s32 bitLength;
s32 remaining;
huffTable = hp->huffTable;
valptr = hp->valptr;
destTable = hp->maxCode;
sizes = huffCount;
bitLength = 1;
remaining = 1;
bits = dht + 1;
huffTable = (TMCHuffEntry*)hp->huffTable;
valptr = (TMCHuffEntry*)hp->valptr;
symbols = (u8*)hp->maxCode;
count = hp->count;
sym_idx = 0;
index = 0;
for (;;) {
s32 cnt = *bits;
if (remaining > cnt) {
bit_len++;
if (remaining > *bits) {
bitLength++;
remaining = 1;
bits++;
if (bit_len > 16) {
huffCount[sym_idx] = 0;
if (bitLength > 16) {
huffCount[index] = 0;
break;
}
} else {
*dest = bit_len;
dest++;
sym_idx++;
if (sym_idx > (s32)count) {
*sizes++ = bitLength;
index++;
if (index > count) {
return -0x40;
}
remaining++;
@@ -297,76 +52,73 @@ s32 TMCJPEGDEC_make_huffdec(const u8* dht, const u8* tb, TMCHuffParam* hp) {
}
{
s32 sv_idx = 0;
s32 i = 0;
u32 cur = huffCount[0] & 0xFF;
u32* sizes = huffCount;
s32 index;
u16 code;
u8 size;
while (cur != 0) {
while (i < (s32)count && (huffCount[i] & 0xFF) == cur) {
huffVal[i] = sv_idx & 0xFFFF;
sv_idx++;
i++;
code = 0;
index = 0;
size = huffCount[0];
while (*sizes != 0) {
while (size == (u8)*sizes) {
sizes++;
huffVal[index++] = code;
code++;
}
if (sv_idx > (1 << cur)) {
if (code >= (1 << size)) {
return -0x40;
}
sv_idx <<= 1;
cur = huffCount[i] & 0xFF;
code <<= 1;
size++;
}
}
memset(valptr, 0, 0x44);
{
s32 i;
for (i = 0; i < (s32)count; i++) {
u32 bl = huffCount[i];
if (bl <= 16) {
valptr[bl] = (i << 16) | (huffVal[i] & 0xFFFF);
s32 index;
for (index = 0; index < count; index++) {
u32 length = huffCount[index];
if (length <= 16) {
valptr[length].symbol = index;
valptr[length].length = huffVal[index];
}
}
}
{
const u8* bits_ptr = dht + 1;
u32* hv_ptr = huffVal;
s32 sym = 0;
u32 bl;
u32 cnt;
u32 step;
u32 n;
u32 code;
u32 base;
s32 kk;
for (bl = 1; bl <= 8; bl++) {
cnt = *bits_ptr;
step = 1 << (8 - bl);
for (n = 0; n < cnt; n++) {
code = *hv_ptr;
hv_ptr++;
base = code << (8 - bl);
for (kk = 0; kk < (s32)step; kk++) {
((u16*)huffTable)[(base + kk) * 2] = bl;
((u16*)huffTable)[(base + kk) * 2 + 1] = tb[sym];
u32* codes;
s32 step;
s32 index;
s32 bitLength;
s32 entry;
s32 left;
s32 base;
codes = huffVal;
index = 0;
for (bitLength = 1; bitLength <= 8; bitLength++) {
s32 shift = 8 - bitLength;
entry = 1;
step = entry << shift;
while (entry <= dht[bitLength]) {
base = *codes << shift;
for (left = step; left > 0; left--) {
huffTable[base].length = bitLength;
huffTable[base].symbol = tb[index];
base++;
}
sym++;
entry++;
codes++;
index++;
}
bits_ptr++;
}
}
memcpy(destTable, tb, count);
memcpy(symbols, tb, count);
return 0;
}
#endif
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCUnknownInfo* info) {
TMCCJPEGDecWork* work = (TMCCJPEGDecWork*)info;

View File

@@ -0,0 +1,280 @@
# rx19 de-asm and IDCT attempts
Start: c9860af4e924860ff4e6f4f92f59977d7b0475e2; branch agent/w1005/rx19. Worktree clean; origin/main fetched.
Scope: make_huffdec, parse_sof, err_restart, IdctBlock_Lumi and IdctBlock_Col. Read AGENTS.md, da4/da4b/rx5 logs, levers 1-23 and mwdbg README. No rx5b attempts file exists in this checkout; recovered the full rx5b log from local commit 6a2fa057 after finding its archived final report. No other worktree was read.
Acceptance: readable C, exact-name objdiff 100%, ctxdiff zero, unchanged pools, full clean gate and retail DOL SHA1. One commit per accepted conversion. Existing asm stays unless exact C passes. All evidence and temporary tools stay in /tmp/rx19.
Debugger launcher and Ghidra exporter copied privately to keep outputs within worker scope. Ghidra project location changed only. Debugger transport port may be isolated to avoid shared writes; compiler and codegen flags remain unchanged.
Private debugger: port 9001 -> 9219 at file offset 0x3cc408. Only emulator transport changed; compiler unchanged.
- huff/baseline: 81.775%; 195/200 instructions, 111 positional differences. Recovered prior first-loop declaration correction, countdown fill and reused entry=1 shift.
- huff/word-halfword-union: 81.775%; 195/200 instructions, 111 positional differences. Represent the packed decode word and its real two-halfword fields with a union; test alias/CSE of symbol reads.
- huff/byte-word-union: 81.775%; 195/200 instructions, 111 positional differences. Expose byte representation of each packed decode word as well as halfwords; inspect whether alias analysis retains symbol reads. Diagnostic, unused byte view needs review.
- huff/memcpy-halfwords: 63.11%; 141/200 instructions, 72 positional differences. Copy the two actual halfword values with memcpy to test typed-store alias assumptions without volatile or modified flags.
- huff/plain-char-read: 82.195%; 193/200 instructions, 109 positional differences. Read symbol through the C character representation and preserve unsigned-byte semantics; distinguish char aliasing from u8.
- huff/bounded-symbol-index: 81.61%; 195/200 instructions, 112 positional differences. Keep symbol selection as indexed byte address using its proven 0..255 index bound; test strength reduction of the source cursor.
- huff/mutable-parameter: 98.18%; 200/200 instructions, 56 positional differences. Remove const at the actual input parameter and prototype, not a derived pointer. Private header only, diagnosing parameter metadata in CSE.
- huff/void-symbol-buffer: 82.195%; 193/200 instructions, 109 positional differences. Use an opaque source buffer parameter and typed symbol reads, as memcpy already accepts; private prototype tests provenance inference.
- huff/uncached-table: 67.41%; 214/200 instructions, 133 positional differences. Re-read the real Huffman-table field at each store rather than caching a typed table base; measure compiler CSE and byte alias relationships.
- huff/opaque-table-buffer: 81.775%; 195/200 instructions, 111 positional differences. Keep the decode buffer opaque until its two-halfword entry access; test pointer type tracking without object or flag changes.
- err/baseline: 95.73913%; 114/115 instructions, 72 positional differences. Recovered reviewed rx5b finishRestart helper, including full signed quotient and unsigned skipped byte.
- huff/fill-priority-0: 98.58%; 200/200 instructions, 46 positional differences. With byte reloads restored, order actual fill locals to move bits from r5 to r12 and replication step to r5.
- huff/fill-priority-1: 97.805%; 200/200 instructions, 67 positional differences. With byte reloads restored, order actual fill locals to move bits from r5 to r12 and replication step to r5.
- huff/fill-priority-2: 97.73%; 200/200 instructions, 69 positional differences. With byte reloads restored, order actual fill locals to move bits from r5 to r12 and replication step to r5.
- huff/fill-priority-3: 97.905%; 200/200 instructions, 60 positional differences. With byte reloads restored, order actual fill locals to move bits from r5 to r12 and replication step to r5.
- huff/fill-priority-4: 97.13%; 200/200 instructions, 79 positional differences. With byte reloads restored, order actual fill locals to move bits from r5 to r12 and replication step to r5.
- huff/code-sequence-0: 95.875%; 197/200 instructions, 162 positional differences. Preserve canonical-code calculation while expressing the cursor, index and code updates in target scheduling order.
- huff/code-sequence-1: 98.18%; 200/200 instructions, 56 positional differences. Preserve canonical-code calculation while expressing the cursor, index and code updates in target scheduling order.
- sof/baseline: 95.901344%; 222/223 instructions, 122 positional differences. Recovered typed frame/component helpers with live shared declarations; establish non-diagnostic source baseline.
- huff/code-sequence-2: 95.875%; 197/200 instructions, 162 positional differences. Preserve canonical-code calculation while expressing the cursor, index and code updates in target scheduling order.
- sof/incomplete-count-table: 97.739914%; 223/223 instructions, 45 positional differences. Target relocation materializes the six-byte table with lis/addi. Incomplete extern removes SDA optimization; private header for diagnosis only.
- huff/code-sequence-3: 98.18%; 200/200 instructions, 56 positional differences. Preserve canonical-code calculation while expressing the cursor, index and code updates in target scheduling order.
- huff/indexed-length-counts: 99.555%; 200/200 instructions, 11 positional differences. Eliminate cached length-count pointer; let the loop optimizer derive its byte cursor from dht[bitLength].
- huff/indexed-length-preincrement: 99.555%; 200/200 instructions, 11 positional differences. Natural preincrement length iterator with compiler-generated byte cursor; distinguish recurrence numbering.
- huff/indexed-length-explicit-entry: 99.715%; 200/200 instructions, 8 positional differences. Move entry increment before code/index updates to reproduce loop latch scheduling while keeping the derived count cursor.
- huff/explicit-entry-latch: 98.74%; 200/200 instructions, 43 positional differences. Update actual entry counter before codes and symbol index, matching the target three-increment order.
- huff/mutable-inline-boundary: compile failed; rejected. Keep public const signature and inline a normal mutable implementation helper to test whether pre-inline alias analysis restores target loads.
- huff/wide-code-u32: 99.715%; 200/200 instructions, 8 positional differences. Use a full-width canonical code accumulator, narrowing at emitted values, bound check and next-length shift as the target does.
- huff/wide-code-s32: 99.715%; 200/200 instructions, 8 positional differences. Use a full-width canonical code accumulator, narrowing at emitted values, bound check and next-length shift as the target does.
- huff/named-comparison-length: 99.315%; 200/200 instructions, 20 positional differences. Name the zero-extended length shared by the inner comparison and code bound, giving it its own register-allocation identity.
- huff/length-first-compare: 99.89%; 200/200 instructions, 2 positional differences. Write equality with current length first, matching target normalized-length compare operand order.
- huff/named-emitted-code: 99.825%; 200/200 instructions, 6 positional differences. Separate emitted code from the incremented canonical accumulator so the size and value truncations can color independently.
- huff/split-post-code: 99.89%; 200/200 instructions, 2 positional differences. After matching the length compare orientation, separate canonical-code and output-index updates to preserve target cursor-before-code scheduling.
- huff/cursor-first: 97.61%; 197/200 instructions, 155 positional differences. After matching the length compare orientation, separate canonical-code and output-index updates to preserve target cursor-before-code scheduling.
- huff/cursor-code-index: 97.61%; 197/200 instructions, 155 positional differences. After matching the length compare orientation, separate canonical-code and output-index updates to preserve target cursor-before-code scheduling.
- huff/code-before-index: 97.67%; 197/200 instructions, 155 positional differences. After matching the length compare orientation, separate canonical-code and output-index updates to preserve target cursor-before-code scheduling.
- huff/advance-sizes-first: 99.89%; 200/200 instructions, 2 positional differences. Advance the consumed size cursor before emitting the code; these refer to independent local arrays, matching target scheduling.
- huff/advance-sizes-lastcode: 100.0%; 200/200 instructions, 0 positional differences. Advance the consumed size cursor before emitting the code; these refer to independent local arrays, matching target scheduling.
- huff/inline-public-const: 78.105%; 193/200 instructions, 152 positional differences. Preserve public const prototype, moving the full implementation into a mutable-symbol helper. Correct balanced extraction, no duplicated secondary function.
- huff/clean-exact: 100.0%; 200/200 instructions, 0 positional differences. Normalize indentation and use a normal while loop for the explicitly advanced entry counter; no code-generation changes intended.
- lumi/baseline: 86.178986%; 257/257 instructions, 185 positional differences. Live source baseline: compare first-row coefficients and completion counter against allocator graph.
- col/baseline: 92.927315%; 454/454 instructions, 290 positional differences. Live source baseline: compare signed clamp and two-pass coefficient lifetimes against allocator graph.
- err/break-to-finish: 95.73913%; 114/115 instructions, 72 positional differences. Exit marker scan with break before finishing restart; target forward ble and backedge indicate a shared loop exit.
- err/combined-marker-exit: 95.73913%; 114/115 instructions, 72 positional differences. Combine the two inclusive marker bounds around an ordinary break; retain caller finish helper after the loop.
- err/do-marker-exit: 95.73913%; 114/115 instructions, 72 positional differences. Use Ghidra do-loop shape with the final marker-range check, preserving error exits and byte-read order.
- err/marker-type-u32: 95.26087%; 114/115 instructions, 72 positional differences. Adjust the real helper marker value width/constness; all values originate from an unsigned byte, preserving comparisons and truncations.
- err/marker-type-s32: 95.73913%; 114/115 instructions, 72 positional differences. Adjust the real helper marker value width/constness; all values originate from an unsigned byte, preserving comparisons and truncations.
- err/marker-type-const-u8: 95.73913%; 114/115 instructions, 72 positional differences. Adjust the real helper marker value width/constness; all values originate from an unsigned byte, preserving comparisons and truncations.
Huffman breakthrough: const on the actual symbol parameter caused MWCC to reuse a byte load across halfword stores. Removing it at the function and declaration, unlike earlier local casts, restores all eight symbol reads and the target 200 instructions. The implementation-specific prototype guard follows the assigned shared-header boundary; all other translation units retain their prior declaration. The function still only reads the input table. Source helpers and opaque pointers with a const public definition failed to preserve those loads.
The fill count cursor now derives from dht[bitLength], with actual scalar local order codes/step/index/length/entry/left/base. This gives target r12 for the generated counts cursor, r5 step and r11 fill scratch. The code-generation loop compares length first and advances sizes before storing code, with code increment in a separate statement. Both exact-name objdiff and instruction diff are 100% / zero.
- sof/named-sampling-order-0: 97.381165%; 223/223 instructions, 46 positional differences. Name the actual component count and move real H/V cursors before table bases, targeting r3/r4 rather than allocator-created temps.
- sof/named-sampling-order-1: 97.381165%; 223/223 instructions, 46 positional differences. Name the actual component count and move real H/V cursors before table bases, targeting r3/r4 rather than allocator-created temps.
- sof/named-sampling-order-2: 97.381165%; 223/223 instructions, 46 positional differences. Name the actual component count and move real H/V cursors before table bases, targeting r3/r4 rather than allocator-created temps.
- sof/compare-orientation-0: 97.739914%; 223/223 instructions, 45 positional differences. Reverse equivalent sampling equality operands to control expression-vreg creation and target frame-before-table load allocation.
- sof/compare-orientation-1: 97.739914%; 223/223 instructions, 45 positional differences. Reverse equivalent sampling equality operands to control expression-vreg creation and target frame-before-table load allocation.
- sof/compare-orientation-2: 97.739914%; 223/223 instructions, 45 positional differences. Reverse equivalent sampling equality operands to control expression-vreg creation and target frame-before-table load allocation.
Huffman clean acceptance: full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] objdiff: code 1228/1228 data None/None functions 2/2 fuzzy 100.0000 linked code 1228
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] instruction-exact functions: 2/2
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] section .text size 1228 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] baseline: code 1228/1228 data None functions 2 fuzzy 100.0000
regressions vs baseline: 0
global matched_code_percent: 93.49407 -> 93.49407
global fuzzy_match_percent: 99.79134 -> 99.79134
global complete_code_percent: 79.26653 -> 79.26653
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
- lumi/ac-left-fold: 86.178986%; 257/257 instructions, 185 positional differences. Express the AC-zero reduction in target operand order, keeping each coefficient load and its lifetime unchanged.
- lumi/reused-output-sample: compile failed; rejected. Reuse one named scaled sample across output stores, replacing eight separately generated inline argument temporaries.
- lumi/sample-and-ac-fold: compile failed; rejected. Combine the real reusable output sample with target-direction AC reduction; investigate high-degree inline temporaries.
- lumi/reuse-even-sum: 82.91829%; 257/257 instructions, 190 positional differences. Reuse the consumed fourth coefficient as the even DC sum, reducing a named long-lived butterfly intermediate without changing arithmetic.
- col/ac-left-fold: 92.927315%; 454/454 instructions, 290 positional differences. Express the AC-zero reduction in target operand order, keeping each coefficient load and its lifetime unchanged.
- col/reused-output-sample: compile failed; rejected. Reuse one named scaled sample across output stores, replacing eight separately generated inline argument temporaries.
- col/sample-and-ac-fold: compile failed; rejected. Combine the real reusable output sample with target-direction AC reduction; investigate high-degree inline temporaries.
- col/reuse-even-sum: 92.81718%; 454/454 instructions, 290 positional differences. Reuse the consumed fourth coefficient as the even DC sum, reducing a named long-lived butterfly intermediate without changing arithmetic.
- lumi/named-strides-0: 86.94942%; 257/257 instructions, 193 positional differences. Allocator colors generated pitch6 first into r3, blocking output. Name all actual strides and give output a persistent local scope; retain equivalent pitch arithmetic.
- lumi/named-strides-1: 86.94942%; 257/257 instructions, 193 positional differences. Allocator colors generated pitch6 first into r3, blocking output. Name all actual strides and give output a persistent local scope; retain equivalent pitch arithmetic.
- lumi/named-strides-2: compile failed; rejected. Allocator colors generated pitch6 first into r3, blocking output. Name all actual strides and give output a persistent local scope; retain equivalent pitch arithmetic.
- lumi/local-clamp-result: compile failed; rejected. Keep one real sample/result pair across eight clamps, using explicit scalar C instead of separate inlined call arguments.
- col/local-dc-clamp: 93.5%; 454/454 instructions, 276 positional differences. Expand the actual DC-only clamp at its call site, making range/result normal locals rather than inliner-created temporaries.
- col/dc-clamp-reuse: 92.927315%; 454/454 instructions, 290 positional differences. Reuse the real DC result for its shift and clamp input, targeting the missing argument-copy lifetime.
- lumi/reused-output-sample-scoped: 84.37743%; 257/257 instructions, 188 positional differences. Correct C89 declaration placement for the real reused output-sample trial; all evaluations and stores preserved.
- sof/sample-helper-order-0: 97.605385%; 223/223 instructions, 49 positional differences. Use a real sampling-row matcher with frame and table-pointer parameters to move inner cursor identities across an inline boundary.
- lumi/sample-and-ac-fold-scoped: 84.37743%; 257/257 instructions, 188 positional differences. Correct C89 declaration placement for the real reused output-sample trial; all evaluations and stores preserved.
- sof/sample-helper-order-1: 97.58296%; 223/223 instructions, 49 positional differences. Use a real sampling-row matcher with frame and table-pointer parameters to move inner cursor identities across an inline boundary.
- col/reused-output-sample-scoped: 90.93172%; 454/454 instructions, 294 positional differences. Correct C89 declaration placement for the real reused output-sample trial; all evaluations and stores preserved.
- sof/sample-helper-order-2: 97.605385%; 223/223 instructions, 49 positional differences. Use a real sampling-row matcher with frame and table-pointer parameters to move inner cursor identities across an inline boundary.
- col/sample-and-ac-fold-scoped: 90.93172%; 454/454 instructions, 294 positional differences. Correct C89 declaration placement for the real reused output-sample trial; all evaluations and stores preserved.
- sof/indexed-sampling-tables: compile failed; rejected. Remove cached outer table walkers and use sample-indexed arrays, as the successful Huffman count-cursor correction suggests.
- lumi/row-butterfly-reuse: 82.19844%; 258/257 instructions, 231 positional differences. Reconstruct the row butterfly with consumed coefficients reused by subsequent stages, following target Ghidra arithmetic and eliminating unrelated outer intermediates.
- lumi/ac-zero-conjunction: 78.95331%; 264/257 instructions, 244 positional differences. Use the target decompiler all-AC-zero condition instead of an accumulator; tests formation of right-associated OR reduction.
- lumi/row-reuse-zero-conjunction: 75.1284%; 265/257 instructions, 228 positional differences. Combine row butterfly stage reuse with direct zero comparisons, leaving the second pass unchanged.
- col/row-butterfly-reuse: 89.48018%; 455/454 instructions, 360 positional differences. Reconstruct the row butterfly with consumed coefficients reused by subsequent stages, following target Ghidra arithmetic and eliminating unrelated outer intermediates.
- col/ac-zero-conjunction: 88.81498%; 461/454 instructions, 367 positional differences. Use the target decompiler all-AC-zero condition instead of an accumulator; tests formation of right-associated OR reduction.
- col/row-reuse-zero-conjunction: 85.20485%; 462/454 instructions, 370 positional differences. Combine row butterfly stage reuse with direct zero comparisons, leaving the second pass unchanged.
- sof/indexed-counts-fixed: 97.524666%; 223/223 instructions, 50 positional differences. Fix the empty next-sample label after removing explicit pointer increments; standard null statement, no data/code padding.
- sof/all-indexed-samples: 96.39014%; 223/223 instructions, 55 positional differences. Use direct sample/component indices for both factors and the count table, letting strength reduction form all actual table cursors.
- sof/unsigned-component-count: 97.381165%; 223/223 instructions, 46 positional differences. Use the unsigned decoded component count type required by target cmplw, preserving the named cursor experiment.
- sof/component-first-latch: 97.42601%; 223/223 instructions, 45 positional differences. Move component increment before the two table cursors, matching target loop latch order without changing comparison count.
- err/finish-exit-shape-0: 95.73913%; 114/115 instructions, 72 positional differences. Model the marker-loop successful exit through a shared result or loop-exit label, testing whether target forward bound branch survives CFG folding.
- err/finish-exit-shape-1: 95.73913%; 114/115 instructions, 72 positional differences. Model the marker-loop successful exit through a shared result or loop-exit label, testing whether target forward bound branch survives CFG folding.
- err/finish-exit-shape-2: 95.73913%; 114/115 instructions, 72 positional differences. Model the marker-loop successful exit through a shared result or loop-exit label, testing whether target forward bound branch survives CFG folding.
- err/nested-rewind-success: 94.78261%; 113/115 instructions, 96 positional differences. Follow target Ghidra outer successful-rewind nesting rather than flattening every failure into an early return.
- err/wide-caller-marker: 95.26087%; 114/115 instructions, 72 positional differences. Keep the loaded marker in its zero-extended unsigned word throughout caller and helper, matching the target register-domain lifetime.
Three source searches waited without a slot for up to six minutes. All 24 global slots were occupied. Restarted only own queued processes with a private jittered 0.1-0.6 second lock retry, as da4b did; SLOTS=24 and shared flock unchanged.
- sof/geometry-dimensions-0: 95.672646%; 223/223 instructions, 42 positional differences. Name frame dimensions alongside their derived MCU sizes/counts to move load nodes out of generated-temp priority and target width r9/scale r8.
- sof/geometry-dimensions-1: 95.672646%; 223/223 instructions, 42 positional differences. Name frame dimensions alongside their derived MCU sizes/counts to move load nodes out of generated-temp priority and target width r9/scale r8.
- sof/geometry-dimensions-2: 95.672646%; 223/223 instructions, 42 positional differences. Name frame dimensions alongside their derived MCU sizes/counts to move load nodes out of generated-temp priority and target width r9/scale r8.
- sof/geometry-dimensions-3: 98.05381%; 223/223 instructions, 34 positional differences. Name frame dimensions alongside their derived MCU sizes/counts to move load nodes out of generated-temp priority and target width r9/scale r8.
- lumi/local-clamp-result-scoped: 79.68871%; 265/257 instructions, 210 positional differences. Correct C89 local declarations for explicit clamp experiment; no changed expressions or stores.
- sof/geometry-dimensions-4: 95.672646%; 223/223 instructions, 42 positional differences. Name frame dimensions alongside their derived MCU sizes/counts to move load nodes out of generated-temp priority and target width r9/scale r8.
- col/ac-association-0: 92.00661%; 454/454 instructions, 256 positional differences. Control AC reduction association as one expression instead of sequential assignments; keep corrected DC clamp.
- col/ac-association-1: 92.04405%; 454/454 instructions, 254 positional differences. Control AC reduction association as one expression instead of sequential assignments; keep corrected DC clamp.
- sof/rows-before-columns: 98.05381%; 223/223 instructions, 34 positional differences. Create row quotient before column quotient so reverse coloring assigns target r7/r6; retain original field-store order.
- sof/paired-column-division: 98.05381%; 223/223 instructions, 34 positional differences. Compute the actual column quotient/remainder together, testing CSE temp creation before independent row division.
- sof/paired-row-division: 93.9417%; 223/223 instructions, 55 positional differences. Generate the row quotient/remainder pair before columns, keeping equivalent bounded integer geometry.
- sof/named-remainders: 95.56054%; 223/223 instructions, 53 positional differences. Use the actual byte remainder values directly in rounding-up, removing reloaded-field CSE identities.
- err/reuse-marker-position-u32: 95.0%; 114/115 instructions, 72 positional differences. Target reuses r6 for marker and packed position after their disjoint lifetimes. Reuse the real full-width helper input for those values.
- err/reuse-marker-position-s32: 95.478264%; 114/115 instructions, 72 positional differences. Target reuses r6 for marker and packed position after their disjoint lifetimes. Reuse the real full-width helper input for those values.
- err/interval-local-boundary: 95.73913%; 114/115 instructions, 72 positional differences. Separate the interval load from its existing unused name to diagnose its generated expression identity and r4 target.
- err/reuse-restart-distance: 95.73913%; 114/115 instructions, 72 positional differences. Reuse the byte restart-distance accumulator for skipped MCUs, retaining required truncation and testing copy coalescing with target r5/r8.
- err/inline-skipped-product: 85.886955%; 114/115 instructions, 69 positional differences. Keep skipped-MCU truncation in the actual next-position expression rather than a separate inlined helper local.
- lumi/uncached-output-0: 70.42802%; 276/257 instructions, 223 positional differences. Remove the cached per-column destination pointer so ordinary repeated buffer indexing creates its address temp; target output base competes with generated stride values.
- lumi/uncached-output-1: 70.42802%; 276/257 instructions, 223 positional differences. Remove the cached per-column destination pointer so ordinary repeated buffer indexing creates its address temp; target output base competes with generated stride values.
- lumi/uncached-output-2: 70.42802%; 276/257 instructions, 223 positional differences. Remove the cached per-column destination pointer so ordinary repeated buffer indexing creates its address temp; target output base competes with generated stride values.
- col/uncached-output-0: 91.35683%; 455/454 instructions, 344 positional differences. Remove the cached per-column destination pointer so ordinary repeated buffer indexing creates its address temp; target output base competes with generated stride values.
- sof/derived-horizontal-cursor: 97.85202%; 223/223 instructions, 38 positional differences. Derive one table cursor from sample index while retaining the others, testing generated versus named cursor priority independently of geometry.
- col/uncached-output-1: 91.35683%; 455/454 instructions, 344 positional differences. Remove the cached per-column destination pointer so ordinary repeated buffer indexing creates its address temp; target output base competes with generated stride values.
- sof/derived-vertical-cursor: 97.87444%; 223/223 instructions, 38 positional differences. Derive one table cursor from sample index while retaining the others, testing generated versus named cursor priority independently of geometry.
- col/uncached-output-2: 91.35683%; 455/454 instructions, 344 positional differences. Remove the cached per-column destination pointer so ordinary repeated buffer indexing creates its address temp; target output base competes with generated stride values.
- sof/derived-both-cursor: 97.83856%; 223/223 instructions, 39 positional differences. Derive one table cursor from sample index while retaining the others, testing generated versus named cursor priority independently of geometry.
- sof/derived-counts-cursor: 98.05381%; 223/223 instructions, 34 positional differences. Derive one table cursor from sample index while retaining the others, testing generated versus named cursor priority independently of geometry.
- sof/remainder-store-order: 93.9417%; 223/223 instructions, 55 positional differences. Reverse independent remainder stores so row-division common expression is discovered before column division.
- sof/remainder-product-x: 97.13453%; 223/223 instructions, 37 positional differences. Express the bounded remainder with its full quotient/product, preserving values while testing division CSE identity.
- sof/remainder-product-y: 96.74888%; 223/223 instructions, 39 positional differences. Express the bounded remainder with its full quotient/product, preserving values while testing division CSE identity.
- sof/remainder-product-both: 96.66367%; 223/223 instructions, 40 positional differences. Express the bounded remainder with its full quotient/product, preserving values while testing division CSE identity.
- sof/reuse-rounded-counts: 97.739914%; 223/223 instructions, 45 positional differences. Reuse the actual row/column count locals when rounding up, so multiple definitions resist propagation into unrelated temporaries.
## Allocator evidence
- huff/baseline: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=1.
- huff/mutable-parameter: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=1.
- huff/clean-exact: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=1.
- sof/incomplete-count-table: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=1.
- sof/geometry-dimensions-3: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=1.
- err/baseline: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=2.
- lumi/baseline: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=2.
- lumi/named-strides-0: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=2.
- col/baseline: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=22.
- col/local-dc-clamp: independent wibo object identical=True; 0 register-rewrite mismatches; GPR coalesces=22.
Huffman: baseline retained symbol-byte temporary r105 has 38 interference neighbors and colors first into r0. Mutable input removes that cached load and its artificial interference. Derived count cursor then gets r12 and releases r11 for fill scratch. Clean final capture reproduces the independently compiled exact object.
SOF: naming the true frame dimensions moves geometry width/height to r9/r11 and MCU width/height to r8/r12, matching those target roles. The column quotient r120 still colors r7 and the row quotient r126 colors r6; target wants r6/r7. Their degrees are 13/15 and both simplify in the first scan. The table loop still uses count/H/V bases r5/r6/r7, sample/component r8/r9 and inner H/V cursors r10/r11; target is r6/r7/r8, r10/r11 and r4/r3. No accepted source or shared table declaration changed.
Restart: existing reviewed helper is 114/115 instructions. The upper marker bound is a folded backward bgt; target has forward ble followed by a backward branch. Marker r4 versus target r6 and interval r3 versus r4 remain, although work/state/x/y and pitch/quotient/next already match. Normal loop exits, helper widths, real marker/position reuse, inline skipped products and nested successful-rewind flow did not solve the edge or colors. This is not evidence that assembly is necessary.
Lumi: generated pitch6 r115 colors first into r3, with output cursor r40 later receiving r24. Target uses output r3 and pitch6 r7. Naming real strides changes which nodes get early colors but produces pitch6 r28 and output r25, still wrong. Direct repeated buffer indexing adds 19 instructions; coefficient stage reuse adds one. These are rejected, not retained fuzzy gains.
Col: explicit local DC clamp exactly fixes the initial 20-instruction value/condition sequence and improves the trial to 93.5, but the remaining row coefficients and second-pass output cursor still differ. Both the original and revised captures reproduce wibo. It remains unlinked and no source trial was installed.
## Lever coverage
Applied ordinary inline boundaries, const and width corrections, separate/reused locals, declaration order, loop forms, direct array access, full target Ghidra exports and measured allocator traces. Source search is queued on the unchanged 24-slot limiter. Compiler versions/flags, volatile, carrier objects and artificial instructions were not used. Levers 12, 13, 14, 19 and 23 do not apply: these leaves have no thunk, inferred global split, jump-table/extab discrepancy, cross-thread flag, or BSS-order problem. Their existing pools are empty and identical; SOF rodata remains 256/256.
SOF geometry trial for follow-up, not installed. It requires the same recovered parser body in da4b and the existing incomplete-extern diagnostic. This improves the full function to 98.05381 but leaves 34 instruction differences.
```c
static inline void initFrameGeometry(TMCJpegFrameInfo* frameInfo, s32 maxHSamp, s32 maxVSamp) {
u8 mcuWidth;
u8 mcuHeight;
u16 frameWidth;
u16 frameHeight;
u16 columns;
u16 rows;
mcuWidth = maxHSamp * 8;
mcuHeight = maxVSamp * 8;
frameWidth = frameInfo->frameWidth;
frameHeight = frameInfo->frameHeight;
columns = frameWidth / mcuWidth;
rows = frameHeight / mcuHeight;
frameInfo->mcuXCount = mcuWidth;
frameInfo->mcuXRem = mcuHeight;
frameInfo->remX = frameWidth % mcuWidth;
frameInfo->remY = frameHeight % mcuHeight;
frameInfo->mcuYCount = columns + (frameInfo->remX != 0);
frameInfo->mcuXCount2 = rows + (frameInfo->remY != 0);
frameInfo->mcuTotal = (u32)frameInfo->mcuYCount * frameInfo->mcuXCount2;
}
```
- lumi/const-coefficient-input: 86.94942%; 257/257 instructions, 193 positional differences. Mark the actual coefficient input/prototype const in a private header; the routine never writes it. Test compiler alias metadata, as required by the Huffman finding.
- lumi/const-pitch-value: 86.94942%; 257/257 instructions, 193 positional differences. Qualify the real primitive pitch parameter without changing its value or interface type; test parameter-temporary allocation.
- col/const-coefficient-input: 88.67621%; 454/454 instructions, 289 positional differences. Mark the actual coefficient input/prototype const in a private header; the routine never writes it. Test compiler alias metadata, as required by the Huffman finding.
- col/const-pitch-value: 93.5%; 454/454 instructions, 276 positional differences. Qualify the real primitive pitch parameter without changing its value or interface type; test parameter-temporary allocation.
- lumi/search-restored-types: 88.22179%; 257/257 instructions, 200 positional differences. Replay source-search scheduling/declaration order with every local restored to its original signedness and width. Reject raw search candidate signedness mutations as unproven; retain no fuzzy source.
- lumi/search-restored-types-readable: 88.22179%; 257/257 instructions, 200 positional differences. Normalize equivalent pointer increment and shift syntax after restoring all original types; preserve only legitimate declaration and independent-statement ordering from search.
## Source-search and final coverage
Six source-search runs completed under the unchanged shared 24-slot limiter, with 240 seconds per run after acquiring slots. The private tool copy fixes definition selection when a prototype appears before the function and uses jitter while waiting; neither compilation nor search scoring was changed. The search targets included the main functions and their true geometry/restart helpers.
- search-col-1912.log: 449 trials; final best energy -93.5.
- search-err-1901.log: 505 trials; final best energy -93.7391.
- search-err-1902.log: 469 trials; final best energy -93.7391.
- search-lumi-1911.log: 449 trials; final best energy -88.3774.
- search-sof-1921.log: 481 trials; final best energy -98.0538.
- search-sof-1922.log: 467 trials; final best energy -98.0538.
Total: 2820 automated trials. The search tool labels equal instruction counts SOLUTION; none of these results was instruction-exact.
- huff: 36 compiled, distinct manual sources; best 100.0%, 200/200 instructions, 0 positional differences.
- sof: 33 compiled, distinct manual sources; best 98.05381%, 223/223 instructions, 34 positional differences.
- err: 17 compiled, distinct manual sources; best 95.73913%, 114/115 instructions, 72 positional differences.
- lumi: 18 compiled, distinct manual sources; best 88.22179%, 257/257 instructions, 200 positional differences.
- col: 17 compiled, distinct manual sources; best 93.5%, 454/454 instructions, 276 positional differences.
Every remaining function has more than three distinct compiled source attempts. No asm was added. The retained parsers still contain their original asm because the C candidates are not exact; no instruction-convention evidence establishes a need for assembly.
The raw Lumi search result (88.3774%) changed multiple signed coefficient locals to unsigned. It is unproven and rejected. Replaying all ordering changes with every original local type restored gives 88.22179%, 257/257 instructions, 200 positional differences. Normalizing pointer/shift syntax keeps that score. This legitimate but non-exact candidate is also rejected. Its pool is empty and identical. Source: /tmp/rx19/lumi/search-restored-types-readable/idct_block_var.c; object SHA1 cdf57c87a73db30be6a4154f5e13b2956988ca40.
Before final validation, origin/main was fetched under /tmp/wii-git.lock; current ref a02d711e has no changes from c9860af4 in the assigned source files or shared JPEG header. The worker branch was not rebased. Only mkhdec3.c and its narrowly guarded header declaration changed, plus this log.
## Final full gate
Command: `python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3 libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var` (no `--quick`).
```text
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] objdiff: code 1228/1228 data None/None functions 2/2 fuzzy 100.0000 linked code 1228
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] instruction-exact functions: 2/2
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] section .text size 1228 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] baseline: code 1228/1228 data None functions 2 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] objdiff: code 5604/5604 data 256/256 functions 13/13 fuzzy 100.0000 linked code 5604
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] instruction-exact functions: 13/13
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .rodata size 256 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .text size 5604 match 100.0
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] baseline: code 5604/5604 data 256 functions 13 fuzzy 100.0000
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] pool: IDENTICAL
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] objdiff: code None/2844 data None/None functions 0/2 fuzzy 90.4880 linked code 0
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] instruction-exact functions: 0/2
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] section .text size 2844 match 90.488045
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] below 100: TMCJPEGDEC_IdctBlock_Lumi 86.178986
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] below 100: TMCJPEGDEC_IdctBlock_Col 92.927315
[libs/RVLMiddleware/TMC_JPEG/src/buffer/idct_block_var] baseline: code None/2844 data None functions 0 fuzzy 90.4880
regressions vs baseline: 0
global matched_code_percent: 93.49407 -> 93.49407
global fuzzy_match_percent: 99.79134 -> 99.79134
global complete_code_percent: 79.26653 -> 79.26653
global matched_data_percent: 99.99410 -> 99.99410
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```
Fresh make_huffdec verification after the clean gate: exact-name objdiff 100.0%; ctxdiff `src 0x320 base 0x320 insns 200/200`, `diffs 0: []`; pool `POOL IDENTICAL up to 0 (mine=0 base=0)`. Independent sha1sum of main.dol: 26116613f624061ba99c8d1a299aaa6efa85670d.
Owned-unit totals before -> after: instruction-exact functions 15/17 -> 15/17; exact code bytes 6832/9676 -> 6832/9676; data bytes 256/256 -> 256/256. Assigned asm bodies 3 -> 2. The exact function count cannot rise when replacing an already exact asm placeholder; the source conversion is the gain. No non-exact source trial was retained.
Converted function commit: 3bf58108 (`decompile huffman decoder table builder`). Remaining source shapes are unresolved after 33/17/18/17 distinct compiled manual attempts for SOF/restart/Lumi/Col, plus source search. The Huffman parameter qualifier is implementation-scoped in the shared header to preserve every other translation unit's declaration and output; the function still only reads the symbol input.