#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 X_imp(int, double, double);
double log(int);
void compute_dos_log(double *gl, int N, double P, double K, int live) {
  int i, j, lim;
  double Xf;
  double m;
  m = log(2. - X_imp(0, K, P));
  gl[0] = log(0.5) + m + log(1 - X_imp(0, K, P) * X_imp(1, K, P));
  if (live == 1) {
    lim = (N - K - 1);
  } else {
    lim = (N - 1);
  }
  for (i = 1; i < lim; ++i) {
    m += log(X_imp(i - 1, K, P));
    gl[i] = log(0.5) + m + log(1 - X_imp(i, K, P) * X_imp(i + 1, K, P));
  }
  if (live == 1) {
    m += log(X_imp(i, K, P));
    j = 0;
    for (i = lim; i < (N - 1); ++i) {
      gl[i] =
          log(0.5) + m +
          log(1 - (K - j) / (K - j + 1) * (K - (j + 1)) / (K - (j + 1) + 1));
      m += log((K - j) / (K - j + 1));
      ++j;
    }
    ++i;
    m -= log((K - (j - 1)) / (K - (j - 1) + 1));
    Xf = -(K - j) / (K - j + 1);
    gl[N - 1] = log(0.5) + m + log(1 - (K - j) / (K - j + 1) * Xf);
  } else {
    ++i;
    m += log(X_imp(i - 1, K, P));
    Xf = -X_imp(i, K, P);
    gl[N - 1] = log(0.5) + m + log(1 - X_imp(i, K, P) * Xf);
  }
}


x86 assembly (clang, -O0):
<compute_dos_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
xor    %edi,%edi
call   1040 <X_imp@plt>
movaps %xmm0,%xmm1
movsd  0xead(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  %xmm0,-0x40(%rbp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
xor    %edi,%edi
call   1040 <X_imp@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    $0x1,%edi
call   1040 <X_imp@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe2d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
cmpl   $0x1,-0x24(%rbp)
jne    1220 <compute_dos_log+0x100>
cvtsi2sdl -0xc(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
jmp    1229 <compute_dos_log+0x109>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1300 <compute_dos_log+0x1e0>
mov    -0x28(%rbp),%edi
sub    $0x1,%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x28(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%edi
add    $0x1,%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd34(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1230 <compute_dos_log+0x110>
cmpl   $0x1,-0x24(%rbp)
jne    157e <compute_dos_log+0x45e>
mov    -0x28(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1448 <compute_dos_log+0x328>
xor    %edi,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm0
subsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm2
subsd  %xmm2,%xmm0
movsd  0xc7e(%rip),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm2
subsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm2
subsd  %xmm2,%xmm0
movsd  0xc44(%rip),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
movsd  0xc34(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0xbea(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    133c <compute_dos_log+0x21c>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
subsd  %xmm2,%xmm1
movsd  0xb81(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0xb24(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
cvtsi2sdl -0x2c(%rbp),%xmm2
subsd  %xmm2,%xmm1
movsd  0xae2(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xab2(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1653 <compute_dos_log+0x533>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
sub    $0x1,%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x28(%rbp),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <X_imp@plt>
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0x9d8(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_dos_log>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r15d
movapd %xmm1,%xmm2
movapd %xmm1,0x10(%rsp)
movaps %xmm0,%xmm1
movsd  %xmm0,0x20(%rsp)
mov    %esi,%ebp
mov    %rdi,%r12
xor    %edi,%edi
movapd %xmm2,%xmm0
call   1040 <X_imp@plt>
movsd  0xea4(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <log@plt>
movsd  %xmm0,(%rsp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
movaps 0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <X_imp@plt>
movsd  %xmm0,0x40(%rsp)
mov    $0x1,%edi
movapd 0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <X_imp@plt>
mulsd  0x40(%rsp),%xmm0
movsd  0xe4c(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <log@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r12)
cmp    $0x1,%r15d
jne    11fb <compute_dos_log+0xdb>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movapd 0x10(%rsp),%xmm2
subsd  %xmm2,%xmm0
addsd  0xe1c(%rip),%xmm0
cvttsd2si %xmm0,%r13d
jmp    1205 <compute_dos_log+0xe5>
lea    -0x1(%rbp),%r13d
movapd 0x10(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
mov    $0x1,%edi
cmp    $0x2,%r13d
jl     12dc <compute_dos_log+0x1bc>
mov    %rbp,0x38(%rsp)
mov    %r13d,%r14d
add    $0xffffffffffffffff,%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
movapd %xmm2,%xmm0
call   1040 <X_imp@plt>
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x1(%rbp),%rbx
mov    %ebx,%edi
movaps 0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <X_imp@plt>
movsd  %xmm0,0x40(%rsp)
lea    0x2(%rbp),%edi
movapd 0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <X_imp@plt>
mulsd  0x40(%rsp),%xmm0
movsd  0xd66(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <log@plt>
movsd  0x20(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%r12,%rbp,8)
mov    %rbx,%rbp
cmp    %rbx,%r14
jne    1230 <compute_dos_log+0x110>
mov    %r13d,%edi
mov    0x38(%rsp),%rbp
cmp    $0x1,%r15d
jne    13dc <compute_dos_log+0x2bc>
movapd %xmm2,%xmm0
call   1040 <X_imp@plt>
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0xffffffff,%ebp
mov    %ebp,%r14d
sub    %r13d,%r14d
jle    1460 <compute_dos_log+0x340>
mov    %rbp,0x38(%rsp)
movslq %r13d,%rax
lea    (%r12,%rax,8),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm4
subsd  %xmm0,%xmm4
movapd %xmm4,%xmm0
movsd  0xca0(%rip),%xmm3
addsd  %xmm3,%xmm0
lea    0x1(%rbx),%rbp
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
divsd  %xmm0,%xmm4
movsd  %xmm4,0x8(%rsp)
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
mulsd  %xmm4,%xmm1
addsd  %xmm3,%xmm0
divsd  %xmm0,%xmm1
movapd %xmm3,%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
cvttsd2si 0x8(%rsp),%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
mov    %rbp,%rbx
cmp    %ebp,%r14d
jne    1330 <compute_dos_log+0x210>
mov    0x38(%rsp),%rbp
jmp    1463 <compute_dos_log+0x343>
lea    0x1(%rdi),%ebx
movapd %xmm2,%xmm0
call   1040 <X_imp@plt>
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %ebx,%edi
movapd 0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <X_imp@plt>
movsd  %xmm0,0x8(%rsp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
movapd 0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
call   1040 <X_imp@plt>
mulsd  0x8(%rsp),%xmm0
addsd  0xbbe(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
add    $0xffffffff,%ebp
jmp    150b <compute_dos_log+0x3eb>
xor    %r14d,%r14d
movsd  %xmm0,(%rsp)
lea    -0x1(%r14),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0xb7f(%rip),%xmm2
addsd  %xmm2,%xmm0
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
call   1030 <log@plt>
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movapd 0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd 0xb5e(%rip),%xmm0
xorpd  %xmm1,%xmm0
addsd  0xb3a(%rip),%xmm1
divsd  %xmm1,%xmm0
movapd %xmm0,0x20(%rsp)
xor    %edi,%edi
call   1030 <log@plt>
addsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  0xb0c(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <log@plt>
addsd  0x10(%rsp),%xmm0
movslq %ebp,%rax
movsd  %xmm0,(%r12,%rax,8)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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