Implement a similar zero division safe guard into the generated C code

As we can actually catch the exceptions we throw from C++ functions that we
call from C code we don't actually use the mark_failed trick. Another reason
for this is that we can't do a goto from an inline if statement, while we
can call a callback function from which we can throw ;)