#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 binarySearch(int *, int, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int a[] = {0, 1, 4, 9, 11, 17, 90};
  printf("The index of 5 is %d.\n", binarySearch(a, 7, 5));
  printf("The index of 4 is %d.\n", binarySearch(a, 7, 4));
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xeb9(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
mov    $0x5,%edx
call   1050 <binarySearch@plt>
mov    %eax,%esi
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x7,%esi
mov    $0x4,%edx
call   1050 <binarySearch@plt>
mov    %eax,%esi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movups 0xed0(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x5,%edx
call   1050 <binarySearch@plt>
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x4,%edx
call   1050 <binarySearch@plt>
lea    0xeab(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [7 x i32] [i32 0, i32 1, i32 4, i32 9, i32 11, i32 17, i32 90]
@.str = [23 x i8] c"The index of 5 is %d.\0A\00"
@.str.1 = [23 x i8] c"The index of 4 is %d.\0A\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @binarySearch(i32* %3, i32 7, i32 5)
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%7 = call i32 @binarySearch(i32* %6, i32 7, i32 4)
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [7 x i32] [i32 0, i32 1, i32 4, i32 9, i32 11, i32 17, i32 90]
@.str = [23 x i8] c"The index of 5 is %d.\0A\00"
@.str.1 = [23 x i8] c"The index of 4 is %d.\0A\00"
define i32 @main() {
%1 = alloca [7 x i32]
%2 = bitcast [7 x i32]* %1 to i8*
%3 = getelementptr inbounds [7 x i32], [7 x i32]* %1, i64 0, i64 0
%4 = call i32 @binarySearch(i32* %3, i32 7, i32 5)
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @binarySearch(i32* %3, i32 7, i32 4)
%7 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 (...) @getchar()
ret i32 0
}