void InitPops(double **Pops, double **OutsidePop, double **AF, int npop,
              int nSNP) {
  int i, j;
  *OutsidePop = malloc(sizeof(double) * nSNP);
  *Pops = malloc(sizeof(double) * nSNP * npop);
  *AF = malloc(sizeof(double) * npop);
  init_random();
  for (i = 0; i < nSNP; i++) {
    *(*(OutsidePop) + i) = (double)rand_beta(1, 9);
  }
  for (j = 0; j < npop; j++) {
    for (i = 0; i < nSNP; i++) {
      *(*(Pops) + j * nSNP + i) = *(*(OutsidePop) + i);
    }
  }
}


x86 assembly (clang, -O0):
<InitPops>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movslq -0x20(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movslq -0x20(%rbp),%rdi
shl    $0x3,%rdi
movslq -0x1c(%rbp),%rax
imul   %rax,%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movslq -0x1c(%rbp),%rdi
shl    $0x3,%rdi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <init_random@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11e5 <InitPops+0xb5>
mov    $0x1,%edi
mov    $0x9,%esi
mov    $0x0,%al
call   1050 <rand_beta@plt>
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a6 <InitPops+0x76>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125d <InitPops+0x12d>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    124a <InitPops+0x11a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x28(%rbp),%ecx
imul   -0x20(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ff <InitPops+0xcf>
jmp    124f <InitPops+0x11f>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ec <InitPops+0xbc>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<InitPops>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,0x8(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r14
movslq %r8d,%r13
lea    0x0(,%r13,8),%rbx
mov    %rbx,%rdi
call   1040 <malloc@plt>
mov    %rax,0x0(%rbp)
mov    %r12d,0x10(%rsp)
movslq %r12d,%r12
imul   %r12,%rbx
mov    %rbx,%rdi
call   1040 <malloc@plt>
mov    %r14,0x40(%rsp)
mov    %rax,(%r14)
shl    $0x3,%r12
mov    %r12,%rdi
call   1040 <malloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx)
xor    %eax,%eax
call   1030 <init_random@plt>
mov    %r15d,%r12d
test   %r13d,%r13d
jle    11da <InitPops+0xaa>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    $0x9,%esi
xor    %eax,%eax
call   1050 <rand_beta@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x0(%rbp),%rax
movsd  %xmm0,(%rax,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11b0 <InitPops+0x80>
mov    %rbp,0x8(%rsp)
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    1423 <InitPops+0x2f3>
mov    %eax,%eax
mov    %rax,0x10(%rsp)
mov    %r12d,%eax
and    $0xfffffffc,%eax
mov    %rax,0x30(%rsp)
add    $0xfffffffffffffffc,%rax
mov    %rax,0x28(%rsp)
shr    $0x2,%rax
add    $0x1,%rax
mov    %eax,%r14d
and    $0x3,%r14d
and    $0xfffffffffffffffc,%rax
mov    %rax,0x18(%rsp)
mov    %r12d,%eax
and    $0x3,%eax
mov    %rax,0x38(%rsp)
mov    %r14,0x20(%rsp)
shl    $0x5,%r14
mov    $0xe,%esi
mov    $0x2,%ecx
xor    %eax,%eax
xor    %r8d,%r8d
jmp    1268 <InitPops+0x138>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r8
add    %r13,%rsi
add    %r13,%rax
add    %r13,%rcx
cmp    0x10(%rsp),%r8
je     1423 <InitPops+0x2f3>
test   %r15d,%r15d
jle    1250 <InitPops+0x120>
mov    0x8(%rsp),%rdx
mov    (%rdx),%r9
mov    0x40(%rsp),%rdx
mov    (%rdx),%r10
cmp    $0x4,%r15d
jb     12ab <InitPops+0x17b>
mov    %r8,%rdx
imul   %r13,%rdx
lea    (%r10,%rdx,8),%rdi
lea    (%r9,%r12,8),%rbp
cmp    %rbp,%rdi
jae    134d <InitPops+0x21d>
add    %r12,%rdx
lea    (%r10,%rdx,8),%rdx
cmp    %rdx,%r9
jae    134d <InitPops+0x21d>
xor    %r11d,%r11d
mov    %r11,%rdx
not    %rdx
add    %r12,%rdx
mov    0x38(%rsp),%rdi
test   %rdi,%rdi
je     12e6 <InitPops+0x1b6>
lea    (%r10,%rax,8),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r9,%r11,8),%xmm0
movsd  %xmm0,(%rbx,%r11,8)
add    $0x1,%r11
add    $0xffffffffffffffff,%rdi
jne    12d0 <InitPops+0x1a0>
cmp    $0x3,%rdx
jb     1250 <InitPops+0x120>
mov    %r12,%rdx
sub    %r11,%rdx
lea    (%r11,%rcx,1),%rdi
lea    (%r10,%rdi,8),%rbp
lea    (%r9,%r11,8),%rbx
add    $0x18,%rbx
xor    %edi,%edi
nopl   0x0(%rax,%rax,1)
movsd  -0x18(%rbx,%rdi,8),%xmm0
movsd  %xmm0,-0x10(%rbp,%rdi,8)
movsd  -0x10(%rbx,%rdi,8),%xmm0
movsd  %xmm0,-0x8(%rbp,%rdi,8)
movsd  -0x8(%rbx,%rdi,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rdi,8)
movsd  (%rbx,%rdi,8),%xmm0
movsd  %xmm0,0x8(%rbp,%rdi,8)
add    $0x4,%rdi
cmp    %rdi,%rdx
jne    1310 <InitPops+0x1e0>
jmp    1250 <InitPops+0x120>
cmpq   $0xc,0x28(%rsp)
jae    1359 <InitPops+0x229>
xor    %edx,%edx
jmp    13d2 <InitPops+0x2a2>
lea    (%r10,%rsi,8),%rbx
mov    0x18(%rsp),%rbp
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movups (%r9,%rdx,8),%xmm0
movups 0x10(%r9,%rdx,8),%xmm1
movups %xmm0,-0x70(%rbx,%rdx,8)
movups %xmm1,-0x60(%rbx,%rdx,8)
movups 0x20(%r9,%rdx,8),%xmm0
movups 0x30(%r9,%rdx,8),%xmm1
movups %xmm0,-0x50(%rbx,%rdx,8)
movups %xmm1,-0x40(%rbx,%rdx,8)
movups 0x40(%r9,%rdx,8),%xmm0
movups 0x50(%r9,%rdx,8),%xmm1
movups %xmm0,-0x30(%rbx,%rdx,8)
movups %xmm1,-0x20(%rbx,%rdx,8)
movupd 0x60(%r9,%rdx,8),%xmm0
movups 0x70(%r9,%rdx,8),%xmm1
movupd %xmm0,-0x10(%rbx,%rdx,8)
movups %xmm1,(%rbx,%rdx,8)
add    $0x10,%rdx
add    $0xfffffffffffffffc,%rbp
jne    1370 <InitPops+0x240>
cmpq   $0x0,0x20(%rsp)
je     140d <InitPops+0x2dd>
lea    (%rdx,%rax,1),%rdi
lea    (%r10,%rdi,8),%rdi
lea    (%r9,%rdx,8),%rdx
add    $0x10,%rdx
xor    %ebp,%ebp
nopl   0x0(%rax)
movupd -0x10(%rdx,%rbp,1),%xmm0
movups (%rdx,%rbp,1),%xmm1
movupd %xmm0,(%rdi,%rbp,1)
movups %xmm1,0x10(%rdi,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%r14
jne    13f0 <InitPops+0x2c0>
mov    0x30(%rsp),%rdx
mov    %rdx,%r11
cmp    %r12,%rdx
je     1250 <InitPops+0x120>
jmp    12ae <InitPops+0x17e>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @InitPops(double** %0, double** %1, double** %2, i32 %3, i32 %4) {
%6 = alloca double**
%7 = alloca double**
%8 = alloca double**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store double** %0, double*** %6
store double** %1, double*** %7
store double** %2, double*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%13 = load i32, i32* %10
%14 = sext i32 %13 to i64
%15 = mul i64 8, %14
%16 = call i8* @malloc(i64 %15)
%17 = bitcast i8* %16 to double*
%18 = load double**, double*** %7
store double* %17, double** %18
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = mul i64 %21, %23
%25 = call i8* @malloc(i64 %24)
%26 = bitcast i8* %25 to double*
%27 = load double**, double*** %6
store double* %26, double** %27
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = mul i64 8, %29
%31 = call i8* @malloc(i64 %30)
%32 = bitcast i8* %31 to double*
%33 = load double**, double*** %8
store double* %32, double** %33
%34 = call i32 (...) @init_random()
store i32 0, i32* %11
br label %35
35: ; preds = %47, %5
%36 = load i32, i32* %11
%37 = load i32, i32* %10
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %50
39: ; preds = %35
%40 = call i32 (i32, i32, ...) bitcast (i32 (...)* @rand_beta to i32 (i32, i32, ...)*)(i32 1, i32 9)
%41 = sitofp i32 %40 to double
%42 = load double**, double*** %7
%43 = load double*, double** %42
%44 = load i32, i32* %11
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double %41, double* %46
br label %47
47: ; preds = %39
%48 = load i32, i32* %11
%49 = add nsw i32 %48, 1
store i32 %49, i32* %11
br label %35
50: ; preds = %35
store i32 0, i32* %12
br label %51
51: ; preds = %81, %50
%52 = load i32, i32* %12
%53 = load i32, i32* %9
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %84
55: ; preds = %51
store i32 0, i32* %11
br label %56
56: ; preds = %77, %55
%57 = load i32, i32* %11
%58 = load i32, i32* %10
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %80
60: ; preds = %56
%61 = load double**, double*** %7
%62 = load double*, double** %61
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = load double**, double*** %6
%68 = load double*, double** %67
%69 = load i32, i32* %12
%70 = load i32, i32* %10
%71 = mul nsw i32 %69, %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %68, i64 %72
%74 = load i32, i32* %11
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds double, double* %73, i64 %75
store double %66, double* %76
br label %77
77: ; preds = %60
%78 = load i32, i32* %11
%79 = add nsw i32 %78, 1
store i32 %79, i32* %11
br label %56
80: ; preds = %56
br label %81
81: ; preds = %80
%82 = load i32, i32* %12
%83 = add nsw i32 %82, 1
store i32 %83, i32* %12
br label %51
84: ; preds = %51
ret void
}

LLVM IR (-O2):
define void @InitPops(double** nocapture %0, double** nocapture %1, double** nocapture writeonly %2, i32 %3, i32 %4) {
%6 = sext i32 %4 to i64
%7 = shl nsw i64 %6, 3
%8 = tail call i8* @malloc(i64 %7)
%9 = bitcast double** %1 to i8**
store i8* %8, i8** %9
%10 = sext i32 %3 to i64
%11 = mul i64 %7, %10
%12 = tail call i8* @malloc(i64 %11)
%13 = bitcast double** %0 to i8**
store i8* %12, i8** %13
%14 = shl nsw i64 %10, 3
%15 = tail call i8* @malloc(i64 %14)
%16 = bitcast double** %2 to i8**
store i8* %15, i8** %16
%17 = tail call i32 (...) @init_random()
%18 = icmp sgt i32 %4, 0
br i1 %18, label %19, label %21
19: ; preds = %5
%20 = zext i32 %4 to i64
br label %39
21: ; preds = %39, %5
%22 = icmp sgt i32 %3, 0
br i1 %22, label %23, label %169
23: ; preds = %21
%24 = zext i32 %3 to i64
%25 = zext i32 %4 to i64
%26 = and i64 %25, 4294967292
%27 = add nsw i64 %26, -4
%28 = lshr exact i64 %27, 2
%29 = add nuw nsw i64 %28, 1
%30 = icmp ult i32 %4, 4
%31 = and i64 %25, 4294967292
%32 = and i64 %29, 3
%33 = icmp ult i64 %27, 12
%34 = and i64 %29, 9223372036854775804
%35 = icmp eq i64 %32, 0
%36 = icmp eq i64 %31, %25
%37 = and i64 %25, 3
%38 = icmp eq i64 %37, 0
br label %47
39: ; preds = %19, %39
%40 = phi i64 [ 0, %19 ], [ %45, %39 ]
%41 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @rand_beta to i32 (i32, i32, ...)*)(i32 1, i32 9)
%42 = sitofp i32 %41 to double
%43 = load double*, double** %1
%44 = getelementptr inbounds double, double* %43, i64 %40
store double %42, double* %44
%45 = add nuw nsw i64 %40, 1
%46 = icmp eq i64 %45, %20
br i1 %46, label %21, label %39
47: ; preds = %23, %166
%48 = phi i64 [ 0, %23 ], [ %167, %166 ]
%49 = mul i64 %48, %6
%50 = add i64 %49, %25
br i1 %18, label %51, label %166
51: ; preds = %47
%52 = load double*, double** %1
%53 = load double*, double** %0
%54 = mul nsw i64 %48, %6
%55 = getelementptr inbounds double, double* %53, i64 %54
br i1 %30, label %131, label %56
56: ; preds = %51
%57 = getelementptr double, double* %53, i64 %50
%58 = getelementptr double, double* %52, i64 %25
%59 = icmp ult double* %55, %58
%60 = icmp ult double* %52, %57
%61 = and i1 %59, %60
br i1 %61, label %131, label %62
62: ; preds = %56
br i1 %33, label %112, label %63
63: ; preds = %62, %63
%64 = phi i64 [ %109, %63 ], [ 0, %62 ]
%65 = phi i64 [ %110, %63 ], [ 0, %62 ]
%66 = getelementptr inbounds double, double* %52, i64 %64
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %66, i64 2
%70 = bitcast double* %69 to <2 x double>*
%71 = load <2 x double>, <2 x double>* %70
%72 = getelementptr inbounds double, double* %55, i64 %64
%73 = bitcast double* %72 to <2 x double>*
store <2 x double> %68, <2 x double>* %73
%74 = getelementptr inbounds double, double* %72, i64 2
%75 = bitcast double* %74 to <2 x double>*
store <2 x double> %71, <2 x double>* %75
%76 = or i64 %64, 4
%77 = getelementptr inbounds double, double* %52, i64 %76
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = getelementptr inbounds double, double* %77, i64 2
%81 = bitcast double* %80 to <2 x double>*
%82 = load <2 x double>, <2 x double>* %81
%83 = getelementptr inbounds double, double* %55, i64 %76
%84 = bitcast double* %83 to <2 x double>*
store <2 x double> %79, <2 x double>* %84
%85 = getelementptr inbounds double, double* %83, i64 2
%86 = bitcast double* %85 to <2 x double>*
store <2 x double> %82, <2 x double>* %86
%87 = or i64 %64, 8
%88 = getelementptr inbounds double, double* %52, i64 %87
%89 = bitcast double* %88 to <2 x double>*
%90 = load <2 x double>, <2 x double>* %89
%91 = getelementptr inbounds double, double* %88, i64 2
%92 = bitcast double* %91 to <2 x double>*
%93 = load <2 x double>, <2 x double>* %92
%94 = getelementptr inbounds double, double* %55, i64 %87
%95 = bitcast double* %94 to <2 x double>*
store <2 x double> %90, <2 x double>* %95
%96 = getelementptr inbounds double, double* %94, i64 2
%97 = bitcast double* %96 to <2 x double>*
store <2 x double> %93, <2 x double>* %97
%98 = or i64 %64, 12
%99 = getelementptr inbounds double, double* %52, i64 %98
%100 = bitcast double* %99 to <2 x double>*
%101 = load <2 x double>, <2 x double>* %100
%102 = getelementptr inbounds double, double* %99, i64 2
%103 = bitcast double* %102 to <2 x double>*
%104 = load <2 x double>, <2 x double>* %103
%105 = getelementptr inbounds double, double* %55, i64 %98
%106 = bitcast double* %105 to <2 x double>*
store <2 x double> %101, <2 x double>* %106
%107 = getelementptr inbounds double, double* %105, i64 2
%108 = bitcast double* %107 to <2 x double>*
store <2 x double> %104, <2 x double>* %108
%109 = add nuw i64 %64, 16
%110 = add nuw i64 %65, 4
%111 = icmp eq i64 %110, %34
br i1 %111, label %112, label %63
112: ; preds = %63, %62
%113 = phi i64 [ 0, %62 ], [ %109, %63 ]
br i1 %35, label %130, label %114
114: ; preds = %112, %114
%115 = phi i64 [ %127, %114 ], [ %113, %112 ]
%116 = phi i64 [ %128, %114 ], [ 0, %112 ]
%117 = getelementptr inbounds double, double* %52, i64 %115
%118 = bitcast double* %117 to <2 x double>*
%119 = load <2 x double>, <2 x double>* %118
%120 = getelementptr inbounds double, double* %117, i64 2
%121 = bitcast double* %120 to <2 x double>*
%122 = load <2 x double>, <2 x double>* %121
%123 = getelementptr inbounds double, double* %55, i64 %115
%124 = bitcast double* %123 to <2 x double>*
store <2 x double> %119, <2 x double>* %124
%125 = getelementptr inbounds double, double* %123, i64 2
%126 = bitcast double* %125 to <2 x double>*
store <2 x double> %122, <2 x double>* %126
%127 = add nuw i64 %115, 4
%128 = add i64 %116, 1
%129 = icmp eq i64 %128, %32
br i1 %129, label %130, label %114
130: ; preds = %114, %112
br i1 %36, label %166, label %131
131: ; preds = %56, %51, %130
%132 = phi i64 [ 0, %56 ], [ 0, %51 ], [ %31, %130 ]
%133 = xor i64 %132, -1
%134 = add nsw i64 %133, %25
br i1 %38, label %144, label %135
135: ; preds = %131, %135
%136 = phi i64 [ %141, %135 ], [ %132, %131 ]
%137 = phi i64 [ %142, %135 ], [ 0, %131 ]
%138 = getelementptr inbounds double, double* %52, i64 %136
%139 = load double, double* %138
%140 = getelementptr inbounds double, double* %55, i64 %136
store double %139, double* %140
%141 = add nuw nsw i64 %136, 1
%142 = add i64 %137, 1
%143 = icmp eq i64 %142, %37
br i1 %143, label %144, label %135
144: ; preds = %135, %131
%145 = phi i64 [ %132, %131 ], [ %141, %135 ]
%146 = icmp ult i64 %134, 3
br i1 %146, label %166, label %147
147: ; preds = %144, %147
%148 = phi i64 [ %164, %147 ], [ %145, %144 ]
%149 = getelementptr inbounds double, double* %52, i64 %148
%150 = load double, double* %149
%151 = getelementptr inbounds double, double* %55, i64 %148
store double %150, double* %151
%152 = add nuw nsw i64 %148, 1
%153 = getelementptr inbounds double, double* %52, i64 %152
%154 = load double, double* %153
%155 = getelementptr inbounds double, double* %55, i64 %152
store double %154, double* %155
%156 = add nuw nsw i64 %148, 2
%157 = getelementptr inbounds double, double* %52, i64 %156
%158 = load double, double* %157
%159 = getelementptr inbounds double, double* %55, i64 %156
store double %158, double* %159
%160 = add nuw nsw i64 %148, 3
%161 = getelementptr inbounds double, double* %52, i64 %160
%162 = load double, double* %161
%163 = getelementptr inbounds double, double* %55, i64 %160
store double %162, double* %163
%164 = add nuw nsw i64 %148, 4
%165 = icmp eq i64 %164, %25
br i1 %165, label %166, label %147
166: ; preds = %144, %147, %130, %47
%167 = add nuw nsw i64 %48, 1
%168 = icmp eq i64 %167, %24
br i1 %168, label %169, label %47
169: ; preds = %166, %21
ret void
}