#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 binsearch(int, int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int v[10], x, i;
  x = 40;
  for (i = 0; i < 10; i++)
    v[i] = i;
  printf("%d\n", binsearch(x, v, 10));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x28,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    1160 <main+0x40>
mov    -0x38(%rbp),%ecx
movslq -0x38(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    113d <main+0x1d>
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <binsearch@plt>
mov    %eax,%esi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x900000008,%rax
mov    %rax,0x20(%rsp)
mov    %rsp,%rsi
mov    $0x28,%edi
mov    $0xa,%edx
call   1030 <binsearch@plt>
lea    0xebd(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 40, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %13, %0
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i32, i32* %4
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %11
store i32 %9, i32* %12
br label %13
13: ; preds = %8
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %5
16: ; preds = %5
%17 = load i32, i32* %3
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%19 = call i32 @binsearch(i32 %17, i32* %18, i32 10)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %4
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %6
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 8, i32* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 9, i32* %8
%9 = call i32 @binsearch(i32 40, i32* %3, i32 10)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}