#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 */

/* Variables and functions */
int Test_BinarySearch();
int Test_Rescale();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int ret[(2)];
  ret[0] = Test_BinarySearch();
  if (ret[0] != (0)) {
    printf("Test_BinarySearch Failed! Error Code %d\n", ret[0]);
  } else {
    printf("Test_BinarySearch Passed!\n");
  }
  ret[1] = Test_Rescale();
  if (ret[1] != (0)) {
    printf("Test_Rescale Failed! Error Code %d\n", ret[1]);
  } else {
    printf("Test_Rescale Passed!\n");
  }
  int i;
  printf("\n\n====TEST SUMMARY====\n");
  for (i = 0; i < (2); i++) {
    if (ret[i] != (0)) {
      printf("Test[%d] Failed!\n", i);
    } else {
      printf("Test[%d] Passed!\n", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <Test_BinarySearch@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1169 <main+0x39>
mov    -0xc(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1177 <main+0x47>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <Test_Rescale@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11a1 <main+0x71>
mov    -0x8(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11af <main+0x7f>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    1217 <main+0xe7>
movslq -0x10(%rbp),%rax
cmpl   $0x0,-0xc(%rbp,%rax,4)
je     11f3 <main+0xc3>
mov    -0x10(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1204 <main+0xd4>
mov    -0x10(%rbp),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1209 <main+0xd9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c4 <main+0x94>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <Test_BinarySearch@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1163 <main+0x23>
lea    0xea8(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    116f <main+0x2f>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <Test_Rescale@plt>
test   %eax,%eax
je     1193 <main+0x53>
lea    0xea8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%r14
jmp    11a6 <main+0x66>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%r14
lea    0xef3(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
lea    0xea4(%rip),%rax
lea    0xe8b(%rip),%rdi
cmove  %rax,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [41 x i8] c"Test_BinarySearch Failed! Error Code %d\0A\00"
@.str.2 = [36 x i8] c"Test_Rescale Failed! Error Code %d\0A\00"
@.str.5 = [18 x i8] c"Test[%d] Failed!\0A\00"
@.str.6 = [18 x i8] c"Test[%d] Passed!\0A\00"
@str = [26 x i8] c"Test_BinarySearch Passed!\00"
@str.7 = [21 x i8] c"Test_Rescale Passed!\00"
@str.8 = [23 x i8] c"\0A\0A====TEST SUMMARY====\00"
define i32 @main() {
%1 = tail call i32 (...) @Test_BinarySearch()
%2 = icmp eq i32 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %7
7: ; preds = %5, %3
%8 = tail call i32 (...) @Test_Rescale()
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %14
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.7, i64 0, i64 0))
br label %14
14: ; preds = %12, %10
%15 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), %12 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), %10 ]
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.8, i64 0, i64 0))
%17 = select i1 %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %17, i32 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i32 1)
ret i32 0
}