tests: C89
diff --git a/tests/test.c b/tests/test.c
index 0565808..e5fa8ee 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -174,6 +174,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		printf("****************\n");
@@ -187,13 +188,13 @@
 		if (platforms[i].opt_type)
 			cs_option(handle, platforms[i].opt_type, platforms[i].opt_value);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			print_string_hex(platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
-
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t\t%s\n",
 						insn[j].address, insn[j].mnemonic, insn[j].op_str);
diff --git a/tests/test_arm.c b/tests/test_arm.c
index 7b3a86c..29f8107 100644
--- a/tests/test_arm.c
+++ b/tests/test_arm.c
@@ -33,6 +33,7 @@
 static void print_insn_detail(cs_insn *ins)
 {
 	cs_arm *arm;
+	int i;
 
 	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
 	if (ins->detail == NULL)
@@ -43,7 +44,6 @@
 	if (arm->op_count)
 		printf("\top_count: %u\n", arm->op_count);
 
-	int i;
 	for (i = 0; i < arm->op_count; i++) {
 		cs_arm_op *op = &(arm->operands[i]);
 		switch((int)op->type) {
@@ -199,6 +199,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -212,14 +213,14 @@
 		if (platforms[i].syntax)
 			cs_option(handle, CS_OPT_SYNTAX, platforms[i].syntax);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(&insn[j]);
diff --git a/tests/test_arm64.c b/tests/test_arm64.c
index 4418e12..13a9516 100644
--- a/tests/test_arm64.c
+++ b/tests/test_arm64.c
@@ -154,6 +154,7 @@
 	uint64_t address = 0x2c;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -164,14 +165,15 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(&insn[j]);
diff --git a/tests/test_detail.c b/tests/test_detail.c
index abe0192..d0e655a 100644
--- a/tests/test_detail.c
+++ b/tests/test_detail.c
@@ -171,6 +171,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *all_insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		printf("****************\n");
@@ -186,13 +187,14 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &all_insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &all_insn);
 		if (count) {
+			size_t j;
+			int n;
+
 			print_string_hex(platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
-			int n;
 			for (j = 0; j < count; j++) {
 				cs_insn *i = &(all_insn[j]);
 				printf("0x%"PRIx64":\t%s\t\t%s // insn-ID: %u, insn-mnem: %s\n",
diff --git a/tests/test_mips.c b/tests/test_mips.c
index fcbefa1..a58e405 100644
--- a/tests/test_mips.c
+++ b/tests/test_mips.c
@@ -31,6 +31,7 @@
 
 static void print_insn_detail(cs_insn *ins)
 {
+	int i;
 	cs_mips *mips;
 
 	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
@@ -41,7 +42,6 @@
 	if (mips->op_count)
 		printf("\top_count: %u\n", mips->op_count);
 
-	int i;
 	for (i = 0; i < mips->op_count; i++) {
 		cs_mips_op *op = &(mips->operands[i]);
 		switch((int)op->type) {
@@ -101,6 +101,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -111,14 +112,15 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(&insn[j]);
diff --git a/tests/test_ppc.c b/tests/test_ppc.c
index 7620a11..f7beebb 100644
--- a/tests/test_ppc.c
+++ b/tests/test_ppc.c
@@ -31,6 +31,7 @@
 static void print_insn_detail(cs_insn *ins)
 {
 	cs_ppc *ppc;
+	int i;
 
 	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
 	if (ins->detail == NULL)
@@ -40,7 +41,6 @@
 	if (ppc->op_count)
 		printf("\top_count: %u\n", ppc->op_count);
 
-	int i;
 	for (i = 0; i < ppc->op_count; i++) {
 		cs_ppc_op *op = &(ppc->operands[i]);
 		switch((int)op->type) {
@@ -93,6 +93,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -103,14 +104,15 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(&insn[j]);
diff --git a/tests/test_skipdata.c b/tests/test_skipdata.c
index 7730af1..7ffd5da 100644
--- a/tests/test_skipdata.c
+++ b/tests/test_skipdata.c
@@ -54,6 +54,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		printf("****************\n");
@@ -70,13 +71,13 @@
 		// turn on SKIPDATA option
 		cs_option(handle, CS_OPT_SKIPDATA, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			print_string_hex(platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
-
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t\t%s\n",
 						insn[j].address, insn[j].mnemonic, insn[j].op_str);
diff --git a/tests/test_sparc.c b/tests/test_sparc.c
index 8b6ca06..1de86d8 100644
--- a/tests/test_sparc.c
+++ b/tests/test_sparc.c
@@ -31,6 +31,7 @@
 static void print_insn_detail(cs_insn *ins)
 {
 	cs_sparc *sparc;
+	int i;
 
 	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
 	if (ins->detail == NULL)
@@ -40,7 +41,6 @@
 	if (sparc->op_count)
 		printf("\top_count: %u\n", sparc->op_count);
 
-	int i;
 	for (i = 0; i < sparc->op_count; i++) {
 		cs_sparc_op *op = &(sparc->operands[i]);
 		switch((int)op->type) {
@@ -102,6 +102,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -112,14 +113,15 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(&insn[j]);
diff --git a/tests/test_systemz.c b/tests/test_systemz.c
index 9ef7966..be4d24a 100644
--- a/tests/test_systemz.c
+++ b/tests/test_systemz.c
@@ -31,6 +31,7 @@
 static void print_insn_detail(cs_insn *ins)
 {
 	cs_sysz *sysz;
+	int i;
 
 	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
 	if (ins->detail == NULL)
@@ -40,7 +41,6 @@
 	if (sysz->op_count)
 		printf("\top_count: %u\n", sysz->op_count);
 
-	int i;
 	for (i = 0; i < sysz->op_count; i++) {
 		cs_sysz_op *op = &(sysz->operands[i]);
 		switch((int)op->type) {
@@ -95,6 +95,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -105,14 +106,15 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(&insn[j]);
diff --git a/tests/test_x86.c b/tests/test_x86.c
index 00a633b..c9624b2 100644
--- a/tests/test_x86.c
+++ b/tests/test_x86.c
@@ -33,7 +33,7 @@
 
 static void print_insn_detail(csh ud, cs_mode mode, cs_insn *ins)
 {
-	int i;
+	int count, i;
 	cs_x86 *x86;
 
 	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
@@ -62,7 +62,7 @@
 					cs_reg_name(handle, x86->sib_base));
 	}
 
-	int count = cs_op_count(ud, ins, X86_OP_IMM);
+	count = cs_op_count(ud, ins, X86_OP_IMM);
 	if (count) {
 		printf("\timm_count: %u\n", count);
 		for (i = 1; i < count + 1; i++) {
@@ -169,6 +169,7 @@
 	uint64_t address = 0x1000;
 	cs_insn *insn;
 	int i;
+	size_t count;
 
 	for (i = 0; i < sizeof(platforms)/sizeof(platforms[0]); i++) {
 		cs_err err = cs_open(platforms[i].arch, platforms[i].mode, &handle);
@@ -182,14 +183,15 @@
 
 		cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
 
-		size_t count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
+		count = cs_disasm_ex(handle, platforms[i].code, platforms[i].size, address, 0, &insn);
 		if (count) {
+			size_t j;
+
 			printf("****************\n");
 			printf("Platform: %s\n", platforms[i].comment);
 			print_string_hex("Code:", platforms[i].code, platforms[i].size);
 			printf("Disasm:\n");
 
-			size_t j;
 			for (j = 0; j < count; j++) {
 				printf("0x%"PRIx64":\t%s\t%s\n", insn[j].address, insn[j].mnemonic, insn[j].op_str);
 				print_insn_detail(handle, platforms[i].mode, &insn[j]);