Decompile a binary or assembly file to clean C++ code. Use when converting binaries, assembly, or Ghidra output to readable C++.
Decompile binaries, assembly, or Ghidra output to clean C++ code.
/decompile <file>
↓
1. Python scripts run: Ghidra/RetDec decompile → parse & filter → parsed C
2. Agent refines parsed C into clean C++
3. Compile refined C++; feedback loop: fix errors, recompile until it builds
4. Final test: compare compiled C++ binary to original (objdump diff)
In chat: type /decompile <path> and send. The agent runs the full pipeline and replies in chat.
/decompile program # Binary
/decompile program.s # Assembly
/decompile ghidra_output.c # Existing Ghidra C file
File location: If the agent is sandboxed (can't leave the repo), the user must put the file inside the repo or grant permission to access external paths.
Optional flags (usually not needed):
-o DIR — output directory--no-validate — skip compile check--list-backends — show available decompilers (ghidra, retdec, llm)| Input | Examples |
|---|---|
| Binary | program, program.elf, program.o |
| Assembly | program.s, program.asm |
| Ghidra C | *_decompiled.c |
asm2cpp <input> — Python scripts run (extract, parse, validate); output parsed C to *_parsed.c| Ghidra | C++ |
|---|---|
undefined8 | uint64_t |
undefined4 | uint32_t |
ulong | uint64_t |
uint | uint32_t |
byte | uint8_t |
PTR_, DAT_, LAB_ prefixes with readable names<cstdint>, <iostream>, etc. instead of raw typesvar1, param_1, etc.# 1. Ensure asm2cpp is available
if ! command -v asm2cpp &> /dev/null; then
pip install -e . # or: curl -LsSf <install.sh> | sh
fi
# 2. Run decompilation
asm2cpp <input> -o output
# 3. Refine parsed C to clean C++; compile; fix errors until it builds; compare binary to original
x86, x86_64, ARM, ARM64, RISC-V
Ghidra not found — Install: brew install ghidra (macOS) or use RetDec.
Output has 0 functions — Ghidra output must use // Function: name at 0x... format.
Won't compile — Fix includes, add stubs for unknown functions, replace Ghidra types per the table above.