Wouldn't a total re-write be the right thing to do instead?
Yes, if you can get the proper requirements. (This does not apply to the current article, since I assume that the requirements for these syscalls, etc. are well described.)
On most business systems, especially one that us written over the course of a few months, the requirements are just as spaghetti as the code, so rewriting the system from scratch might also rewriting the requirements from scratch, which is a monumental task if it already have customers with different configurations.
On a more humorous note, I find it funny that this is today's article on The Daily WTF: Seven Minutes In Heaven