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

/* Variables and functions */
int binary_search(int, int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int sequence[] = {0, 2, 3, 5, 6, 7, 9};
  printf("Binary Search: %d\n",
         binary_search(1, sequence, sizeof(sequence) / sizeof(sequence[0])));
  printf("Binary Search: %d\n",
         binary_search(3, sequence, sizeof(sequence) / sizeof(sequence[0])));
  printf("Binary Search: %d\n",
         binary_search(6, sequence, sizeof(sequence) / sizeof(sequence[0])));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x1,%edi
mov    $0x7,%edx
call   1040 <binary_search@plt>
mov    %eax,%esi
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    $0x3,%edi
mov    $0x7,%edx
call   1040 <binary_search@plt>
mov    %eax,%esi
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    $0x6,%edi
mov    $0x7,%edx
call   1040 <binary_search@plt>
mov    %eax,%esi
lea    0xe5e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movups 0xede(%rip),%xmm0
movups %xmm0,0xc(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <binary_search@plt>
lea    0xec2(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x3,%edi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <binary_search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    $0x6,%edi
mov    %r14,%rsi
mov    $0x7,%edx
call   1040 <binary_search@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.sequence = [7 x i32] [i32 0, i32 2, i32 3, i32 5, i32 6, i32 7, i32 9]
@.str = [19 x i8] c"Binary Search: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [7 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast [7 x i32]* %6 to i8*
%8 = getelementptr inbounds [7 x i32], [7 x i32]* %6, i64 0, i64 0
%9 = call i32 @binary_search(i32 1, i32* %8, i32 7)
%10 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [7 x i32], [7 x i32]* %6, i64 0, i64 0
%12 = call i32 @binary_search(i32 3, i32* %11, i32 7)
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [7 x i32], [7 x i32]* %6, i64 0, i64 0
%15 = call i32 @binary_search(i32 6, i32* %14, i32 7)
%16 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.sequence = [7 x i32] [i32 0, i32 2, i32 3, i32 5, i32 6, i32 7, i32 9]
@.str = [19 x i8] c"Binary Search: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [7 x i32]
%4 = bitcast [7 x i32]* %3 to i8*
%5 = getelementptr inbounds [7 x i32], [7 x i32]* %3, i64 0, i64 0
%6 = call i32 @binary_search(i32 1, i32* %5, i32 7)
%7 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @binary_search(i32 3, i32* %5, i32 7)
%9 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = call i32 @binary_search(i32 6, i32* %5, i32 7)
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}