C89 patch for MS Visual Studio 2008 Express Edition

- Declare all variables before statements in a function.
- Likewise, place all function prototypes before statements.

These changes support Microsoft Visual Studio 2008 Express Edition, which follows C89-style rules.