#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 r8_normal_01(int *);
double r8_uniform_01(int *);
double sqrt(double);
int sample_from_DDM_C(double *parsamples, int N, int P, double dt, double maxRT,
                      int *seed, double *choices, double *RTs) {
  int n;
  double s, v, sv, a, z, sz, ndt, sndt, RT;
  if (P != 8)
    return 1;
  for (n = 0; n < N; n++) {
    v = parsamples[n * P];
    sv = parsamples[n * P + 1];
    a = parsamples[n * P + 2];
    z = parsamples[n * P + 3] * a;
    sz = parsamples[n * P + 4];
    ndt = parsamples[n * P + 5];
    sndt = parsamples[n * P + 6];
    s = parsamples[n * P + 7];
    if (sv > 0) {
      v = r8_normal_01(seed) * sv + v;
    }
    if (sndt > 0) {
      ndt = (r8_uniform_01(seed) - 0.5) * sndt + ndt;
      ndt = (ndt > 0) ? ndt : 0;
    }
    if (sz > 0) {
      z = (r8_uniform_01(seed) - 0.5) * sz * a + z;
    }
    RT = ndt;
    while (((0 < z) & (z < a)) & (RT < maxRT)) {
      z += v * dt + sqrt(dt) * s * r8_normal_01(seed);
      RT += dt;
    }
    if (RT > maxRT) {
      choices[n] = 0;
      RTs[n] = maxRT + 1.0;
    } else if (z > a) {
      choices[n] = 1.0;
      RTs[n] = RT;
    } else {
      choices[n] = 2.0;
      RTs[n] = RT;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<sample_from_DDM_C>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9,-0x40(%rbp)
cmpl   $0x8,-0x18(%rbp)
je     1171 <sample_from_DDM_C+0x41>
movl   $0x1,-0x4(%rbp)
jmp    1509 <sample_from_DDM_C+0x3d9>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1502 <sample_from_DDM_C+0x3d2>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x5,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1293 <sample_from_DDM_C+0x163>
mov    -0x30(%rbp),%rdi
call   1050 <r8_normal_01@plt>
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x88(%rbp),%xmm0
ff
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1318 <sample_from_DDM_C+0x1e8>
mov    -0x30(%rbp),%rdi
call   1030 <r8_uniform_01@plt>
movsd  0xd47(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x88(%rbp),%xmm2
ff
movsd  -0x80(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12fb <sample_from_DDM_C+0x1cb>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    130b <sample_from_DDM_C+0x1db>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    130b <sample_from_DDM_C+0x1db>
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    135b <sample_from_DDM_C+0x22b>
mov    -0x30(%rbp),%rdi
call   1030 <r8_uniform_01@plt>
movsd  0xcc5(%rip),%xmm1
subsd  %xmm1,%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
movsd  -0x70(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
movsd  -0x90(%rbp),%xmm1
ff
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     143f <sample_from_DDM_C+0x30f>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x20(%rbp),%xmm0
call   1040 <sqrt@plt>
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    -0x30(%rbp),%rdi
call   1050 <r8_normal_01@plt>
movsd  -0xb0(%rbp),%xmm1
ff
movsd  -0xa8(%rbp),%xmm2
ff
movaps %xmm0,%xmm3
movsd  -0xa0(%rbp),%xmm0
ff
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
addsd  -0x90(%rbp),%xmm0
ff
movsd  %xmm0,-0x90(%rbp)
ff
jmp    1368 <sample_from_DDM_C+0x238>
movsd  -0x90(%rbp),%xmm0
ff
ucomisd -0x28(%rbp),%xmm0
jbe    1481 <sample_from_DDM_C+0x351>
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  0xba6(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    14ef <sample_from_DDM_C+0x3bf>
movsd  -0x70(%rbp),%xmm0
ucomisd -0x68(%rbp),%xmm0
jbe    14c0 <sample_from_DDM_C+0x390>
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xb6f(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    14ea <sample_from_DDM_C+0x3ba>
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  0xb38(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x90(%rbp),%xmm0
ff
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    14ef <sample_from_DDM_C+0x3bf>
jmp    14f4 <sample_from_DDM_C+0x3c4>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1178 <sample_from_DDM_C+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_from_DDM_C>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  %xmm1,0x18(%rsp)
mov    $0x1,%eax
cmp    $0x8,%edx
jne    1405 <sample_from_DDM_C+0x2d5>
test   %esi,%esi
jle    1403 <sample_from_DDM_C+0x2d3>
mov    %r9,%r14
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rdi,%r12
movsd  0xe92(%rip),%xmm1
addsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x48(%rsp)
mov    %esi,%r13d
xor    %ebp,%ebp
xorpd  %xmm2,%xmm2
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
movsd  %xmm1,0x58(%rsp)
movsd  %xmm0,0x28(%rsp)
jmp    11c1 <sample_from_DDM_C+0x91>
nopl   0x0(%rax,%rax,1)
movq   $0x0,(%r15,%rbp,8)
movsd  0x48(%rsp),%xmm3
movsd  %xmm3,(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %r13,%rbp
je     1403 <sample_from_DDM_C+0x2d3>
mov    %rbp,%rax
shl    $0x6,%rax
movsd  (%r12,%rax,1),%xmm3
movsd  0x8(%r12,%rax,1),%xmm6
movsd  0x10(%r12,%rax,1),%xmm0
movsd  0x18(%r12,%rax,1),%xmm1
movsd  %xmm0,0x20(%rsp)
mulsd  %xmm0,%xmm1
movsd  0x20(%r12,%rax,1),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%r12,%rax,1),%xmm0
movsd  0x30(%r12,%rax,1),%xmm5
movsd  0x38(%r12,%rax,1),%xmm4
movsd  %xmm4,0x60(%rsp)
ucomisd %xmm2,%xmm6
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm5,0x40(%rsp)
jbe    125b <sample_from_DDM_C+0x12b>
mov    %rbx,%rdi
movsd  %xmm3,0x38(%rsp)
movsd  %xmm6,0x50(%rsp)
call   1050 <r8_normal_01@plt>
movsd  0x40(%rsp),%xmm5
movsd  0x38(%rsp),%xmm3
xorpd  %xmm2,%xmm2
mulsd  0x50(%rsp),%xmm0
addsd  %xmm0,%xmm3
movsd  %xmm3,0x38(%rsp)
ucomisd %xmm2,%xmm5
jbe    12a0 <sample_from_DDM_C+0x170>
mov    %rbx,%rdi
call   1030 <r8_uniform_01@plt>
xorpd  %xmm2,%xmm2
addsd  0xd8d(%rip),%xmm0
mulsd  0x40(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
maxsd  %xmm2,%xmm0
movapd %xmm0,%xmm3
jmp    12a6 <sample_from_DDM_C+0x176>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
ucomisd %xmm2,%xmm0
jbe    1300 <sample_from_DDM_C+0x1d0>
mov    %rbx,%rdi
movsd  %xmm3,0x8(%rsp)
call   1030 <r8_uniform_01@plt>
movsd  0x8(%rsp),%xmm3
xorpd  %xmm2,%xmm2
addsd  0xd36(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0x20(%rsp),%xmm1
movsd  0x30(%rsp),%xmm4
addsd  %xmm1,%xmm4
movsd  0x28(%rsp),%xmm1
ucomisd %xmm2,%xmm4
ja     1316 <sample_from_DDM_C+0x1e6>
jmp    13d0 <sample_from_DDM_C+0x2a0>
nopl   (%rax)
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm4
ucomisd %xmm2,%xmm4
jbe    13d0 <sample_from_DDM_C+0x2a0>
movsd  0x20(%rsp),%xmm0
ucomisd %xmm4,%xmm0
jbe    13d0 <sample_from_DDM_C+0x2a0>
cs nopw 0x0(%rax,%rax,1)
movsd  0x18(%rsp),%xmm0
ucomisd %xmm3,%xmm0
jbe    13d0 <sample_from_DDM_C+0x2a0>
movsd  %xmm4,0x30(%rsp)
movsd  %xmm3,0x8(%rsp)
ucomisd %xmm2,%xmm1
movsd  0x58(%rsp),%xmm0
jae    1363 <sample_from_DDM_C+0x233>
movsd  0x28(%rsp),%xmm0
call   1040 <sqrt@plt>
mulsd  0x60(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1050 <r8_normal_01@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x28(%rsp),%xmm5
mulsd  %xmm5,%xmm1
addsd  %xmm0,%xmm1
movsd  0x30(%rsp),%xmm4
addsd  %xmm1,%xmm4
movsd  0x8(%rsp),%xmm3
addsd  %xmm5,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm4
jbe    13d0 <sample_from_DDM_C+0x2a0>
movsd  0x20(%rsp),%xmm0
ucomisd %xmm4,%xmm0
jbe    13d0 <sample_from_DDM_C+0x2a0>
movapd %xmm5,%xmm1
jmp    1330 <sample_from_DDM_C+0x200>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
ucomisd 0x18(%rsp),%xmm3
ja     11a0 <sample_from_DDM_C+0x70>
ucomisd 0x20(%rsp),%xmm4
jbe    13f0 <sample_from_DDM_C+0x2c0>
movabs $0x3ff0000000000000,%rax
jmp    13fa <sample_from_DDM_C+0x2ca>
movabs $0x4000000000000000,%rax
mov    %rax,(%r15,%rbp,8)
jmp    11ae <sample_from_DDM_C+0x7e>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @sample_from_DDM_C(double* nocapture %0, i32 %1, i32 %2, double %3, double %4, i32* %5, double* nocapture writeonly %6, double* nocapture writeonly %7) {
%9 = icmp eq i32 %2, 8
br i1 %9, label %10, label %101
10: ; preds = %8
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %101
12: ; preds = %10
%13 = fadd double %4, 1.000000e+00
%14 = zext i32 %1 to i64
br label %15
15: ; preds = %12, %96
%16 = phi i64 [ 0, %12 ], [ %99, %96 ]
%17 = shl nsw i64 %16, 3
%18 = getelementptr inbounds double, double* %0, i64 %17
%19 = load double, double* %18
%20 = or i64 %17, 1
%21 = getelementptr inbounds double, double* %0, i64 %20
%22 = load double, double* %21
%23 = or i64 %17, 2
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = load double, double* %24
%26 = or i64 %17, 3
%27 = getelementptr inbounds double, double* %0, i64 %26
%28 = load double, double* %27
%29 = fmul double %25, %28
%30 = or i64 %17, 4
%31 = getelementptr inbounds double, double* %0, i64 %30
%32 = load double, double* %31
%33 = or i64 %17, 5
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = load double, double* %34
%36 = or i64 %17, 6
%37 = getelementptr inbounds double, double* %0, i64 %36
%38 = load double, double* %37
%39 = or i64 %17, 7
%40 = getelementptr inbounds double, double* %0, i64 %39
%41 = load double, double* %40
%42 = fcmp ogt double %22, 0.000000e+00
br i1 %42, label %43, label %46
43: ; preds = %15
%44 = tail call double @r8_normal_01(i32* %5)
%45 = tail call double @llvm.fmuladd.f64(double %44, double %22, double %19)
br label %46
46: ; preds = %43, %15
%47 = phi double [ %45, %43 ], [ %19, %15 ]
%48 = fcmp ogt double %38, 0.000000e+00
br i1 %48, label %49, label %55
49: ; preds = %46
%50 = tail call double @r8_uniform_01(i32* %5)
%51 = fadd double %50, -5.000000e-01
%52 = tail call double @llvm.fmuladd.f64(double %51, double %38, double %35)
%53 = fcmp ogt double %52, 0.000000e+00
%54 = select i1 %53, double %52, double 0.000000e+00
br label %55
55: ; preds = %49, %46
%56 = phi double [ %54, %49 ], [ %35, %46 ]
%57 = fcmp ogt double %32, 0.000000e+00
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = tail call double @r8_uniform_01(i32* %5)
%60 = fadd double %59, -5.000000e-01
%61 = fmul double %32, %60
%62 = tail call double @llvm.fmuladd.f64(double %61, double %25, double %29)
br label %63
63: ; preds = %58, %55
%64 = phi double [ %62, %58 ], [ %29, %55 ]
%65 = fcmp ogt double %64, 0.000000e+00
%66 = fcmp olt double %64, %25
%67 = and i1 %65, %66
%68 = fcmp olt double %56, %4
%69 = and i1 %67, %68
br i1 %69, label %70, label %85
70: ; preds = %63, %70
%71 = phi double [ %79, %70 ], [ %56, %63 ]
%72 = phi double [ %78, %70 ], [ %64, %63 ]
%73 = tail call double @sqrt(double %3)
%74 = fmul double %41, %73
%75 = tail call double @r8_normal_01(i32* %5)
%76 = fmul double %74, %75
%77 = tail call double @llvm.fmuladd.f64(double %47, double %3, double %76)
%78 = fadd double %72, %77
%79 = fadd double %71, %3
%80 = fcmp ogt double %78, 0.000000e+00
%81 = fcmp olt double %78, %25
%82 = and i1 %80, %81
%83 = fcmp olt double %79, %4
%84 = and i1 %82, %83
br i1 %84, label %70, label %85
85: ; preds = %70, %63
%86 = phi double [ %64, %63 ], [ %78, %70 ]
%87 = phi double [ %56, %63 ], [ %79, %70 ]
%88 = fcmp ogt double %87, %4
br i1 %88, label %89, label %91
89: ; preds = %85
%90 = getelementptr inbounds double, double* %6, i64 %16
store double 0.000000e+00, double* %90
br label %96
91: ; preds = %85
%92 = fcmp ogt double %86, %25
%93 = getelementptr inbounds double, double* %6, i64 %16
br i1 %92, label %94, label %95
94: ; preds = %91
store double 1.000000e+00, double* %93
br label %96
95: ; preds = %91
store double 2.000000e+00, double* %93
br label %96
96: ; preds = %89, %95, %94
%97 = phi double [ %13, %89 ], [ %87, %95 ], [ %87, %94 ]
%98 = getelementptr inbounds double, double* %7, i64 %16
store double %97, double* %98
%99 = add nuw nsw i64 %16, 1
%100 = icmp eq i64 %99, %14
br i1 %100, label %101, label %15
101: ; preds = %96, %10, %8
%102 = phi i32 [ 1, %8 ], [ 0, %10 ], [ 0, %96 ]
ret i32 %102
}