If I assume correctly that you're writing code in C, just turn on filetype-specific indenting, or turn on 'cindent'. If you want to tweak the automatic indenting, update the 'cinoptions' setting.
See the following for a basic introduction for Vim's indentation features:
http://vim.wikia.com/wiki/Indenting_source_code
For a tool outside of Vim, you might like "uncrustify":
http://uncrustify.sourceforge.net/
It has hundreds of options to match a wide variety of styles,
and it does a good job of parsing and reformatting source code.
Michael Henry
If you do find an external tool you like, you can invoke it from within Vim to replace the built-in format and/or indent commands.
See :help 'formatprg' and :help 'equalprg'. I'd suggest 'formatprg' for heavy-duty formatting like adding whitespace within lines or moving text between lines, and 'equalprg' for more lightweight indentation stuff.