Decompile a DOS game into C source that rebuilds the original binary

crc32 used LLMs from OpenAI, Anthropic and Google to rebuild Civilization 1 as C source that compiles with Microsoft C 5.1 to a byte-for-byte match of the 1991 executable.

Done withClaudeChatGPTGemini· Oct 20, 2026

What they did

The poster, crc32 on Hacker News (sjmelia on GitHub), set LLMs the job of reconstructing the C and assembler source for the MS-DOS release of Sid Meier's Civilization. The target was strict: the output had to build with the period toolchain (Microsoft C 5.1, MASM 5.10, LINK 5.01, run in DOSBox-X) and produce the original CIV.EXE exactly. That fixed target let the models check their own work against pinned hashes and iterate. The poster pointed the models at OpenCiv1, an earlier decompilation project, and used the result to write a technical book, an annotated story of the source, and a second repo that builds the game for modern systems. Code and docs were edited and verified by hand after the models wrote them.

How it went

The rebuilt source produces a byte-for-byte match with version 474.05 of the executable, apart from a four-byte startup correction the poster believes was a patch applied after linking. The graphics driver, sound driver and MISC.EXE are checked against hashes too. It took a couple of months of on-and-off use of roughly 15 pounds a month subscriptions from OpenAI, Anthropic and Google, without hitting their limits. The poster has since started the same approach on a newer, less documented game, with no result yet.

Worth knowing

Matching the binary does not mean this is the original source: names, comments and some types are guesses, though the compiler's layout depends on identifier names and length limits, which narrows them. The poster credits OpenCiv1 and notes it was likely in the models' training data, so a less studied program may go much worse. Legality was raised in the comments and left open. The poster did not say which tools or harness ran the models.

Try it

With Claude· 7 parts to fill in

Reconstruct source code for [the program, e.g. an old DOS game] so that it compiles with [the original compiler, assembler and linker versions] to a byte-for-byte match of [the original executable]. Set up a build that runs [in DOSBox-X or the period toolchain] and a verify step that compares the output against [pinned SHA-256 hashes]. Use [prior decompilation work or disassembly] as a reference. Work one function or module at a time: write it, rebuild, compare, and keep iterating until that part matches. Mark every inferred name or comment as a guess. Stop and report to me when a part will not match after [number] attempts, and when the whole binary matches.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related