Remix.run Logo
▲ AshamedCaptain a day ago

Is it even better than raw decompiler output? Frankly, I have been saying this forever but always criticized: getting C output that compiles has always been the easy part, getting stuff that is readable is actually where the problem is, and franky these "AI decompilers" are hardly an improvement so far.

But people act as if "well we got something that compiles down to the same binary, this must be the actual C source!" Welp. It couldn't be more different than the original source. In fact, it's probably even distracting if your goal is to reconstruct the original source. This is just AI slop in a form that you can't even easily recognize.

Not to mention the licensing aspect of all of this. One should be wary of Watcom because of its terrible license, even though it is technically Open Source.If as a consequence Watcom is kind of a minefield, I don't even know how to start describing this. The trenches at Verdun?

▲gavinsyancey a day ago | parent [-]

IMO there are two things that decompiling is useful for:

1. Understanding how the program works. But for this you need a good decompilation, not just "portable assembly in C"

2. Porting to a new platform. Once you have something that builds with a C compiler, you can rebuild it for a different platform, usually more performantly than running in an emulator. And it's often doable (if a lot of work) to also swap out graphics APIs, etc. But I'm not sure there's anyone who would care to run Borland DOS compilers on e.g. apple-aarch64, and DOSbox is more than good enough for anyone who does.

▲AshamedCaptain 6 hours ago | parent | next [-]

Note that generating portable C is not as easy as generating "C that compiles to the same bytes", either.

▲mlyle 20 hours ago | parent | prev [-]

Portable assembly in C is a good first step. Then you can start to name leaf functions and variables… and look for common inlined bits. You can confirm all your higher level transformations continue to produce equivalent bits.

You can leave a model to crank on this for a couple of days and get something much closer to idiomatic source.

It will not be THE source but it will be readable source that produces the same bits.