#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 /*<<< orphan*/ free(double *);
scalar_t__ log(double);
scalar_t__ malloc(int);
void nllkexch(int np, double *th, double *fnv) {
  extern double **x;
  extern int *y, nn, nc, dmax, ncl;
  extern int *dvec, *dstart;
  double *pa, *pb;
  double pr, nlk, eps, b0, *b, tem, rr;
  int i, j, k, jc, d, start;
  double pnorms(double);
  double exchmvn(int, double[], double[], double, double);
  b = (double *)malloc((nc + 1) * sizeof(double));
  pa = (double *)malloc((dmax + 1) * sizeof(double));
  pb = (double *)malloc((dmax + 1) * sizeof(double));
  nlk = 0.;
  eps = 1.e-6;
  b0 = th[1];
  for (jc = 1; jc <= nc; jc++)
    b[jc] = th[jc + 1];
  rr = th[np];
  if (rr < 0. || rr >= 1.) {
    *fnv = 1.e10;
    return;
  }
  for (i = 1; i <= ncl; i++) {
    d = dvec[i];
    start = dstart[i];
    for (j = 1; j <= d; j++) {
      for (jc = 1, tem = b0; jc <= nc; jc++) {
        tem += b[jc] * x[start + j - 1][jc];
      }
      k = y[start + j - 1];
      if (y[start + j - 1] == 1) {
        pa[j] = -6.;
        pb[j] = tem;
      } else {
        pa[j] = tem;
        pb[j] = 6.;
      }
    }
    if (d >= 2)
      pr = exchmvn(d, pa, pb, rr, eps);
    else
      pr = pnorms(pb[1]) - pnorms(pa[1]);
    if (pr <= 0.)
      pr = 1.e-15;
    nlk -= log(pr);
  }
  *fnv = nlk;
  free(b);
  free(pa);
  free(pb);
  return;
}


x86 assembly (clang, -O0):
<nllkexch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe33(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x1,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    0x2dcf(%rip),%rcx
cmp    (%rcx),%eax
jg     1226 <nllkexch+0xd6>
mov    -0x10(%rbp),%rax
mov    -0x70(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x50(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    11e7 <nllkexch+0x97>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x60(%rbp),%xmm0
ja     125d <nllkexch+0x10d>
movsd  -0x60(%rbp),%xmm0
movsd  0xdb5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1272 <nllkexch+0x122>
mov    -0x18(%rbp),%rax
movsd  0xdbf(%rip),%xmm0
movsd  %xmm0,(%rax)
jmp    14a9 <nllkexch+0x359>
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    0x2d65(%rip),%rcx
cmp    (%rcx),%eax
jg     1481 <nllkexch+0x331>
mov    0x2d3e(%rip),%rax
mov    (%rax),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x74(%rbp)
mov    0x2d22(%rip),%rax
mov    (%rax),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x78(%rbp)
movl   $0x1,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x74(%rbp),%eax
jg     13db <nllkexch+0x28b>
movl   $0x1,-0x70(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x70(%rbp),%eax
mov    0x2cdf(%rip),%rcx
cmp    (%rcx),%eax
jg     1339 <nllkexch+0x1e9>
mov    -0x50(%rbp),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2cb3(%rip),%rax
mov    (%rax),%rax
mov    -0x78(%rbp),%ecx
add    -0x68(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x70(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    12d7 <nllkexch+0x187>
mov    0x2c98(%rip),%rax
mov    (%rax),%rax
mov    -0x78(%rbp),%ecx
add    -0x68(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2c7c(%rip),%rax
mov    (%rax),%rax
mov    -0x78(%rbp),%ecx
add    -0x68(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    13a1 <nllkexch+0x251>
mov    -0x20(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  0xc9b(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    13c8 <nllkexch+0x278>
movsd  -0x58(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  0xc55(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    13cd <nllkexch+0x27d>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12ba <nllkexch+0x16a>
cmpl   $0x2,-0x74(%rbp)
jl     1409 <nllkexch+0x2b9>
mov    -0x74(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
movsd  -0x60(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
call   1050 <exchmvn@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    143b <nllkexch+0x2eb>
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <pnorms@plt>
movsd  %xmm0,-0x80(%rbp)
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <pnorms@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     1456 <nllkexch+0x306>
movsd  0xbbf(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1070 <log@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1279 <nllkexch+0x129>
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nllkexch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,0x18(%rsp)
mov    %rsi,%r13
mov    %edi,%r14d
mov    0x2e50(%rip),%r15
mov    (%r15),%eax
lea    0x8(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    0x2e57(%rip),%rbp
mov    0x0(%rbp),%eax
lea    0x8(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    0x0(%rbp),%eax
lea    0x8(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,0x8(%rsp)
movsd  0x8(%r13),%xmm4
mov    (%r15),%edx
test   %edx,%edx
jle    130f <nllkexch+0x1bf>
lea    0x1(%rdx),%rax
mov    $0x1,%ecx
cmp    $0x4,%rdx
jb     1291 <nllkexch+0x141>
lea    0x8(%rbx),%rsi
lea    0x8(,%rax,8),%rdi
add    %r13,%rdi
cmp    %rdi,%rsi
jae    11fa <nllkexch+0xaa>
lea    (%rbx,%rax,8),%rsi
lea    0x10(%r13),%rdi
cmp    %rsi,%rdi
jb     1291 <nllkexch+0x141>
mov    %edx,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rsi
mov    %rsi,%rbp
shr    $0x2,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     1633 <nllkexch+0x4e3>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
xor    %esi,%esi
movups 0x10(%r13,%rsi,8),%xmm0
movups 0x20(%r13,%rsi,8),%xmm1
movups %xmm0,0x8(%rbx,%rsi,8)
movups %xmm1,0x18(%rbx,%rsi,8)
movupd 0x30(%r13,%rsi,8),%xmm0
movups 0x40(%r13,%rsi,8),%xmm1
movupd %xmm0,0x28(%rbx,%rsi,8)
movups %xmm1,0x38(%rbx,%rsi,8)
add    $0x8,%rsi
add    $0xfffffffffffffffe,%rdi
jne    1220 <nllkexch+0xd0>
test   $0x1,%bpl
je     1284 <nllkexch+0x134>
shl    $0x3,%rsi
mov    %rsi,%rdi
or     $0x10,%rdi
movupd 0x0(%r13,%rdi,1),%xmm0
movups 0x10(%r13,%rdi,1),%xmm1
or     $0x8,%rsi
movupd %xmm0,(%rbx,%rsi,1)
movups %xmm1,0x10(%rbx,%rsi,1)
cmp    %rcx,%rdx
je     130f <nllkexch+0x1bf>
or     $0x1,%rcx
mov    %eax,%edi
sub    %ecx,%edi
mov    %rcx,%rsi
not    %rsi
add    %rax,%rsi
and    $0x3,%rdi
je     15ea <nllkexch+0x49a>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rcx),%rdx
movsd  0x8(%r13,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
mov    %rdx,%rcx
add    $0xffffffffffffffff,%rdi
jne    12b0 <nllkexch+0x160>
cmp    $0x3,%rsi
jb     130f <nllkexch+0x1bf>
nop
movsd  0x8(%r13,%rdx,8),%xmm0
movsd  %xmm0,(%rbx,%rdx,8)
movsd  0x10(%r13,%rdx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rdx,8)
movsd  0x18(%r13,%rdx,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rdx,8)
movsd  0x20(%r13,%rdx,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rdx,8)
lea    0x4(%rdx),%rcx
mov    %rcx,%rdx
cmp    %rcx,%rax
jne    12d0 <nllkexch+0x180>
movslq %r14d,%rax
movsd  0x0(%r13,%rax,8),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     15c9 <nllkexch+0x479>
ucomisd 0xcd1(%rip),%xmm1
jae    15c9 <nllkexch+0x479>
mov    0x2cac(%rip),%rax
cmpl   $0x0,(%rax)
jle    15fc <nllkexch+0x4ac>
movsd  %xmm1,0x30(%rsp)
mov    $0x1,%ebp
movsd  0xcb0(%rip),%xmm5
movsd  0xcb0(%rip),%xmm7
xorpd  %xmm6,%xmm6
movsd  %xmm4,0x38(%rsp)
jmp    1405 <nllkexch+0x2b5>
nop
mov    0x8(%rsp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <pnorms@plt>
movaps %xmm0,0x20(%rsp)
mov    0x10(%rsp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <pnorms@plt>
movapd 0x20(%rsp),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
cmpnlesd 0xc7e(%rip),%xmm0
andpd  %xmm0,%xmm2
movsd  0xc6a(%rip),%xmm1
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
call   1070 <log@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x50(%rsp),%xmm6
subsd  %xmm0,%xmm6
lea    0x1(%rbp),%rax
mov    0x2c08(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rbp
mov    %rax,%rbp
movsd  0x38(%rsp),%xmm4
movsd  0xc11(%rip),%xmm5
movsd  0xc11(%rip),%xmm7
jge    1600 <nllkexch+0x4b0>
mov    0x2bc4(%rip),%rax
mov    (%rax),%rax
mov    (%rax,%rbp,4),%ecx
test   %ecx,%ecx
movsd  %xmm6,0x50(%rsp)
jle    1370 <nllkexch+0x220>
mov    0x2ba1(%rip),%rax
mov    (%rax),%rax
mov    %rbp,0x48(%rsp)
mov    (%rax,%rbp,4),%r8d
mov    0x2b86(%rip),%rax
mov    (%rax),%r11d
mov    0x2b6c(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
add    $0xffffffff,%r8d
mov    0x2b81(%rip),%rax
mov    (%rax),%r10
lea    0x1(%r11),%r9d
mov    %rcx,0x40(%rsp)
lea    0x1(%rcx),%r12
lea    -0x1(%r9),%rsi
add    $0xfffffffffffffffe,%r9
mov    %esi,%ebp
and    $0x3,%ebp
and    $0xfffffffffffffffc,%rsi
mov    $0x1,%ecx
jmp    14a1 <nllkexch+0x351>
nop
mov    0x10(%rsp),%rax
movsd  %xmm1,(%rax,%rcx,8)
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax,%rcx,8)
add    $0x1,%rcx
cmp    %r12,%rcx
je     1590 <nllkexch+0x440>
lea    (%r8,%rcx,1),%eax
movslq %eax,%r13
movapd %xmm4,%xmm0
test   %r11d,%r11d
jle    1567 <nllkexch+0x417>
mov    0x20(%rsp),%rax
mov    (%rax,%r13,8),%r14
mov    $0x1,%r15d
movapd %xmm4,%xmm0
cmp    $0x3,%r9
jb     1535 <nllkexch+0x3e5>
movapd %xmm4,%xmm0
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x8(%rbx,%r15,8),%xmm1
movsd  0x10(%rbx,%r15,8),%xmm2
mulsd  0x8(%r14,%r15,8),%xmm1
mulsd  0x10(%r14,%r15,8),%xmm2
addsd  %xmm0,%xmm1
movsd  0x18(%rbx,%r15,8),%xmm3
mulsd  0x18(%r14,%r15,8),%xmm3
addsd  %xmm1,%xmm2
movsd  0x20(%rbx,%r15,8),%xmm0
mulsd  0x20(%r14,%r15,8),%xmm0
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm0
add    $0x4,%r15
cmp    %r15,%rsi
jne    14e0 <nllkexch+0x390>
add    $0x1,%r15
test   %rbp,%rbp
je     1567 <nllkexch+0x417>
lea    (%r14,%r15,8),%rdx
lea    (%rbx,%r15,8),%rax
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rax,%rdi,8),%xmm1
mulsd  (%rdx,%rdi,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rdi
cmp    %rdi,%rbp
jne    1550 <nllkexch+0x400>
cmpl   $0x1,(%r10,%r13,4)
movapd %xmm5,%xmm1
je     1576 <nllkexch+0x426>
movapd %xmm0,%xmm1
je     1480 <nllkexch+0x330>
movapd %xmm7,%xmm0
jmp    1480 <nllkexch+0x330>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x40(%rsp),%rdi
cmp    $0x2,%edi
mov    0x48(%rsp),%rbp
jl     1370 <nllkexch+0x220>
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
movsd  0x30(%rsp),%xmm0
movsd  0xa5d(%rip),%xmm1
call   1050 <exchmvn@plt>
movapd %xmm0,%xmm2
jmp    139d <nllkexch+0x24d>
movabs $0x4202a05f20000000,%rax
a0 02 42
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rcx,%rdx
cmp    $0x3,%rsi
jae    12d0 <nllkexch+0x180>
jmp    130f <nllkexch+0x1bf>
xorpd  %xmm6,%xmm6
mov    0x18(%rsp),%rax
movsd  %xmm6,(%rax)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
xor    %esi,%esi
test   $0x1,%bpl
jne    125e <nllkexch+0x10e>
jmp    1284 <nllkexch+0x134>

LLVM IR (-O0):
@nc = external global i32
@dmax = external global i32
@ncl = external global i32
@dvec = external global i32*
@dstart = external global i32*
@x = external global double**
@y = external global i32*
define void @nllkexch(i32 %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double*
%14 = alloca double
%15 = alloca double
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 %0, i32* %4
store double* %1, double** %5
store double* %2, double** %6
%22 = load i32, i32* @nc
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
%27 = call i64 @malloc(i32 %26)
%28 = inttoptr i64 %27 to double*
store double* %28, double** %13
%29 = load i32, i32* @dmax
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = mul i64 %31, 8
%33 = trunc i64 %32 to i32
%34 = call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to double*
store double* %35, double** %7
%36 = load i32, i32* @dmax
%37 = add nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = mul i64 %38, 8
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to double*
store double* %42, double** %8
store double 0.000000e+00, double* %10
store double 0x3EB0C6F7A0B5ED8D, double* %11
%43 = load double*, double** %5
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
store double %45, double* %12
store i32 1, i32* %19
br label %46
46: ; preds = %61, %3
%47 = load i32, i32* %19
%48 = load i32, i32* @nc
%49 = icmp sle i32 %47, %48
br i1 %49, label %50, label %64
50: ; preds = %46
%51 = load double*, double** %5
%52 = load i32, i32* %19
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %51, i64 %54
%56 = load double, double* %55
%57 = load double*, double** %13
%58 = load i32, i32* %19
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
store double %56, double* %60
br label %61
61: ; preds = %50
%62 = load i32, i32* %19
%63 = add nsw i32 %62, 1
store i32 %63, i32* %19
br label %46
64: ; preds = %46
%65 = load double*, double** %5
%66 = load i32, i32* %4
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double, double* %65, i64 %67
%69 = load double, double* %68
store double %69, double* %15
%70 = load double, double* %15
%71 = fcmp olt double %70, 0.000000e+00
br i1 %71, label %75, label %72
72: ; preds = %64
%73 = load double, double* %15
%74 = fcmp oge double %73, 1.000000e+00
br i1 %74, label %75, label %77
75: ; preds = %72, %64
%76 = load double*, double** %6
store double 1.000000e+10, double* %76
br label %210
77: ; preds = %72
store i32 1, i32* %16
br label %78
78: ; preds = %198, %77
%79 = load i32, i32* %16
%80 = load i32, i32* @ncl
%81 = icmp sle i32 %79, %80
br i1 %81, label %82, label %201
82: ; preds = %78
%83 = load i32*, i32** @dvec
%84 = load i32, i32* %16
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %83, i64 %85
%87 = load i32, i32* %86
store i32 %87, i32* %20
%88 = load i32*, i32** @dstart
%89 = load i32, i32* %16
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %88, i64 %90
%92 = load i32, i32* %91
store i32 %92, i32* %21
store i32 1, i32* %17
br label %93
93: ; preds = %165, %82
%94 = load i32, i32* %17
%95 = load i32, i32* %20
%96 = icmp sle i32 %94, %95
br i1 %96, label %97, label %168
97: ; preds = %93
store i32 1, i32* %19
%98 = load double, double* %12
store double %98, double* %14
br label %99
99: ; preds = %123, %97
%100 = load i32, i32* %19
%101 = load i32, i32* @nc
%102 = icmp sle i32 %100, %101
br i1 %102, label %103, label %126
103: ; preds = %99
%104 = load double*, double** %13
%105 = load i32, i32* %19
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds double, double* %104, i64 %106
%108 = load double, double* %107
%109 = load double**, double*** @x
%110 = load i32, i32* %21
%111 = load i32, i32* %17
%112 = add nsw i32 %110, %111
%113 = sub nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double*, double** %109, i64 %114
%116 = load double*, double** %115
%117 = load i32, i32* %19
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %116, i64 %118
%120 = load double, double* %119
%121 = load double, double* %14
%122 = call double @llvm.fmuladd.f64(double %108, double %120, double %121)
store double %122, double* %14
br label %123
123: ; preds = %103
%124 = load i32, i32* %19
%125 = add nsw i32 %124, 1
store i32 %125, i32* %19
br label %99
126: ; preds = %99
%127 = load i32*, i32** @y
%128 = load i32, i32* %21
%129 = load i32, i32* %17
%130 = add nsw i32 %128, %129
%131 = sub nsw i32 %130, 1
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i32, i32* %127, i64 %132
%134 = load i32, i32* %133
store i32 %134, i32* %18
%135 = load i32*, i32** @y
%136 = load i32, i32* %21
%137 = load i32, i32* %17
%138 = add nsw i32 %136, %137
%139 = sub nsw i32 %138, 1
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i32, i32* %135, i64 %140
%142 = load i32, i32* %141
%143 = icmp eq i32 %142, 1
br i1 %143, label %144, label %154
144: ; preds = %126
%145 = load double*, double** %7
%146 = load i32, i32* %17
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double, double* %145, i64 %147
store double -6.000000e+00, double* %148
%149 = load double, double* %14
%150 = load double*, double** %8
%151 = load i32, i32* %17
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %150, i64 %152
store double %149, double* %153
br label %164
154: ; preds = %126
%155 = load double, double* %14
%156 = load double*, double** %7
%157 = load i32, i32* %17
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %156, i64 %158
store double %155, double* %159
%160 = load double*, double** %8
%161 = load i32, i32* %17
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds double, double* %160, i64 %162
store double 6.000000e+00, double* %163
br label %164
164: ; preds = %154, %144
br label %165
165: ; preds = %164
%166 = load i32, i32* %17
%167 = add nsw i32 %166, 1
store i32 %167, i32* %17
br label %93
168: ; preds = %93
%169 = load i32, i32* %20
%170 = icmp sge i32 %169, 2
br i1 %170, label %171, label %178
171: ; preds = %168
%172 = load i32, i32* %20
%173 = load double*, double** %7
%174 = load double*, double** %8
%175 = load double, double* %15
%176 = load double, double* %11
%177 = call double @exchmvn(i32 %172, double* %173, double* %174, double %175, double %176)
store double %177, double* %9
br label %188
178: ; preds = %168
%179 = load double*, double** %8
%180 = getelementptr inbounds double, double* %179, i64 1
%181 = load double, double* %180
%182 = call double @pnorms(double %181)
%183 = load double*, double** %7
%184 = getelementptr inbounds double, double* %183, i64 1
%185 = load double, double* %184
%186 = call double @pnorms(double %185)
%187 = fsub double %182, %186
store double %187, double* %9
br label %188
188: ; preds = %178, %171
%189 = load double, double* %9
%190 = fcmp ole double %189, 0.000000e+00
br i1 %190, label %191, label %192
191: ; preds = %188
store double 1.000000e-15, double* %9
br label %192
192: ; preds = %191, %188
%193 = load double, double* %9
%194 = call i64 @log(double %193)
%195 = sitofp i64 %194 to double
%196 = load double, double* %10
%197 = fsub double %196, %195
store double %197, double* %10
br label %198
198: ; preds = %192
%199 = load i32, i32* %16
%200 = add nsw i32 %199, 1
store i32 %200, i32* %16
br label %78
201: ; preds = %78
%202 = load double, double* %10
%203 = load double*, double** %6
store double %202, double* %203
%204 = load double*, double** %13
%205 = call i32 @free(double* %204)
%206 = load double*, double** %7
%207 = call i32 @free(double* %206)
%208 = load double*, double** %8
%209 = call i32 @free(double* %208)
br label %210
210: ; preds = %201, %75
ret void
}

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