I have a C translation here that should be pretty readable https://github.com/tgies/copy-fail-c