Manuscript Offprint
arXiv:2610.38337DIFUZZI: A Differential Fuzzing Tool for Code Functional Similarity Assessment
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Simantika Bhattacharjee Dristi
University of Virginia
Charlottesville, Virginia, USA
Matthew B. Dwyer
University of Virginia
Charlottesville, Virginia, USA
Abstract—A range of software engineering tasks, such as optimization and refactoring, seek to preserve the behavior of software components and require methods to assess functional similarity. Research has explored formal approaches to prove functional equivalence and used machine learning methods to approximate it, but the former does not scale and does not quantify the extent of similarity and the latter struggles when subtle semantic differences are present. Differential fuzzing offers a scalable approach for differencing programs semantically, but applying it often requires substantial manual effort to construct input generators that are well-suited to a target pair of programs. To address this challenge, we introduce DIFUZZI, which incorporates an LLM-based generator synthesis step that is iteratively validated and repaired. By automating this step, DIFUZZI paves the way for broader applicability of differential fuzzing. We release DIFUZZI at https://github.com/Dristi123/difuzzi_tool, with a demonstration video at https://youtu.be/FIHNOHuo9WE
Index Terms—Equivalence Checking, Functional Similarity Assessment, Fuzzing
I. INTRODUCTION
Assessing the functional correctness of candidate programs against reference implementations is fundamental to a wide range of software engineering (SE) tasks such as code generation, refactoring, optimization, and translation [1]–[3]. While binary correctness metrics distinguish correct from incorrect programs, continuous functional similarity scores capture the extent of behavioral agreement, providing finer-grained feedback for debugging and iterative code improvement [4], [5]. However, existing approaches to functional similarity assessment have several limitations. Unit testing provides execution-based evidence but requires adequate predefined test suites. On the other hand, static code evaluation metrics (CEMs) like CodeBLEU [6] offer inexpensive, execution-free evaluation but remain sensitive to surface-level similarities that may not reflect functional behavior [7]. Similarly, LLM-judges can estimate similarity without execution [8] but often struggle to reason about deeper program semantics [9]. Differential fuzzing offers a promising solution to these limitations by dynamically generating test inputs without requiring predefined test suites, while providing execution-based evidence of functional similarity that LLM-judges or static metrics lack.
Despite its potential, differential fuzzing remains underexplored for code similarity and correctness evaluation. The few existing approaches [1], [7] often require manual intervention, making large-scale analysis impractical, while the lack of open-source end-to-end tools further limits practical adoption.
To address these gaps, in this paper, we present DIFUZZI, an automated, coverage-guided differential fuzzing tool that estimates functional similarity between source code implementations. Given a reference and a candidate, DIFUZZI generates test inputs guided by coverage feedback from both implementations, executes them on the same inputs, and compares their outputs to assess functional agreement. Supporting Python and Java at both function and file levels, DIFUZZI provides fine-grained functional similarity scores and also identifies concrete counterexamples that establish non-equivalence.
DIFUZZI offers a fully automated workflow comprising LLM-based input generator synthesis, automated validation, and coverage-guided differential fuzzing. First, an LLM synthesizes a problem-specific generator that transforms raw fuzzer bytes into valid program inputs. DIFUZZI then validates the LLM-synthesized generator for structural correctness, robustness, and input validity, using feedback-driven LLM repair to address failures. Once validated, the generator is integrated with a coverage-guided fuzzer, which mutates input bytes using coverage feedback from both implementations to exercise different execution paths and assess their functional agreement.
Our experiments in Section IV, conducted on 500 Python and Java program pairs from 5 benchmarks, demonstrate DIFUZZI's effectiveness in functional similarity estimation relative to baselines.
The use of differential fuzzing for functional correctness assessment is not new. However, prior approaches [1], [7] are limited to Python, rely on manually validated input generators, and lack a publicly available, general-purpose tool. Furthermore, neither systematically evaluates the effectiveness of differential fuzzing itself for functional similarity estimation.

Fig. 1. Example of input generator synthesis (Section III-A1)
This work addresses these gaps by introducing DIFUZZI, which automates the workflow and supports both Python and Java, and by empirically evaluating DIFUZZI's effectiveness against existing approaches.
III. FRAMEWORK
Given a reference program , one or more candidate implementations of the same problem, at least one example input, and an optional NL description of , DIFUZZI estimates the functional similarity of each candidate to .
Assumptions. DIFUZZI makes two assumptions about and : (a) Each program is self-contained, i.e., includes all necessary dependencies (e.g., helper functions and imports), and can be executed in isolation; and (b) Each program produces a comparable output, through return values (function level) or standard output (file level). These outputs define the scope of observable behavior in the current version of DIFUZZI.
A. Approach
Fig. 2 presents the overall architecture of DIFUZZI, highlighting the three main steps discussed below.
- Input Generator Synthesis: Since DIFUZZI uses fuzzers that operate on raw bytes without knowledge of program-specific input constraints, it is necessary that the test inputs remain valid and relevant to the programs under test. To address this, step 1 uses few-shot prompting to have an LLM synthesize an input generator, given , example inputs, and an optional NL description. The synthesized generator transforms raw fuzzers bytes into valid inputs for . As shown in Fig. 1, the synthesized generator for binary search produces sorted lists of distinct integers and varies the search target by either selecting an element from the list or by generating an independent integer. This ensures that the generated inputs satisfy 's constraints and cover both scenarios: where the target is present in the list and where it is absent.

Fig. 2. Overview of DIFUZZI. The input generator is synthesized and validated once per reference program and reused for each candidate.
- Validation and Repair: In Step 2, DIFUZZI identifies and addresses potential errors in LLM-synthesized input generators before fuzzing. To eliminate manual effort, DIFUZZI applies three automated guardrails, each targeting a specific property:
- G1 (Structural Correctness): Verifies that the generator compiles successfully and implements the required generate (See Fig. 1) interface.
- G2 (Robustness): Executes the input generator on 100 randomly generated byte sequences, checking that each produces an input without exceptions or timeouts.
- G3 (Input Validity): Checks whether each input generated during G2 is valid for . An input is considered valid if returns or exits normally within the time limit.
If any check fails, DIFUZZI feeds the error messages and failing examples back to the LLM to guide generator repair. If no generator passes all checks within three attempts, DIFUZZI reports the unresolved failures and terminates without estimating functional similarity for the reference and its candidates.
- Coverage-guided Differential Fuzzing: In the final step, the validated input generator is integrated with a coverage-guided fuzzer. A single fuzz target combining both and is constructed, where each generated input is passed to both implementations and their outputs are compared. Note that while the LLM-synthesized generator (Section III-A1) defines the input space, coverage-guided fuzzing drives the exploration of that space towards diverse inputs. The generator is excluded from coverage instrumentation so that fuzzing is guided solely by coverage from and . Duplicate inputs are discarded, and fuzzing continues until the target number of distinct inputs (1,000 by default) or the time limit (60 s by default) is reached.
Similarity score. DIFUZZI measures functional similarity as the fraction of evaluated inputs on which and exhibit the same outcome (identical outputs or both failing):
where a score of 1 indicates that no evaluated input distinguishes the two programs, with lower scores reflecting a greater proportion of inputs on which deviates from . When a binary decision is needed, the score can be mapped to a verdict: .
Each execution produces an HTML report (See https://github.com/Dristi123/difuzzi_tool) summarizing functional similarity, identified counterexamples, and line and branch coverage of and .
B. Implementation and Tool Usage
DIFUZZI is written in about 2,600 lines of Python code, requiring Python 3.12+ and JDK 17-19 for Java support. For Python, it uses Atheris [12] as the fuzzer and coverage.py for coverage measurement, while Java uses Jazzer [13] and JaCoCo, respectively. DIFUZZI supports Kimi and Google Gemini APIs and allows flexible model selection from either provider. A typical invocation for evaluating cand.py () against ref.py () with input examples in ex.txt is:
difuzzi ref.py cand.py --examples ex.txt
DIFUZZI provides 14 command-line options for flexible configuration, including --early-stop, which terminates fuzzing at the first disagreement and returns a counterexample, thereby reducing testing cost when only a binary verdict is needed. All other command-line options, implementation details and setup instructions are documented in the repository.
IV. EVALUATION
A. Dataset
We build our evaluation dataset using five widely used coding benchmarks: CodeContests-Python, HumanEval+, and MBPP+ for Python, along with CodeContests-Java and HumanEval-X for Java, sampling 50 tasks from each. For each task, we pair the reference implementation with two candidate implementations : a single-edit mutant generated using MutPy [14] (Python) or Major [15] (Java), and a non-mutant implementation. While mutants introduce subtle code changes, non-mutants are expected to exhibit greater structural differences from the reference. Non-mutants are drawn from human-written solutions in CodeContests or generated using Qwen 2.5 Coder-32B for the other benchmarks that lack human-written solutions. This yields 500 pairs.
To approximate ground-truth functional similarity, we execute and on the benchmark-provided test suites and compute their output agreement (Eq. 1). The median number of tests used to estimate ground-truth similarity is 944 for HumanEval+, 108 for MBPP+, 888 for HumanEval-X, and 201 for CodeContests (Python and Java).
B. Baselines
We compare DIFUZZI against four baselines that can provide continuous similarity scores: CodeScore [4], a CEM, and three LLM judges. We select CodeScore because it is trained on program execution outcomes, unlike other commonly used CEMs that rely on textual similarity to reference implementations. For the LLM judges, we use Kimi K2.5, Gemini 2.5 Flash, and Qwen 2.5 Coder-32B.
TABLE I SPEARMAN'S WITH THE GROUND-TRUTH SIMILARITY. THE "ALL" COLUMN IS COMPUTED OVER ALL 500 PAIRS
| Technique | Python | Java | All | ||
|---|---|---|---|---|---|
| Mutant | Non-mutant | Mutant | Non-mutant | ||
| CodeScore | 0.31 | 0.52 | - | - | 0.35 |
| Kimi K2.5 | 0.51 | 0.77 | 0.84 | 0.84 | 0.86 |
| Gemini 2.5 Flash | 0.65 | 0.57 | 0.80 | 0.62 | 0.81 |
| Qwen 2.5 Coder | 0.33 | 0.40 | 0.51 | 0.32 | 0.63 |
| DIFUZZI | 0.81 | 0.90 | 0.92 | 0.91 | 0.94 |
C. Experimental Setup
We prompt each LLM-judge to assign a functional similarity score in [0, 1] given the task description, the reference and the candidate. For CodeScore, we use its released pretrained checkpoint and treat its predicted pass ratio as the similarity score. Since CodeScore is trained on Python, we evaluate it only on Python pairs. We run DIFUZZI with the task description, a single example input, its default budgets, and Kimi K2.5 for input generator synthesis. Table I reports Spearman's between each technique's score and the ground-truth.
D. Results and Analysis
DIFUZZI correlates most strongly with the ground-truth across all settings (Table I), reaching overall, compared to 0.86 for the best baseline. CodeScore and Qwen 2.5 Coder exhibit weak correlations across all settings, whereas the closed-source models (Kimi K2.5, Gemini 2.5 Flash) achieve comparatively stronger results. Interestingly, no single LLM judge consistently outperforms the others across all settings (on Python mutants, Gemini leads Kimi, vs. 0.51; on Python non-mutants, Kimi leads Gemini, 0.77 vs. 0.57). This variation raises concerns about relying on a single LLM judge across settings, in contrast to DIFUZZI, which outperforms all baselines throughout.
We further compare DIFUZZI with the LLM judges on non-equivalence detection and counterexample validity (Table II). For non-equivalence detection, we measure the percentage of ground-truth non-equivalent pairs that each technique correctly identifies (similarity score < 1, Eq. 1). For pairs identified as non-equivalent, we ask each LLM to provide up to 20 counterexamples, the same maximum number in DIFUZZI's report. Counterexample validity is measured as the percentage of reported inputs that produce different outputs when executed on and .
As Table II shows, the LLM judges detect nearly all non-equivalent single-edit mutants, but their detection rates drop substantially for non-mutants (Kimi: 82%, Gemini: 75%, Qwen: 51%), compared to 92% for DIFUZZI. We hypothesize that LLMs may have learned common mutation patterns during training, allowing them to identify single-edit mutants easily, whereas the greater structural diversity of independently written human and LLM solutions makes non-equivalence harder to detect. Counterexample validity similarly drops to 86% for Kimi and 11% for Qwen on non-mutants. In contrast, DIFUZZI
TABLE II NON-EQUIVALENCE DETECTION AND COUNTEREXAMPLE VALIDITY.
| Technique | Non-equivalence (%) | Cex. Validity (%) | ||
|---|---|---|---|---|
| Mutant | Non-mut. | Mutant | Non-mut. | |
| Kimi K2.5 | 100 | 82 | 93 | 86 |
| Gemini 2.5 Flash | 100 | 75 | 90 | 72 |
| Qwen 2.5 Coder | 95 | 51 | 43 | 11 |
| DIFUZZI | 100 | 92 | 100 | 100 |
achieves 100% counterexample validity by construction, as every reported counterexample is verified through execution to produce different outputs for and . Beyond these empirical results, DIFUZZI offers a conceptual advantage: its coverage-guided fuzzing and reported coverage statistics allow users to assess how extensively the programs were tested and thereby better interpret the similarity scores, whereas LLM judges lack comparable evidence of testing thoroughness.
Finally, we evaluate the quality of the input generators through coverage and input validity. During our experiments, DIFUZZI achieved mean branch coverage of 96% for Python and 99% for Java references, providing strong evidence of diverse program behavior exploration. Moreover, only 8 of the 459K inputs generated by DIFUZZI (< 0.01%) caused a reference failure, suggesting that the generators largely produce valid inputs. Together, these results support the effectiveness of our input generator synthesis and validation steps.
V. APPLICATIONS
The differential fuzzing approach underlying DIFUZZI has supported three of our prior studies addressing distinct software engineering problems. In [7], it was used to build a benchmark with ground-truth functional similarity scores for evaluating CEMs. In our study of LLM-generated code refactorings [1], we applied it to assess functional equivalence between original and refactored code, uncovering behavioral differences missed by existing test suites. In [16], differential fuzzing supported code summary evaluation by measuring the functional similarity between the original code and code regenerated from summaries. However, these studies required substantial manual effort to configure and execute differential fuzzing, motivating us to refine and automate the workflow and make DIFUZZI publicly available. We envision DIFUZZI's broader applications in regression testing, validation of automated program repairs, code optimizations, and other tasks requiring functional similarity estimates, which DIFUZZI can provide without relying on pre-existing test cases.
VI. THREATS TO VALIDITY
The validity and input diversity of LLM-synthesized generators may affect our findings. To mitigate this risk, we validate and repair generators before fuzzing and rely on coverage-guided fuzzing, rather than the LLM, to explore the input space. The ground-truth similarity estimates (Section IV) may not reflect true functional similarity, as they are derived from finite test suites. Nevertheless, we use extended test
suites where available to obtain a reasonable approximation of ground truth. Finally, although DIFUZZI generates a large number of inputs per pair, we note that agreement on these inputs is not a formal proof of functional equivalence.
VII. CONCLUSION
This work presents DIFUZZI, an open-source differential fuzzing tool for estimating functional similarity without pre-existing test suites. It uses LLM-based input generator synthesis, automated validation, and coverage-guided fuzzing to estimate functional similarity and identify counterexamples. Experiments demonstrate that DIFUZZI achieves very strong correlations with ground-truth scores, while ensuring 100% counterexample validity by construction. Moreover, the synthesized input generators achieve high coverage and input validity, demonstrating that DIFUZZI can reliably automate the workflow. We hope that the provided repository, documentation, and demonstration video will facilitate broader adoption of DIFUZZI. As future work, we plan to extend DIFUZZI to support cross-language functional similarity assessment and broaden its scope of observable behavior beyond return values and standard output to include side effects such as changes to global state and file writes.
REFERENCES
[1] S. B. Dristi and M. B. Dwyer, "A differential fuzzing-based evaluation of functional equivalence in llm-generated code refactorings," in Proceedings of the 34th ACM International Conference on the Foundations of Software Engineering, ser. FSE Companion '26, 2026, p. 1708–1712. [2] M. L. Siddiq et al., "The fault in our stars: Quality assessment of code generation benchmarks," in 2024 IEEE International Conference on Source Code Analysis and Manipulation (SCAM), 2024, pp. 201–212. [3] A. G. Shypula et al., "Learning performance-improving code edits," in The Twelfth International Conference on Learning Representations, 2024. [4] Y. Dong et al., "Codescore: Evaluating code generation by learning code execution," ACM Trans. Softw. Eng. Methodol., vol. 34, no. 3, Feb. 2025. [5] C. C. Le et al., "Benchmarking code improvement with progressive, adaptive, and interactive feedback," 2026. [Online]. Available: https://arxiv.org/abs/2607.01360 [6] S. Ren et al., "Codebleu: a method for automatic evaluation of code synthesis," 2020. [Online]. Available: https://arxiv.org/abs/2009.10297 [7] S. B. Dristi and M. B. Dwyer, "Local: Countering surface bias in code evaluation metrics," Proc. ACM Softw. Eng., vol. 3, no. FSE, Jun. 2026. [8] M. Meus et al., "Detecting functional memorization in code language models," 2026. [Online]. Available: https://arxiv.org/abs/2606.12764 [9] A. Wei et al., "EquiBench: Benchmarking large language models' reasoning about program semantics via equivalence checking," in Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, Nov. 2025, pp. 33868–33881. [10] P. Schanely, "Crosshair," https://github.com/pschanely/CrossHair, 2026, gitHub repository, accessed October 19, 2026. [11] K. Etemadi et al., "Mokav: Execution-driven differential testing with llms," Journal of Systems and Software, vol. 230, p. 112571, Dec. 2025. [12] "Atheris: A coverage-guided, native python fuzzer," https://github.com/google/atheris, 2020. [13] S. Dechand et al., "Jazzer: Coverage-guided fuzzing for semantic vulnerabilities in the java ecosystem," in 2026 IEEE Symposium on Security and Privacy (SP), 2026, pp. 3720–3739. [14] K. Halas and Contributors, "MutPy: Mutation testing tool for python," https://github.com/mutpy/mutpy, 2015. [15] R. Just, "The major mutation framework: efficient and scalable mutation analysis for java," in International Symposium on Software Testing and Analysis, 2014. [16] S. B. Dristi and M. B. Dwyer, "Sonar: Task-aware code summary evaluation for llm consumers without references," 2026. [Online]. Available: https://arxiv.org/abs/2608.04195