The Locked Box Is Open: How AI Made Decompiling Easy

Every program you have ever run started as readable text. Someone typed it, named things, left notes for the next person. Then a compiler flattened it into a file of numbers and threw the notes away. For decades, going backwards from that file was a craft that took years to learn and months to apply.

That is changing fast. A developer can now open a terminal, point an AI agent at a compiled game, and watch it name functions, explain what they do and rebuild the code, often while they sleep. A job that once took weeks can take an afternoon. This post explains how we got here, what is really happening, and where the limits are.

Source code is compiled into a binary, and a decompiler turns it back into rough source

What decompiling is

A compiler turns source code into machine code, the numbers a processor runs. Along the way it removes variable names, comments and structure, and it rearranges logic to run faster. What is left is correct but hard to read.

A decompiler walks that road backwards. It looks at the machine code and writes C-like text that does the same thing. The result works, but names like count and player are gone, replaced by labels such as local_18 and param_2. A person has to study the code and slowly give things meaning again.

That slow part is the bottleneck. Reading thousands of functions, guessing what each one does and writing the guess down is exactly the kind of patient, repetitive reading that language models are good at.

Two tools at the center

Two programs do most of the heavy lifting. Ghidra is a free, open source reverse engineering suite released by a US government research agency under the Apache 2.0 license. It disassembles, decompiles, graphs and scripts, supports a wide range of processors, and can run in both interactive and automated modes. IDA Pro is the long-standing commercial standard, known for a very strong decompiler and a deep plugin ecosystem.

The first tool is free and the second is paid, but the two share the feature that matters here. Both can run without a person clicking through windows. Ghidra has a headless mode built for scripts. IDA can be driven by plugins and scripts.

Until recently this was a niche skill. You had to learn the interface, the shortcuts and the habits of the compilers that produced the code. Now an agent can learn all of that on the job.

Why a terminal session changes the game

The turning point was connecting the agent to the tool. A tool server, usually built on the Model Context Protocol, sits between the CLI session and the reverse engineering suite. The agent asks for something in plain terms, and the server does it.

Typical requests are to decompile a function, list everything that calls it, rename a variable, add a comment, or search the whole program for a pattern. One popular Ghidra server exposes 272 tools for this. A widely used IDA server has passed ten thousand stars on GitHub. Others run Ghidra fully headless, so no window is needed at all.

A CLI agent talks to a headless tool server, which drives Ghidra or IDA Pro

This matters because the terminal is where agents are strongest. They can write scripts, save notes to files, run builds and chain steps together. We covered why in our post on binaries and agents. The same logic applies here: a text interface with clear results is the easiest thing for a model to use.

The agent also works at a pace no person can. It reads a function in seconds, writes its notes, moves to the next, and never gets tired of the thousandth one. Several agents can work at once on different parts of the same program.

The trick that makes it reliable

Language models make mistakes, and nobody wants a decompiler that confidently invents things. The solution that unlocked the whole field is simple: give the model something it can check.

This approach is called matching decompilation. The goal is to write source code that, when compiled with the same compiler and settings as the original, produces exactly the same bytes. There is no room for opinion. The output either matches or it does not.

That turns a fuzzy task into a game with a clear score. The agent writes a function, compiles it, compares the bytes and reads the difference. If they do not match, it adjusts and tries again. A small comparison script is the judge, and it never gets tired or flattered.

The agent writes C, compiles it with the same compiler, and compares the bytes with the original until they match

People who run these projects report the same lesson again and again. Objective checking matters more than model size. With a strict pass or fail test, even cheaper models become useful, because the test catches wrong answers for them.

The numbers

The clearest example comes from a community project that rebuilt source for a 1990s console game. The same developer did two similar games. The first took 596 days by hand. The second, with 2,145 functions, took 84 days using AI agents running in parallel, each in its own copy of the repository, while humans handled the blockers.

Bar chart of days to decompile a comparable game: 596 by hand and 84 with AI agents

Another developer reported more progress in three weeks with an agent running unattended for eight hours or more than in the previous three months. Others are applying the same method to handheld, console and PC titles across several generations.

A larger experiment pushed the idea further. One developer let agents work for about three months on a classic first-person shooter, using the CLI sessions and an IDA tool server. The agents used hundreds of billions of tokens. The result was source for about 99 percent of the game's functions, with 83 percent matching the original bytes exactly. The team began with a handful of agents and ended with sixteen working on their own.

Those are big numbers, but notice what they say. Full source reconstruction still took weeks or months, only far fewer than before.

From weeks to hours

The biggest change is not in full rebuilds. It is in focused changes. Suppose you want to change one behavior in a program, such as a speed limit, a menu option or a hardcoded path, and you do not have the source.

The old workflow was to learn the program's layout, hunt for the right function among thousands, understand it well enough to change it safely, and test. That could take a skilled person weeks. Now the agent can search the decompiled code, find the likely function, explain what it does and propose the smallest change. You review it and test it.

A chart comparing the time to change one behavior: weeks to months before, days with a decompiler, hours with a decompiler and an agent

This chart is an illustration of the general trend, not a measured benchmark. Hard cases still take longer. But many modders and maintainers report that a small, well-understood patch is now an afternoon of work, and sometimes less.

What a patch session looks like

Here is a typical session on a program you own and are allowed to modify, such as an old utility whose source is lost.

  1. Load the program into Ghidra or IDA through the tool server, and let it finish its automatic analysis.
  2. Ask the agent to list the functions and group them by what they appear to do, such as file handling, drawing or settings.
  3. Describe the behavior you want to change in plain words, for example "the window always opens at a fixed size".
  4. The agent searches for the related strings and numbers, follows the references and shows you the two or three functions that matter.
  5. It explains each one in plain language and renames variables as it learns, so the notes build up for next time.
  6. You pick the change. The agent proposes the smallest edit and writes the patch as a script you can rerun.
  7. You apply it to a copy, run the program and check the result. If it fails, the agent reads the error and tries again.

Notice that you stay in charge of the goal and the test, while the agent does the reading. Notice too that the notes stay behind. The next change starts with names and comments already filled in, so each session is faster than the last.

This is why the time falls so sharply. Most of the old effort was spent just orienting yourself. The agent does that part in minutes, and the human time goes to judgment.

Why emulators matter less

An emulator pretends to be old hardware. It copies the processor, the graphics chip and the sound chip in software, so the original game believes it is running on its first machine. This works well and has preserved a huge amount of history, but it carries a cost. The game stays locked inside a pretend console, so changes are limited and speed is limited.

A newer approach is static recompilation. Instead of imitating the machine while the game runs, a tool translates the game's code once, ahead of time, into code a modern computer can run directly. The result is a native program. It runs fast, it can use modern graphics, and its internals are open to inspection and change.

Emulation imitates the old hardware at runtime, while recompilation translates the code once into a native program

Recompiled ports bring wide screens, high frame rates, better controls and modern lighting to games that never had them. Some projects now report that most of a console's library can be translated this way.

Decompilation feeds directly into this. The better you understand a program, the easier it is to translate and to patch. Agents make that understanding cheap, so more games get native ports and fewer need a pretend console to run.

Emulators are not dead

It would be wrong to say emulators are going away. They are still the right tool when you want to run a game exactly as it was, to study unusual hardware behavior, or to preserve platforms where no one has done the translation work.

What is shrinking is the gap. Before, an emulator was the only practical way to keep an old game alive. Now there is a second path, and it gets cheaper every month. For popular titles on well-understood hardware, a native port is increasingly within reach of a small team, or one person with an agent.

Think of it as a choice of tools. Emulation is a perfect copy of the old world. Recompilation is a new building made from the old plans. Both are useful, and the second one used to be far out of reach.

Beyond games

The same approach works for older business software, lost utilities, abandoned drivers and firmware. If a program still runs but the source is long gone, an agent can often recover enough understanding to fix a bug or move it to a new system.

Games get the headlines because fans care and the machines are old and well documented. But the method applies to any software whose behavior can be observed and checked. If you can run the program and compare results, an agent has a score to chase.

Security work benefits too. Analysts use these tools to understand suspicious files, find weaknesses and check what closed software does. The same speed that helps a modder helps a defender, which is why many in the field welcome the change.

Researchers have also trained models for the task directly. One open project fine-tuned models from 1.3 billion to 33 billion parameters to turn binaries back into C, and reported more than double the success rate of a general model and of Ghidra's own output on its benchmarks. Their best setup used Ghidra's output and then refined it with the model, which shows the tools work better together than apart.

Where AI still stalls

None of this is magic. Agents struggle in predictable places.

Progress stalled near 90 percent until human compiler experts helped

Percent complete can also mislead. A game that boots to the title screen has not been tested through its last boss. Always ask what was actually verified.

This is the part to take seriously. Reverse engineering sits in a gray area that depends on where you live and what you do with the results.

Policies inside communities also differ. Some projects ban AI-written code entirely, while others allow it with disclosure. Publishers have been sending takedown notices, and they tend to target distributed game files and binaries more than source repositories.

A safe approach is to work on software you own or have permission to study, avoid sharing copyrighted assets, keep notes on how you reached each result, and talk to a lawyer before publishing anything.

What happens next

The direction is clear. The cost of understanding a compiled program is falling toward the cost of reading a document. When that cost drops, more programs get ported, patched, fixed and preserved, and fewer get lost when a company moves on.

It also changes how software should be built. If any program can be studied, then security cannot depend on secrecy, and good design matters more. For developers, this is a reminder to keep your own source, your notes and your build recipes safe.

For hobbyists, it is an open door. A curious person with a free tool, a terminal and an agent can now do what used to need a team and a year. The skill to learn is not the tool's menus anymore. It is asking good questions, setting clear tests and checking the answers.

The locked box is open. What people build from what is inside is the part still to be decided.

Sources