Add gamma function to CCodePrinter

This is a little rework of #2369.

Will merge in 24hr.