#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 EXIT_SUCCESS;
int binarySearch(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int arr[10] = {1, 12, 23, 44, 65, 76, 77, 98, 109, 110};
  int ind;
  for (ind = 0; ind < 10; ind++) {
    printf("%d\n", binarySearch(arr, arr[ind], 10));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    119e <main+0x6e>
lea    -0x40(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
mov    $0xa,%edx
call   1050 <binarySearch@plt>
mov    %eax,%esi
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1162 <main+0x32>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    0xef2(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x14(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x18(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x20(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x24(%rsp),%esi
mov    %r14,%rdi
mov    $0xa,%edx
call   1040 <binarySearch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.arr = [10 x i32] [i32 1, i32 12, i32 23, i32 44, i32 65, i32 76, i32 77, i32 98, i32 109, i32 110]
@.str = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i32]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [10 x i32]* %6 to i8*
store i32 0, i32* %7
br label %9
9: ; preds = %20, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @binarySearch(i32* %13, i32 %17, i32 10)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %9
23: ; preds = %9
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}

LLVM IR (-O2):
@__const.main.arr = [10 x i32] [i32 1, i32 12, i32 23, i32 44, i32 65, i32 76, i32 77, i32 98, i32 109, i32 110]
@.str = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [10 x i32]
%4 = bitcast [10 x i32]* %3 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%6 = call i32 @binarySearch(i32* %5, i32 1, i32 10)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
%9 = load i32, i32* %8
%10 = call i32 @binarySearch(i32* %5, i32 %9, i32 10)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
%13 = load i32, i32* %12
%14 = call i32 @binarySearch(i32* %5, i32 %13, i32 10)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
%17 = load i32, i32* %16
%18 = call i32 @binarySearch(i32* %5, i32 %17, i32 10)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
%21 = load i32, i32* %20
%22 = call i32 @binarySearch(i32* %5, i32 %21, i32 10)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
%25 = load i32, i32* %24
%26 = call i32 @binarySearch(i32* %5, i32 %25, i32 10)
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
%29 = load i32, i32* %28
%30 = call i32 @binarySearch(i32* %5, i32 %29, i32 10)
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
%33 = load i32, i32* %32
%34 = call i32 @binarySearch(i32* %5, i32 %33, i32 10)
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
%37 = load i32, i32* %36
%38 = call i32 @binarySearch(i32* %5, i32 %37, i32 10)
%39 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
%41 = load i32, i32* %40
%42 = call i32 @binarySearch(i32* %5, i32 %41, i32 10)
%43 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @EXIT_SUCCESS
ret i32 %44
}