#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 */
double INFINITY;
int exp(double);
int fabs(double);
int /*<<< orphan*/ free(double *);
double const log(double const);
double *malloc(int const);
int sqrt(double);
double ln_evaluate_lscv(const double *data, const double *weight, const int n,
                        const double bandwidth, const double threshold) {
  if (bandwidth <= 0) {
    return INFINITY;
  }
  double lscv1 = 0, lscv2 = 0;
  double total_weight = 0;
  double *log_data = malloc(n * sizeof(double));
  double *scaled_data = malloc(n * sizeof(double));
  for (int i = 0; i < n; i++) {
    log_data[i] = log(data[i]) / bandwidth;
    scaled_data[i] = data[i] * bandwidth;
    total_weight += weight[i];
  }
  for (int i = 0; i < n; i++) {
    lscv1 += weight[i] * weight[i] / scaled_data[i];
    for (int j = i + 1; j < n; j++) {
      double residual = log_data[i] - log_data[j];
      if (fabs(residual) < 2 * threshold || threshold <= 0) {
        double exponential = exp(-0.25 * residual * residual);
        lscv1 += 2 * weight[i] * weight[j] * exponential /
                 sqrt(scaled_data[i] * scaled_data[j]);
        lscv2 += exponential * exponential * weight[i] * weight[j] *
                 (1 / ((total_weight - weight[i]) * scaled_data[i]) +
                  1 / ((total_weight - weight[j]) * scaled_data[j]));
      }
    }
  }
  lscv1 *= exp(0.25 * bandwidth * bandwidth) /
           (2 * 1.772453851 * total_weight * total_weight);
  lscv2 *= -2 / (total_weight * 2.506628275);
  free(log_data);
  free(scaled_data);
  return lscv1 + lscv2;
}


x86 assembly (clang, -O0):
<ln_evaluate_lscv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11a3 <ln_evaluate_lscv+0x43>
mov    0x2e53(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    14be <ln_evaluate_lscv+0x35e>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125c <ln_evaluate_lscv+0xfc>
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <log@plt>
divsd  -0x28(%rbp),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11e8 <ln_evaluate_lscv+0x88>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    143f <ln_evaluate_lscv+0x2df>
mov    -0x18(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x60(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x60(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    142c <ln_evaluate_lscv+0x2cc>
mov    -0x50(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x64(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd36(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     1307 <ln_evaluate_lscv+0x1a7>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1419 <ln_evaluate_lscv+0x2b9>
movsd  0xd21(%rip),%xmm0
mulsd  -0x70(%rbp),%xmm0
mulsd  -0x70(%rbp),%xmm0
call   1060 <exp@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsd  0xce9(%rip),%xmm0
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x58(%rbp),%rax
movslq -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
call   1080 <sqrt@plt>
movsd  -0x80(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x78(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x60(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x60(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
mov    -0x58(%rbp),%rax
movslq -0x60(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
movsd  0xc54(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  -0x48(%rbp),%xmm3
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm3
mov    -0x58(%rbp),%rax
movslq -0x64(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm3
movsd  0xc29(%rip),%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm1,%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    141e <ln_evaluate_lscv+0x2be>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12a9 <ln_evaluate_lscv+0x149>
jmp    1431 <ln_evaluate_lscv+0x2d1>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1263 <ln_evaluate_lscv+0x103>
movsd  0xbd1(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1060 <exp@plt>
cvtsi2sd %eax,%xmm0
movsd  0xbae(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
divsd  %xmm1,%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xb86(%rip),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  0xb71(%rip),%xmm0
divsd  %xmm1,%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x38(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln_evaluate_lscv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
movsd  %xmm1,0x58(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    1471 <ln_evaluate_lscv+0x311>
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%r13
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x30(%rsp)
lea    0x0(,%rbx,8),%r14d
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
test   %ebx,%ebx
jle    148e <ln_evaluate_lscv+0x32e>
mov    %rbx,0x10(%rsp)
mov    %ebx,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movapd %xmm0,0x30(%rsp)
movsd  0x0(%r13,%rbx,8),%xmm0
call   1070 <log@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
movsd  0x0(%r13,%rbx,8),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,8)
movapd 0x30(%rsp),%xmm0
addsd  0x0(%rbp,%rbx,8),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11e0 <ln_evaluate_lscv+0x80>
cmpl   $0x0,0x10(%rsp)
jle    1488 <ln_evaluate_lscv+0x328>
movsd  0x58(%rsp),%xmm1
addsd  %xmm1,%xmm1
movsd  %xmm1,0x78(%rsp)
movapd %xmm0,0x30(%rsp)
unpcklpd %xmm0,%xmm0
movapd %xmm0,0xa0(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
xor    %eax,%eax
mov    %r12,%r13
mov    %r15,0x40(%rsp)
mov    %r15,%rbx
mov    %rbp,0x50(%rsp)
mov    %r14,0x48(%rsp)
mov    %r14,0x68(%rsp)
mov    %r12,0x60(%rsp)
mov    0x50(%rsp),%r15
jmp    12ba <ln_evaluate_lscv+0x15a>
nopl   0x0(%rax,%rax,1)
addq   $0x8,0x48(%rsp)
add    $0x8,%rbp
add    $0x8,%rbx
add    $0xffffffffffffffff,%r13
mov    0x60(%rsp),%r12
mov    0x70(%rsp),%rax
cmp    %r12,%rax
mov    0x68(%rsp),%r14
je     1481 <ln_evaluate_lscv+0x321>
mov    %r12,%rcx
mov    %rax,%r12
mov    0x50(%rsp),%rax
movsd  (%rax,%r12,8),%xmm0
mulsd  %xmm0,%xmm0
movsd  (%r14,%r12,8),%xmm1
movapd %xmm1,0x90(%rsp)
divsd  %xmm1,%xmm0
movapd 0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
lea    0x1(%r12),%rax
mov    %rax,0x70(%rsp)
cmp    %rcx,%rax
jae    1290 <ln_evaluate_lscv+0x130>
mov    0x40(%rsp),%rax
movsd  (%rax,%r12,8),%xmm0
movsd  %xmm0,0x88(%rsp)
mov    $0x1,%r14d
jmp    142f <ln_evaluate_lscv+0x2cf>
movsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  0xcce(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <exp@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  %xmm1,0x80(%rsp)
movsd  (%r15,%r12,8),%xmm0
addsd  %xmm0,%xmm0
mulsd  0x0(%rbp,%r14,8),%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm0,0xb0(%rsp)
mov    0x48(%rsp),%rax
movsd  (%rax,%r14,8),%xmm1
movapd %xmm1,0x10(%rsp)
movapd 0x90(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0xb0(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd 0x20(%rsp),%xmm2
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm4
movsd  0x80(%rsp),%xmm3
mulsd  %xmm3,%xmm3
movsd  (%r15,%r12,8),%xmm0
mulsd  %xmm0,%xmm3
movsd  0x0(%rbp,%r14,8),%xmm1
mulsd  %xmm1,%xmm3
unpcklpd %xmm1,%xmm0
movapd 0xa0(%rsp),%xmm1
subpd  %xmm0,%xmm1
movapd 0x90(%rsp),%xmm0
unpcklpd 0x10(%rsp),%xmm0
mulpd  %xmm1,%xmm0
movapd 0xc24(%rip),%xmm1
divpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
unpckhpd %xmm2,%xmm2
addsd  %xmm0,%xmm2
unpcklpd %xmm2,%xmm4
movapd %xmm4,0x20(%rsp)
add    $0x1,%r14
cmp    %r14,%r13
je     1290 <ln_evaluate_lscv+0x130>
movsd  0x88(%rsp),%xmm0
subsd  (%rbx,%r14,8),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <fabs@plt>
xorpd  %xmm0,%xmm0
ucomisd 0x58(%rsp),%xmm0
jae    1320 <ln_evaluate_lscv+0x1c0>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x78(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    1422 <ln_evaluate_lscv+0x2c2>
jmp    1320 <ln_evaluate_lscv+0x1c0>
mov    0x2b70(%rip),%rax
movsd  (%rax),%xmm0
jmp    150e <ln_evaluate_lscv+0x3ae>
mov    0x40(%rsp),%r15
jmp    148e <ln_evaluate_lscv+0x32e>
movapd %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  0xb6c(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1060 <exp@plt>
movsd  0xb5f(%rip),%xmm0
movapd 0x30(%rsp),%xmm1
mulsd  %xmm1,%xmm0
unpcklpd %xmm1,%xmm1
shufpd $0x2,0xb68(%rip),%xmm0
mulpd  %xmm1,%xmm0
movapd 0xb6c(%rip),%xmm1
cvtsi2sd %eax,%xmm1
divpd  %xmm0,%xmm1
mulpd  0x20(%rsp),%xmm1
movapd %xmm1,0x10(%rsp)
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INFINITY = global double 0.000000e+00
define double @ln_evaluate_lscv(double* %0, double* %1, i32 %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca double
store double* %0, double** %7
store double* %1, double** %8
store i32 %2, i32* %9
store double %3, double* %10
store double %4, double* %11
%22 = load double, double* %10
%23 = fcmp ole double %22, 0.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %5
%25 = load double, double* @INFINITY
store double %25, double* %6
br label %244
26: ; preds = %5
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %14
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 8
%30 = trunc i64 %29 to i32
%31 = call double* @malloc(i32 %30)
store double* %31, double** %15
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 8
%35 = trunc i64 %34 to i32
%36 = call double* @malloc(i32 %35)
store double* %36, double** %16
store i32 0, i32* %17
br label %37
37: ; preds = %72, %26
%38 = load i32, i32* %17
%39 = load i32, i32* %9
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %75
41: ; preds = %37
%42 = load double*, double** %7
%43 = load i32, i32* %17
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %42, i64 %44
%46 = load double, double* %45
%47 = call double @log(double %46)
%48 = load double, double* %10
%49 = fdiv double %47, %48
%50 = load double*, double** %15
%51 = load i32, i32* %17
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %50, i64 %52
store double %49, double* %53
%54 = load double*, double** %7
%55 = load i32, i32* %17
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double, double* %54, i64 %56
%58 = load double, double* %57
%59 = load double, double* %10
%60 = fmul double %58, %59
%61 = load double*, double** %16
%62 = load i32, i32* %17
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %61, i64 %63
store double %60, double* %64
%65 = load double*, double** %8
%66 = load i32, i32* %17
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
%70 = load double, double* %14
%71 = fadd double %70, %69
store double %71, double* %14
br label %72
72: ; preds = %41
%73 = load i32, i32* %17
%74 = add nsw i32 %73, 1
store i32 %74, i32* %17
br label %37
75: ; preds = %37
store i32 0, i32* %18
br label %76
76: ; preds = %215, %75
%77 = load i32, i32* %18
%78 = load i32, i32* %9
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %218
80: ; preds = %76
%81 = load double*, double** %8
%82 = load i32, i32* %18
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds double, double* %81, i64 %83
%85 = load double, double* %84
%86 = load double*, double** %8
%87 = load i32, i32* %18
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds double, double* %86, i64 %88
%90 = load double, double* %89
%91 = fmul double %85, %90
%92 = load double*, double** %16
%93 = load i32, i32* %18
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
%96 = load double, double* %95
%97 = fdiv double %91, %96
%98 = load double, double* %12
%99 = fadd double %98, %97
store double %99, double* %12
%100 = load i32, i32* %18
%101 = add nsw i32 %100, 1
store i32 %101, i32* %19
br label %102
102: ; preds = %211, %80
%103 = load i32, i32* %19
%104 = load i32, i32* %9
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %214
106: ; preds = %102
%107 = load double*, double** %15
%108 = load i32, i32* %18
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %107, i64 %109
%111 = load double, double* %110
%112 = load double*, double** %15
%113 = load i32, i32* %19
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %112, i64 %114
%116 = load double, double* %115
%117 = fsub double %111, %116
store double %117, double* %20
%118 = load double, double* %20
%119 = call i32 @fabs(double %118)
%120 = sitofp i32 %119 to double
%121 = load double, double* %11
%122 = fmul double 2.000000e+00, %121
%123 = fcmp olt double %120, %122
br i1 %123, label %127, label %124
124: ; preds = %106
%125 = load double, double* %11
%126 = fcmp ole double %125, 0.000000e+00
br i1 %126, label %127, label %210
127: ; preds = %124, %106
%128 = load double, double* %20
%129 = fmul double -2.500000e-01, %128
%130 = load double, double* %20
%131 = fmul double %129, %130
%132 = call i32 @exp(double %131)
%133 = sitofp i32 %132 to double
store double %133, double* %21
%134 = load double*, double** %8
%135 = load i32, i32* %18
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds double, double* %134, i64 %136
%138 = load double, double* %137
%139 = fmul double 2.000000e+00, %138
%140 = load double*, double** %8
%141 = load i32, i32* %19
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds double, double* %140, i64 %142
%144 = load double, double* %143
%145 = fmul double %139, %144
%146 = load double, double* %21
%147 = fmul double %145, %146
%148 = load double*, double** %16
%149 = load i32, i32* %18
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %148, i64 %150
%152 = load double, double* %151
%153 = load double*, double** %16
%154 = load i32, i32* %19
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds double, double* %153, i64 %155
%157 = load double, double* %156
%158 = fmul double %152, %157
%159 = call i32 @sqrt(double %158)
%160 = sitofp i32 %159 to double
%161 = fdiv double %147, %160
%162 = load double, double* %12
%163 = fadd double %162, %161
store double %163, double* %12
%164 = load double, double* %21
%165 = load double, double* %21
%166 = fmul double %164, %165
%167 = load double*, double** %8
%168 = load i32, i32* %18
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %167, i64 %169
%171 = load double, double* %170
%172 = fmul double %166, %171
%173 = load double*, double** %8
%174 = load i32, i32* %19
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds double, double* %173, i64 %175
%177 = load double, double* %176
%178 = fmul double %172, %177
%179 = load double, double* %14
%180 = load double*, double** %8
%181 = load i32, i32* %18
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds double, double* %180, i64 %182
%184 = load double, double* %183
%185 = fsub double %179, %184
%186 = load double*, double** %16
%187 = load i32, i32* %18
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds double, double* %186, i64 %188
%190 = load double, double* %189
%191 = fmul double %185, %190
%192 = fdiv double 1.000000e+00, %191
%193 = load double, double* %14
%194 = load double*, double** %8
%195 = load i32, i32* %19
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds double, double* %194, i64 %196
%198 = load double, double* %197
%199 = fsub double %193, %198
%200 = load double*, double** %16
%201 = load i32, i32* %19
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds double, double* %200, i64 %202
%204 = load double, double* %203
%205 = fmul double %199, %204
%206 = fdiv double 1.000000e+00, %205
%207 = fadd double %192, %206
%208 = load double, double* %13
%209 = call double @llvm.fmuladd.f64(double %178, double %207, double %208)
store double %209, double* %13
br label %210
210: ; preds = %127, %124
br label %211
211: ; preds = %210
%212 = load i32, i32* %19
%213 = add nsw i32 %212, 1
store i32 %213, i32* %19
br label %102
214: ; preds = %102
br label %215
215: ; preds = %214
%216 = load i32, i32* %18
%217 = add nsw i32 %216, 1
store i32 %217, i32* %18
br label %76
218: ; preds = %76
%219 = load double, double* %10
%220 = fmul double 2.500000e-01, %219
%221 = load double, double* %10
%222 = fmul double %220, %221
%223 = call i32 @exp(double %222)
%224 = sitofp i32 %223 to double
%225 = load double, double* %14
%226 = fmul double 0x400C5BF891BB6D99, %225
%227 = load double, double* %14
%228 = fmul double %226, %227
%229 = fdiv double %224, %228
%230 = load double, double* %12
%231 = fmul double %230, %229
store double %231, double* %12
%232 = load double, double* %14
%233 = fmul double %232, 0x40040D932002D4C7
%234 = fdiv double -2.000000e+00, %233
%235 = load double, double* %13
%236 = fmul double %235, %234
store double %236, double* %13
%237 = load double*, double** %15
%238 = call i32 @free(double* %237)
%239 = load double*, double** %16
%240 = call i32 @free(double* %239)
%241 = load double, double* %12
%242 = load double, double* %13
%243 = fadd double %241, %242
store double %243, double* %6
br label %244
244: ; preds = %218, %24
%245 = load double, double* %6
ret double %245
}

LLVM IR (-O2):
@INFINITY = global double 0.000000e+00
define double @ln_evaluate_lscv(double* nocapture %0, double* nocapture %1, i32 %2, double %3, double %4) {
%6 = fcmp ugt double %3, 0.000000e+00
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = load double, double* @INFINITY
br label %134
9: ; preds = %5
%10 = shl i32 %2, 3
%11 = tail call double* @malloc(i32 %10)
%12 = tail call double* @malloc(i32 %10)
%13 = icmp sgt i32 %2, 0
br i1 %13, label %14, label %44
14: ; preds = %9
%15 = zext i32 %2 to i64
br label %24
16: ; preds = %24
br i1 %13, label %17, label %44
17: ; preds = %16
%18 = fmul double %4, 2.000000e+00
%19 = fcmp ole double %4, 0.000000e+00
%20 = zext i32 %2 to i64
%21 = zext i32 %2 to i64
%22 = insertelement <2 x double> poison, double %37, i64 0
%23 = shufflevector <2 x double> %22, <2 x double> poison, <2 x i32> zeroinitializer
br label %64
24: ; preds = %14, %24
%25 = phi i64 [ 0, %14 ], [ %38, %24 ]
%26 = phi double [ 0.000000e+00, %14 ], [ %37, %24 ]
%27 = getelementptr inbounds double, double* %0, i64 %25
%28 = load double, double* %27
%29 = tail call double @log(double %28)
%30 = fdiv double %29, %3
%31 = getelementptr inbounds double, double* %11, i64 %25
store double %30, double* %31
%32 = load double, double* %27
%33 = fmul double %32, %3
%34 = getelementptr inbounds double, double* %12, i64 %25
store double %33, double* %34
%35 = getelementptr inbounds double, double* %1, i64 %25
%36 = load double, double* %35
%37 = fadd double %26, %36
%38 = add nuw nsw i64 %25, 1
%39 = icmp eq i64 %38, %15
br i1 %39, label %16, label %24
40: ; preds = %130, %64
%41 = phi <2 x double> [ %78, %64 ], [ %131, %130 ]
%42 = add nuw nsw i64 %66, 1
%43 = icmp eq i64 %76, %21
br i1 %43, label %44, label %64
44: ; preds = %40, %9, %16
%45 = phi double [ %37, %16 ], [ 0.000000e+00, %9 ], [ %37, %40 ]
%46 = phi <2 x double> [ zeroinitializer, %16 ], [ zeroinitializer, %9 ], [ %41, %40 ]
%47 = fmul double %3, 2.500000e-01
%48 = fmul double %47, %3
%49 = tail call i32 @exp(double %48)
%50 = sitofp i32 %49 to double
%51 = fmul double %45, 0x400C5BF891BB6D99
%52 = insertelement <2 x double> poison, double %45, i64 0
%53 = shufflevector <2 x double> %52, <2 x double> poison, <2 x i32> zeroinitializer
%54 = insertelement <2 x double> <double poison, double 0x40040D932002D4C7>, double %51, i64 0
%55 = fmul <2 x double> %53, %54
%56 = insertelement <2 x double> <double poison, double 2.000000e+00>, double %50, i64 0
%57 = fdiv <2 x double> %56, %55
%58 = fmul <2 x double> %46, %57
%59 = tail call i32 @free(double* %11)
%60 = tail call i32 @free(double* %12)
%61 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%62 = fsub <2 x double> %58, %61
%63 = extractelement <2 x double> %62, i64 0
br label %134
64: ; preds = %17, %40
%65 = phi i64 [ 0, %17 ], [ %76, %40 ]
%66 = phi i64 [ 1, %17 ], [ %42, %40 ]
%67 = phi <2 x double> [ zeroinitializer, %17 ], [ %41, %40 ]
%68 = getelementptr inbounds double, double* %1, i64 %65
%69 = load double, double* %68
%70 = fmul double %69, %69
%71 = getelementptr inbounds double, double* %12, i64 %65
%72 = load double, double* %71
%73 = fdiv double %70, %72
%74 = extractelement <2 x double> %67, i64 0
%75 = fadd double %74, %73
%76 = add nuw nsw i64 %65, 1
%77 = icmp ult i64 %76, %20
%78 = insertelement <2 x double> %67, double %75, i64 0
br i1 %77, label %79, label %40
79: ; preds = %64
%80 = getelementptr inbounds double, double* %11, i64 %65
%81 = load double, double* %80
%82 = insertelement <2 x double> poison, double %72, i64 0
br label %83
83: ; preds = %79, %130
%84 = phi i64 [ %66, %79 ], [ %132, %130 ]
%85 = phi <2 x double> [ %78, %79 ], [ %131, %130 ]
%86 = getelementptr inbounds double, double* %11, i64 %84
%87 = load double, double* %86
%88 = fsub double %81, %87
%89 = tail call i32 @fabs(double %88)
%90 = sitofp i32 %89 to double
%91 = fcmp ogt double %18, %90
%92 = or i1 %19, %91
br i1 %92, label %93, label %130
93: ; preds = %83
%94 = fmul double %88, -2.500000e-01
%95 = fmul double %88, %94
%96 = tail call i32 @exp(double %95)
%97 = sitofp i32 %96 to double
%98 = load double, double* %68
%99 = fmul double %98, 2.000000e+00
%100 = getelementptr inbounds double, double* %1, i64 %84
%101 = load double, double* %100
%102 = fmul double %99, %101
%103 = fmul double %102, %97
%104 = getelementptr inbounds double, double* %12, i64 %84
%105 = load double, double* %104
%106 = fmul double %72, %105
%107 = tail call i32 @sqrt(double %106)
%108 = sitofp i32 %107 to double
%109 = fdiv double %103, %108
%110 = extractelement <2 x double> %85, i64 0
%111 = fadd double %110, %109
%112 = fmul double %97, %97
%113 = load double, double* %68
%114 = fmul double %112, %113
%115 = load double, double* %100
%116 = fmul double %114, %115
%117 = insertelement <2 x double> poison, double %113, i64 0
%118 = insertelement <2 x double> %117, double %115, i64 1
%119 = fsub <2 x double> %23, %118
%120 = insertelement <2 x double> %82, double %105, i64 1
%121 = fmul <2 x double> %120, %119
%122 = fdiv <2 x double> <double 1.000000e+00, double 1.000000e+00>, %121
%123 = shufflevector <2 x double> %122, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%124 = fadd <2 x double> %122, %123
%125 = extractelement <2 x double> %124, i64 0
%126 = extractelement <2 x double> %85, i64 1
%127 = tail call double @llvm.fmuladd.f64(double %116, double %125, double %126)
%128 = insertelement <2 x double> poison, double %111, i64 0
%129 = insertelement <2 x double> %128, double %127, i64 1
br label %130
130: ; preds = %83, %93
%131 = phi <2 x double> [ %129, %93 ], [ %85, %83 ]
%132 = add nuw nsw i64 %84, 1
%133 = icmp eq i64 %132, %21
br i1 %133, label %40, label %83
134: ; preds = %44, %7
%135 = phi double [ %8, %7 ], [ %63, %44 ]
ret double %135
}