decomp(aes): improve decrypt declaration order to 76.71% #1084

Merged
coah80 merged 1 commits from agent/bittle/aes-state-final into main 2026-10-03 09:02:30 +00:00
coah80 commented 2026-10-03 09:01:01 +00:00 (Migrated from github.com)

Scope

Splits the existing uninitialized u32 a,b,c,d; declaration in place and reorders only those four state declarations to d,b,c,a. No new variable, initializer, expression, assignment, scope, type, helper, table, ABI or linking change. The original a,b,c,d formatting-only split was separately rebuilt and proved whole-object/full-report neutral before searching.

Independent parent verification on 9e8ca608

  • AESiDecryptBlock fuzzy 72.30677% → 76.70518%; unit82.04506% →83.64971%
  • Still251/251 instructions, positional differences217 →205; this is partial, not exact
  • AESiEncryptBlock65.81013% and its body unchanged; all8 sibling instruction streams unchanged
  • Exact7/9, matched code1116/2752 and data2800/2800 preserved
  • All1027-unit report and allocated-object comparisons: only AES text changes, no regressions; all45 relocations and nontext data unchanged
  • Parent freshly compiled actual baseline/candidate C under UBSan and independently reran2406 AES-128/192/256 CBC known-answer/randomized cases per source, including in-place/incremental operation
  • Parent reran2688 direct-block partial input/output-overlap cases under UBSan, offsets−3 through+3 words
  • Actual source/original final-round interpreter passes4608 state/key-publication cases for both, including eight placements overlapping/adjoining key words. Interleaved K0-load/O0-store through K3-load/O3-store remains preserved. Immutable S-box load scheduling still differs; these diagnostic alias tests are not a new public API guarantee or full Wii runtime proof
  • Pool4/4 identical; literal audit9 functions /5 arguments, no candidates/skips/errors
  • Full default progress/43U/ok build, worktree/diff gates pass; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d

One unchanged declsearch invocation, lines201–204, max24: (93,217) →(68,215) →(61,214) →(60,205). Natural local fixed point after17 evaluated orders, not all24 permutations. No second run, initialized-local reordering or forced register construct. This changes compiler allocation/scheduling, not reconstructed algorithm behavior.

Candidate object SHA2569eaf814a28a1585d780efa84a36f8981711b95c64566f67cf99469154eefc970 remains identical after rebase. Uploaded tree44dc083e0ab87b1e27aaf9b53fdc7a6234789dc2 equals parent-tested tree. Evidence and reproduction commands included in attempts log. No merge or auto-merge requested.

Note

Reorder AES state declarations in AESiDecryptBlock to match decompilation at 76.71%

Splits and reorders the four local state declarations in AESiDecryptBlock in aes.c to improve decompilation match to 76.71%. No initializer, type, scope, or control-flow changes.

Macroscope summarized 42f6da1.

## Scope Splits the existing uninitialized `u32 a,b,c,d;` declaration in place and reorders only those four state declarations to d,b,c,a. No new variable, initializer, expression, assignment, scope, type, helper, table, ABI or linking change. The original a,b,c,d formatting-only split was separately rebuilt and proved whole-object/full-report neutral before searching. ## Independent parent verification on 9e8ca608 - AESiDecryptBlock fuzzy 72.30677% → 76.70518%; unit82.04506% →83.64971% - Still251/251 instructions, positional differences217 →205; this is partial, not exact - AESiEncryptBlock65.81013% and its body unchanged; all8 sibling instruction streams unchanged - Exact7/9, matched code1116/2752 and data2800/2800 preserved - All1027-unit report and allocated-object comparisons: only AES text changes, no regressions; all45 relocations and nontext data unchanged - Parent freshly compiled actual baseline/candidate C under UBSan and independently reran2406 AES-128/192/256 CBC known-answer/randomized cases per source, including in-place/incremental operation - Parent reran2688 direct-block partial input/output-overlap cases under UBSan, offsets−3 through+3 words - Actual source/original final-round interpreter passes4608 state/key-publication cases for both, including eight placements overlapping/adjoining key words. Interleaved K0-load/O0-store through K3-load/O3-store remains preserved. Immutable S-box load scheduling still differs; these diagnostic alias tests are not a new public API guarantee or full Wii runtime proof - Pool4/4 identical; literal audit9 functions /5 arguments, no candidates/skips/errors - Full default progress/43U/ok build, worktree/diff gates pass; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d ## Bounded official search One unchanged declsearch invocation, lines201–204, max24: (93,217) →(68,215) →(61,214) →(60,205). Natural local fixed point after17 evaluated orders, not all24 permutations. No second run, initialized-local reordering or forced register construct. This changes compiler allocation/scheduling, not reconstructed algorithm behavior. Candidate object SHA2569eaf814a28a1585d780efa84a36f8981711b95c64566f67cf99469154eefc970 remains identical after rebase. Uploaded tree44dc083e0ab87b1e27aaf9b53fdc7a6234789dc2 equals parent-tested tree. Evidence and reproduction commands included in attempts log. No merge or auto-merge requested. <!-- 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 AES state declarations in `AESiDecryptBlock` to match decompilation at 76.71% > Splits and reorders the four local state declarations in `AESiDecryptBlock` in [aes.c](https://github.com/coah80/wii-ipl/pull/1084/files#diff-7415b165f7916eb45d6d57b772d27d3eb931d2ce912411adf8b0ad45f3a5fbe9) to improve decompilation match to 76.71%. No initializer, type, scope, or control-flow changes. > > - Adds [allhands-aes-state-declaration-order.attempts.md](https://github.com/coah80/wii-ipl/pull/1084/files#diff-a6ad0ecc5988c471f2e501a56f09c7439cdb04a57f3732b6b3c62a60035121a3), a log of the declaration-order search, candidate build comparisons, and final gate results. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 42f6da1.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 09:02:27 +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.