Manuscript Offprint

arXiv:2608.27889

Decoupling is a Necessity: Transformation-Agnostic Decompiled Code Recovery under Optimization and Obfuscation

Zhiping Zhou, Xiaohong Li, Ruitao Feng, Yao Zhang, Yuekang Li, Wenbu Feng

Zhiping Zhou

Tianjin University

Tianjin, China

zhou_zhiping@tju.edu.cn

Yao Zhang ∗^{*}

Tianjin University

Tianjin, China

zzyy@tju.edu.cn

Xiaohong Li

Tianjin University

Tianjin, China

xiaohongli@tju.edu.cn

Yuekang Li

University of New South Wales

Sydney, Australia

yuekang.li@unsw.edu.au

Ruitao Feng ∗^{*}

Southern Cross University

Lismore, Australia

ruitao.feng@scu.edu.au

Wenbu Feng

Tianjin University

Tianjin, China

ianx@tju.edu.cn

Abstract

Reverse engineering is essential for software security analysis and vulnerability detection. Decompilation, the process of lifting binaries to high-level pseudocode, is central to this task. However, production binaries are hostile environments: aggressive compiler optimizations and adversarial obfuscation jointly mangle control structures, obscure variable intents, and disguise high-level program logic. Consequently, existing LLM-based decompilation tools frequently suffer from structural collapse and semantic hallucinations. We present ReSource, the first multi-phase LLM framework designed for transformation-agnostic source recovery. To tackle these intertwined distortions, ReSource conceptualizes the binary-to-source discrepancies into three orthogonal tiers, namely lexical, syntactic, and semantic, and decouples the recovery process accordingly. First, to ground the LLM and prevent logic drift, it retrieves empirical priors from a curated Semantic Distortion Database. Second, to resolve control-flow flattening, it integrates a lightweight predictor to reconstruct the source-level structural skeleton. Finally, a contextual lexical deduction stage refines identifiers to restore human readability. Evaluated on a massive benchmark of over 80,000 decompiled–source function pairs across three optimization levels and four obfuscation techniques, ReSource achieves an 83% Top-5 source retrieval accuracy and an average similarity score of 0.66. By maintaining robust semantic identifiability where state-of-the-art baselines (DeGPT, LLM4Decompile, and FidelityGPT) severely overfit or degrade, ReSource provides a scalable and reliable foundation for downstream security analysis.

CCS Concepts

• Security and privacy → Software reverse engineering.

Keywords

Reverse Engineering, Decompilation, Compiler Optimizations, Code Obfuscation, Large Language Models

1 Introduction

Reverse engineering [15] is the cornerstone of software security analysis, enabling critical downstream tasks like patch diffing [24, 28], binary similarity analysis [8, 12], and vulnerability discovery. Because analyzing low-level assembly or graphs [5, 9, 13, 26] struggles to support source-level reasoning, analysts heavily rely on decompilers (e.g., IDA Pro [6], Ghidra [4]) to lift binaries into C-like pseudocode. Recently, the structural similarity between this pseudocode and natural programming languages has prompted a surge in adopting Large Language Models (LLMs) to bridge the semantic gap between machine-generated artifacts and human-readable source code.

Current LLM-assisted decompilation generally follows two trajectories. The first is direct translation, such as fine-tuning models on massive assembly-to-C datasets [19]. The second is post-processing, commonly defined in this domain as source recovery, which involves taking raw decompiler pseudocode and restoring its original structural and semantic intent to produce readable, high-fidelity source representations [7, 30].

Despite these advances, existing frameworks operate under a critical flaw: they primarily target benign, lightly optimized code (e.g., O1 or O2). In reality, production binaries are hostile environments, heavily transformed by aggressive compiler optimizations (e.g., O3) and adversarial obfuscation (e.g., Control-Flow Flattening). Because current LLM approaches rely heavily on superficial sequence-to-sequence pattern matching, they severely overfit to benign transformation distributions. When confronted with the intertwined chaos of optimization and obfuscation, these models suffer catastrophic structural collapse and hallucinate incorrect logic, yielding code that is semantically hazardous for downstream security tasks [27].

To bridge this critical gap and enable faithful recovery from heavily optimized and obfuscated binaries, we identify four core challenges that must be systematically addressed:

C1: Unified recovery across diverse transformations. Since the exact combination of optimizations and obfuscations is typically unknown during analysis, recovery methods must avoid overfitting to specific patterns and instead handle heterogeneous distortions through a unified formulation.

C2: Preserving semantic fidelity against opaque artifacts. Aggressive transformations replace human-readable logic with opaque artifacts. Confronted with these alien patterns, vanilla LLMs lose their reasoning context and frequently hallucinate incorrect business logic.

∗^{*}Joint corresponding authors.

C3: Structural collapse from control-flow distortion. Adversarial transformations like control-flow flattening completely obliterate program hierarchies, dismantling readable loops and branches into artificial state machines. Standard sequence-to-sequence LLMs struggle to naturally “un-flatten” this structural chaos.

C4: Limitations of superficial evaluation. Traditional metrics (e.g., BLEU) reward superficial token overlap but are blind to functional equivalence under structural divergence. Robust assessment must directly measure semantic identifiability to ensure real-world utility.

To tackle these challenges, we reframe decompilation: faithful recovery is not a monolithic sequence-to-sequence mapping, but a multi-dimensional reconstruction problem requiring explicit structural and empirical priors. Guided by this principle, we present ReSource, the first multi-phase LLM framework for transformation-agnostic source recovery. To achieve unified recovery (addressing C1), ReSource decouples the process across lexical, syntactic, and semantic tiers. First, it queries a novel Semantic Distortion Database to retrieve empirical priors, resolving opaque artifacts and mitigating hallucinations (addressing C2). Second, a lightweight control-flow predictor reconstructs the source-level architectural skeleton to reverse structural collapse (addressing C3). Finally, lexical finalization refines identifiers to restore human readability.

We evaluate ReSource on a massive benchmark of over 80,000 function pairs across three optimization levels and four obfuscation schemes. To directly validate semantic identifiability and overcome the limits of shallow evaluation (addressing C4), we introduce a rigorous retrieval-based methodology. Experimental results show that ReSource consistently outperforms state-of-the-art baselines (DeGPT, FidelityGPT, LLM4Decompile), achieving an 83% average Top-5 retrieval accuracy and maintaining remarkable stability even under severe control-flow obfuscation.

Contributions. This paper makes the following key contributions:

• We propose ReSource, the first multi-stage LLM framework for transformation-agnostic source recovery against the joint threats of aggressive optimization and adversarial obfuscation.

  • We design a synergistic architecture that decouples semantic guidance (via a data-driven Semantic Distortion Database) from structural repair (via a skeleton predictor), effectively neutralizing LLM hallucinations and structural collapse.

  • We construct a comprehensive benchmark of 80,000+ binary-source pairs and introduce a rigorous retrieval-based evaluation methodology to accurately assess global semantic identifiability.

References (3)

  • Unleashing the Power of Generative Model in Recovering Variable Names from Stripped Binary
  • Unseen horizons: Unveiling the real capability of llm code generation beyond the familiar
  • A Survey of Large Language Models