NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ASAP: Assembly-Source Aligned Pseudocode Refinement For Binary Decompilation

Yujian Zhuang, Dehong Gao, Qichao Zhang, QiJing Lai, Jiaxin Wang, Libin Yang, Xiaoyan CaiNeurIPS 2026

TL;DR

Translating compiled machine binaries back into readable source code—decompilation—is like trying to reconstruct a recipe by tasting the finished cake. Existing AI approaches either polish the flawed guesses of traditional tools or choke on massive walls of raw assembly instructions. ASAP mimics human reverse engineers by giving an LLM the high-level "draft" (pseudocode) alongside a compressed, semantically translated "cheat sheet" of the raw assembly—significantly boosting the rate at which recovered code actually compiles and passes functional tests.

What Problem Does This Paper Address?

When software is compiled into a binary, variable names, high-level types, and comments vanish. Reverse engineers rely on rule-based decompilers (like Ghidra or IDA Pro) to turn binaries into C-like pseudocode. While readable, this pseudocode is a lossy, heuristic guess—it frequently fumbles low-level details like whether a number is signed or unsigned, especially in heavily optimized binaries.

When applying LLMs to this problem, researchers usually pick one of two flawed paths:

  1. Pseudocode refinement: Ask an LLM to clean up the decompiler's pseudocode. The catch? If the pseudocode contains a subtle logic bug, the LLM just polishes the bug into prettier code.
  2. End-to-end assembly translation: Feed raw assembly instructions directly into the LLM. However, assembly is brutally long and syntactically alien compared to the C or Python code LLMs know best.

Why not just paste both pseudocode and assembly into the prompt? Because LLMs are "lazy" readers. Pseudocode looks so much like target source code that the model exhibits attention bias—copying the pseudocode shortcut and ignoring the assembly's corrective evidence.

Figure 1: Comparison of our proposed ASAP with existing binary decompilation approaches. The top shows the standard compilation and decompilation process from source code to binary, assembly, and decompiler-produced pseudocode. Below, three approaches are compared: (1) Pseudocode refinement takes decompiler output as input and improves it with an LLM; (2) End-to-end translation directly generates source code from assembly; (3) ASAP augments the pseudocode refinement with assembly tokens, addressing the representation gap and attention bias.

Methods

ASAP (Assembly-Source Aligned Pseudocode refinement) bridges the representation gap and breaks the LLM's lazy habits using a two-stage training pipeline:

Figure 2: Our ASAP framework follows a two-stage training pipeline. (1) In assembly-source alignment, an assembly encoder is trained via function-level and snippet-level contrastive learning against a frozen source encoder to align assembly and source representations. (2) In assembly- augmented refinement, the pretrained assembly encoder is frozen, while a Q-Former compresses assembly features into compact assembly tokens for the LLM, which is optimized with pseudocode masking and an assembly-advantage objective for binary decompilation.
  • Stage 1: Assembly-Source Alignment (ASA). Before the LLM ever sees assembly, ASAP trains a dedicated assembly encoder (initialized from UniXcoder) to map assembly chunks into the same semantic space as C source code using contrastive learning. Crucially, it aligns them at two scales: function-level (grouping the same function compiled at different optimization levels like -O0 through -O3) and snippet-level (using compiler debug line-mappings during training to capture granular details like pointer arithmetic and bit-widths).
  • Stage 2: Assembly-Augmented Refinement (AAR). At this stage, the assembly encoder is frozen. Instead of feeding hundreds of raw assembly lines to the LLM (LLM4Decompile-9B), a standard Q-Former acts as a bottleneck compressor, distilling variable-length assembly features into a fixed, compact set of dense "assembly tokens" prepended to the pseudocode.
  • Forcing the LLM to pay attention (The Secret Sauce): To cure attention bias during training, ASAP introduces two clever tricks:
  • Stochastic Pseudocode Masking: Randomly hiding non-structural tokens (constants, operators, identifiers) while keeping braces and if/while keywords intact, forcing the LLM to look at the assembly tokens to fill in the blanks.
  • Assembly-Advantage Objective: A custom loss function that compares the model's prediction with assembly tokens against a detached reference pass where assembly tokens are zeroed out—explicitly penalizing the LLM unless the assembly tokens measurably improve its accuracy.

Datasets

No new benchmarks were introduced; ASAP relies on established datasets compiled with GCC across four optimization levels (O0–O3):

  • Training: 100,000 C functions randomly sampled from ExeBench.
  • Decompilation Evaluation: C-language adaptations of HumanEval and MBPP (with additional appendix tests on BringUpBench).
  • Downstream Analysis: BinMetric, evaluating how well the recovered code helps other LLMs perform Signature Recovery, Binary Code Summarization, and Algorithm Classification.

Key Insights and Ideas

  • Raw assembly is just noise without alignment: In ablation studies, feeding raw assembly text to the LLM performed virtually identically to using an unaligned assembly encoder (~67.7% vs. 67.3% re-execution). Low-level evidence only helps when pre-translated into source-like semantics.
  • Both the forest and the trees matter: Dropping either function-level or snippet-level alignment caused an almost identical ~3% drop in functional accuracy—proving global intent and local instruction idioms contribute equally.
  • Assembly as a targeted corrective, not a standalone source: Because the Q-Former outputs a fixed number of tokens regardless of binary length, ASAP doesn't try to pack every instruction into those tokens—just enough operational evidence to overrule bad decompiler guesses.

Key Results

Averaged across HumanEval and MBPP across all four compiler optimization levels (O0–O3):

  • Re-execution Rate (passing unit tests): ASAP hits 71.9%, jumping +7.2 percentage points over the strongest specialized baseline (SK2Decompile at 64.7%) and nearly +10 points over its base model, LLM4Decompile-9B (62.0%). Even at aggressive -O3 optimization, ASAP reaches 63.7% (vs. Ghidra's 19.0%).
  • Recompilation Rate (valid syntax): Reaches 96.6%, up from 91.6% (SK2Decompile) and 80.5% (Gemini-3.1-flash).
  • Readability vs. Execution Trade-off: On the GPT-Judge readability metric (1–5 scale), Gemini-3.1-flash scores highest (4.07 vs. ASAP's 3.87) because frontier chatbots invent verbose, human-friendly variable names—even when their underlying code logic fails to compile or pass tests.
  • Downstream Utility: Feeding ASAP's decompiled code into downstream LLMs (like DeepSeek-Coder-V2 and CodeLlama) consistently yielded top scores in recovering function signatures and classifying algorithms.

Limitations and Future Work

  • Tests aren't formal proofs: Passing official unit tests is strong empirical evidence of equivalence, but formally proving two arbitrary programs behave identically is mathematically undecidable (Rice's theorem).
  • Variable naming: ASAP focuses on functional logic and syntax rather than guessing human-readable variable names. Pairing ASAP with dedicated identifier-renaming pipelines (like SK2Decompile's "skeleton-to-skin" approach) is a natural next step.
  • Flat chunking: The assembly encoder slices code into linear chunks without explicitly modeling control-flow or data-flow graphs between basic blocks.
  • Scale and scope: Future work aims to incorporate graph structures, scale up to larger frontier LLMs, tackle obfuscated malware binaries, and expand beyond x86_64 to multiple instruction set architectures.

Summary updated

BibTeX
@inproceedings{zhuang2026asap,
  author = {Yujian Zhuang and Dehong Gao and Qichao Zhang and QiJing Lai and Jiaxin Wang and Libin Yang and Xiaoyan Cai},
  title = {{ASAP: Assembly-Source Aligned Pseudocode Refinement For Binary Decompilation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=x36xk9UY3Z},
}
Figure