#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int gcd(int, int);
int gcd_c(int, int);
int /*<<< orphan*/ printf(char *, ...);
void gcd_test(void) {
  int error_count = 0;
  uint32_t i, j;
  for (i = 1; i < 100; i++) {
    for (j = 1; j < 100; j++) {
      if (gcd(i, j) != gcd_c(i, j)) {
        printf("GCD Error: Input (%d,%d), Expected %d, Received %d\n", i, j,
               gcd_c(i, j), gcd(i, j));
        error_count++;
      }
    }
  }
  if (!error_count) {
    printf("GCD Tests Passed\n");
  } else {
    printf("GCD Test: %d errors\n", error_count);
  }
}


x86 assembly (clang, -O0):
<gcd_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11f5 <gcd_test+0xc5>
movl   $0x1,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    11e2 <gcd_test+0xb2>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gcd@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <gcd_c@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
je     11cf <gcd_test+0x9f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <gcd_c@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <gcd@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    %eax,%r8d
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <gcd_test+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1157 <gcd_test+0x27>
jmp    11e7 <gcd_test+0xb7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <gcd_test+0x16>
cmpl   $0x0,-0x4(%rbp)
jne    1212 <gcd_test+0xe2>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1223 <gcd_test+0xf3>
mov    -0x4(%rbp),%esi
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcd_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r12d
lea    0xeab(%rip),%r14
xor    %r15d,%r15d
jmp    116a <gcd_test+0x2a>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
cmp    $0x64,%r12d
je     11d2 <gcd_test+0x92>
mov    $0x1,%ebx
jmp    1188 <gcd_test+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x64,%ebx
je     1160 <gcd_test+0x20>
mov    %r12d,%edi
mov    %ebx,%esi
call   1060 <gcd@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %ebx,%esi
call   1030 <gcd_c@plt>
cmp    %eax,%ebp
je     1180 <gcd_test+0x40>
mov    %r12d,%edi
mov    %ebx,%esi
call   1030 <gcd_c@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %ebx,%esi
call   1060 <gcd@plt>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
jmp    1180 <gcd_test+0x40>
test   %r15d,%r15d
je     11f0 <gcd_test+0xb0>
lea    0xe56(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>
lea    0xe52(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"GCD Error: Input (%d,%d), Expected %d, Received %d\0A\00"
@.str.1 = [18 x i8] c"GCD Tests Passed\0A\00"
@.str.2 = [21 x i8] c"GCD Test: %d errors\0A\00"
define void @gcd_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %36, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 100
br i1 %6, label %7, label %39
7: ; preds = %4
store i32 1, i32* %3
br label %8
8: ; preds = %32, %7
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @gcd(i32 %12, i32 %13)
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 @gcd_c(i32 %15, i32 %16)
%18 = icmp ne i32 %14, %17
br i1 %18, label %19, label %31
19: ; preds = %11
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @gcd_c(i32 %22, i32 %23)
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @gcd(i32 %25, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21, i32 %24, i32 %27)
%29 = load i32, i32* %1
%30 = add nsw i32 %29, 1
store i32 %30, i32* %1
br label %31
31: ; preds = %19, %11
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %8
35: ; preds = %8
br label %36
36: ; preds = %35
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
store i32 %38, i32* %2
br label %4
39: ; preds = %4
%40 = load i32, i32* %1
%41 = icmp ne i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %47
44: ; preds = %39
%45 = load i32, i32* %1
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %44, %42
ret void
}

LLVM IR (-O2):
@.str = [52 x i8] c"GCD Error: Input (%d,%d), Expected %d, Received %d\0A\00"
@.str.2 = [21 x i8] c"GCD Test: %d errors\0A\00"
@str = [17 x i8] c"GCD Tests Passed\00"
define void @gcd_test() {
br label %1
1: ; preds = %0, %19
%2 = phi i32 [ 1, %0 ], [ %20, %19 ]
%3 = phi i32 [ 0, %0 ], [ %16, %19 ]
br label %4
4: ; preds = %1, %15
%5 = phi i32 [ 1, %1 ], [ %17, %15 ]
%6 = phi i32 [ %3, %1 ], [ %16, %15 ]
%7 = tail call i32 @gcd(i32 %2, i32 %5)
%8 = tail call i32 @gcd_c(i32 %2, i32 %5)
%9 = icmp eq i32 %7, %8
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = tail call i32 @gcd_c(i32 %2, i32 %5)
%12 = tail call i32 @gcd(i32 %2, i32 %5)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %5, i32 %11, i32 %12)
%14 = add nsw i32 %6, 1
br label %15
15: ; preds = %4, %10
%16 = phi i32 [ %14, %10 ], [ %6, %4 ]
%17 = add nuw nsw i32 %5, 1
%18 = icmp eq i32 %17, 100
br i1 %18, label %19, label %4
19: ; preds = %15
%20 = add nuw nsw i32 %2, 1
%21 = icmp eq i32 %20, 100
br i1 %21, label %22, label %1
22: ; preds = %19
%23 = icmp eq i32 %16, 0
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %28
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %28
28: ; preds = %26, %24
ret void
}