Haha yea that is some straight up Mathematica -> C codegen (damn you //cform). A couple of years ago I inherited a project with a 90 meg .c file that was auto generated by Mathematica... the thing caused GCC to allocate ~4 gigs of ram. Simplifying the math by hand we got it down to a few hundred lines of code, and reduced the build time by three orders of magnitude.
We got a couple of big ass whiteboards and carefully went through the math. Lots of big expressions simplified to zero that Mathematica couldn't see, and we were able to factor out a lot of shared expressions.