← Latest papers
🤖 AI

Decaf: Improving Neural Decompilation with Automatic Feedback and Search

The paper introduces Decaf, a system that leverages compiler feedback and search to significantly improve the semantic correctness of neural decompilation outputs, raising the success rate on the Real -O2 split from 26.0% to 83.9% without compromising similarity to the original source code.

Original authors: Alexander Shypula, Osbert Bastani, Edward Schwartz

Published 2026-05-13
📖 5 min read🧠 Deep dive

Original authors: Alexander Shypula, Osbert Bastani, Edward Schwartz

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Problem: The "Lost Translation"

Imagine you have a book written in a complex, high-level language (like English). A machine translates this book into a secret code (machine code) to run on a computer. Once the translation happens, the machine throws away the original book, the chapter titles, the character names, and even the grammar rules.

Now, imagine you are a detective trying to figure out what the original story was, but you only have the secret code. This is decompilation.

Traditional tools (like Ghidra) are like a very literal translator. They can turn the secret code back into words, but the result is a mess. The sentences are awkward, the names are replaced with "Variable_1" and "Variable_2," and the logic is hard to follow. It's technically correct, but it's impossible to read.

On the other hand, modern AI (Large Language Models) is like a creative writer. It can guess the story, invent cool character names, and write smooth sentences. But because it's so creative, it sometimes hallucinates. It might invent a plot twist that never happened or miss a crucial detail, making the story factually wrong even if it reads beautifully.

The Solution: "Decaf" (Decompilation with Automated Feedback)

The authors of this paper, Alexander Shypula and his team, realized that relying on just one guess from the AI isn't enough. They built a system called Decaf that works like a talent show with a strict judge.

Here is how the Decaf process works, step-by-step:

1. The "Talent Show" (Sampling Many Candidates)

Instead of asking the AI to write the story once and hoping for the best, Decaf asks the AI to write 32 different versions of the story.

  • Analogy: Imagine asking 32 different chefs to cook the same dish. Some might burn it, some might make it too salty, but one of them might just happen to make the perfect version.
  • The paper found that if you only ask for one dish, you have a 60% chance of getting something edible. If you ask for 32, you have an 88% chance that at least one of them is perfect.

2. The "Taste Test" (Automatic Feedback)

Now you have 32 different versions of the code. How do you know which one is the real original? You can't just read them; they all look like code.

  • The Trick: Decaf takes every single AI-generated version and re-compiles it. It turns the code back into the secret machine code.
  • The Comparison: It then compares this new secret code against the original secret code you started with.
  • Analogy: Imagine you have the original secret recipe. You take the 32 chefs' dishes, turn them back into ingredients, and see which set of ingredients matches the original list exactly. If the ingredients match, the dish is correct.

3. The "Head Judge" (The Neural Reranker)

Sometimes, the re-compiling step isn't enough because the ingredients might look slightly different but taste the same. So, Decaf uses a second AI, called a Reranker, to act as the Head Judge.

  • This judge looks at the "secret code" of the original and the "secret code" of the AI's guess.
  • It doesn't just look at the words; it looks at the logic. It asks, "Do these two pieces of code do the exact same thing?"
  • The judge picks the winner and discards the rest.

The Results: Why It Matters

The paper tested this system on a massive benchmark called ExeBench. Here is what happened:

  • Before Decaf: The best AI models could only get the logic right about 26% of the time. They were either too messy (like traditional tools) or too creative (hallucinating errors).
  • With Decaf: The system jumped to 83.9% accuracy.
  • The "Perfect Match": Even better, the code produced by Decaf was so similar to the original that, in 70.9% of cases, if you re-compiled it, the computer code was byte-for-byte identical to the original.

A Real-World Example from the Paper

The paper shows a specific function (a small piece of code) that calculates numbers.

  • Traditional Tool (Ghidra): Gave a correct but ugly answer with names like iVar1 and iVar2.
  • Standard AI (LLM4Decompile): Gave a beautiful, readable answer, but it missed a critical step (a "break" condition), making the logic wrong.
  • Decaf: Generated 32 versions. It found the one that had the beautiful names and the correct logic. It successfully picked the winner using its "taste test" and "Head Judge."

The "Stress Test"

The authors also tested if their system worked when the "ingredients" changed. They tried to use a different compiler (Clang instead of GCC) to check the answers.

  • Result: The system still worked well, though it got slightly less accurate. This is like a judge who is used to tasting Italian food but is asked to judge French food; they can still tell if the dish is good, but they aren't quite as perfect as when judging their native cuisine.

Summary

Decaf doesn't try to make the AI smarter by feeding it more data. Instead, it changes the strategy:

  1. Generate many options (don't settle for the first guess).
  2. Verify them automatically by turning them back into machine code.
  3. Use a smart judge to pick the one that is both readable and factually correct.

This approach turns a "guessing game" into a "search and verify" process, dramatically improving the ability to understand computer code that has been compiled and stripped of its original meaning.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →