decomp(md5): refine verified local declaration order #1072

Merged
coah80 merged 1 commits from agent/bittle/md5-order-review into main 2026-10-03 06:57:35 +00:00
coah80 commented 2026-10-03 06:57:04 +00:00 (Migrated from github.com)

Partial declaration-order gain

Reorder only the five existing uninitialized pointer/counter declarations. Initial state loads, all assignments, scopes, cursor helpers, arithmetic and memory operations remain source-identical.

  • ProcessBlock: 94.98366% → 95.55556%, still 306/306 instructions
  • Unit: 96.63377% → 97.01755%
  • Exact APIs 3/4, matched code 600 and data 456/456 preserved

The unchanged official declaration tool found the order in a bounded 23-evaluation run. A separately bounded continuation evaluated the retained order and all 22 swap/move neighbors without improvement, establishing a local fixed point for the tool's structural/positional comparator. No initialized declarations, helper changes or register hints.

Independent verification

Base a4d145c010bc8a8d3198e68baff458a161899c96; tested tree a8f4d6ea3d.

  • Full 43U build/progress/report/DOL passed; all 1,027 units compared, only MD5 fuzzy changes, zero regressions
  • Actual emitted source/original instruction streams reduce to the same unsigned symbolic 64-step MD5 recurrence with all message/constant/index loads and four state writes checked
  • 3,088 production-C digest/chunking vectors and 20,000 arbitrary-state block checks pass ASan/UBSan; context count, block and canaries preserved; leak checks disabled under ptrace
  • Host padding is supplied externally; exact GetDigest's PPC-endian length stores are not tested on the host
  • All three public APIs independently remain instruction-exact; allocated nontext data unchanged
  • Pool empty/identical; literal audit all four functions, no candidates/errors
  • DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d; worktree/diff checks pass

Partial fuzzy gain, no exact/linking claim. Details and both search trajectories: tools/decomp-assist/allhands-md5-declaration-order.attempts.md.

Note

Reorder local declarations in MD5 ProcessBlock to verified order

Reorders the five uninitialized locals in ProcessBlock in md5.c to index, block, constant, round, word. No types, logic, or behavior change; this matches the decompilation target.

Also adds a log of the declaration-order search in allhands-md5-declaration-order.attempts.md.

Macroscope summarized 823c109.

## Partial declaration-order gain Reorder only the five existing uninitialized pointer/counter declarations. Initial state loads, all assignments, scopes, cursor helpers, arithmetic and memory operations remain source-identical. - ProcessBlock: 94.98366% → 95.55556%, still 306/306 instructions - Unit: 96.63377% → 97.01755% - Exact APIs 3/4, matched code 600 and data 456/456 preserved The unchanged official declaration tool found the order in a bounded 23-evaluation run. A separately bounded continuation evaluated the retained order and all 22 swap/move neighbors without improvement, establishing a local fixed point for the tool's structural/positional comparator. No initialized declarations, helper changes or register hints. ## Independent verification Base a4d145c010bc8a8d3198e68baff458a161899c96; tested tree a8f4d6ea3d4ab650d19ccfce942c2e63e34890d5. - Full 43U build/progress/report/DOL passed; all 1,027 units compared, only MD5 fuzzy changes, zero regressions - Actual emitted source/original instruction streams reduce to the same unsigned symbolic 64-step MD5 recurrence with all message/constant/index loads and four state writes checked - 3,088 production-C digest/chunking vectors and 20,000 arbitrary-state block checks pass ASan/UBSan; context count, block and canaries preserved; leak checks disabled under ptrace - Host padding is supplied externally; exact GetDigest's PPC-endian length stores are not tested on the host - All three public APIs independently remain instruction-exact; allocated nontext data unchanged - Pool empty/identical; literal audit all four functions, no candidates/errors - DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d; worktree/diff checks pass Partial fuzzy gain, no exact/linking claim. Details and both search trajectories: tools/decomp-assist/allhands-md5-declaration-order.attempts.md. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Reorder local declarations in MD5 `ProcessBlock` to verified order > Reorders the five uninitialized locals in `ProcessBlock` in [md5.c](https://github.com/coah80/wii-ipl/pull/1072/files#diff-dbadc0abfbe32c537af7f9f3221ac1d057cd9705ae3611325af96ae5627bce7d) to index, block, constant, round, word. No types, logic, or behavior change; this matches the decompilation target. > > Also adds a log of the declaration-order search in [allhands-md5-declaration-order.attempts.md](https://github.com/coah80/wii-ipl/pull/1072/files#diff-135e5486e899d82ff26a6080cad2eb53d3719e2b1bddcf65c8ac5ef8be4b6ad8). > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 823c109.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 06:57:33 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.