{"slug": "rats-1994-source-code-reconstruction-using-qwen-3-8", "title": "Rats!* (1994) source code reconstruction using Qwen 3.8", "summary": "A developer reconstructed the source code for the 1994 Windows game Rats! using the local LLM Qwen3.8 27B BF16 on a 2024 MacBook Pro with an Apple M4 Max and 128 GB of memory, achieving an average reconstruction time of 2 minutes 32.1 seconds per function across 36 retained functions. The project, led by Sean O'Connor's original game, uses Microsoft Visual C++ 4.1 under wibo and DREAMM for testing, with Codex and Claude restricted to repository setup and benchmark orchestration only. The reconstruction is imperfect but realistic, with 177 internal functions analyzed via Ghidra and a tool called binary-recons automating the process.", "body_md": "This repository is a work-in-progress reconstruction of the source code for\n`RATS.EXE`\n\n, the original Windows version of\n[ Rats!](https://www.windowsgames.co.uk/rats.html) (1994) by Sean O'Connor. It builds\na Win32 executable with Microsoft Visual C++ 4.1 under\n\n[wibo](https://github.com/neuromancer/wibo)and can be tested in\n\n[DREAMM](https://dreamm.aarongiles.com/).\n\nThe experiment explores how far local LLMs can take source reconstruction on a small but realistic codebase rather than a toy example. Match fidelity remains uneven, which is useful here: the aim is to present a realistic view of the process and its current limitations, not to hide difficult functions.\n\nFunction reconstruction is restricted to local LLMs. Codex and Claude are used for repository setup and benchmark orchestration, but they are not allowed to write or edit the reconstructed source.\n\nUnless noted otherwise, all experiments used Qwen3.8 27B BF16 on a 2024 MacBook Pro with an Apple M4 Max (16-core CPU, 40-core GPU) and 128 GB of memory. The approach works—imperfectly, but usefully: the 36 retained functions took an average logged time of 2m 32.1s each to reconstruct.\n\nClone with submodules, or initialise them after cloning:\n\n```\ngit submodule update --init --recursive\n```\n\nThe original executable is not included. Download the free Windows version\nfrom the [official Rats! page](https://www.windowsgames.co.uk/rats.html) and\nplace its\n\n`RATS.EXE`\n\nin the repository root to use the original-executable and\nbinary-comparison targets.\n\n```\nmake                 # build out/RATS_RE.EXE, .map, .obj, and .asm\nmake toolchain       # download, extract, and verify Microsoft Visual C++ 4.1\nmake run             # launch the rebuilt executable in DREAMM\nmake run-original    # launch the preserved original RATS.EXE\nmake test            # bounded DREAMM smoke test of the rebuilt executable\nmake test-original   # bounded DREAMM smoke test of the original executable\nmake debug           # start the rebuilt executable in DREAMM's debugger\nmake report          # report similarity for every reconstructed function\nmake compare-func FUNC=SaveHighScores ADDR=00409092\n```\n\nThe checksum-pinned\n[MSVC 4.1 archive](https://github.com/decompme/compilers/releases/download/compilers/msvc4.1.tar.gz),\nthe required MSVC 4.1 libraries, wibo's compatible `msvcrt40.dll`\n\n, and DREAMM\n`4.0x21`\n\nare downloaded on demand. They remain ignored local build dependencies\nand are not committed.\n\nThe checked-in `ghidra/`\n\ndirectory contains assembly and decompiler exports for\nall 177 internal functions. Assembly is the comparison authority; decompiled C\nis only a semantic seed.\n\nInstall [ binary-recons](https://github.com/gg-sl-oss/binary-recons) once, then\nrun it from the repository root:\n\n```\npython3 -m pip install -e /path/to/binary-recons\nbinary-recons --next-function           # reconstruct the next safe missing target\nbinary-recons --address 0x409092        # reconstruct or improve a specific target\n```\n\nThe tool discovers Qwen automatically in the standard Hugging Face cache;\n`BINARY_RECONS_MODEL_PATH`\n\ncan override it. `binary-recons.toml`\n\nkeeps automatic\nselection inside the game-code ranges, starts and stops llama.cpp, and defines\nthe transactional files and `binary-comp`\n\ncommand. Each bounded run seeds one\nfunction from Ghidra, asks Qwen for focused compile or assembly-diff repairs,\nand retains the best safe compiling candidate. Use `--target-score 95`\n\nfor a\ndeeper pass or `--dry-run-prompt`\n\nto inspect the prompt without loading Qwen.\n\nMeasured local-model runs are recorded in\n[docs/MODEL_RESULTS.md](/neuromancer/rats-re/blob/main/docs/MODEL_RESULTS.md).\n\n## Model results: 36 retained functions and 3 deferred addresses\n\nMost retained candidates were generated with Unsloth's\n[Qwen3.8 27B GGUF](https://unsloth.ai/docs/models/qwen3.8) in BF16\n(`Qwen3.8-27B-BF16`\n\n, served as `qwen3.8-27b-bf16`\n\n) through llama.cpp with a\n32,768-token context and the `qwen`\n\nmodel preset. The current workflow uses\nGhidra's decompilation as a mechanical seed, asks Qwen only for a meaningful\ncontract and bounded source edits, follows valid edits as a repair trajectory,\nand retains the best result measured by `binary-comp`\n\n. Gemma 4 31B IT BF16 was\nalso benchmarked, but none of its candidates is retained in the source tree.\n\nThe scores below were remeasured from the current source tree with MSVC 4.1 and\n`binary-comp`\n\non 2026-08-16. Logged time includes managed-server startup,\ngeneration or repair, build, and comparison for the retained candidate. It\nexcludes unsuccessful exploratory runs and repair turns made after a resumable\ncandidate had already been produced; those remain available in the run logs.\n\n| Address | Function | Current similarity | Logged time |\n|---|---|---|---|\n`0x0040215C` |\n`IsLevelIndexInRange` |\n65.31% | 3m 06.4s |\n`0x00402205` |\n`ShowLevelComplete` |\n93.96% | 5m 26.1s |\n`0x0040250C` |\n`SubmitHighScore` |\n97.37% | 1m 49.7s |\n`0x004026D0` |\n`RenderScoreboard` |\n95.40% | 2m 30.9s |\n`0x00402BF3` |\n`AddLevelToTable` |\n73.85% | 4m 04.6s |\n`0x00402DC6` |\n`UpdateGameDisplay` |\n78.18% | 1m 36.4s |\n`0x00402EE7` |\n`GetLevelDisplayInfo` |\n71.70% | 2m 15.9s |\n`0x00402FD5` |\n`GetLevelIndex` |\n87.27% | 5m 48.3s |\n`0x00403430` |\n`IsBombAtLevel` |\n80.62% | 27.3 s |\n`0x00403607` |\n`PlaceLevel` |\n80.00% | 2m 32.6s |\n`0x00404764` |\n`DrawLevelIndicator` |\n97.33% | 1m 35.6s |\n`0x0040499F` |\n`RenderCornerGlyph` |\n69.83% | 1m 50.9s |\n`0x00404D6E` |\n`DrawBitmapPair` |\n98.67% | 1m 04.6s |\n`0x00404E3B` |\n`RenderBitmapToWindow` |\n94.74% | 26.4 s |\n`0x00404ECE` |\n`DrawBitmapToWindow` |\n95.59% | 59.3 s |\n`0x00404F8B` |\n`DrawScore` |\n96.20% | 1m 32.4s |\n`0x0040507F` |\n`DrawScorePanel` |\n97.97% | 2m 45.0s |\n`0x0040525D` |\n`DrawScoreDigits` |\n94.20% | 2m 13.7s |\n`0x00405343` |\n`RenderScoreOverlay` |\n77.78% | 1m 28.1s |\n`0x0040546B` |\n`DrawFrameBorder` |\n84.93% | 37.0 s |\n`0x0040552E` |\n`ExplodeBomb` |\n64.71% | 1m 50.9s |\n`0x0040560E` |\n`RenderExplosionWave` |\n85.07% | 5m 40.0s |\n`0x0040591A` |\n`DrawBombExplosion` |\n89.31% | 1m 45.8s |\n`0x00405AF5` |\n`DrawPausedOverlay` |\n96.21% | 1m 05.1s |\n`0x00405C52` |\n`HighScoreDialogProc` |\n79.82% | 41.5 s |\n`0x00405DB8` |\n`ScorePanelDialogProc` |\n50.34% | 1m 53.1s |\n`0x00405F72` |\n`DemoVersionDialogProc` |\n46.31% | 4m 18.5s |\n`0x004061D3` |\n`OrderDialogProc` |\n53.16% | 10m 46.5s |\n`0x00408854` |\n`DrawStartButton` |\n70.80% | 1m 35.6s |\n`0x00408A51` |\n`UpdateMainMenuState` |\n97.56% | 28.9 s |\n`0x00408AD3` |\n`InitializeGameLevel` |\n83.72% | 5m 35.7s |\n`0x00408E6A` |\n`LoadLevelData` |\n77.50% | 52.5 s |\n`0x00408F02` |\n`LoadHighScores` |\n79.61% | 1m 15.0s |\n`0x00409092` |\n`SaveHighScores` |\n94.12% | 1m 25.9s |\n`0x0040910C` |\n`LoadLevelBitmaps` |\n98.93% | 7m 08.4s |\n`0x00409DB6` |\n`IsRatsHelpFile` |\n91.67% | 41.5 s |\n\nReconstruction attempts for the following addresses were exhausted without retaining a source implementation. Time spent is cumulative across all logged attempts.\n\n| Deferred address | Time spent | Outcome |\n|---|---|---|\n`0x00401000` |\n10m 29.7s | Function too large for a bounded first pass; original 1.13% scaffold retained |\n`0x00403840` |\n13m 10.0s | No compilable candidate; too large for a fast bounded pass |\n`0x00406674` |\n— | Skipped: too large for a fast bounded pass |\n\nSpecial thanks to:\n\n[Sean O'Connor](https://www.windowsgames.co.uk/)for creatingand continuing to make its original Windows release available from the*Rats!*[official game page](https://www.windowsgames.co.uk/rats.html).", "url": "https://wpnews.pro/news/rats-1994-source-code-reconstruction-using-qwen-3-8", "canonical_source": "https://github.com/neuromancer/rats-re", "published_at": "2026-08-16 13:59:06+00:00", "updated_at": "2026-08-16 14:40:53.662526+00:00", "lang": "en", "topics": ["artificial-intelligence", "large-language-models", "developer-tools"], "entities": ["Qwen3.8", "Sean O'Connor", "Microsoft Visual C++ 4.1", "wibo", "DREAMM", "Ghidra", "binary-recons", "Unsloth"], "alternates": {"html": "https://wpnews.pro/news/rats-1994-source-code-reconstruction-using-qwen-3-8", "markdown": "https://wpnews.pro/news/rats-1994-source-code-reconstruction-using-qwen-3-8.md", "text": "https://wpnews.pro/news/rats-1994-source-code-reconstruction-using-qwen-3-8.txt", "jsonld": "https://wpnews.pro/news/rats-1994-source-code-reconstruction-using-qwen-3-8.jsonld"}}