AI recompiles Portal 2's machine code – game runs natively on Mac and iPhone

Working with Claude Opus 5.5, a developer has built a tool that translates the Linux version of Portal 2 back into C code and turns it into native apps for Mac and iPhone. No emulator, no Wine, no Rosetta. The first playable room was up and running after two days, even though Claude itself had estimated months.

Tools Nov 5, 2026 5 min read Source: Reddit r/ClaudeAI
Illustrative image, AI-generated

What's going on

Over on the r/ClaudeAI subreddit, a developer has shown off a project that gets Valve's puzzle game Portal 2 running as a genuine native app on Apple silicon Macs – and even on the iPhone. He didn't remake the game, and it isn't running in an emulator (a program that mimics a different computer). Instead, he worked with Anthropic's AI model Claude Opus 5.5 to build a tool that automatically translates the compiled machine code of Portal 2's Linux version back into the C programming language. The result: around 125,000 functions. The tool then recompiles that C code for ARM64, the processor architecture used by Apple's chips.

The project is public on GitHub (kanapitsas/portal2-recomp), and contributions are explicitly welcome.

How it works: translation, not imitation

If you want to get a game running on a different platform, you usually have three options:

  • Emulation: A program imitates the foreign hardware. It's flexible, but it eats a lot of processing power.
  • Translation layers like Wine or Rosetta: Wine translates Windows calls for other operating systems. Apple's Rosetta translates Intel programs for Apple chips at runtime.
  • Static recompilation: The machine code is translated once, up front and in full, into another form – here, C – and then recompiled for the target platform. What you end up with is a perfectly ordinary native program.

This project takes the third route. According to the developer, there's no emulator, Wine or Rosetta involved. Static recompilation is well known in the fan community, for example from ports of old console games. But it's normally months of manual work, because edge cases, graphics calls and system functions all have to be handled one by one. That's what makes the timeline so striking: after just two days, a first room was playable. Claude itself had estimated beforehand that it would take many months.

What already works

The developer lists a few concrete features:

  • iPhone: Portal 2 is playable with touch controls on an iPhone 15 Pro Max. You fire portals by tapping the back of the phone. He's posted a demo video on YouTube.
  • Controllers: Bluetooth gamepads work; he tested with an 8BitDo model.
  • Co-op: Playing together works over a local network. One Mac hosts, and a second Mac or an iPhone joins via IP address.

Faster with a direct path to Metal

Portal 2's Source engine was originally designed around Direct3D 9, Microsoft's Windows graphics API. The Linux version renders through OpenGL, a cross-platform graphics API that Apple stopped developing years ago. The project has since replaced OpenGL with a direct translation path from Direct3D 9 to Metal, Apple's own graphics API, built on the open-source project mtld3d.

The difference is significant. In one scene on a MacBook with an M3 Pro, the frame rate went from 81 to 122 frames per second – an increase of roughly 50 percent. The developer himself stresses, though, that numbers vary a lot from room to room. So this is a single measurement, not a systematic benchmark.

Who did what?

The developer is upfront about the division of labor:

Claude Code wrote the code; I set the direction, tested on my devices and made the decisions.

He also brought in OpenAI's coding agent Codex as a reviewer, checking the code and offering second opinions whenever Claude got stuck. That makes the project a good example of how developers are combining multiple AI agents: one model writes, a second reviews, and the human steers and tests.

Legal: bring your own copy

The repository contains no Valve game files. You need your own legitimately purchased copy of the Linux version of Portal 2. The native app is then built on your machine from those files. That's standard practice for recompilation projects, as it avoids distributing copyrighted material. Whether or how Valve will respond to the project is unknown.

Our take

Technically, the project is interesting for two reasons. First, it shows that AI agents can now handle big, tedious jobs like translating machine code back into source in days rather than months – as long as an experienced human is guiding them. Second, this approach opens up a way to bring older PC games to Apple devices that never got an official version, without the performance hit of an emulator.

Plenty of questions remain, though. All the claims come from the developer and haven't been independently verified. The post doesn't say how complete or stable the game is across all levels. It's also unclear how much of the result rests on the human's expertise, and how well the tool would carry over to other games. "Two days to a playable room" doesn't mean the whole game is fully ported. The project is still looking for contributors. Still, if you're a tinkerer with a Mac or iPhone and your own copy of Portal 2, it's one of the most vivid demonstrations yet of what agentic coding with Claude Code can do today.

Sources

#claude code#reverse engineering#gaming#apple silicon#recompilation
Read the original source

Ask the AI assistant

Questions about this article, installation or background? Our assistant knows this page and runs on our own machine, not in someone else's cloud.

Connecting …

The Assistant is an AI (Gemma 4) and can make mistakes – please check important details against the source. Questions are used only to generate an answer and are deleted after one hour. Please don't enter any personal data.

Comments

What do you think? Already tried it? Write it here, no sign-up needed.

  1. Loading comments …

Comments are public. Links aren't allowed, and we delete abusive posts. You can delete your own comment at any time in this browser. Learn more in the Privacy Policy.