Be C89 friendly, declare variables on the top of the functions

Fix broken build of commit 7488655ec55aec5de0ee89bf5f3853c62f20ce5e