#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 */
float CLOCKS_PER_SEC;
int binsearch(int, int *, int);
int clock();
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int somearray[100000], i, t;
  for (i = 1; i <= 99999; i++)
    somearray[i - 1] = i;
  t = clock();
  printf("%d\n", binsearch(1, somearray, 99999));
  t = clock() - t;
  printf("It took me %d clicks (%f seconds).\n", t,
         ((float)t) / CLOCKS_PER_SEC);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61aa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x61a94(%rbp)
cmpl   $0x1869f,-0x61a94(%rbp)
jg     1188 <main+0x58>
mov    -0x61a94(%rbp),%ecx
mov    -0x61a94(%rbp),%eax
sub    $0x1,%eax
cltq
mov    %ecx,-0x61a90(%rbp,%rax,4)
mov    -0x61a94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61a94(%rbp)
jmp    114c <main+0x1c>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x61a98(%rbp)
lea    -0x61a90(%rbp),%rsi
mov    $0x1,%edi
mov    $0x1869f,%edx
call   1030 <binsearch@plt>
mov    %eax,%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <clock@plt>
sub    -0x61a98(%rbp),%eax
mov    %eax,-0x61a98(%rbp)
mov    -0x61a98(%rbp),%esi
cvtsi2ssl -0x61a98(%rbp),%xmm0
ff
mov    0x2e05(%rip),%rax
divss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe12(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x61aa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x61a80,%rsp
movdqa 0xec0(%rip),%xmm3
mov    $0x1c,%eax
movdqa 0xec2(%rip),%xmm8
movdqa 0xec9(%rip),%xmm9
movdqa 0xed0(%rip),%xmm10
movdqa 0xed8(%rip),%xmm4
movdqa 0xee0(%rip),%xmm5
movdqa 0xee8(%rip),%xmm6
movdqa 0xef0(%rip),%xmm7
movdqa 0xef8(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movdqa %xmm3,%xmm0
paddd  %xmm8,%xmm0
movdqa %xmm3,-0x70(%rsp,%rax,4)
movdqa %xmm0,-0x60(%rsp,%rax,4)
movdqa %xmm3,%xmm0
paddd  %xmm9,%xmm0
movdqa %xmm3,%xmm2
paddd  %xmm10,%xmm2
movdqa %xmm0,-0x50(%rsp,%rax,4)
movdqa %xmm2,-0x40(%rsp,%rax,4)
movdqa %xmm3,%xmm0
paddd  %xmm4,%xmm0
movdqa %xmm3,%xmm2
paddd  %xmm5,%xmm2
movdqa %xmm0,-0x30(%rsp,%rax,4)
movdqa %xmm2,-0x20(%rsp,%rax,4)
cmp    $0x1869c,%rax
je     120c <main+0xdc>
movdqa %xmm3,%xmm0
paddd  %xmm6,%xmm0
movdqa %xmm3,%xmm2
paddd  %xmm7,%xmm2
movdqa %xmm0,-0x10(%rsp,%rax,4)
movdqa %xmm2,(%rsp,%rax,4)
paddd  %xmm1,%xmm3
add    $0x20,%rax
jmp    1190 <main+0x60>
movaps 0xe7d(%rip),%xmm0
movaps %xmm0,0x61a60(%rsp)
movabs $0x1869e0001869d,%rax
mov    %rax,0x61a70(%rsp)
movl   $0x1869f,0x61a78(%rsp)
xor    %eax,%eax
call   1040 <clock@plt>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    $0x1,%edi
mov    $0x1869f,%edx
call   1030 <binsearch@plt>
lea    0xe46(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mov    0x2d6e(%rip),%rcx
divss  (%rcx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1b(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x61a80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [36 x i8] c"It took me %d clicks (%f seconds).\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca [100000 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 99999
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32, i32* %3
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 %12
store i32 %9, i32* %13
br label %14
14: ; preds = %8
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %5
17: ; preds = %5
%18 = call i32 (...) @clock()
store i32 %18, i32* %4
%19 = getelementptr inbounds [100000 x i32], [100000 x i32]* %2, i64 0, i64 0
%20 = call i32 @binsearch(i32 1, i32* %19, i32 99999)
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 (...) @clock()
%23 = load i32, i32* %4
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = load i32, i32* %4
%27 = sitofp i32 %26 to float
%28 = load float, float* @CLOCKS_PER_SEC
%29 = fdiv float %27, %28
%30 = fpext float %29 to double
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %25, double %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [36 x i8] c"It took me %d clicks (%f seconds).\0A\00"
@CLOCKS_PER_SEC = global float 0.000000e+00
define i32 @main() {
%1 = alloca [100000 x i32]
%2 = bitcast [100000 x i32]* %1 to i8*
br label %3
3: ; preds = %27, %0
%4 = phi i64 [ 0, %0 ], [ %34, %27 ]
%5 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %0 ], [ %35, %27 ]
%6 = add <4 x i32> %5, <i32 4, i32 4, i32 4, i32 4>
%7 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, 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 [100000 x i32], [100000 x i32]* %1, 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 [100000 x i32], [100000 x i32]* %1, 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 = icmp eq i64 %25, 99992
br i1 %26, label %36, label %27
27: ; preds = %3
%28 = add <4 x i32> %5, <i32 24, i32 24, i32 24, i32 24>
%29 = add <4 x i32> %5, <i32 28, i32 28, i32 28, i32 28>
%30 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 %25
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %31
%32 = getelementptr inbounds i32, i32* %30, i64 4
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %29, <4 x i32>* %33
%34 = add nuw nsw i64 %4, 32
%35 = add <4 x i32> %5, <i32 32, i32 32, i32 32, i32 32>
br label %3
36: ; preds = %3
%37 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99992
store i32 99993, i32* %37
%38 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99993
store i32 99994, i32* %38
%39 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99994
store i32 99995, i32* %39
%40 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99995
store i32 99996, i32* %40
%41 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99996
store i32 99997, i32* %41
%42 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99997
store i32 99998, i32* %42
%43 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 99998
store i32 99999, i32* %43
%44 = tail call i32 (...) @clock()
%45 = getelementptr inbounds [100000 x i32], [100000 x i32]* %1, i64 0, i64 0
%46 = call i32 @binsearch(i32 1, i32* %45, i32 99999)
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %46)
%48 = call i32 (...) @clock()
%49 = sub nsw i32 %48, %44
%50 = sitofp i32 %49 to float
%51 = load float, float* @CLOCKS_PER_SEC
%52 = fdiv float %50, %51
%53 = fpext float %52 to double
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %49, double %53)
ret i32 0
}