#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 *dvector(int /*<<< orphan*/, int);
double erf1(double *);
int /*<<< orphan*/ free_dvector(double *, int /*<<< orphan*/);
double phiinv(double);
double ranf();
double sqrt(double);
void normal_truncc(int n, double *mu, double *sigma2, double *left,
                   double *right, double *out) {
  int i;
  double *lowerProb, *upperProb, *u, *sqrtsig;
  double *phi1, *phi2;
  u = dvector(0, n - 1);
  sqrtsig = dvector(0, n - 1);
  lowerProb = dvector(0, n - 1);
  upperProb = dvector(0, n - 1);
  phi1 = dvector(0, n - 1);
  phi2 = dvector(0, n - 1);
  for (i = 0; i < n; i++)
    sqrtsig[i] = sqrt(sigma2[i]);
  for (i = 0; i < n; i++) {
    lowerProb[i] = (left[i] - mu[i]) / sqrtsig[i];
    upperProb[i] = (right[i] - mu[i]) / sqrtsig[i];
  }
  for (i = 0; i < n; i++) {
    phi1[i] = lowerProb[i] / sqrt(2.0);
    phi2[i] = upperProb[i] / sqrt(2.0);
    lowerProb[i] = 0.5 * (1.0 + erf1(&phi1[i]));
    upperProb[i] = 0.5 * (1.0 + erf1(&phi2[i]));
  }
  for (i = 0; i < n; i++)
    u[i] = lowerProb[i] + (upperProb[i] - lowerProb[i]) * ranf();
  for (i = 0; i < n; i++)
    out[i] = mu[i] + phiinv(u[i]) * sqrtsig[i];
  free_dvector(u, 0);
  free_dvector(lowerProb, 0);
  free_dvector(upperProb, 0);
  free_dvector(sqrtsig, 0);
  free_dvector(phi1, 0);
  free_dvector(phi2, 0);
}


x86 assembly (clang, -O0):
<normal_truncc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1050 <dvector@plt>
mov    %rax,-0x50(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1050 <dvector@plt>
mov    %rax,-0x58(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1050 <dvector@plt>
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1050 <dvector@plt>
mov    %rax,-0x48(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1050 <dvector@plt>
mov    %rax,-0x60(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
xor    %edi,%edi
call   1050 <dvector@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1228 <normal_truncc+0xc8>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1080 <sqrt@plt>
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ef <normal_truncc+0x8f>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12b1 <normal_truncc+0x151>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
divsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    122f <normal_truncc+0xcf>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13b4 <normal_truncc+0x254>
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd32(%rip),%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x60(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xcfa(%rip),%xmm0
call   1080 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x68(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rdi
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <erf1@plt>
movsd  0xcb8(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xca4(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%rdi
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <erf1@plt>
movsd  0xc7f(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xc6b(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12b8 <normal_truncc+0x158>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1435 <normal_truncc+0x2d5>
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    $0x0,%al
call   1040 <ranf@plt>
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x50(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13bb <normal_truncc+0x25b>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    14a7 <normal_truncc+0x347>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x50(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <phiinv@plt>
movsd  -0x90(%rbp),%xmm1
ff
mov    -0x58(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    143c <normal_truncc+0x2dc>
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    -0x48(%rbp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    -0x58(%rbp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    -0x60(%rbp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    -0x68(%rbp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normal_truncc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x58(%rsp)
mov    %r8,0x28(%rsp)
mov    %rcx,0x60(%rsp)
mov    %rdx,%r13
mov    %rsi,0x48(%rsp)
mov    %edi,%ebx
lea    -0x1(%rbx),%r12d
xor    %edi,%edi
mov    %r12d,%esi
call   1050 <dvector@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r12d,%esi
call   1050 <dvector@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %r12d,%esi
call   1050 <dvector@plt>
mov    %rax,0x20(%rsp)
xor    %edi,%edi
mov    %r12d,%esi
call   1050 <dvector@plt>
mov    %rax,0x18(%rsp)
xor    %edi,%edi
mov    %r12d,%esi
call   1050 <dvector@plt>
mov    %rax,0x50(%rsp)
xor    %edi,%edi
mov    %r12d,%esi
call   1050 <dvector@plt>
mov    %rbp,%r8
mov    %rax,0x30(%rsp)
test   %ebx,%ebx
jle    1466 <normal_truncc+0x306>
mov    %r14,0x8(%rsp)
mov    %r8,0x40(%rsp)
mov    %ebx,%ebp
lea    -0x1(%rbp),%rax
mov    %ebp,%ecx
and    $0x3,%ecx
mov    %rcx,(%rsp)
cmp    $0x3,%rax
mov    %rbx,0x10(%rsp)
mov    %rbp,0x38(%rsp)
jae    14b8 <normal_truncc+0x358>
xor    %r12d,%r12d
mov    0x8(%rsp),%rbp
cmpq   $0x0,(%rsp)
je     127b <normal_truncc+0x11b>
lea    0x0(,%r12,8),%r14
add    %rbp,%r14
lea    0x0(,%r12,8),%r15
add    %r13,%r15
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1269 <normal_truncc+0x109>
cs nopw 0x0(%rax,%rax,1)
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,(%rsp)
je     127b <normal_truncc+0x11b>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1250 <normal_truncc+0xf0>
sqrtsd %xmm0,%xmm0
jmp    1259 <normal_truncc+0xf9>
cmpl   $0x0,0x10(%rsp)
mov    0x48(%rsp),%rcx
mov    0x40(%rsp),%r8
mov    %rbp,%r14
mov    0x38(%rsp),%rdi
jle    1466 <normal_truncc+0x306>
xor    %eax,%eax
mov    0x20(%rsp),%rdx
mov    0x18(%rsp),%rsi
mov    0x28(%rsp),%rbx
mov    0x60(%rsp),%rbp
xchg   %ax,%ax
movsd  0x0(%rbp,%rax,8),%xmm0
subsd  (%rcx,%rax,8),%xmm0
divsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,(%rdx,%rax,8)
movsd  (%rbx,%rax,8),%xmm0
subsd  (%rcx,%rax,8),%xmm0
divsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,(%rsi,%rax,8)
add    $0x1,%rax
cmp    %rax,%rdi
jne    12b0 <normal_truncc+0x150>
cmpl   $0x0,0x10(%rsp)
jle    1466 <normal_truncc+0x306>
lea    0x0(,%rdi,8),%rax
mov    %rax,(%rsp)
xor    %ebx,%ebx
mov    0x50(%rsp),%r13
mov    0x20(%rsp),%r14
mov    0x18(%rsp),%r12
nopl   0x0(%rax)
movsd  (%r14,%rbx,1),%xmm0
movsd  0xce2(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    (%rbx,%r13,1),%rdi
movsd  %xmm0,0x0(%r13,%rbx,1)
movsd  (%r12,%rbx,1),%xmm0
divsd  %xmm1,%xmm0
mov    0x30(%rsp),%rax
lea    (%rax,%rbx,1),%rbp
mov    0x30(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,1)
call   1070 <erf1@plt>
movsd  0xcb1(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xcad(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,(%r14,%rbx,1)
mov    %rbp,%rdi
call   1070 <erf1@plt>
addsd  0xc8b(%rip),%xmm0
mulsd  0xc8b(%rip),%xmm0
movsd  %xmm0,(%r12,%rbx,1)
add    $0x8,%rbx
cmp    %rbx,(%rsp)
jne    1310 <normal_truncc+0x1b0>
cmpl   $0x0,0x10(%rsp)
mov    0x40(%rsp),%r8
mov    0x38(%rsp),%r12
mov    0x8(%rsp),%r14
jle    1466 <normal_truncc+0x306>
xor    %ebx,%ebx
mov    0x20(%rsp),%r13
mov    0x18(%rsp),%rbp
mov    %r8,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x0(%rbp,%rbx,8),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x28(%rsp)
xor    %eax,%eax
call   1040 <ranf@plt>
mulsd  0x28(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    13d0 <normal_truncc+0x270>
cmpl   $0x0,0x10(%rsp)
mov    %r14,%r8
mov    0x8(%rsp),%r14
mov    0x58(%rsp),%rbp
mov    0x48(%rsp),%r15
jle    1466 <normal_truncc+0x306>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  (%r15,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r8,%rbx,8),%xmm0
mov    %r8,%r13
call   1030 <phiinv@plt>
mov    %r13,%r8
mulsd  (%r14,%rbx,8),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x0(%rbp,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1430 <normal_truncc+0x2d0>
mov    %r8,%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    0x20(%rsp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    0x18(%rsp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    0x50(%rsp),%rdi
xor    %esi,%esi
call   1060 <free_dvector@plt>
mov    0x30(%rsp),%rdi
xor    %esi,%esi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <free_dvector@plt>
mov    %ebp,%ebx
and    $0xfffffffc,%ebx
xor    %r12d,%r12d
xorpd  %xmm1,%xmm1
mov    0x8(%rsp),%rbp
jmp    14ed <normal_truncc+0x38d>
nopl   0x0(%rax,%rax,1)
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x18(%rbp,%r12,8)
add    $0x4,%r12
cmp    %r12,%rbx
je     1221 <normal_truncc+0xc1>
movsd  0x0(%r13,%r12,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1500 <normal_truncc+0x3a0>
sqrtsd %xmm0,%xmm0
jmp    1509 <normal_truncc+0x3a9>
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x0(%rbp,%r12,8)
movsd  0x8(%r13,%r12,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1530 <normal_truncc+0x3d0>
sqrtsd %xmm0,%xmm0
jmp    1539 <normal_truncc+0x3d9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%rbp,%r12,8)
movsd  0x10(%r13,%r12,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1560 <normal_truncc+0x400>
sqrtsd %xmm0,%xmm0
jmp    1569 <normal_truncc+0x409>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1080 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x10(%rbp,%r12,8)
movsd  0x18(%r13,%r12,8),%xmm0
ucomisd %xmm1,%xmm0
jb     14d0 <normal_truncc+0x370>
sqrtsd %xmm0,%xmm0
jmp    14d9 <normal_truncc+0x379>

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

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