int initializeVariables__f(double **U, double **Sigma, double **V,
                           double **SNPSd, double **Cov, double **miss,
                           double **mAF, int K, int nSNP, int nIND) {
  int i, j;
  init_random();
  *Sigma = calloc(K, sizeof(double));
  *U = malloc(sizeof(double) * nSNP * K);
  for (i = 0; i < K; i++) {
    for (j = 0; j < nSNP; j++) {
      *(*(U) + i * nSNP + j) = rand_normal(0, 1);
    }
  }
  *SNPSd = malloc(sizeof(double) * nSNP);
  *V = calloc(K * nIND, sizeof(double));
  *Cov = calloc(nIND * nIND, sizeof(double));
  for (i = 0; i < K * nIND; i++)
    *(*(V) + i) = rand_normal_r();
  *miss = calloc(nSNP, sizeof(double));
  *mAF = calloc(nSNP, sizeof(double));
  return 0;
}


x86 assembly (clang, -O0):
<initializeVariables__f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x0,%al
call   1040 <init_random@plt>
movslq 0x18(%rbp),%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movslq 0x20(%rbp),%rdi
shl    $0x3,%rdi
movslq 0x18(%rbp),%rax
imul   %rax,%rdi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1235 <initializeVariables__f+0xe5>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    1222 <initializeVariables__f+0xd2>
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <rand_normal@plt>
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x34(%rbp),%ecx
imul   0x20(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x38(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11d5 <initializeVariables__f+0x85>
jmp    1227 <initializeVariables__f+0xd7>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c2 <initializeVariables__f+0x72>
movslq 0x20(%rbp),%rdi
shl    $0x3,%rdi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    0x18(%rbp),%eax
imul   0x28(%rbp),%eax
movslq %eax,%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    0x28(%rbp),%eax
imul   0x28(%rbp),%eax
movslq %eax,%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x18(%rbp),%ecx
imul   0x28(%rbp),%ecx
cmp    %ecx,%eax
jge    12ca <initializeVariables__f+0x17a>
mov    $0x0,%al
call   1030 <rand_normal_r@plt>
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    128f <initializeVariables__f+0x13f>
movslq 0x20(%rbp),%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
movslq 0x20(%rbp),%rdi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initializeVariables__f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x30(%rsp)
mov    %r8,0x18(%rsp)
mov    %rcx,0x10(%rsp)
mov    %rdx,0x28(%rsp)
mov    %rsi,%rbp
mov    %rdi,%r12
movslq 0x78(%rsp),%rbx
xor    %eax,%eax
call   1040 <init_random@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
call   1050 <calloc@plt>
mov    %rax,0x0(%rbp)
movslq 0x80(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x0(,%rax,8),%rdi
mov    %rdi,0x8(%rsp)
imul   %rbx,%rdi
call   1060 <malloc@plt>
mov    %rax,(%r12)
mov    %rbx,%rax
mov    %rbx,(%rsp)
test   %rbx,%rbx
jle    123b <initializeVariables__f+0xeb>
mov    (%rsp),%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11ee <initializeVariables__f+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
add    0x8(%rsp),%rbp
cmp    %r13,%rbx
je     123b <initializeVariables__f+0xeb>
cmpl   $0x0,0x80(%rsp)
jle    11e0 <initializeVariables__f+0x90>
mov    0x80(%rsp),%r14d
mov    %rbp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <rand_normal@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r12),%rax
movsd  %xmm0,(%rax,%r15,1)
add    $0x8,%r15
add    $0xffffffffffffffff,%r14
jne    1210 <initializeVariables__f+0xc0>
jmp    11e0 <initializeVariables__f+0x90>
mov    0x70(%rsp),%r15
mov    0x8(%rsp),%rdi
call   1060 <malloc@plt>
mov    0x10(%rsp),%rcx
mov    %rax,(%rcx)
mov    0x88(%rsp),%ebp
mov    %ebp,%ebx
imul   (%rsp),%ebx
movslq %ebx,%r12
mov    $0x8,%esi
mov    %r12,%rdi
call   1050 <calloc@plt>
mov    0x28(%rsp),%r14
mov    %rax,(%r14)
imul   %ebp,%ebp
mov    $0x8,%esi
mov    %rbp,%rdi
call   1050 <calloc@plt>
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx)
test   %r12d,%r12d
jle    12bf <initializeVariables__f+0x16f>
mov    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rand_normal_r@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    (%r14),%rax
movsd  %xmm0,(%rax,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    12a0 <initializeVariables__f+0x150>
mov    $0x8,%esi
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <calloc@plt>
mov    0x30(%rsp),%rcx
mov    %rax,(%rcx)
mov    $0x8,%esi
mov    %rbx,%rdi
call   1050 <calloc@plt>
mov    %rax,(%r15)
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @initializeVariables__f(double** %0, double** %1, double** %2, double** %3, double** %4, double** %5, double** %6, i32 %7, i32 %8, i32 %9) {
%11 = alloca double**
%12 = alloca double**
%13 = alloca double**
%14 = alloca double**
%15 = alloca double**
%16 = alloca double**
%17 = alloca double**
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store double** %0, double*** %11
store double** %1, double*** %12
store double** %2, double*** %13
store double** %3, double*** %14
store double** %4, double*** %15
store double** %5, double*** %16
store double** %6, double*** %17
store i32 %7, i32* %18
store i32 %8, i32* %19
store i32 %9, i32* %20
%23 = call i32 (...) @init_random()
%24 = load i32, i32* %18
%25 = sext i32 %24 to i64
%26 = call i8* @calloc(i64 %25, i64 8)
%27 = bitcast i8* %26 to double*
%28 = load double**, double*** %12
store double* %27, double** %28
%29 = load i32, i32* %19
%30 = sext i32 %29 to i64
%31 = mul i64 8, %30
%32 = load i32, i32* %18
%33 = sext i32 %32 to i64
%34 = mul i64 %31, %33
%35 = call i8* @malloc(i64 %34)
%36 = bitcast i8* %35 to double*
%37 = load double**, double*** %11
store double* %36, double** %37
store i32 0, i32* %21
br label %38
38: ; preds = %64, %10
%39 = load i32, i32* %21
%40 = load i32, i32* %18
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %67
42: ; preds = %38
store i32 0, i32* %22
br label %43
43: ; preds = %60, %42
%44 = load i32, i32* %22
%45 = load i32, i32* %19
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %63
47: ; preds = %43
%48 = call i32 (i32, i32, ...) bitcast (i32 (...)* @rand_normal to i32 (i32, i32, ...)*)(i32 0, i32 1)
%49 = sitofp i32 %48 to double
%50 = load double**, double*** %11
%51 = load double*, double** %50
%52 = load i32, i32* %21
%53 = load i32, i32* %19
%54 = mul nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %51, i64 %55
%57 = load i32, i32* %22
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
store double %49, double* %59
br label %60
60: ; preds = %47
%61 = load i32, i32* %22
%62 = add nsw i32 %61, 1
store i32 %62, i32* %22
br label %43
63: ; preds = %43
br label %64
64: ; preds = %63
%65 = load i32, i32* %21
%66 = add nsw i32 %65, 1
store i32 %66, i32* %21
br label %38
67: ; preds = %38
%68 = load i32, i32* %19
%69 = sext i32 %68 to i64
%70 = mul i64 8, %69
%71 = call i8* @malloc(i64 %70)
%72 = bitcast i8* %71 to double*
%73 = load double**, double*** %14
store double* %72, double** %73
%74 = load i32, i32* %18
%75 = load i32, i32* %20
%76 = mul nsw i32 %74, %75
%77 = sext i32 %76 to i64
%78 = call i8* @calloc(i64 %77, i64 8)
%79 = bitcast i8* %78 to double*
%80 = load double**, double*** %13
store double* %79, double** %80
%81 = load i32, i32* %20
%82 = load i32, i32* %20
%83 = mul nsw i32 %81, %82
%84 = sext i32 %83 to i64
%85 = call i8* @calloc(i64 %84, i64 8)
%86 = bitcast i8* %85 to double*
%87 = load double**, double*** %15
store double* %86, double** %87
store i32 0, i32* %21
br label %88
88: ; preds = %102, %67
%89 = load i32, i32* %21
%90 = load i32, i32* %18
%91 = load i32, i32* %20
%92 = mul nsw i32 %90, %91
%93 = icmp slt i32 %89, %92
br i1 %93, label %94, label %105
94: ; preds = %88
%95 = call i32 (...) @rand_normal_r()
%96 = sitofp i32 %95 to double
%97 = load double**, double*** %13
%98 = load double*, double** %97
%99 = load i32, i32* %21
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds double, double* %98, i64 %100
store double %96, double* %101
br label %102
102: ; preds = %94
%103 = load i32, i32* %21
%104 = add nsw i32 %103, 1
store i32 %104, i32* %21
br label %88
105: ; preds = %88
%106 = load i32, i32* %19
%107 = sext i32 %106 to i64
%108 = call i8* @calloc(i64 %107, i64 8)
%109 = bitcast i8* %108 to double*
%110 = load double**, double*** %16
store double* %109, double** %110
%111 = load i32, i32* %19
%112 = sext i32 %111 to i64
%113 = call i8* @calloc(i64 %112, i64 8)
%114 = bitcast i8* %113 to double*
%115 = load double**, double*** %17
store double* %114, double** %115
ret i32 0
}

LLVM IR (-O2):
define i32 @initializeVariables__f(double** nocapture %0, double** nocapture writeonly %1, double** nocapture %2, double** nocapture writeonly %3, double** nocapture writeonly %4, double** nocapture writeonly %5, double** nocapture writeonly %6, i32 %7, i32 %8, i32 %9) {
%11 = tail call i32 (...) @init_random()
%12 = sext i32 %7 to i64
%13 = tail call i8* @calloc(i64 %12, i64 8)
%14 = bitcast double** %1 to i8**
store i8* %13, i8** %14
%15 = sext i32 %8 to i64
%16 = shl nsw i64 %15, 3
%17 = mul i64 %16, %12
%18 = tail call i8* @malloc(i64 %17)
%19 = bitcast double** %0 to i8**
store i8* %18, i8** %19
%20 = icmp sgt i32 %7, 0
br i1 %20, label %21, label %41
21: ; preds = %10
%22 = icmp sgt i32 %8, 0
%23 = zext i32 %7 to i64
%24 = zext i32 %8 to i64
br label %25
25: ; preds = %21, %38
%26 = phi i64 [ 0, %21 ], [ %39, %38 ]
br i1 %22, label %27, label %38
27: ; preds = %25
%28 = mul nsw i64 %26, %15
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %36, %29 ]
%31 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @rand_normal to i32 (i32, i32, ...)*)(i32 0, i32 1)
%32 = sitofp i32 %31 to double
%33 = load double*, double** %0
%34 = getelementptr inbounds double, double* %33, i64 %28
%35 = getelementptr inbounds double, double* %34, i64 %30
store double %32, double* %35
%36 = add nuw nsw i64 %30, 1
%37 = icmp eq i64 %36, %24
br i1 %37, label %38, label %29
38: ; preds = %29, %25
%39 = add nuw nsw i64 %26, 1
%40 = icmp eq i64 %39, %23
br i1 %40, label %41, label %25
41: ; preds = %38, %10
%42 = tail call i8* @malloc(i64 %16)
%43 = bitcast double** %3 to i8**
store i8* %42, i8** %43
%44 = mul nsw i32 %9, %7
%45 = sext i32 %44 to i64
%46 = tail call i8* @calloc(i64 %45, i64 8)
%47 = bitcast double** %2 to i8**
store i8* %46, i8** %47
%48 = mul nsw i32 %9, %9
%49 = zext i32 %48 to i64
%50 = tail call i8* @calloc(i64 %49, i64 8)
%51 = bitcast double** %4 to i8**
store i8* %50, i8** %51
%52 = icmp sgt i32 %44, 0
br i1 %52, label %53, label %63
53: ; preds = %41
%54 = zext i32 %44 to i64
br label %55
55: ; preds = %53, %55
%56 = phi i64 [ 0, %53 ], [ %61, %55 ]
%57 = tail call i32 (...) @rand_normal_r()
%58 = sitofp i32 %57 to double
%59 = load double*, double** %2
%60 = getelementptr inbounds double, double* %59, i64 %56
store double %58, double* %60
%61 = add nuw nsw i64 %56, 1
%62 = icmp eq i64 %61, %54
br i1 %62, label %63, label %55
63: ; preds = %55, %41
%64 = tail call i8* @calloc(i64 %15, i64 8)
%65 = bitcast double** %5 to i8**
store i8* %64, i8** %65
%66 = tail call i8* @calloc(i64 %15, i64 8)
%67 = bitcast double** %6 to i8**
store i8* %66, i8** %67
ret i32 0
}