#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 busquedaBin1(double *, int, int);
int busquedaBin2(double *, int, int);
main() {
  double a[125000];
  int n = 125000;
  int i;
  for (i = 0; i < n; i++)
    a[i] = i + 1;
  ;
  i = busquedaBin1(a, n, 0);
  for (i = 0; i < n; i++)
    i = busquedaBin1(a, n, i + 1);
  i = busquedaBin1(a, n, n + 1);
  ;
  ;
  i = busquedaBin2(a, n, 0);
  for (i = 0; i < n; i++)
    i = busquedaBin2(a, n, i + 1);
  i = busquedaBin2(a, n, n + 1);
  ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4260,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1e848,-0xf4254(%rbp)
movl   $0x0,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
cmp    -0xf4254(%rbp),%eax
jge    1189 <main+0x69>
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movslq -0xf4258(%rbp),%rax
movsd  %xmm0,-0xf4250(%rbp,%rax,8)
f0 ff
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    1146 <main+0x26>
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%esi
xor    %edx,%edx
call   1040 <busquedaBin1@plt>
mov    %eax,-0xf4258(%rbp)
movl   $0x0,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
cmp    -0xf4254(%rbp),%eax
jge    11f4 <main+0xd4>
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%esi
mov    -0xf4258(%rbp),%edx
add    $0x1,%edx
call   1040 <busquedaBin1@plt>
mov    %eax,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    11ad <main+0x8d>
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%esi
mov    -0xf4254(%rbp),%edx
add    $0x1,%edx
call   1040 <busquedaBin1@plt>
mov    %eax,-0xf4258(%rbp)
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%esi
xor    %edx,%edx
call   1030 <busquedaBin2@plt>
mov    %eax,-0xf4258(%rbp)
movl   $0x0,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
cmp    -0xf4254(%rbp),%eax
jge    1280 <main+0x160>
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%esi
mov    -0xf4258(%rbp),%edx
add    $0x1,%edx
call   1030 <busquedaBin2@plt>
mov    %eax,-0xf4258(%rbp)
mov    -0xf4258(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
jmp    1239 <main+0x119>
lea    -0xf4250(%rbp),%rdi
mov    -0xf4254(%rbp),%esi
mov    -0xf4254(%rbp),%edx
add    $0x1,%edx
call   1030 <busquedaBin2@plt>
mov    %eax,-0xf4258(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf4260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xf4248,%rsp
movdqa 0xecf(%rip),%xmm0
mov    $0x6,%eax
pcmpeqd %xmm1,%xmm1
movdqa 0xece(%rip),%xmm2
movdqa 0xed6(%rip),%xmm3
movdqa 0xede(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
pshufd $0xe8,%xmm0,%xmm5
movdqa %xmm5,%xmm6
psubd  %xmm1,%xmm6
paddd  %xmm2,%xmm5
cvtdq2pd %xmm6,%xmm6
cvtdq2pd %xmm5,%xmm5
movaps %xmm6,-0x30(%rsp,%rax,8)
movaps %xmm5,-0x20(%rsp,%rax,8)
movdqa %xmm0,%xmm5
paddq  %xmm3,%xmm5
pshufd $0xe8,%xmm5,%xmm5
movdqa %xmm5,%xmm6
psubd  %xmm1,%xmm6
cvtdq2pd %xmm6,%xmm6
paddd  %xmm2,%xmm5
cvtdq2pd %xmm5,%xmm5
movaps %xmm6,-0x10(%rsp,%rax,8)
movaps %xmm5,(%rsp,%rax,8)
paddq  %xmm4,%xmm0
add    $0x8,%rax
cmp    $0x1e84e,%rax
jne    1160 <main+0x40>
mov    %rsp,%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    $0x1e848,%esi
xor    %edx,%edx
call   1040 <busquedaBin1@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x1e848,%esi
mov    %ebp,%edx
call   1040 <busquedaBin1@plt>
lea    0x1(%rax),%ebp
cmp    $0x1e847,%eax
jl     11e0 <main+0xc0>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1e848,%esi
mov    $0x1e849,%edx
call   1040 <busquedaBin1@plt>
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    $0x1e848,%esi
xor    %edx,%edx
call   1030 <busquedaBin2@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x1e848,%esi
mov    %ebp,%edx
call   1030 <busquedaBin2@plt>
lea    0x1(%rax),%ebp
cmp    $0x1e847,%eax
jl     1230 <main+0x110>
mov    %rsp,%rdi
mov    $0x1e848,%esi
mov    $0x1e849,%edx
call   1030 <busquedaBin2@plt>
xor    %eax,%eax
add    $0xf4248,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [125000 x double]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 125000, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = load i32, i32* %4
%11 = add nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 %14
store double %12, double* %15
br label %16
16: ; preds = %9
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %5
19: ; preds = %5
%20 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 0
%21 = load i32, i32* %3
%22 = call i32 @busquedaBin1(double* %20, i32 %21, i32 0)
store i32 %22, i32* %4
store i32 0, i32* %4
br label %23
23: ; preds = %33, %19
%24 = load i32, i32* %4
%25 = load i32, i32* %3
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 0
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
%32 = call i32 @busquedaBin1(double* %28, i32 %29, i32 %31)
store i32 %32, i32* %4
br label %33
33: ; preds = %27
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %23
36: ; preds = %23
%37 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 0
%38 = load i32, i32* %3
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
%41 = call i32 @busquedaBin1(double* %37, i32 %38, i32 %40)
store i32 %41, i32* %4
%42 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 0
%43 = load i32, i32* %3
%44 = call i32 @busquedaBin2(double* %42, i32 %43, i32 0)
store i32 %44, i32* %4
store i32 0, i32* %4
br label %45
45: ; preds = %55, %36
%46 = load i32, i32* %4
%47 = load i32, i32* %3
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %58
49: ; preds = %45
%50 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 0
%51 = load i32, i32* %3
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
%54 = call i32 @busquedaBin2(double* %50, i32 %51, i32 %53)
store i32 %54, i32* %4
br label %55
55: ; preds = %49
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %45
58: ; preds = %45
%59 = getelementptr inbounds [125000 x double], [125000 x double]* %2, i64 0, i64 0
%60 = load i32, i32* %3
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
%63 = call i32 @busquedaBin2(double* %59, i32 %60, i32 %62)
store i32 %63, i32* %4
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [125000 x double]
%2 = bitcast [125000 x double]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %28, %3 ]
%5 = phi <2 x i64> [ <i64 0, i64 1>, %0 ], [ %29, %3 ]
%6 = trunc <2 x i64> %5 to <2 x i32>
%7 = add <2 x i32> %6, <i32 1, i32 1>
%8 = trunc <2 x i64> %5 to <2 x i32>
%9 = add <2 x i32> %8, <i32 3, i32 3>
%10 = sitofp <2 x i32> %7 to <2 x double>
%11 = sitofp <2 x i32> %9 to <2 x double>
%12 = getelementptr inbounds [125000 x double], [125000 x double]* %1, i64 0, i64 %4
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> %10, <2 x double>* %13
%14 = getelementptr inbounds double, double* %12, i64 2
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> %11, <2 x double>* %15
%16 = or i64 %4, 4
%17 = add <2 x i64> %5, <i64 4, i64 4>
%18 = trunc <2 x i64> %17 to <2 x i32>
%19 = add <2 x i32> %18, <i32 1, i32 1>
%20 = trunc <2 x i64> %17 to <2 x i32>
%21 = add <2 x i32> %20, <i32 3, i32 3>
%22 = sitofp <2 x i32> %19 to <2 x double>
%23 = sitofp <2 x i32> %21 to <2 x double>
%24 = getelementptr inbounds [125000 x double], [125000 x double]* %1, i64 0, i64 %16
%25 = bitcast double* %24 to <2 x double>*
store <2 x double> %22, <2 x double>* %25
%26 = getelementptr inbounds double, double* %24, i64 2
%27 = bitcast double* %26 to <2 x double>*
store <2 x double> %23, <2 x double>* %27
%28 = add nuw nsw i64 %4, 8
%29 = add <2 x i64> %5, <i64 8, i64 8>
%30 = icmp eq i64 %28, 125000
br i1 %30, label %31, label %3
31: ; preds = %3
%32 = getelementptr inbounds [125000 x double], [125000 x double]* %1, i64 0, i64 0
%33 = call i32 @busquedaBin1(double* %32, i32 125000, i32 0)
br label %34
34: ; preds = %31, %34
%35 = phi i32 [ 0, %31 ], [ %38, %34 ]
%36 = add nsw i32 %35, 1
%37 = call i32 @busquedaBin1(double* %32, i32 125000, i32 %36)
%38 = add nsw i32 %37, 1
%39 = icmp slt i32 %37, 124999
br i1 %39, label %34, label %40
40: ; preds = %34
%41 = call i32 @busquedaBin1(double* %32, i32 125000, i32 125001)
%42 = call i32 @busquedaBin2(double* %32, i32 125000, i32 0)
br label %43
43: ; preds = %40, %43
%44 = phi i32 [ 0, %40 ], [ %47, %43 ]
%45 = add nsw i32 %44, 1
%46 = call i32 @busquedaBin2(double* %32, i32 125000, i32 %45)
%47 = add nsw i32 %46, 1
%48 = icmp slt i32 %46, 124999
br i1 %48, label %43, label %49
49: ; preds = %43
%50 = call i32 @busquedaBin2(double* %32, i32 125000, i32 125001)
ret i32 0
}