/* Ground-truth C for FUN_00001200 @ blob offset 0x1200 (36 bytes / 9 insts). * * Pattern: word-aligned memcpy; length rounded down to word multiple. * Signature: void memcpy32(uint32_t *dst, const uint32_t *src, size_t len_bytes); * * AArch64 ABI: X0 = dst, X1 = src, X2 = len (in bytes, rounded down to 4) * Scratch: X3 = byte index i, W4 = word register for transfer * * Notes the decompiler should ideally recover: * - `AND x2, x2, #0xFFFFFFFC` is `len &= ~3` — mask-out low 2 bits. * (Tools often render as `len & 0xFFFFFFFC` or `len & ~3`.) * - Inner loop reads/writes 4 bytes at a time — tools should recognise * uint32_t pointers, or at least `*(u32*)(x0+i) = *(u32*)(x1+i)`. * - Addressing is byte-indexed with a step of 4 — some tools may emit * `for (i = 0; i < len; i += 4)` in bytes; others may normalise into * an index-based word loop. */ #include #include void memcpy32(uint32_t *dst, const uint32_t *src, size_t len_bytes) { len_bytes &= ~(size_t)3; /* round down to 4 */ size_t i = 0; while (i != len_bytes) { *(uint32_t *)((uint8_t *)dst + i) = *(const uint32_t *)((const uint8_t *)src + i); i += 4; } }