# Ghidra recipe — 01_memset ## Load **File → Import File…** → `func.bin`. In the import dialog: - **Format:** Raw Binary - **Language:** AArch64:LE:64:v8A - **Base Address:** `0x0aac` ← critical; branches are PC-relative and the absolute function address matters for readability (though the code at 0xaac has no absolute-addr refs of its own). After import, click **Yes** on the "Analyze now?" prompt; default analyzers are fine. ## What to look for in Ghidra's decompiler output - Function automatically detected at 0xaac (the file starts there). - Decompiler should produce something like: ```c void FUN_00000aac(long param_1, byte param_2, long param_3) { long local_10 = 0; while (local_10 != param_3) { *(byte *)(param_1 + local_10) = param_2; local_10++; } } ``` - Idiomatic match rate: high for this pattern; Ghidra's decompiler recognises the pre-test loop well. - Ghidra types: `byte` (uint8_t), `long` (the 64-bit register) — not directly `uint8_t` / `size_t`. Manual retyping is usually needed. ## Benchmark notes - Time to understandable output: ~seconds (auto-analysis). - Manual cleanup: rename `FUN_00000aac` → `memset_byte`; retype `param_1` to `void *`, `param_2` to `uint8_t`, `param_3` to `size_t`. - Limits: Ghidra's decompiler is position-dependent on the load address only for jump targets beyond the slice — irrelevant here.