void load_fold(char *source_file, char *fold_file, int fold, double ***trainX,
               double **trainY, int *n_train, double ***testX, double **testY,
               int *n_test, int *n_features, double *train_rmse,
               double *test_rmse) {
  int i;
  double **all_data, **X, *Y;
  int n_rows, n_cols, n_feat;
  int *train_instances, *test_instances;
  all_data = read_values(source_file, &n_rows, &n_cols);
  n_feat = n_cols - 1;
  *n_features = n_feat;
  load_folds(fold_file, fold, n_rows, &train_instances, n_train,
             &test_instances, n_test);
  X = malloc(*n_train * sizeof(double *));
  X[0] = malloc(*n_train * n_feat * sizeof(double));
  Y = malloc(*n_train * sizeof(double));
  for (i = 0; i < *n_train; ++i) {
    X[i] = X[0] + (i * n_feat);
    memcpy(X[i], all_data[train_instances[i]], n_feat * sizeof(double));
    Y[i] = all_data[train_instances[i]][n_feat];
  }
  *trainX = X;
  *trainY = Y;
  X = malloc(*n_test * sizeof(double *));
  X[0] = malloc(*n_test * n_feat * sizeof(double));
  Y = malloc(*n_test * sizeof(double));
  for (i = 0; i < *n_test; ++i) {
    X[i] = X[0] + (i * n_feat);
    memcpy(X[i], all_data[test_instances[i]], n_feat * sizeof(double));
    Y[i] = all_data[test_instances[i]][n_feat];
  }
  *testX = X;
  *testY = Y;
  if (train_rmse)
    *train_rmse = compute_rmse(*trainY, *n_train);
  if (test_rmse)
    *test_rmse = compute_rmse(*testY, *n_test);
  free(test_instances);
  free(train_instances);
  free(all_data[0]);
  free(all_data);
}


x86 assembly (clang, -O0):
<load_fold>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x54(%rbp),%rsi
lea    -0x58(%rbp),%rdx
mov    $0x0,%al
call   1060 <read_values@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x58(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%ecx
mov    0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x54(%rbp),%edx
mov    -0x30(%rbp),%r8
mov    0x20(%rbp),%rax
lea    -0x68(%rbp),%rcx
lea    -0x70(%rbp),%r9
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <load_folds@plt>
mov    -0x30(%rbp),%rax
movslq (%rax),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
imul   -0x5c(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
movslq (%rax),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%rcx
cmp    (%rcx),%eax
jge    12d0 <load_fold+0x170>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdx
mov    -0x34(%rbp),%eax
imul   -0x5c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x40(%rbp),%rax
mov    -0x68(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x5c(%rbp),%rdx
shl    $0x3,%rdx
call   1070 <memcpy@plt>
mov    -0x40(%rbp),%rax
mov    -0x68(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%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    1239 <load_fold+0xd9>
mov    -0x48(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x50(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    0x20(%rbp),%rax
movslq (%rax),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    0x20(%rbp),%rax
mov    (%rax),%eax
imul   -0x5c(%rbp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
mov    %rcx,(%rax)
mov    0x20(%rbp),%rax
movslq (%rax),%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    13cc <load_fold+0x26c>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdx
mov    -0x34(%rbp),%eax
imul   -0x5c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x40(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x5c(%rbp),%rdx
shl    $0x3,%rdx
call   1070 <memcpy@plt>
mov    -0x40(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%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    1335 <load_fold+0x1d5>
mov    -0x48(%rbp),%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x50(%rbp),%rcx
mov    0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,0x30(%rbp)
je     140d <load_fold+0x2ad>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1040 <compute_rmse@plt>
cvtsi2sd %eax,%xmm0
mov    0x30(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,0x38(%rbp)
je     1438 <load_fold+0x2d8>
mov    0x18(%rbp),%rax
mov    (%rax),%rdi
mov    0x20(%rbp),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1040 <compute_rmse@plt>
cvtsi2sd %eax,%xmm0
mov    0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_fold>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%rbx
mov    %r8,0x38(%rsp)
mov    %rcx,0x50(%rsp)
mov    %edx,%r14d
mov    %rsi,%rbp
mov    0xa0(%rsp),%r15
lea    0x34(%rsp),%rsi
lea    0x30(%rsp),%rdx
xor    %eax,%eax
call   1060 <read_values@plt>
movslq %eax,%r13
movslq 0x30(%rsp),%r12
add    $0xffffffffffffffff,%r12
mov    0xa8(%rsp),%rax
mov    %r12d,(%rax)
mov    0x34(%rsp),%edx
mov    %r15,(%rsp)
lea    0x28(%rsp),%rcx
lea    0x20(%rsp),%r9
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %rbx,%r8
xor    %eax,%eax
call   1050 <load_folds@plt>
mov    %rbx,0x40(%rsp)
movslq (%rbx),%rbx
lea    0x0(,%rbx,8),%rbp
mov    %rbp,%rdi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    %r12,%rdi
imul   %rbx,%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    %rax,(%r14)
mov    %rbp,%rdi
call   1080 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %r12,0x48(%rsp)
movslq %r12d,%rax
mov    %rax,0x18(%rsp)
test   %rbx,%rbx
jle    129a <load_fold+0x13a>
mov    0x18(%rsp),%rax
lea    0x0(,%rax,8),%r12
mov    $0x1,%ebp
mov    0x28(%rsp),%rax
xor    %ebx,%ebx
nopl   0x0(%rax)
add    %rbx,%r15
mov    %r15,-0x8(%r14,%rbp,8)
movslq -0x4(%rax,%rbp,4),%rax
mov    0x0(%r13,%rax,8),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
call   1070 <memcpy@plt>
mov    0x28(%rsp),%rax
movslq -0x4(%rax,%rbp,4),%rcx
mov    0x0(%r13,%rcx,8),%rcx
mov    0x18(%rsp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    0x10(%rsp),%rcx
movsd  %xmm0,-0x8(%rcx,%rbp,8)
mov    0x40(%rsp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rbp
jge    129a <load_fold+0x13a>
mov    (%r14),%r15
add    %r12,%rbx
add    $0x1,%rbp
jmp    1240 <load_fold+0xe0>
mov    0x50(%rsp),%rax
mov    %r14,(%rax)
mov    0x38(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    %rcx,(%rax)
mov    0xa0(%rsp),%rax
movslq (%rax),%rbp
lea    0x0(,%rbp,8),%r14
mov    %r14,%rdi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%eax
imul   0x48(%rsp),%eax
movslq %eax,%rdi
shl    $0x3,%rdi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,(%r12)
mov    %r14,%rdi
call   1080 <malloc@plt>
mov    %rax,0x10(%rsp)
test   %rbp,%rbp
jle    137f <load_fold+0x21f>
mov    0x18(%rsp),%rax
lea    0x0(,%rax,8),%rbp
mov    $0x1,%r14d
mov    0x20(%rsp),%rax
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
add    %r15,%rbx
mov    %rbx,-0x8(%r12,%r14,8)
movslq -0x4(%rax,%r14,4),%rax
mov    0x0(%r13,%rax,8),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1070 <memcpy@plt>
mov    0x20(%rsp),%rax
movslq -0x4(%rax,%r14,4),%rcx
mov    0x0(%r13,%rcx,8),%rcx
mov    0x18(%rsp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    0x10(%rsp),%rcx
movsd  %xmm0,-0x8(%rcx,%r14,8)
mov    0xa0(%rsp),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%r14
jge    137f <load_fold+0x21f>
mov    (%r12),%rbx
add    %rbp,%r15
add    $0x1,%r14
jmp    1320 <load_fold+0x1c0>
mov    0xb8(%rsp),%r14
mov    0x90(%rsp),%rax
mov    %r12,(%rax)
mov    0x98(%rsp),%rbp
mov    0x10(%rsp),%rax
mov    %rax,0x0(%rbp)
mov    0xb0(%rsp),%rbx
test   %rbx,%rbx
je     13d1 <load_fold+0x271>
mov    0x38(%rsp),%rax
mov    (%rax),%rdi
mov    0x40(%rsp),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1040 <compute_rmse@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rbx)
test   %r14,%r14
je     13f7 <load_fold+0x297>
mov    0x0(%rbp),%rdi
mov    0xa0(%rsp),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   1040 <compute_rmse@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r14)
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0x0(%r13),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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