Updated November 18, 2026
Glossary ToolsBest models

Task · decompiler cleanup

AI decompiler for function naming and cleanup

An AI decompiler renames functions and variables, recovers types and names constants in Ghidra or IDA output. The decompiler still decompiles.

By AI for Reverse EngineeringUpdated November 18, 2026
On this page

Example

Decompile: FUN_00101a40parse_frame.c6 renames · 4 constants · 1 comment
Decompiler outputGhidra-style
 1undefined4 FUN_00101a40(byte *param_1,uint param_2) 2  3{ 4  ushort uVar1; 5  uint uVar2; 6  uint local_c; 7  8  if (param_2 < 5) { 9    return 0xffffffff;10  }11  if ((*param_1 != 0x5a) || (param_1[1] != 0xa5)) {12    return 0xfffffffe;13  }14  uVar1 = CONCAT11(param_1[2],param_1[3]);15  if (param_2 < (uint)uVar1 + 5) {16    return 0xfffffffd;17  }18  uVar2 = 0;19  for (local_c = 0; local_c < uVar1; local_c = local_c + 1) {20    uVar2 = uVar2 + param_1[local_c + 4] & 0xff;21  }22  if (uVar2 != param_1[(ulong)uVar1 + 4]) {23    return 0xfffffffc;24  }25  return (uint)uVar1;26}
After an LLM passchecked by hand
 1/* Checks one serial packet: magic 5A A5, a big-endian 2   16-bit payload length, the payload, then an 8-bit 3   additive checksum. Returns the payload length, or 4   an error code below zero. 5   Likely a UART link layer (guess, medium confidence). */ 6int parse_frame(const uint8_t *frame, uint32_t frame_len) 7{ 8  if (frame_len < FRAME_OVERHEAD)          /* 5 bytes */ 9    return ERR_TOO_SHORT;                  /* -1 */10  if (frame[0] != 0x5a || frame[1] != 0xa5)11    return ERR_BAD_MAGIC;                  /* -2 */12 13  uint16_t payload_len = (frame[2] << 8) | frame[3];14  if (frame_len < payload_len + FRAME_OVERHEAD)15    return ERR_TRUNCATED;                  /* -3 */16 17  uint8_t sum = 0;18  for (uint32_t i = 0; i < payload_len; i++)19    sum += frame[4 + i];20 21  if (sum != frame[4 + payload_len])22    return ERR_BAD_CHECKSUM;               /* -4 */23 24  return payload_len;25}
  • FUN_00101a40parse_frameChecks magic, length and checksum, then returns the length
  • param_1frameIndexed as bytes from 0 to the checksum
  • param_2frame_lenCompared against the header and payload size
  • uVar1payload_lenBuilt big-endian from bytes 2 and 3
  • uVar2sumAccumulated modulo 256, compared to the last byte
  • local_ciLoop counter
A harmless sample we wrote: a frame parser of the kind found in device firmware, shown as a decompiler prints it and after the cleanup a model does. The right side is an illustration, not a recorded model reply. Real output varies, so check each name against the code, as the right pane's own comment does.

Trained models

LLM4Decompile is "the first and largest open-source LLM series (1.3B to 33B) trained to decompile binary code". Its authors report that it beats GPT-4o and Ghidra on HumanEval and ExeBench "by over 100% in terms of re-executability rate", and that its Ref models add another 16.2%. code and models

Workflow

  1. Name libraries first. Run auto-analysis and apply FLIRT or Lumina.
  2. Name leaves before their callers.
  3. Send the function, its callee names, strings and trusted types.
  4. Ask for a confidence of high, medium or guess, and the line that supports the name.
  5. Apply the high-confidence names. A person checks the guesses.
  6. Run a second pass once the callee names are better.

Tools

ToolHow it renames
Gepetto (IDA Pro)Ctrl+Alt+R renames the variables in the pseudocode window
IDAssist (IDA Pro)Rename suggestions from the right-click menu
GhidrAssist (Ghidra)Proposes renames in bulk in its Actions tab
r2ai (radare2)r2ai -d decompiles with the model; r2ai -q autoname and varnames rename
BinAssist (Binary Ninja)Rename suggestions through native tool calling
Any MCP agentRenames across the whole database, then writes a report

Cost

A small function is about 1,500 tokens in and 300 out. On DeepSeek V4.1 Flash 1017 at $0.24 in and $0.90 out per 1M tokens, that is about $0.00063 a function, or about $3.15 for 5,000 functions, at Silk Compute read November 18, 2026. Save Kimi K3.1 Pro for the functions that resist.

Pitfalls

  • Let the tool convert hex and bytes, as the ida-pro-mcp README advises.
  • Check widths and signedness in the disassembly.
  • Name inlined memcpy, division and switch tables first.