#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 /*<<< orphan*/ a;

/* Variables and functions */
int atoi(char *);
int binSearch(int *, int, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int a[] = {1, 4, 5, 66, 88, 100, 130, 500};
  int size = sizeof(a) / sizeof(a[0]);
  int item = atoi(argv[1]);
  int flag = binSearch(a, size, item);
  if (flag == -1)
    printf("\n%d , not found\n", item);
  else
    printf("\n%d , found\n", item);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xeb3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xead(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x8,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1040 <binSearch@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    11b9 <main+0x89>
mov    -0x38(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
jmp    11c8 <main+0x98>
mov    -0x38(%rbp),%esi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
mov    $0x8,%esi
mov    %eax,%edx
call   1040 <binSearch@plt>
cmp    $0xffffffff,%eax
lea    0xeb0(%rip),%rax
lea    0xeba(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [8 x i32] [i32 1, i32 4, i32 5, i32 66, i32 88, i32 100, i32 130, i32 500]
@.str = [17 x i8] c"\0A%d , not found\0A\00"
@.str.1 = [13 x i8] c"\0A%d , found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [8 x i32]* %6 to i8*
store i32 8, i32* %7
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %8
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = call i32 @binSearch(i32* %15, i32 %16, i32 %17)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %2
%22 = load i32, i32* %8
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %27
24: ; preds = %2
%25 = load i32, i32* %8
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %21
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [8 x i32] [i32 1, i32 4, i32 5, i32 66, i32 88, i32 100, i32 130, i32 500]
@.str = [17 x i8] c"\0A%d , not found\0A\00"
@.str.1 = [13 x i8] c"\0A%d , found\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i32]
%4 = bitcast [8 x i32]* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%9 = call i32 @binSearch(i32* %8, i32 8, i32 %7)
%10 = icmp eq i32 %9, -1
%11 = select i1 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0)
%12 = call i32 @printf(i8* %11, i32 %7)
ret i32 0
}