use c99 scopes

This commit moves variable declarations to where the variables
are used.
make indent