AI
New AI Framework Enhances Accuracy of Binary Code Reconstruction
Researchers introduce ASAP, a learning-based approach that uses assembly-level insights to improve how AI systems translate compiled binaries back into human-readable pseudocode.
Binary decompilation—the process of reconstructing readable code from compiled binaries—remains a thorny challenge in software engineering and security. While traditional decompilers produce C-like pseudocode that aids human analysts, their outputs are approximations marred by errors, particularly when binaries have been heavily optimized and critical details have been stripped away.
The Problem with Current Approaches#
Conventional decompilers rely on hardcoded rules to translate machine instructions into high-level representations. These heuristics inevitably introduce inaccuracies and lose information during the transformation. Recent advances have applied large language models to refine decompiler output, but these models often ignore the underlying assembly instructions and lean too heavily on the pseudocode alone—meaning they perpetuate and sometimes amplify existing decompiler errors.
ASAP's Hybrid Strategy#
Researchers have developed ASAP (Assembly-Source Aligned Pseudocode Refinement), a framework that bridges assembly-level and pseudocode-level insights. The key innovation lies in how the system learns to align source code with assembly representations using paired training data. By employing both function-level and snippet-level contrastive learning, ASAP captures meaningful relationships between raw machine code and its higher-level meaning.
A component called a Q-Former then compresses detailed assembly features into a compact set of tokens that feed into the decompilation language model alongside the traditional pseudocode. This dual input forces the model to weigh evidence from both sources rather than dismissing the assembly-level context.
Training Refinements#
To prevent the model from ignoring assembly signals, the researchers employ stochastic pseudocode masking during training—randomly hiding parts of the pseudocode input to ensure the model must rely on assembly signals to fill gaps. An additional relative assembly-advantage loss further encourages the model to trust low-level instruction information.
Results and Impact#
Tested on two decompilation benchmarks across multiple compiler optimization levels, ASAP improved the re-execution success rate from 64.7% to 71.9% and the recompilation success rate from 91.6% to 96.6%, substantially outperforming previous best approaches. These gains suggest the framework meaningfully recovers lost information from optimized binaries and produces more faithful reconstructions of original code.

