#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*/ evolve2D(double *, double *, double *, int, int, int, int,
                            double, double, double, int, int);
int /*<<< orphan*/ expandNewpop2D(double *, double *, int, int, int, int, int,
                                  int, int);
int /*<<< orphan*/ initExpansion2D(double *, int, int, int, int, int);
scalar_t__ rand_normal(double, double);
void expand2D(double *Pops, double *OutsidePop, double *AF, int n1, int n2,
              int nSNP, double m1, double m2, double minf, int Ne, int Loss,
              int gen, int timeStart, int timeEnd, int popStart, int popEnd,
              int nSteps, int lengthSteps, int ke, int admixture) {
  int npopColonized = (int)(gen - timeStart - 1) / lengthSteps + 1;
  int p1, p2, l;
  if ((gen == timeStart) && (!admixture))
    initExpansion2D(Pops, nSNP, n1, n2, popStart, popEnd);
  if (gen > timeStart) {
    for (p1 = 0; p1 < n1; p1++) {
      for (p2 = popStart - 1; p2 < popStart - 1 + npopColonized; p2++) {
        for (l = 0; l < nSNP; l++) {
          double af = Pops[(p1 + p2 * n1) * nSNP + l];
          if ((af > 0) && (af < 1))
            af = (double)rand_normal(af, af * (1 - af) / (2 * Ne));
          if (af > 1)
            af = 1;
          if (af < 0)
            af = 0;
          Pops[(p1 + p2 * n1) * nSNP + l] = af;
        }
      }
      if (((gen - timeStart) % lengthSteps == 0) &&
          (npopColonized < (popEnd - popStart + 1)))
        expandNewpop2D(Pops, AF, popStart + npopColonized - 1, nSNP, n1, n2, Ne,
                       ke, admixture);
    }
  }
  if (popStart > 1)
    evolve2D(Pops, OutsidePop, AF, (popStart - 1) * n1, n1, popStart - 1, nSNP,
             m1, m2, minf, Ne, Loss);
  if (popEnd < n2)
    evolve2D(Pops + nSNP * n1 * popEnd, OutsidePop, AF, n1 * (n2 - popEnd), n1,
             n2 - popEnd, nSNP, m1, m2, minf, Ne, Loss);
}


x86 assembly (clang, -O0):
<expand2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x60(%rbp),%eax
mov    0x58(%rbp),%eax
mov    0x50(%rbp),%eax
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
movsd  %xmm2,-0x40(%rbp)
mov    0x20(%rbp),%eax
sub    0x28(%rbp),%eax
sub    $0x1,%eax
cltd
idivl  0x50(%rbp)
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    0x20(%rbp),%eax
cmp    0x28(%rbp),%eax
jne    11d2 <expand2D+0x92>
cmpl   $0x0,0x60(%rbp)
jne    11d2 <expand2D+0x92>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    0x38(%rbp),%r8d
mov    0x40(%rbp),%r9d
call   1030 <initExpansion2D@plt>
mov    0x20(%rbp),%eax
cmp    0x28(%rbp),%eax
jle    1399 <expand2D+0x259>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1394 <expand2D+0x254>
mov    0x38(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x38(%rbp),%ecx
sub    $0x1,%ecx
add    -0x44(%rbp),%ecx
cmp    %ecx,%eax
jge    1321 <expand2D+0x1e1>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    130e <expand2D+0x1ce>
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    -0x4c(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
imul   -0x24(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12a2 <expand2D+0x162>
movsd  0xda1(%rip),%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    12a2 <expand2D+0x162>
movsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  0xd84(%rip),%xmm2
subsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
mov    0x10(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm2
divsd  %xmm2,%xmm1
call   1060 <rand_normal@plt>
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  0xd51(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12c6 <expand2D+0x186>
movsd  0xd3f(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x58(%rbp),%xmm0
jbe    12dc <expand2D+0x19c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    -0x4c(%rbp),%edx
imul   -0x1c(%rbp),%edx
add    %edx,%ecx
imul   -0x24(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1215 <expand2D+0xd5>
jmp    1313 <expand2D+0x1d3>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11fa <expand2D+0xba>
mov    0x20(%rbp),%eax
sub    0x28(%rbp),%eax
cltd
idivl  0x50(%rbp)
cmp    $0x0,%edx
jne    1381 <expand2D+0x241>
mov    -0x44(%rbp),%eax
mov    0x40(%rbp),%ecx
sub    0x38(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1381 <expand2D+0x241>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x38(%rbp),%edx
add    -0x44(%rbp),%edx
sub    $0x1,%edx
mov    -0x24(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    0x10(%rbp),%r11d
mov    0x58(%rbp),%r10d
mov    0x60(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <expandNewpop2D@plt>
jmp    1386 <expand2D+0x246>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    11e5 <expand2D+0xa5>
jmp    1399 <expand2D+0x259>
cmpl   $0x1,0x38(%rbp)
jle    13f1 <expand2D+0x2b1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x38(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    0x38(%rbp),%r9d
sub    $0x1,%r9d
mov    -0x24(%rbp),%r11d
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <evolve2D@plt>
mov    0x40(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1461 <expand2D+0x321>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%eax
imul   -0x1c(%rbp),%eax
imul   0x40(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%eax
sub    0x40(%rbp),%eax
imul   %eax,%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
sub    0x40(%rbp),%r9d
mov    -0x24(%rbp),%r11d
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1050 <evolve2D@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movsd  %xmm2,0x50(%rsp)
movsd  %xmm1,0x48(%rsp)
movsd  %xmm0,0x40(%rsp)
mov    %r9,0x8(%rsp)
mov    %r8d,%ebp
mov    %ecx,0x4(%rsp)
mov    %rdx,0x20(%rsp)
mov    %rsi,0x38(%rsp)
mov    %rdi,0x10(%rsp)
mov    0xd8(%rsp),%r14d
mov    0xd0(%rsp),%r15d
mov    %r15d,%eax
sub    %r14d,%eax
add    $0xffffffff,%eax
cltd
idivl  0x100(%rsp)
mov    %rax,0x58(%rsp)
mov    %r15d,%eax
mov    0xf0(%rsp),%r9d
mov    0xe8(%rsp),%ebx
sub    %r14d,%eax
mov    %eax,0x34(%rsp)
jne    11e2 <expand2D+0xa2>
mov    0x110(%rsp),%eax
test   %eax,%eax
jne    11e2 <expand2D+0xa2>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   1030 <initExpansion2D@plt>
mov    %ebp,0x1c(%rsp)
cmp    %r14d,%r15d
jle    13b1 <expand2D+0x271>
cmpl   $0x0,0x4(%rsp)
jle    13b1 <expand2D+0x271>
lea    -0x1(%rbx),%eax
mov    0x58(%rsp),%rcx
lea    (%rcx,%rbx,1),%r14d
mov    0xc0(%rsp),%ecx
add    %ecx,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x80(%rsp)
mov    0xf0(%rsp),%ecx
sub    %ebx,%ecx
mov    %ecx,0x30(%rsp)
movslq %eax,%rcx
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%rax
movslq %eax,%rsi
mov    %eax,%r13d
mov    %rsi,%rbp
mov    %rdx,0x70(%rsp)
imul   %rdx,%rbp
mov    %rcx,0x60(%rsp)
mov    %rcx,%rax
imul   %rbp,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rax
mov    %rax,0x28(%rsp)
shl    $0x3,%rsi
mov    %rsi,0x68(%rsp)
shl    $0x3,%rbp
xor    %ecx,%ecx
movsd  0xd85(%rip),%xmm2
jmp    12aa <expand2D+0x16a>
nopl   (%rax)
mov    0x78(%rsp),%rcx
add    $0x1,%rcx
mov    0x28(%rsp),%rax
add    0x68(%rsp),%rax
mov    %rax,0x28(%rsp)
cmp    0x70(%rsp),%rcx
mov    0xe8(%rsp),%ebx
je     13b1 <expand2D+0x271>
mov    %rcx,0x78(%rsp)
cmp    %ebx,%r14d
jge    1320 <expand2D+0x1e0>
mov    0x34(%rsp),%eax
cltd
idivl  0x100(%rsp)
test   %edx,%edx
jne    1280 <expand2D+0x140>
mov    0x30(%rsp),%eax
cmp    %eax,0x58(%rsp)
jge    1280 <expand2D+0x140>
sub    $0x8,%rsp
mov    0x18(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    %r14d,%edx
mov    0x10(%rsp),%rcx
mov    0xc(%rsp),%r8d
mov    0x24(%rsp),%r9d
mov    0x118(%rsp),%eax
push   %rax
mov    0x118(%rsp),%eax
push   %rax
mov    0xd8(%rsp),%eax
push   %rax
call   1040 <expandNewpop2D@plt>
movsd  0xced(%rip),%xmm2
add    $0x20,%rsp
jmp    1280 <expand2D+0x140>
nopl   0x0(%rax)
mov    0x28(%rsp),%r15
mov    0x60(%rsp),%r12
jmp    1340 <expand2D+0x200>
nopl   0x0(%rax)
add    $0x1,%r12
add    %rbp,%r15
cmp    %r12d,%r14d
je     12b4 <expand2D+0x174>
cmpl   $0x0,0x8(%rsp)
jle    1330 <expand2D+0x1f0>
xor    %ebx,%ebx
jmp    136f <expand2D+0x22f>
nopl   0x0(%rax,%rax,1)
movapd %xmm2,%xmm1
minsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
maxsd  %xmm1,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
je     1330 <expand2D+0x1f0>
movsd  (%r15,%rbx,8),%xmm0
ucomisd 0xc8b(%rip),%xmm0
jbe    1350 <expand2D+0x210>
ucomisd %xmm0,%xmm2
jbe    1350 <expand2D+0x210>
movapd %xmm2,%xmm1
subsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
divsd  0x80(%rsp),%xmm1
call   1060 <rand_normal@plt>
movsd  0xc59(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
jmp    1350 <expand2D+0x210>
mov    0xc8(%rsp),%ebp
cmp    $0x2,%ebx
jl     1409 <expand2D+0x2c9>
add    $0xffffffff,%ebx
mov    %ebx,%ecx
mov    0x4(%rsp),%r8d
imul   %r8d,%ecx
sub    $0x8,%rsp
mov    0x18(%rsp),%rdi
mov    0x40(%rsp),%rsi
mov    0x28(%rsp),%rdx
mov    %ebx,%r9d
movsd  0x48(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
movsd  0x58(%rsp),%xmm2
push   %rbp
mov    0xd0(%rsp),%eax
push   %rax
push   0x20(%rsp)
call   1050 <evolve2D@plt>
add    $0x20,%rsp
mov    0x1c(%rsp),%r9d
mov    0xf0(%rsp),%ecx
sub    %ecx,%r9d
jle    1477 <expand2D+0x337>
mov    0x8(%rsp),%rbx
mov    %ebx,%eax
mov    0x4(%rsp),%r8d
imul   %r8d,%eax
imul   %ecx,%eax
cltq
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    %r9d,%ecx
imul   %r8d,%ecx
sub    $0x8,%rsp
mov    0x40(%rsp),%rsi
mov    0x28(%rsp),%rdx
movsd  0x48(%rsp),%xmm0
movsd  0x50(%rsp),%xmm1
movsd  0x58(%rsp),%xmm2
push   %rbp
mov    0xd0(%rsp),%eax
push   %rax
push   %rbx
call   1050 <evolve2D@plt>
add    $0xa8,%rsp
jmp    147e <expand2D+0x33e>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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