#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 /*<<< orphan*/ atoi(char *);
int binary_search(int *, int /*<<< orphan*/, int, int /*<<< orphan*/);
int binary_search_for_floor(int *, int /*<<< orphan*/, int, int /*<<< orphan*/);
int binary_search_with_less_comp(int *, int /*<<< orphan*/, int,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int a[] = {0, 3, 4, 5, 7, 9};
  printf("BS      : %d\n", binary_search(a, 0, 6, atoi(argv[1])));
  printf("BS LC   : %d\n",
         binary_search_with_less_comp(a, 0, 6, atoi(argv[1])));
  printf("BS Floor: %d\n", binary_search_for_floor(a, 0, 6, atoi(argv[1])));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe94(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%ecx
xor    %esi,%esi
mov    $0x6,%edx
call   1060 <binary_search@plt>
mov    %eax,%esi
lea    0xe68(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%ecx
xor    %esi,%esi
mov    $0x6,%edx
call   1030 <binary_search_with_less_comp@plt>
mov    %eax,%esi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%ecx
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <binary_search_for_floor@plt>
mov    %eax,%esi
lea    0xe1a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0xeaf(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xe93(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x6,%edx
mov    %eax,%ecx
call   1060 <binary_search@plt>
lea    0xe83(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x6,%edx
mov    %eax,%ecx
call   1030 <binary_search_with_less_comp@plt>
lea    0xe69(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x6,%edx
mov    %eax,%ecx
call   1040 <binary_search_for_floor@plt>
lea    0xe4f(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.a = [6 x i32] [i32 0, i32 3, i32 4, i32 5, i32 7, i32 9]
@.str = [14 x i8] c"BS : %d\0A\00"
@.str.1 = [14 x i8] c"BS LC : %d\0A\00"
@.str.2 = [14 x i8] c"BS Floor: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [6 x i32]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = bitcast [6 x i32]* %5 to i8*
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%8 = load i8**, i8*** %4
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @atoi(i8* %10)
%12 = call i32 @binary_search(i32* %7, i32 0, i32 6, i32 %11)
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = call i32 @binary_search_with_less_comp(i32* %14, i32 0, i32 6, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [6 x i32], [6 x i32]* %5, i64 0, i64 0
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
%26 = call i32 @binary_search_for_floor(i32* %21, i32 0, i32 6, i32 %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %26)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [6 x i32] [i32 0, i32 3, i32 4, i32 5, i32 7, i32 9]
@.str = [14 x i8] c"BS : %d\0A\00"
@.str.1 = [14 x i8] c"BS LC : %d\0A\00"
@.str.2 = [14 x i8] c"BS Floor: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = call i32 @binary_search(i32* %5, i32 0, i32 6, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %6
%12 = call i32 @atoi(i8* %11)
%13 = call i32 @binary_search_with_less_comp(i32* %5, i32 0, i32 6, i32 %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i8*, i8** %6
%16 = call i32 @atoi(i8* %15)
%17 = call i32 @binary_search_for_floor(i32* %5, i32 0, i32 6, i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret i32 0
}