Reapplying r283383 after revert in r283442. The additional fix is a getting rid of a stray space in a function name, in the refactoring part of the commit.
This avoids falling back to calling out to the GCC rem functions (moddi3, umoddi3) when targeting Windows.
The rt_div functions have flipped the two arguments compared to the aeabi_divmod functions. To match MSVC, we emit a check for division by zero before actually calling the library function (even if the library function itself also might do the same check).
Not all calls to rt_div functions for division are currently merged with calls to the same function with the same parameters for the remainder. This is more wasteful than a div + mls as before, but avoids calls to moddi3.
This is reapplying D24076 with one additional typo fix.