#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 */
long CSPL_Array_bisect(double, double *, int);
int /*<<< orphan*/ printf(char *, double, long);
int main(void) {
  double dat1[5] = {1, 2, 5, 7, 8};
  long ans, i;
  double val;
  for (i = 0; i < 5; i++)
    printf("dat1[%ld]=%lf\n", i, dat1[i]);
  val = -1;
  ans = CSPL_Array_bisect(val, dat1, 5);
  printf("CSPL_Array_bisect(%lf, dat1, 5)=%ld\n", val, ans);
  val = 1.5;
  ans = CSPL_Array_bisect(val, dat1, 5);
  printf("CSPL_Array_bisect(%lf, dat1, 5)=%ld\n", val, ans);
  val = 5.0;
  ans = CSPL_Array_bisect(val, dat1, 5);
  printf("CSPL_Array_bisect(%lf, dat1, 5)=%ld\n", val, ans);
  val = 5.5;
  ans = CSPL_Array_bisect(val, dat1, 5);
  printf("CSPL_Array_bisect(%lf, dat1, 5)=%ld\n", val, ans);
  val = 8.5;
  ans = CSPL_Array_bisect(val, dat1, 5);
  printf("CSPL_Array_bisect(%lf, dat1, 5)=%ld\n", val, ans);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x0,-0x40(%rbp)
cmpq   $0x5,-0x40(%rbp)
jge    11d1 <main+0xa1>
cvtsi2sdq -0x40(%rbp),%xmm0
mov    -0x40(%rbp),%rax
cvttsd2si -0x30(%rbp,%rax,8),%rsi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1198 <main+0x68>
movsd  0xe67(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <CSPL_Array_bisect@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rsi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
movsd  0xe26(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <CSPL_Array_bisect@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rsi
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
movsd  0xdc5(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <CSPL_Array_bisect@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rsi
lea    0xde0(%rip),%rdi
call   1030 <printf@plt>
movsd  0xdac(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <CSPL_Array_bisect@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rsi
lea    0xda7(%rip),%rdi
call   1030 <printf@plt>
movsd  0xd6b(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <CSPL_Array_bisect@plt>
mov    %rax,-0x38(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x38(%rbp),%rsi
lea    0xd6e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x4020000000000000,%rax
mov    %rax,0x20(%rsp)
lea    0xf14(%rip),%rbx
xorps  %xmm0,%xmm0
mov    $0x1,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xeb4(%rip),%xmm0
mov    $0x2,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xea7(%rip),%xmm0
mov    $0x5,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xe9a(%rip),%xmm0
mov    $0x7,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xe8d(%rip),%xmm0
mov    $0x8,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
movsd  0xe80(%rip),%xmm0
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <CSPL_Array_bisect@plt>
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
movsd  0xe5e(%rip),%xmm0
mov    %rax,%rsi
call   1030 <printf@plt>
movsd  0xe56(%rip),%xmm0
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <CSPL_Array_bisect@plt>
mov    %rbx,%rdi
movsd  0xe3e(%rip),%xmm0
mov    %rax,%rsi
call   1030 <printf@plt>
movsd  0xe36(%rip),%xmm0
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <CSPL_Array_bisect@plt>
mov    %rbx,%rdi
movsd  0xe1e(%rip),%xmm0
mov    %rax,%rsi
call   1030 <printf@plt>
movsd  0xe16(%rip),%xmm0
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <CSPL_Array_bisect@plt>
mov    %rbx,%rdi
movsd  0xdfe(%rip),%xmm0
mov    %rax,%rsi
call   1030 <printf@plt>
movsd  0xdf6(%rip),%xmm0
mov    %r14,%rdi
mov    $0x5,%esi
call   1040 <CSPL_Array_bisect@plt>
mov    %rbx,%rdi
movsd  0xdde(%rip),%xmm0
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"dat1[%ld]=%lf\0A\00"
@.str.1 = [37 x i8] c"CSPL_Array_bisect(%lf, dat1, 5)=%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x double]
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
store i32 0, i32* %1
%6 = bitcast [5 x double]* %2 to i8*
%7 = bitcast i8* %6 to [5 x double]*
%8 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 0
store double 1.000000e+00, double* %8
%9 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 1
store double 2.000000e+00, double* %9
%10 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 2
store double 5.000000e+00, double* %10
%11 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 3
store double 7.000000e+00, double* %11
%12 = getelementptr inbounds [5 x double], [5 x double]* %7, i32 0, i32 4
store double 8.000000e+00, double* %12
store i64 0, i64* %4
br label %13
13: ; preds = %24, %0
%14 = load i64, i64* %4
%15 = icmp slt i64 %14, 5
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load i64, i64* %4
%18 = sitofp i64 %17 to double
%19 = load i64, i64* %4
%20 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 %19
%21 = load double, double* %20
%22 = fptosi double %21 to i64
%23 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %18, i64 %22)
br label %24
24: ; preds = %16
%25 = load i64, i64* %4
%26 = add nsw i64 %25, 1
store i64 %26, i64* %4
br label %13
27: ; preds = %13
store double -1.000000e+00, double* %5
%28 = load double, double* %5
%29 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%30 = call i64 @CSPL_Array_bisect(double %28, double* %29, i32 5)
store i64 %30, i64* %3
%31 = load double, double* %5
%32 = load i64, i64* %3
%33 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %31, i64 %32)
store double 1.500000e+00, double* %5
%34 = load double, double* %5
%35 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%36 = call i64 @CSPL_Array_bisect(double %34, double* %35, i32 5)
store i64 %36, i64* %3
%37 = load double, double* %5
%38 = load i64, i64* %3
%39 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %37, i64 %38)
store double 5.000000e+00, double* %5
%40 = load double, double* %5
%41 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%42 = call i64 @CSPL_Array_bisect(double %40, double* %41, i32 5)
store i64 %42, i64* %3
%43 = load double, double* %5
%44 = load i64, i64* %3
%45 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %43, i64 %44)
store double 5.500000e+00, double* %5
%46 = load double, double* %5
%47 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%48 = call i64 @CSPL_Array_bisect(double %46, double* %47, i32 5)
store i64 %48, i64* %3
%49 = load double, double* %5
%50 = load i64, i64* %3
%51 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %49, i64 %50)
store double 8.500000e+00, double* %5
%52 = load double, double* %5
%53 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%54 = call i64 @CSPL_Array_bisect(double %52, double* %53, i32 5)
store i64 %54, i64* %3
%55 = load double, double* %5
%56 = load i64, i64* %3
%57 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double %55, i64 %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"dat1[%ld]=%lf\0A\00"
@.str.1 = [37 x i8] c"CSPL_Array_bisect(%lf, dat1, 5)=%ld\0A\00"
define i32 @main() {
%1 = alloca [5 x double]
%2 = bitcast [5 x double]* %1 to i8*
%3 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 0
%4 = bitcast [5 x double]* %1 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %4
%5 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 2
%6 = bitcast double* %5 to <2 x double>*
store <2 x double> <double 5.000000e+00, double 7.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 4
store double 8.000000e+00, double* %7
%8 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double 0.000000e+00, i64 1)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double 1.000000e+00, i64 2)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double 2.000000e+00, i64 5)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double 3.000000e+00, i64 7)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double 4.000000e+00, i64 8)
%13 = call i64 @CSPL_Array_bisect(double -1.000000e+00, double* %3, i32 5)
%14 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double -1.000000e+00, i64 %13)
%15 = call i64 @CSPL_Array_bisect(double 1.500000e+00, double* %3, i32 5)
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 1.500000e+00, i64 %15)
%17 = call i64 @CSPL_Array_bisect(double 5.000000e+00, double* %3, i32 5)
%18 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 5.000000e+00, i64 %17)
%19 = call i64 @CSPL_Array_bisect(double 5.500000e+00, double* %3, i32 5)
%20 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 5.500000e+00, i64 %19)
%21 = call i64 @CSPL_Array_bisect(double 8.500000e+00, double* %3, i32 5)
%22 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), double 8.500000e+00, i64 %21)
ret i32 0
}