#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(int argc, char **argv) {
  static int v[600000000];
  int x = 600000000;
  int r, i;
  for (i = 0; i < 600000000; i++)
    v[i] = i;
  r = binsearch(x, v, 600000000);
  printf("Element at position: %d\n", r);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x23c34600,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x23c34600,-0x1c(%rbp)
jge    1170 <main+0x50>
mov    -0x1c(%rbp),%edx
movslq -0x1c(%rbp),%rcx
lea    0x2ee1(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1144 <main+0x24>
mov    -0x14(%rbp),%edi
lea    0x2ec6(%rip),%rsi
mov    $0x23c34600,%edx
call   1030 <binsearch@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movdqa 0xed7(%rip),%xmm0
mov    $0x1c,%eax
movdqa 0xed9(%rip),%xmm8
lea    0x2f02(%rip),%rcx
movdqa 0xed9(%rip),%xmm9
movdqa 0xee0(%rip),%xmm10
movdqa 0xee8(%rip),%xmm4
movdqa 0xef0(%rip),%xmm5
movdqa 0xef8(%rip),%xmm6
movdqa 0xf00(%rip),%xmm7
movdqa 0xf08(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqa %xmm0,-0x70(%rcx,%rax,4)
movdqa %xmm2,-0x60(%rcx,%rax,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqa %xmm2,-0x50(%rcx,%rax,4)
movdqa %xmm3,-0x40(%rcx,%rax,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqa %xmm2,-0x30(%rcx,%rax,4)
movdqa %xmm3,-0x20(%rcx,%rax,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqa %xmm2,-0x10(%rcx,%rax,4)
movdqa %xmm3,(%rcx,%rax,4)
paddd  %xmm1,%xmm0
add    $0x20,%rax
cmp    $0x23c3461c,%rax
jne    1180 <main+0x60>
lea    0x2e3f(%rip),%rsi
mov    $0x23c34600,%edi
mov    $0x23c34600,%edx
call   1030 <binsearch@plt>
lea    0xe79(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@main.v = internal global [600000000 x i32] zeroinitializer
@.str = [25 x i8] c"Element at position: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %32, %3 ]
%5 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %2 ], [ %33, %3 ]
%6 = add <4 x i32> %5, <i32 4, i32 4, i32 4, i32 4>
%7 = getelementptr inbounds [600000000 x i32], [600000000 x i32]* @main.v, i64 0, i64 %4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %7, i64 4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %6, <4 x i32>* %10
%11 = or i64 %4, 8
%12 = add <4 x i32> %5, <i32 8, i32 8, i32 8, i32 8>
%13 = add <4 x i32> %5, <i32 12, i32 12, i32 12, i32 12>
%14 = getelementptr inbounds [600000000 x i32], [600000000 x i32]* @main.v, i64 0, i64 %11
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %14, i64 4
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %17
%18 = or i64 %4, 16
%19 = add <4 x i32> %5, <i32 16, i32 16, i32 16, i32 16>
%20 = add <4 x i32> %5, <i32 20, i32 20, i32 20, i32 20>
%21 = getelementptr inbounds [600000000 x i32], [600000000 x i32]* @main.v, i64 0, i64 %18
%22 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %19, <4 x i32>* %22
%23 = getelementptr inbounds i32, i32* %21, i64 4
%24 = bitcast i32* %23 to <4 x i32>*
store <4 x i32> %20, <4 x i32>* %24
%25 = or i64 %4, 24
%26 = add <4 x i32> %5, <i32 24, i32 24, i32 24, i32 24>
%27 = add <4 x i32> %5, <i32 28, i32 28, i32 28, i32 28>
%28 = getelementptr inbounds [600000000 x i32], [600000000 x i32]* @main.v, i64 0, i64 %25
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> %26, <4 x i32>* %29
%30 = getelementptr inbounds i32, i32* %28, i64 4
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %31
%32 = add nuw nsw i64 %4, 32
%33 = add <4 x i32> %5, <i32 32, i32 32, i32 32, i32 32>
%34 = icmp eq i64 %32, 600000000
br i1 %34, label %35, label %3
35: ; preds = %3
%36 = tail call i32 @binsearch(i32 600000000, i32* getelementptr inbounds ([600000000 x i32], [600000000 x i32]* @main.v, i64 0, i64 0), i32 600000000)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %36)
ret i32 0
}