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

/* Variables and functions */
int binsearch(int, int *, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int v[] = {2, 6, 9, 12, 15, 21, 25, 30, 55, 60, 61, 62, 63, 64, 65};
  printf("30: %d\n", binsearch(30, v, sizeof(v) / sizeof(v[0])));
  printf("100: %d\n", binsearch(100, v, sizeof(v) / sizeof(v[0])));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x3c,%edx
call   1050 <memcpy@plt>
lea    -0x40(%rbp),%rsi
mov    $0x1e,%edi
mov    $0xf,%edx
call   1030 <binsearch@plt>
mov    %eax,%esi
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
mov    $0x64,%edi
mov    $0xf,%edx
call   1030 <binsearch@plt>
mov    %eax,%esi
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movups 0xf00(%rip),%xmm0
movups %xmm0,0x2c(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb0(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    $0x1e,%edi
mov    %rbx,%rsi
mov    $0xf,%edx
call   1030 <binsearch@plt>
lea    0xecc(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    $0x64,%edi
mov    %rbx,%rsi
mov    $0xf,%edx
call   1030 <binsearch@plt>
lea    0xeb4(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.v = [15 x i32] [i32 2, i32 6, i32 9, i32 12, i32 15, i32 21, i32 25, i32 30, i32 55, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65]
@.str = [8 x i8] c"30: %d\0A\00"
@.str.1 = [9 x i8] c"100: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i32]
store i32 0, i32* %1
%3 = bitcast [15 x i32]* %2 to i8*
%4 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%5 = call i32 @binsearch(i32 30, i32* %4, i32 15)
%6 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [15 x i32], [15 x i32]* %2, i64 0, i64 0
%8 = call i32 @binsearch(i32 100, i32* %7, i32 15)
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %8)
ret i32 0
}

LLVM IR (-O2):
@__const.main.v = [15 x i32] [i32 2, i32 6, i32 9, i32 12, i32 15, i32 21, i32 25, i32 30, i32 55, i32 60, i32 61, i32 62, i32 63, i32 64, i32 65]
@.str = [8 x i8] c"30: %d\0A\00"
@.str.1 = [9 x i8] c"100: %d\0A\00"
define i32 @main() {
%1 = alloca [15 x i32]
%2 = bitcast [15 x i32]* %1 to i8*
%3 = getelementptr inbounds [15 x i32], [15 x i32]* %1, i64 0, i64 0
%4 = call i32 @binsearch(i32 30, i32* %3, i32 15)
%5 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @binsearch(i32 100, i32* %3, i32 15)
%7 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %6)
ret i32 0
}