refactor function printing into a function
group together initial allocas
fewer casts on math calls