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

LLM4Decompile: Decompiling Binary Code with Large Language Models

Hanzhuo Tan, Qi Luo, Jing Li, Yuqun Zhang

Introduction

Decompilation—the process of translating machine-executable binary code back into high-level source code—is a fundamental task in cybersecurity, malware analysis, and the maintenance of legacy software. However, it is inherently a "lossy" process. During compilation, high-level abstractions such as variable names, comments, and complex control structures are stripped away or transformed into a sequence of assembly instructions.

Traditional decompilers like Ghidra and IDA Pro rely on rule-based engines to produce "pseudo-code." While this output is often sufficient for human analysts to grasp the general logic, it frequently suffers from syntactic errors and logical gaps, making it nearly impossible to re-compile and execute. LLM4Decompile represents a significant shift in this field, utilizing large language models (LLMs) to bridge the gap between low-level assembly and functional, executable C code.

The Decompilation Bottleneck

The primary challenge in decompilation is not just readability, but re-executability. A tool that produces code that looks like C but fails to compile or run correctly is of limited use for automated analysis or software porting. Traditional tools often struggle with the "spaghetti" of assembly jumps and pointer arithmetic created by modern compilers. LLM4Decompile addresses this by treating decompilation as a sequence-to-sequence translation task, leveraging the pattern-recognition capabilities of models ranging from 1.3B to 33B parameters.

The LLM4Decompile Framework

The researchers developed two distinct methodologies to tackle the problem:

  1. LLM4Decompile-End (End-to-End): This model performs direct translation. It takes raw, disassembled assembly code (ASM) as input and attempts to generate the corresponding C source code directly.
  2. LLM4Decompile-Ref (Refinement): This model acts as a post-processor for traditional tools. It takes the messy, often broken pseudo-code output from Ghidra and "refines" it into valid, executable C code.

Technical Innovations

To ensure the models understood the nuances of binary logic, the team implemented several key strategies:

  • Two-Stage Training: The models were first grounded in a massive corpus of "compilable but not linkable" code to learn general syntax. In the second stage, they were fine-tuned on fully executable binaries to prioritize functional correctness.
  • Optimization-Aware Training: By compiling the same source code using four different GCC optimization levels (O0, O1, O2, and O3), the researchers taught the models how a single high-level logic can manifest in diverse assembly patterns.
  • Architecture: Built upon the DeepSeek-Coder base, the models were optimized using a sequence-to-sequence objective, focusing on the negative log-likelihood of source code tokens given assembly inputs.

Evaluation and Benchmarking

To rigorously test the models, the researchers utilized two primary datasets:

  • ExeBench: A dataset of approximately 5 million C functions used for large-scale training and real-world evaluation.
  • HumanEval-Decompile: A new benchmark created by porting the Python-based HumanEval challenges to C. This provides 164 programming problems with associated unit tests, allowing the researchers to verify if the decompiled code actually functions as intended.

Key Results

The results demonstrate a significant leap over both traditional tools and general-purpose LLMs:

  • Re-executability: On the HumanEval-Decompile benchmark, the LLM4Decompile-End-6.7B model achieved a 45.4% success rate. This is more than double the performance of Ghidra (20.1%) and nearly triple that of GPT-4o (16.0%).
  • State-of-the-Art Performance: The LLM4Decompile-Ref-22B model reached a peak average re-executability rate of 64.18%, setting a new benchmark for the industry.
  • Code Quality: Qualitative assessments indicated that LLM4Decompile's output was significantly more "human-like," with higher structural integrity and fewer syntactic errors than traditional pseudo-code.

Insights and Discussion

Several critical insights emerged from the study:

  • The Refinement Advantage: The superior performance of the -Ref models suggests that traditional decompilers are still highly effective at structural analysis. LLMs are best utilized for the "last mile"—fixing syntax and reconstructing logical flow.
  • Scaling and Constraints: While performance improved significantly from 1.3B to 6.7B parameters, the 33B model showed diminishing returns. This was attributed to hardware constraints that limited training duration, suggesting that further compute could unlock even higher accuracy.
  • The Obfuscation Barrier: The models were tested against intentional code protection techniques like "Control Flow Flattening." Success rates dropped by over 70% in these scenarios, indicating that while LLMs are powerful, they are not yet a complete solution against sophisticated code obfuscation.

Future Directions

While LLM4Decompile marks a milestone in binary analysis, several hurdles remain. The current models are limited to the C language and x86 architecture. Expanding to C++, Rust, and ARM/MIPS architectures is a priority for future research. Additionally, the researchers identified the difficulty of "guessing" user-defined types (like custom structs) that are not defined within the binary. Integrating Retrieval-Augmented Generation (RAG) to incorporate external header files or documentation could provide the necessary context to solve this problem.

Summary updated

BibTeX
@inproceedings{tan2024llm,
  author = {Hanzhuo Tan and Qi Luo and Jing Li and Yuqun Zhang},
  title = {{LLM4Decompile: Decompiling Binary Code with Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.203},
}
Figure