From 5bf1be949af0a82193313a71b4ae66d443282fff Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Thu, 1 Oct 2026 01:28:42 +0000 Subject: [PATCH] ATERM/AOSS: small fuzzy gains (worker 52d046e2) --- README.md | 2 +- src/scene/setting/AOSS.c | 81 ++++++++------ src/scene/setting/ATERM.c | 32 +++--- tools/decomp-assist/AOSS.attempts.md | 106 ++++++++++++++++++ tools/decomp-assist/ATERM.attempts.md | 148 ++++++++++++++++++++++++++ 5 files changed, 319 insertions(+), 50 deletions(-) create mode 100644 tools/decomp-assist/AOSS.attempts.md diff --git a/README.md b/README.md index 1e6d9cfb..799521b5 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Progress | Decompiled | Matched | Linked | Data | |:---:|:---:|:---:|:---:| -| 98.89% | 86.34% | 60.34% | 90.92% | +| 98.90% | 86.34% | 60.34% | 90.92% | units 902/1027 complete, functions 12136/12563 matched. diff --git a/src/scene/setting/AOSS.c b/src/scene/setting/AOSS.c index 7d865bd4..47609ded 100644 --- a/src/scene/setting/AOSS.c +++ b/src/scene/setting/AOSS.c @@ -8,8 +8,8 @@ typedef union AOSSWaitSettings { u32 value; struct { - u16 high; - u16 low; + s16 high; + s16 low; } halfwords; } AOSSWaitSettings; @@ -20,6 +20,12 @@ typedef struct AOSSSocketAddress { u32 address; } AOSSSocketAddress; +typedef struct AOSSPollDescriptor { + s32 socket; + s32 events; + s32 returnedEvents; +} AOSSPollDescriptor; + typedef struct AOSSRuntimeState { void* config; u32 configLength; @@ -279,7 +285,7 @@ extern int AOSSi_Status(int status); extern int AOSSi_SetNCDIPAddr(u32 ipAddress, u32 netmask, u32 gateway, u32 dns1, u32 dns2); extern int AOSSi_Sleep(u32 duration); extern int AOSSi_WLANConnect(void); -extern int SOPoll(s32* descriptors, int count, s32 timeoutHigh, s32 timeoutLow); +extern int SOPoll(AOSSPollDescriptor* descriptors, int count, s32 timeoutHigh, s32 timeoutLow); extern int SORecvFrom(int socket, void* buffer, int length, int flags, void* address); extern int SOSendTo(int socket, const void* buffer, int length, int flags, const void* address); extern int SOBind(int socket, const void* address); @@ -414,7 +420,7 @@ int AOSS_Init_old(AOSSInitInput* input) AOSSRequestRecords requestRecords; struct { s16 connection; - u16 response; + s16 response; } waitIntervals; AOSSSocketAddress replyAddress; u8 messageIdentity[8]; @@ -422,9 +428,7 @@ int AOSS_Init_old(AOSSInitInput* input) int pollSeconds; int pollSubseconds; AOSSSocketAddress receivedAddress; - s32 pollArguments[4]; - u32 pollResultHigh; - u32 pollResultLow; + AOSSPollDescriptor pollArguments[2]; u32 networkAddresses[5]; u32 gatewayAddress; @@ -442,11 +446,11 @@ int AOSS_Init_old(AOSSInitInput* input) initialWait = 10; } waitIntervals.response = input->options[1]; - if (waitIntervals.response == 0xffff) { + if (waitIntervals.response == -1) { waitIntervals.response = 100; } waitSettings.halfwords.low = input->options[3]; - if (waitSettings.halfwords.low == 0xffff) { + if (waitSettings.halfwords.low == -1) { waitSettings.halfwords.low = 100; } waitSettings.halfwords.high = initialWait; @@ -990,12 +994,12 @@ invalid_request_state: memset(packetBuffer,0,0x5f8); pollSeconds = timeoutMilliseconds / 1000; pollSubseconds = (timeoutMilliseconds % 1000) * 1000; - pollArguments[1] = 1; - pollArguments[0] = s_socket; - pollArguments[2] = 0; - pollArguments[3] = s_socket; - pollResultLow = 0; - pollResultHigh = 1; + pollArguments[0].events = 1; + pollArguments[0].socket = s_socket; + pollArguments[0].returnedEvents = 0; + pollArguments[1].socket = s_socket; + pollArguments[1].returnedEvents = 0; + pollArguments[1].events = 1; timeoutTicks = (u32)(pollSeconds * (OS_BUS_CLOCK >> 2)); tickRemainder = (u32)(pollSubseconds * ((OS_BUS_CLOCK >> 2) / 125000)) >> 3; requestResult = SOPoll(pollArguments,1,((u32)((timeoutTicks + tickRemainder) >> 32)),(int)timeoutTicks + (int)tickRemainder); @@ -2318,18 +2322,20 @@ int AOSS_81401574(void* packet, AOSSRequestRecords* request, int socket) { int AOSS_81401778(void* packet, void* request, int socket) { AOSSHelloPacket* response = (AOSSHelloPacket*)s_responseBuffer; - AOSSHelloPayload* payload = &response->payload; + AOSSHelloPayload* payload; AOSSRequestRecords* requestRecords = (AOSSRequestRecords*)request; AOSSSocketAddress destination; AOSSKeySchedule schedule; AOSSHelloRecord hello; u8 accessPointName[8]; - u8 checksum; + u32 checksum; u16 nonce; - u32 crc; u32 stateLength; u32 index; u32 firstByte; + u32 firstIndex; + u32 secondIndex; + u8* state; u8 value; u8 swap; s16 responseLength; @@ -2341,6 +2347,7 @@ int AOSS_81401778(void* packet, void* request, int socket) { sequence = 0; memset(&hello, 0, sizeof(hello)); memset(response, 0, 0x5dc); + payload = &response->payload; hello.data.fields.type = 2; hello.data.fields.reserved01 = 0; hello.data.fields.length = SOHtoNs(4); @@ -2349,18 +2356,19 @@ int AOSS_81401778(void* packet, void* request, int socket) { responseLength = 8; if ((s32)s_connectionState == 1) { + const u32* crcTable = s_crcTable; sequence = 1; - crc = 0xffffffff; + checksum = 0xffffffff; AOSS_81401DC0(0, s_crcTable); - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[0]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[1]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[2]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[3]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[4]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[5]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[6]) & 0xff]; - crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[7]) & 0xff]; - checksum = (u8)crc ^ 0xff; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[0]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[1]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[2]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[3]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[4]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[5]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[6]) & 0xff]; + checksum = (checksum >> 8) ^ crcTable[(checksum ^ hello.data.bytes[7]) & 0xff]; + checksum = (checksum ^ 0xffffffff) & 0xff; schedule.bytes = (u8*)AOSSi_Alloc(8); if (schedule.bytes != 0) { @@ -2371,14 +2379,17 @@ int AOSS_81401778(void* packet, void* request, int socket) { AOSS_81401C9C(&schedule, s_packetState.keyNonce, sizeof(s_packetState.keyNonce) + sizeof(s_packetState.keyAddress), 8); for (index = 0; index < 8; index++) { - schedule.i = (schedule.i + 1) % schedule.length & 0xff; - firstByte = schedule.bytes[schedule.i]; - schedule.j = (firstByte + schedule.j) % schedule.length & 0xff; - swap = schedule.bytes[schedule.j]; + state = schedule.bytes; + firstIndex = (schedule.i + 1) % schedule.length & 0xff; + firstByte = state[firstIndex]; + secondIndex = (firstByte + schedule.j) % schedule.length & 0xff; + swap = state[secondIndex]; stateLength = firstByte + swap; - schedule.bytes[schedule.j] = (u8)firstByte; - schedule.bytes[schedule.i] = swap; - value = schedule.bytes[stateLength % schedule.length] ^ hello.data.bytes[index]; + schedule.i = firstIndex; + schedule.j = secondIndex; + state[secondIndex] = (u8)firstByte; + state[firstIndex] = swap; + value = state[stateLength % schedule.length] ^ hello.data.bytes[index]; payload->bytes[index + 4] = value; } AOSSi_Free(schedule.bytes); diff --git a/src/scene/setting/ATERM.c b/src/scene/setting/ATERM.c index a3dc09c3..8c916b9c 100644 --- a/src/scene/setting/ATERM.c +++ b/src/scene/setting/ATERM.c @@ -522,7 +522,7 @@ char gAtermAossSsid[7] = "******"; extern u32 gAtermUseSharedAddress; extern char gAtermProductName[5]; u32 gAtermCancelRequested; -u8 gAtermSelectedBssid[8]; +u8 gAtermSelectedBssid[6]; u32 gAtermProtocolState; u8 gAtermAddressBuffer[8]; u32 gAtermResponseMode; @@ -906,7 +906,7 @@ int ATERM_81402A24(void) { while (iteration < 300 && gAtermCancelRequested == 0) { s64 currentTime = OSGetTime(); now = (u32)OSTicksToMilliseconds(currentTime); - if (gAtermDeadline <= now) { + if (now >= gAtermDeadline) { break; } @@ -931,7 +931,7 @@ int ATERM_81402A24(void) { while ((s32)recordIndex < result) { WDBssDesc* descriptor = (WDBssDesc*)descriptorWords; - memcpy(ssidCursor, descriptor->ssid, + memcpy(ssidCursor, descriptor->ssid, sizeof(currentRecords->entries[recordIndex].ssid)); if (descriptor->ssidLength > sizeof(currentRecords->entries[recordIndex].ssid)) { currentRecords->entries[recordIndex].ssidLength = 0; @@ -941,7 +941,7 @@ int ATERM_81402A24(void) { currentRecords->entries[recordIndex].ssid[ currentRecords->entries[recordIndex].ssidLength] = '\0'; currentRecords->entries[recordIndex].status = (descriptor->capabilities >> 4) & 1; - memcpy(bssidCursor, descriptor->bssid, + memcpy(bssidCursor, descriptor->bssid, sizeof(currentRecords->entries[recordIndex].bssid)); descriptorWords += descriptor->length; ssidCursor += sizeof(AtermApRecord); @@ -1163,9 +1163,11 @@ int ATERM_814031DC(AtermAssociationRequest* request) { if (gAtermUseSharedAddress != 0) { { const u8* addressCursor = interfaceMacAddress; + const u8* addressEnd = interfaceMacAddress + 6; int addressIndex; char* textCursor = interfaceMacText; - for (addressIndex = 0; ; addressIndex++) { + addressIndex = 0; + do { u8 addressByte = *addressCursor++; char* encoded = textCursor; s32 highNibble = (addressByte & 0xF0) >> 4; @@ -1182,18 +1184,20 @@ int ATERM_814031DC(AtermAssociationRequest* request) { } *encoded = 0; textCursor += encoded - textCursor; - if (addressIndex == 5) { - break; + if (addressIndex < 5) { + *textCursor++ = ':'; } - *textCursor++ = ':'; - } + addressIndex++; + } while (addressCursor < addressEnd); *textCursor = '\0'; } { const u8* addressCursor = scanAddress; + const u8* addressEnd = scanAddress + 6; int addressIndex; char* textCursor = scanAddressText; - for (addressIndex = 0; ; addressIndex++) { + addressIndex = 0; + do { u8 addressByte = *addressCursor++; char* encoded = textCursor; s32 highNibble = (addressByte & 0xF0) >> 4; @@ -1210,11 +1214,11 @@ int ATERM_814031DC(AtermAssociationRequest* request) { } *encoded = 0; textCursor += encoded - textCursor; - if (addressIndex == 5) { - break; + if (addressIndex < 5) { + *textCursor++ = ':'; } - *textCursor++ = ':'; - } + addressIndex++; + } while (addressCursor < addressEnd); *textCursor = '\0'; } } diff --git a/tools/decomp-assist/AOSS.attempts.md b/tools/decomp-assist/AOSS.attempts.md new file mode 100644 index 00000000..31e0d5f0 --- /dev/null +++ b/tools/decomp-assist/AOSS.attempts.md @@ -0,0 +1,106 @@ +# AOSS continuation attempts + +Baseline at 07b3a2b5: instruction-exact 15/21, objdiff exact 16/21, code 6436/16192, data 3896/3928, fuzzy 87.91403%. Quick gate passed. Pool identical; .data 368 bytes matches. Only data mismatch is .sbss (32 bytes, 42.857143%). Work lowest scoring functions first, stack frame and initial blocks first. + +- AOSS_Init_old — baseline block and stack audit: 73.34911%; 1494/1584 instructions; frame ('stwu', 'r1, -0x100(r1)')/('clrlwi', 'r11, r1, 0x1b'). + +- AOSS_81401778 — baseline block and stack audit: 80.168495%; 276/273 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- AOSS_Init_old — align the network-settings local to 32 bytes as the target frame requires: 69.66288%; 1549/1584 instructions; frame ('clrlwi', 'r11, r1, 0x1b')/('clrlwi', 'r11, r1, 0x1b'). + +- AOSS_81401778 — derive hello payload after clearing the response buffer: 79.8022%; 276/273 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- AOSS_81401778 — reuse checksum accumulator throughout the CRC block: compiler rejected the variation. + +- AOSS_81401778 — reuse checksum accumulator throughout CRC block with unchanged table name: 79.87546%; 276/273 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- AOSS_81401778 — decode both permutation indices before updating the schedule fields: 84.83883%; 270/273 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- AOSS_81401778 — align payload lifetime and share the CRC and checksum accumulator with a scoped table view: compiler rejected the variation. + +- AOSS_81401778 — scope CRC table at block entry with shared checksum and aligned payload lifetime: 86.67033%; 270/273 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- AOSS_81401E80 — write packet XOR directly with key-mask operand first: 97.993195%; 147/147 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_81401E80 — load packet and key-mask bytes separately then XOR into the mask result: 97.993195%; 147/147 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_81401E80 — express the packet byte update as compound XOR without a temporary: 98.23129%; 147/147 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_81401E80 — keep packet XOR temporary full-width until its byte store: 98.605446%; 147/147 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_814013AC — reuse response-record cursor for nested options: 96.18421%; 114/114 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- AOSS_814013AC — initialize accumulated configuration flags after validating response length: 96.97369%; 114/114 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- AOSS_814013AC — translate response selection as a conditional while loop: 82.149124%; 115/114 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- AOSS_81400830 — initialize encrypted input cursor before plaintext output cursor: 97.0405%; 321/321 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_81400830 — scope encrypted payload lifetime to the decryption blocks: 96.361374%; 321/321 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_81400830 — split decrypted byte expression into encrypted-byte and key-byte temporaries: compiler rejected the variation. + +- AOSS_81400830 — split byte XOR with temporaries declared at loop-block entry: 97.0405%; 321/321 instructions; frame ('stwu', 'r1, -0x40(r1)')/('stwu', 'r1, -0x40(r1)'). + +- AOSS_Init_old — translate the six target poll stores as two real socket poll descriptors: 73.00505%; 1496/1584 instructions; frame ('stwu', 'r1, -0x110(r1)')/('clrlwi', 'r11, r1, 0x1b'). + +- AOSS_Init_old — use signed timeout halfwords and compare the target minus-one sentinel directly: 73.85038%; 1494/1584 instructions; frame ('stwu', 'r1, -0x110(r1)')/('clrlwi', 'r11, r1, 0x1b'). + +Progress: all five objdiff-open AOSS functions have at least three distinct measured attempts. Retained hello permutation update ordering (80.168495 -> 86.67033%) and two typed poll descriptors with signed timeout sentinels (73.34911 -> 73.85038%). Both quick gates passed with zero regressions. The initializer remains 90 instructions short and has an unaligned frame versus the target aligned frame. Data audit and further block work continue. + +- AOSS_814013AC — advance the formal response pointer directly through response and nested options: 95.08772%; 114/114 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +Data audit: .bss: source/target sizes 3496/3496, alignments 8/8, raw section bytes identical. .data: source/target sizes 364/368, alignments 8/8, raw section bytes differ. .sdata2: source/target sizes 8/8, alignments 8/8, raw section bytes identical. .sdata: source/target sizes 24/24, alignments 8/8, raw section bytes identical. .sbss: source/target sizes 32/32, alignments 8/8, raw section bytes identical. +All .sbss globals have the target offsets and sizes (list 0, config 4, name 8/8 bytes, connection 0x10, error 0x14, socketStarted 0x18, response 0x1c). Raw NOBITS extent matches; objdiff .sbss score remains 42.857143%, with semantic source names versus extracted address labels. .data pool and generated tables are reported 100%; no placement objects or symbol renaming added. + +- AOSS_81401778 — give runtime, packet-key and CRC objects their target global binding: 86.67033%; 270/273 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- AOSS_Init_old — represent connection and response waits as the target two-halfword array: 73.85038%; 1494/1584 instructions; frame ('stwu', 'r1, -0x110(r1)')/('clrlwi', 'r11, r1, 0x1b'). + +- AOSS_Init_old — use a whole-word wait pair with signed halfword views for target initialization stores: 73.85038%; 1494/1584 instructions; frame ('stwu', 'r1, -0x110(r1)')/('clrlwi', 'r11, r1, 0x1b'). + +The target-global-binding trial changed no instructions and regressed matched data 3896 -> 400, so it was reverted. Wait-array and whole-word wait-view trials changed no instructions and were reverted. All reverted experiments are absent from the source diff. + +## Round-two final inventory + +| Function | Target bytes | Compiled bytes before -> after | Objdiff % before -> after | Remaining difference | +| --- | ---: | ---: | ---: | --- | +| AOSS_Init_old | 6336 | 5976 -> 5976 | 73.34911 -> 73.85038 | Ninety instructions short; aligned frame and initial halfword stores differ. | +| AOSS_81400830 | 1284 | 1284 -> 1284 | 97.0405 -> 97.0405 | Register allocation and permutation-loop move order. | +| AOSS_814013AC | 456 | 456 -> 456 | 98.77193 -> 98.77193 | Registers and two entry moves exchanged. | +| AOSS_81401778 | 1092 | 1104 -> 1080 | 80.168495 -> 86.67033 | Three instructions short; merged global base, payload lifetime and CRC scheduling. | +| AOSS_81401E80 | 588 | 588 -> 588 | 98.605446 -> 98.605446 | XOR result and pointer registers. | + +Instruction-exact 15/21 -> 15/21; objdiff exact 16/21 -> 16/21. Matched code 6436 -> 6436 of 16192 bytes; matched data 3896 -> 3896 of 3928 bytes. Fuzzy 87.91403 -> 88.54867%. No new instruction-exact function this round; this is partial progress, not unit completion. + +All five nonmatching functions received at least three successful distinct source-level experiments. Changed or failed trials were measured and reverted unless they improved the retained state. No data placement, symbol-address names, artificial objects or inline assembly were introduced. Target-global binding and alternative wait views were discarded. The initializer's original local alignment is unresolved; no unsupported alignment was retained. The gate's CR1 branch normalization still undercounts one already-100% function, as in ATERM. + +Full final gate: + +``` +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[src/scene/setting/AOSS] pool: IDENTICAL +[src/scene/setting/AOSS] objdiff: code 6436/16192 data 3896/3928 functions 16/21 fuzzy 88.5487 linked code 0 +[src/scene/setting/AOSS] instruction-exact functions: 15/21 +[src/scene/setting/AOSS] section .bss size 3496 match 100.0 +[src/scene/setting/AOSS] section .data size 368 match 100.0 +[src/scene/setting/AOSS] section .sbss size 32 match 42.857143 +[src/scene/setting/AOSS] section .sdata size 24 match 100.0 +[src/scene/setting/AOSS] section .sdata2 size 8 match 100.0 +[src/scene/setting/AOSS] section .text size 16192 match 88.54867 +[src/scene/setting/AOSS] below 100: AOSS_Init_old 73.85038 +[src/scene/setting/AOSS] below 100: AOSS_81400830 97.0405 +[src/scene/setting/AOSS] below 100: AOSS_814013AC 98.77193 +[src/scene/setting/AOSS] below 100: AOSS_81401778 86.67033 +[src/scene/setting/AOSS] below 100: AOSS_81401E80 98.605446 +[src/scene/setting/AOSS] baseline: code 6436/16192 data 3896 functions 16 fuzzy 87.9140 +regressions vs baseline: 0 +global matched_code_percent: 86.26884 -> 86.26884 +global fuzzy_match_percent: 98.87921 -> 98.88315 +global complete_code_percent: 60.34391 -> 60.34391 +global matched_data_percent: 90.91213 -> 90.91213 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +GATE PASS +``` diff --git a/tools/decomp-assist/ATERM.attempts.md b/tools/decomp-assist/ATERM.attempts.md index 50f8dd46..e275170b 100644 --- a/tools/decomp-assist/ATERM.attempts.md +++ b/tools/decomp-assist/ATERM.attempts.md @@ -182,3 +182,151 @@ Full gate used a clean 43U build. Regression, forbidden-pattern and readability - 663b43b7: exact AES transforms, scan record indexing and MD5 length encoding. - 7c0020a6: writable MD5 input formal to preserve byte-copy alias dependencies. - e2a5fe66: exact inverse key reversal and source formatting. + +## Continuation at 07b3a2b5 + +Baseline: instruction-exact 14/26, objdiff exact 15/26, code 9296/19204, data 18504/18864, fuzzy 96.46365%. Fresh quick gate passed. Remaining functions will receive new attempts in this round. Data audit first: .rodata tables match; .sdata matches including section tail alignment. .data contains three generated switch tables and MD5 padding. .sbss is 84 bytes versus 80; selected BSSID is used as a six-byte MAC address but declared eight bytes, imposing eight-byte alignment at offset 0x48 instead of target 0x44. + +- Data attempt: declare selected BSSID with its actual six-byte MAC length. Compiled .sbss shrinks 84 -> 80 bytes, BSSID moves 0x48 -> 0x44, cancel flag moves 0x50 -> 0x4c, all matching target offsets. Quick gate passed with zero regressions; objdiff data score remains unchanged. Retained as a real layout correction. + +- ATERM_81402A24 — round-two block alignment audit: 94.73384%; 261/263 instructions; frame ('stwu', 'r1, -0x90(r1)')/('stwu', 'r1, -0x90(r1)'). + +- ATERM_81402A24 — initialize scan iteration after allocation to match block 1 lifetime: 94.52471%; 261/263 instructions; frame ('stwu', 'r1, -0x90(r1)')/('stwu', 'r1, -0x90(r1)'). + +- ATERM_81402A24 — compare current time first as target scan block does: 94.79088%; 261/263 instructions; frame ('stwu', 'r1, -0x90(r1)')/('stwu', 'r1, -0x90(r1)'). + +- ATERM_81402A24 — translate positive scan edge and separate cleanup jump literally: 94.79088%; 261/263 instructions; frame ('stwu', 'r1, -0x90(r1)')/('stwu', 'r1, -0x90(r1)'). + +- ATERM_814031DC — bound MAC formatting by the input byte pointer rather than integer trip count: 91.53384%; 139/133 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- ATERM_814031DC — pointer endpoint equality for six-byte MAC formatting: 91.53384%; 139/133 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- ATERM_814031DC — count six bytes with equality instead of ordered loop bound: 53.969925%; 191/133 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +- ATERM_814031DC — execute guaranteed nonempty MAC pointer loop as do-while: 93.44361%; 133/133 instructions; frame ('stwu', 'r1, -0x60(r1)')/('stwu', 'r1, -0x60(r1)'). + +Progress: MAC formatter now has 133/133 instructions, 93.44361% (from 129/133, 90.766914%). Pointer do-while loops preserve real six-byte bounds; branch control still differs from target CTR loops. Quick gate passed with zero regressions. Scan comparison improvement retained at 94.79088%. Next: initial global-base block of the protocol state machine. + +- ATERM_814038C8 — initialize protocol state before all local addresses and scalar state: 87.43323%; 972/951 instructions; frame ('stwu', 'r1, -0x180(r1)')/('stwu', 'r1, -0x180(r1)'). + +- ATERM_814038C8 — use one typed configuration aggregate view for all members: 87.43323%; 972/951 instructions; frame ('stwu', 'r1, -0x180(r1)')/('stwu', 'r1, -0x180(r1)'). + +- ATERM_814038C8 — reverse alarm and message local declaration order to align the stack block: 87.432175%; 972/951 instructions; frame ('stwu', 'r1, -0x180(r1)')/('stwu', 'r1, -0x180(r1)'). + +- ATERM_81405ACC — name destination at partial block start before indexed byte copy: 83.34028%; 139/144 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81405ACC — increment partial destination index independently of source index: 71.46528%; 152/144 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81405ACC — translate copy blocks as while loops with explicit byte temporaries: 91.263885%; 139/144 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81405ACC — inline ordinary digest byte-copy helper at both copy blocks: 35.618057%; 59/144 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81402E40 — initialize checksum cursor before the payload call to alter formal lifetimes: 79.9375%; 88/96 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81402E40 — initialize checksum immediately before its loop instead of entry: 94.572914%; 96/96 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81402E40 — name the payload header separately from encrypted payload: 99.791664%; 96/96 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_814033F0 — initialize option result after decoding the response end: 97.66423%; 137/137 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- ATERM_814033F0 — initialize decoded key view at entry to change zero and key lifetimes: 99.56204%; 137/137 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- ATERM_814033F0 — scope the decoded key view to the wireless-key option block: 99.56204%; 137/137 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- ATERM_8140276C — initialize record loop index at its loop and result before found flag: 99.05173%; 174/174 instructions; frame ('stwu', 'r1, -0x80(r1)')/('stwu', 'r1, -0x80(r1)'). + +- ATERM_8140276C — initialize previous record view before current record view: 98.93678%; 174/174 instructions; frame ('stwu', 'r1, -0x80(r1)')/('stwu', 'r1, -0x80(r1)'). + +- ATERM_8140276C — translate current-record iteration as a while loop with explicit index advance: 99.034485%; 174/174 instructions; frame ('stwu', 'r1, -0x80(r1)')/('stwu', 'r1, -0x80(r1)'). + +- ATERM_81404844 — initialize wrapping success before the integrity constants: 99.0%; 117/117 instructions; frame ('stwu', 'r1, -0x190(r1)')/('stwu', 'r1, -0x190(r1)'). + +- ATERM_81404844 — write integrity words in increasing array order: 98.9829%; 117/117 instructions; frame ('stwu', 'r1, -0x190(r1)')/('stwu', 'r1, -0x190(r1)'). + +- ATERM_81404844 — initialize block ordinal before output byte offset: 98.97436%; 117/117 instructions; frame ('stwu', 'r1, -0x190(r1)')/('stwu', 'r1, -0x190(r1)'). + +- ATERM_81404BFC — store each decoded key word before loading the next key word: 98.01492%; 268/268 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- ATERM_81404BFC — initialize substitution table before round constants in key schedules: 98.77612%; 268/268 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- ATERM_81404BFC — declare key words in input order and advance round counter as a statement: 98.73881%; 268/268 instructions; frame ('stwu', 'r1, -0x30(r1)')/('stwu', 'r1, -0x30(r1)'). + +- ATERM_814021BC — set socket-start flag directly before initializing success result: 96.51948%; 154/154 instructions; frame ('stwu', 'r1, -0xd0(r1)')/('stwu', 'r1, -0xd0(r1)'). + +- ATERM_814021BC — initialize interface configuration view before clearing it: 97.16883%; 154/154 instructions; frame ('stwu', 'r1, -0xd0(r1)')/('stwu', 'r1, -0xd0(r1)'). + +- ATERM_814021BC — advance interface polling counter at the for-loop edge: 96.61688%; 154/154 instructions; frame ('stwu', 'r1, -0xd0(r1)')/('stwu', 'r1, -0xd0(r1)'). + +- ATERMi_AutoConfigThread — reuse the completed thread result for its equality mask: 94.75%; 40/40 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERMi_AutoConfigThread — compute completed state before storing the deadline sentinel: 94.75%; 40/40 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERMi_AutoConfigThread — express the completion equality mask as a conditional: 84.475%; 42/40 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +Progress: every remaining ATERM function received at least three new source-level attempts. Retained scan deadline, six-byte BSSID layout and MAC loop improvements; all other trials reverted after measurement. Remaining count mismatches: scan 261/263, protocol 972/951 and MD5 update 139/144. Seven near matches have register or scheduling differences with equal counts. Next: AOSS baseline and its two lowest-scoring functions. + +- ATERMi_AutoConfigThread — read reported result before deriving the completed state: 91.45%; 40/40 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +- ATERM_81405ACC — give both digest copy blocks their own source and destination array views: 74.93056%; 138/144 instructions; frame ('stwu', 'r1, -0x20(r1)')/('stwu', 'r1, -0x20(r1)'). + +Data audit: .bss: source/target sizes 8144/8160, alignments 8/32, raw section bytes differ. .rodata: source/target sizes 10280/10280, alignments 8/8, raw section bytes identical. .data: source/target sizes 280/280, alignments 8/8, raw section bytes identical. .sdata2: source/target sizes 7/8, alignments 8/8, raw section bytes differ. .sdata: source/target sizes 53/56, alignments 8/8, raw section bytes differ. .sbss: source/target sizes 80/80, alignments 8/8, raw section bytes identical. +ATERM .data generated switch-table addends remain dependent on nonmatching control-flow offsets. BSSID layout is corrected; raw .sbss extent matches but its symbol matching score remains 38.88889%. No manual tables, address labels or data padding added. + +- ATERM_814021BC — declare network configuration with the target BSS alignment: 94.08442%; 153/154 instructions; frame ('stwu', 'r1, -0xd0(r1)')/('stwu', 'r1, -0xd0(r1)'). + +## Round-two final inventory + +| Function | Target bytes | Compiled bytes before -> after | Objdiff % before -> after | Remaining difference | +| --- | ---: | ---: | ---: | --- | +| ATERM_814021BC | 616 | 616 -> 616 | 97.91558 -> 97.91558 | Global address formation and instruction scheduling. | +| ATERM_8140276C | 696 | 696 -> 696 | 99.166664 -> 99.166664 | Registers only. | +| ATERM_81402A24 | 1052 | 1044 -> 1044 | 94.73384 -> 94.79088 | Two instructions short; scan branch and address formation. | +| ATERM_81402E40 | 384 | 384 -> 384 | 99.791664 -> 99.791664 | Two entry moves exchanged. | +| ATERM_814031DC | 532 | 516 -> 532 | 90.766914 -> 93.44361 | Pointer loop branches versus target CTR; registers and scheduling. | +| ATERM_814033F0 | 548 | 548 -> 548 | 99.56204 -> 99.56204 | Key cursor and zero register swap. | +| ATERM_814038C8 | 3804 | 3888 -> 3888 | 87.43323 -> 87.43323 | Twenty-one extra instructions; global base spills and stack offsets. | +| ATERMi_AutoConfigThread | 160 | 160 -> 160 | 94.75 -> 94.75 | NOR destination and reload/shift scheduling. | +| ATERM_81404844 | 468 | 468 -> 468 | 99.0 -> 99.0 | Registers and block-counter initialization order. | +| ATERM_81404BFC | 1072 | 1072 -> 1072 | 98.94403 -> 98.94403 | Key-load scheduling and AES table registers. | +| ATERM_81405ACC | 576 | 556 -> 556 | 91.263885 -> 91.263885 | Five instructions short; byte-copy pointer induction. | + +Instruction-exact 14/26 -> 14/26; objdiff exact 15/26 -> 15/26. Matched code 9296 -> 9296 of 19204 bytes; matched data 18504 -> 18504 of 18864 bytes. Fuzzy 96.46365 -> 96.54093%. No new instruction-exact function this round; this is partial progress, not unit completion. + +The first-BSS-object alignment trial changed code generation (97.91558 -> 94.08442%) and was reverted. Whole-section .bss and small-data tail alignment is already accepted by objdiff at 100%; no padding added. Earlier raw-byte audit compares unrounded ELF section lengths; differing trailing zero extents do not imply new logical data objects. + +Full final gate: + +``` +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[src/scene/setting/ATERM] pool: IDENTICAL +[src/scene/setting/ATERM] objdiff: code 9296/19204 data 18504/18864 functions 15/26 fuzzy 96.5409 linked code 0 +[src/scene/setting/ATERM] instruction-exact functions: 14/26 +[src/scene/setting/ATERM] section .bss size 8160 match 100.0 +[src/scene/setting/ATERM] section .data size 280 match None +[src/scene/setting/ATERM] section .rodata size 10280 match 100.0 +[src/scene/setting/ATERM] section .sbss size 80 match 38.88889 +[src/scene/setting/ATERM] section .sdata size 56 match 100.0 +[src/scene/setting/ATERM] section .sdata2 size 8 match 100.0 +[src/scene/setting/ATERM] section .text size 19204 match 96.54093 +[src/scene/setting/ATERM] below 100: ATERM_814021BC 97.91558 +[src/scene/setting/ATERM] below 100: ATERM_8140276C 99.166664 +[src/scene/setting/ATERM] below 100: ATERM_81402A24 94.79088 +[src/scene/setting/ATERM] below 100: ATERM_81402E40 99.791664 +[src/scene/setting/ATERM] below 100: ATERM_814031DC 93.44361 +[src/scene/setting/ATERM] below 100: ATERM_814033F0 99.56204 +[src/scene/setting/ATERM] below 100: ATERM_814038C8 87.43323 +[src/scene/setting/ATERM] below 100: ATERMi_AutoConfigThread 94.75 +[src/scene/setting/ATERM] below 100: ATERM_81404844 99.0 +[src/scene/setting/ATERM] below 100: ATERM_81404BFC 98.94403 +[src/scene/setting/ATERM] below 100: ATERM_81405ACC 91.263885 +[src/scene/setting/ATERM] baseline: code 9296/19204 data 18504 functions 15 fuzzy 96.4637 +regressions vs baseline: 0 +global matched_code_percent: 86.26884 -> 86.26884 +global fuzzy_match_percent: 98.87921 -> 98.88315 +global complete_code_percent: 60.34391 -> 60.34391 +global matched_data_percent: 90.91213 -> 90.91213 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +GATE PASS +``` -- 2.49.1