MAINT trim away >10 kLOC of generated C code

Trimmed away some dead code and used lower-level APIs were it didn't hurt readability. This is intended to get smaller code, not extra speed, and the generated C code is <del>hundreds of</del> more than 10.000 lines shorter.
It doesn't. A `-1` return is automatically converted to an exception at the call site due to the `except -1`.