SWEN Research Group
← All talks

SWEN Talk

Simplicity by Obfuscation: Evaluating LLM-Driven Code Transformation with Semantic Elasticity

Lorenzo De Tomasi

SWEN member

PhD Student at Università degli Studi dell'Aquila

Date

27 May 2026

14:30–15:30

Location

Alan Turing Seminar Room

Topic lab

Abstract

Context: Code obfuscation rewrites source code into a functionally equivalent but less readable form. The goal is protecting proprietary software from reverse engineering and IP theft. Traditional techniques (layout, control flow, data transformations, identifier renaming) work, but need manual tuning per code pattern and sometimes break functionality. LLMs understand code semantics well enough to perform code transformations automatically. They are still largely untested on security-oriented obfuscation. Challenge: Existing metrics like cyclomatic complexity and code expansion only reward making code more complex. They miss what LLMs actually do when they transform code in non-traditional ways. We had no empirical baseline: how current LLMs perform on this, which prompting works, whether function type matters. Solution: We tested three LLMs (Claude-3.5-Sonnet, Gemini-1.5, GPT-4-Turbo) on 30 Python functions across five domains: Mathematical, Sorting & Searching, String Manipulation, Data Structures, Recursive. We compared zero-shot and few-shot prompting. We then introduced Semantic Elasticity, a metric combining absolute cyclomatic complexity change, squared pass rate, and code expansion. The metric scores obfuscation quality whether complexity goes up or down. Results: GPT-4-Turbo with few-shot reaches 81% pass rate. Claude-3.5-Sonnet sits at 30%, Gemini-1.5 at 39%. The interesting finding: all three models reduce cyclomatic complexity instead of increasing it. Traditional obfuscation does the opposite. We call this 'obfuscation by simplification'. Function type matters too. String Manipulation hits 56%, Recursive algorithms only 42%.