#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char *calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void writeStats_multifile(char **GenoFileName, char *fileName, double *matrix,
                          double *mAF, double *SNPSd, double *miss, int nrow,
                          int nstat, int nfile, int nSNP_file[64],
                          double threshold) {
  FILE *resultFile;
  FILE *topFile;
  char *topfileName = calloc(256, sizeof(char));
  strcpy(topfileName, topfileName);
  strcat(topfileName, ".top");
  int i, j, file, start = 0;
  char *filestat = malloc(sizeof(char) * 256);
  for (file = 0; file < nfile; file++) {
    strcpy(filestat, fileName);
    char *ext = malloc(sizeof(char) * 10);
    sprintf(ext, "_file%d", file + 1);
    strcat(filestat, ext);
    printf("Opening file %s...\n", filestat);
    strcpy(topfileName, filestat);
    strcat(topfileName, ".top");
    printf("Opening file %s...\n", topfileName);
    if ((resultFile = fopen(filestat, "w")) == NULL)
      printf("ERROR, unable to open %s\n", filestat);
    if ((topFile = fopen(topfileName, "w")) == NULL)
      printf("ERROR, unable to open %s\n", topfileName);
    fprintf(resultFile, "h\'\taxis\th\tmAF\tmiss\n");
    fprintf(topFile, "snp\tPC\tscore\n");
    for (i = start; i < start + nSNP_file[file]; i++) {
      for (j = 0; j < nstat; j++) {
        if (j != 1)
          fprintf(resultFile, "%f ", matrix[i * nstat + j]);
      }
      fprintf(resultFile, "%f %f\n", mAF[i], miss[i]);
      if (matrix[i * nstat] > threshold) {
        fprintf(topFile, "%d %d %f\n", i - start + 1,
                (int)matrix[i * nstat + 2], matrix[i * nstat]);
      }
    }
    start += nSNP_file[file];
    fclose(resultFile);
    fclose(topFile);
  }
}


x86 assembly (clang, -O0):
<writeStats_multifile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x28(%rbp),%rax
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    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movsd  %xmm0,-0x38(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   10a0 <strcat@plt>
movl   $0x0,-0x60(%rbp)
mov    $0x100,%edi
call   1080 <malloc@plt>
mov    %rax,-0x68(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    145e <writeStats_multifile+0x2ce>
mov    -0x68(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    $0xa,%edi
call   1080 <malloc@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x5c(%rbp),%edx
add    $0x1,%edx
lea    0xdbf(%rip),%rsi
call   10b0 <sprintf@plt>
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x68(%rbp),%rsi
lea    0xdaa(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x50(%rbp),%rdi
lea    0xd80(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x50(%rbp),%rsi
lea    0xd7d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x68(%rbp),%rdi
lea    0xd81(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    12c3 <writeStats_multifile+0x133>
mov    -0x68(%rbp),%rsi
lea    0xd65(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
lea    0xd53(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    12f1 <writeStats_multifile+0x161>
mov    -0x50(%rbp),%rsi
lea    0xd37(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x60(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x60(%rbp),%ecx
mov    0x28(%rbp),%rdx
movslq -0x5c(%rbp),%rsi
add    (%rdx,%rsi,4),%ecx
cmp    %ecx,%eax
jge    142d <writeStats_multifile+0x29d>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    138c <writeStats_multifile+0x1fc>
cmpl   $0x1,-0x58(%rbp)
je     1379 <writeStats_multifile+0x1e9>
mov    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x54(%rbp),%ecx
imul   0x18(%rbp),%ecx
add    -0x58(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xced(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    137e <writeStats_multifile+0x1ee>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    133b <writeStats_multifile+0x1ab>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xcb2(%rip),%rsi
mov    $0x2,%al
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    -0x54(%rbp),%ecx
imul   0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    141a <writeStats_multifile+0x28a>
mov    -0x48(%rbp),%rdi
mov    -0x54(%rbp),%edx
sub    -0x60(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
mov    -0x54(%rbp),%ecx
imul   0x18(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
cvttsd2si (%rax,%rcx,8),%ecx
mov    -0x18(%rbp),%rax
mov    -0x54(%rbp),%esi
imul   0x18(%rbp),%esi
movslq %esi,%rsi
movsd  (%rax,%rsi,8),%xmm0
lea    0xc57(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    141f <writeStats_multifile+0x28f>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    131b <writeStats_multifile+0x18b>
mov    0x28(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x60(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    120e <writeStats_multifile+0x7e>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeStats_multifile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
movsd  %xmm0,0x88(%rsp)
mov    %r9,0x80(%rsp)
mov    %rcx,0x78(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,0x50(%rsp)
mov    0xe0(%rsp),%ebp
mov    $0x100,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
lea    0xe04(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strcat@plt>
mov    $0x100,%edi
call   1080 <malloc@plt>
test   %ebp,%ebp
jle    14f9 <writeStats_multifile+0x359>
mov    %rax,%r13
mov    0xd8(%rsp),%eax
cltq
mov    %ebp,%ecx
mov    %rcx,0x48(%rsp)
mov    %eax,%ecx
mov    %rcx,0x68(%rsp)
lea    -0x1(%rax),%ecx
mov    %ecx,0x24(%rsp)
mov    %rax,0x28(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x70(%rsp)
xor    %ebx,%ebx
lea    0xdcf(%rip),%r12
movl   $0x0,0xc(%rsp)
mov    %r14,0x40(%rsp)
mov    %r13,0x38(%rsp)
jmp    12ad <writeStats_multifile+0x10d>
cs nopw 0x0(%rax,%rax,1)
mov    %eax,0xc(%rsp)
mov    0x40(%rsp),%r14
mov    0x38(%rsp),%r13
lea    0xd9c(%rip),%r12
mov    0x18(%rsp),%rbx
mov    %rbp,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    0x58(%rsp),%rax
mov    %rax,%rbx
cmp    0x48(%rsp),%rax
je     14f9 <writeStats_multifile+0x359>
mov    %r13,%rdi
mov    0x50(%rsp),%rsi
call   1030 <strcpy@plt>
mov    $0xa,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
lea    0x1(%rbx),%rdx
mov    %rax,%rdi
lea    0xd30(%rip),%rsi
mov    %rdx,0x58(%rsp)
call   10b0 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   10a0 <strcat@plt>
lea    0xd1c(%rip),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
lea    0xcef(%rip),%rsi
call   10a0 <strcat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1090 <fopen@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1343 <writeStats_multifile+0x1a3>
lea    0xce8(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1365 <writeStats_multifile+0x1c5>
lea    0xcc6(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    $0x13,%esi
mov    $0x1,%edx
lea    0xcc7(%rip),%rdi
mov    %rbp,%rcx
call   10c0 <fwrite@plt>
mov    $0xd,%esi
mov    $0x1,%edx
lea    0xcc2(%rip),%rdi
mov    %r15,0x18(%rsp)
mov    %r15,%rcx
call   10c0 <fwrite@plt>
mov    0xe8(%rsp),%rax
mov    (%rax,%rbx,4),%eax
test   %eax,%eax
jle    14f0 <writeStats_multifile+0x350>
mov    %rbx,0x90(%rsp)
mov    $0x1,%ecx
mov    0xc(%rsp),%eax
sub    %eax,%ecx
mov    %rcx,0x60(%rsp)
movslq %eax,%r13
mov    0x28(%rsp),%rax
imul   %r13,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%rbx
jmp    140e <writeStats_multifile+0x26e>
xchg   %ax,%ax
add    $0x1,%r13
mov    0xe8(%rsp),%rax
mov    0x90(%rsp),%rcx
movslq (%rax,%rcx,4),%rcx
movslq 0xc(%rsp),%rax
add    %rcx,%rax
add    0x70(%rsp),%rbx
cmp    %rax,%r13
jge    1270 <writeStats_multifile+0xd0>
mov    %r13,%rcx
mov    0x28(%rsp),%rax
imul   %rax,%rcx
mov    %rcx,0x30(%rsp)
test   %eax,%eax
lea    0xc37(%rip),%r15
mov    0x68(%rsp),%r14
jle    147c <writeStats_multifile+0x2dc>
mov    0x10(%rsp),%rax
mov    0x30(%rsp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
cmpl   $0x2,0x24(%rsp)
jb     147c <writeStats_multifile+0x2dc>
mov    $0x2,%r12d
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%r12,8),%xmm0
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    1460 <writeStats_multifile+0x2c0>
mov    0x78(%rsp),%rax
movsd  (%rax,%r13,8),%xmm0
mov    0x80(%rsp),%rax
movsd  (%rax,%r13,8),%xmm1
mov    %rbp,%rdi
lea    0xbc4(%rip),%rsi
mov    $0x2,%al
call   1070 <fprintf@plt>
mov    0x10(%rsp),%rax
mov    0x30(%rsp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd 0x88(%rsp),%xmm0
jbe    13e0 <writeStats_multifile+0x240>
mov    0x60(%rsp),%rax
lea    (%rax,%r13,1),%edx
mov    0x10(%rsp),%rax
cvttsd2si 0x10(%rax,%rcx,8),%ecx
mov    0x18(%rsp),%rdi
lea    0xb86(%rip),%rsi
mov    $0x1,%al
call   1070 <fprintf@plt>
jmp    13e0 <writeStats_multifile+0x240>
add    %eax,0xc(%rsp)
jmp    1285 <writeStats_multifile+0xe5>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".top\00"
@.str.1 = [8 x i8] c"_file%d\00"
@.str.2 = [20 x i8] c"Opening file %s...\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [26 x i8] c"ERROR, unable to open %s\0A\00"
@.str.5 = [20 x i8] c"h'\09axis\09h\09mAF\09miss\0A\00"
@.str.6 = [14 x i8] c"snp\09PC\09score\0A\00"
@.str.7 = [4 x i8] c"%f \00"
@.str.8 = [7 x i8] c"%f %f\0A\00"
@.str.9 = [10 x i8] c"%d %d %f\0A\00"
define void @writeStats_multifile(i8** %0, i8* %1, double* %2, double* %3, double* %4, double* %5, i32 %6, i32 %7, i32 %8, i32* %9, double %10) {
%12 = alloca i8**
%13 = alloca i8*
%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 double
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i8*
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i8*
%31 = alloca i8*
store i8** %0, i8*** %12
store i8* %1, i8** %13
store double* %2, double** %14
store double* %3, double** %15
store double* %4, double** %16
store double* %5, double** %17
store i32 %6, i32* %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32* %9, i32** %21
store double %10, double* %22
%32 = call i8* @calloc(i32 256, i32 1)
store i8* %32, i8** %25
%33 = load i8*, i8** %25
%34 = load i8*, i8** %25
%35 = call i32 @strcpy(i8* %33, i8* %34)
%36 = load i8*, i8** %25
%37 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %29
%38 = call i8* @malloc(i32 256)
store i8* %38, i8** %30
store i32 0, i32* %28
br label %39
39: ; preds = %178, %11
%40 = load i32, i32* %28
%41 = load i32, i32* %20
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %181
43: ; preds = %39
%44 = load i8*, i8** %30
%45 = load i8*, i8** %13
%46 = call i32 @strcpy(i8* %44, i8* %45)
%47 = call i8* @malloc(i32 10)
store i8* %47, i8** %31
%48 = load i8*, i8** %31
%49 = load i32, i32* %28
%50 = add nsw i32 %49, 1
%51 = call i32 @sprintf(i8* %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = load i8*, i8** %30
%53 = load i8*, i8** %31
%54 = call i32 @strcat(i8* %52, i8* %53)
%55 = load i8*, i8** %30
%56 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** %25
%58 = load i8*, i8** %30
%59 = call i32 @strcpy(i8* %57, i8* %58)
%60 = load i8*, i8** %25
%61 = call i32 @strcat(i8* %60, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%62 = load i8*, i8** %25
%63 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %62)
%64 = load i8*, i8** %30
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %65, i32** %23
%66 = icmp eq i32* %65, null
br i1 %66, label %67, label %70
67: ; preds = %43
%68 = load i8*, i8** %30
%69 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %68)
br label %70
70: ; preds = %67, %43
%71 = load i8*, i8** %25
%72 = call i32* @fopen(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %72, i32** %24
%73 = icmp eq i32* %72, null
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = load i8*, i8** %25
%76 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %75)
br label %77
77: ; preds = %74, %70
%78 = load i32*, i32** %23
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%80 = load i32*, i32** %24
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%82 = load i32, i32* %29
store i32 %82, i32* %26
br label %83
83: ; preds = %163, %77
%84 = load i32, i32* %26
%85 = load i32, i32* %29
%86 = load i32*, i32** %21
%87 = load i32, i32* %28
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i32, i32* %86, i64 %88
%90 = load i32, i32* %89
%91 = add nsw i32 %85, %90
%92 = icmp slt i32 %84, %91
br i1 %92, label %93, label %166
93: ; preds = %83
store i32 0, i32* %27
br label %94
94: ; preds = %114, %93
%95 = load i32, i32* %27
%96 = load i32, i32* %19
%97 = icmp slt i32 %95, %96
br i1 %97, label %98, label %117
98: ; preds = %94
%99 = load i32, i32* %27
%100 = icmp ne i32 %99, 1
br i1 %100, label %101, label %113
101: ; preds = %98
%102 = load i32*, i32** %23
%103 = load double*, double** %14
%104 = load i32, i32* %26
%105 = load i32, i32* %19
%106 = mul nsw i32 %104, %105
%107 = load i32, i32* %27
%108 = add nsw i32 %106, %107
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds double, double* %103, i64 %109
%111 = load double, double* %110
%112 = call i32 (i32*, i8*, ...) @fprintf(i32* %102, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %111)
br label %113
113: ; preds = %101, %98
br label %114
114: ; preds = %113
%115 = load i32, i32* %27
%116 = add nsw i32 %115, 1
store i32 %116, i32* %27
br label %94
117: ; preds = %94
%118 = load i32*, i32** %23
%119 = load double*, double** %15
%120 = load i32, i32* %26
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds double, double* %119, i64 %121
%123 = load double, double* %122
%124 = load double*, double** %17
%125 = load i32, i32* %26
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds double, double* %124, i64 %126
%128 = load double, double* %127
%129 = call i32 (i32*, i8*, ...) @fprintf(i32* %118, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), double %123, double %128)
%130 = load double*, double** %14
%131 = load i32, i32* %26
%132 = load i32, i32* %19
%133 = mul nsw i32 %131, %132
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %130, i64 %134
%136 = load double, double* %135
%137 = load double, double* %22
%138 = fcmp ogt double %136, %137
br i1 %138, label %139, label %162
139: ; preds = %117
%140 = load i32*, i32** %24
%141 = load i32, i32* %26
%142 = load i32, i32* %29
%143 = sub nsw i32 %141, %142
%144 = add nsw i32 %143, 1
%145 = load double*, double** %14
%146 = load i32, i32* %26
%147 = load i32, i32* %19
%148 = mul nsw i32 %146, %147
%149 = add nsw i32 %148, 2
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds double, double* %145, i64 %150
%152 = load double, double* %151
%153 = fptosi double %152 to i32
%154 = load double*, double** %14
%155 = load i32, i32* %26
%156 = load i32, i32* %19
%157 = mul nsw i32 %155, %156
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %154, i64 %158
%160 = load double, double* %159
%161 = call i32 (i32*, i8*, ...) @fprintf(i32* %140, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %144, i32 %153, double %160)
br label %162
162: ; preds = %139, %117
br label %163
163: ; preds = %162
%164 = load i32, i32* %26
%165 = add nsw i32 %164, 1
store i32 %165, i32* %26
br label %83
166: ; preds = %83
%167 = load i32*, i32** %21
%168 = load i32, i32* %28
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds i32, i32* %167, i64 %169
%171 = load i32, i32* %170
%172 = load i32, i32* %29
%173 = add nsw i32 %172, %171
store i32 %173, i32* %29
%174 = load i32*, i32** %23
%175 = call i32 @fclose(i32* %174)
%176 = load i32*, i32** %24
%177 = call i32 @fclose(i32* %176)
br label %178
178: ; preds = %166
%179 = load i32, i32* %28
%180 = add nsw i32 %179, 1
store i32 %180, i32* %28
br label %39
181: ; preds = %39
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".top\00"
@.str.1 = [8 x i8] c"_file%d\00"
@.str.2 = [20 x i8] c"Opening file %s...\0A\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [26 x i8] c"ERROR, unable to open %s\0A\00"
@.str.5 = [20 x i8] c"h'\09axis\09h\09mAF\09miss\0A\00"
@.str.6 = [14 x i8] c"snp\09PC\09score\0A\00"
@.str.7 = [4 x i8] c"%f \00"
@.str.8 = [7 x i8] c"%f %f\0A\00"
@.str.9 = [10 x i8] c"%d %d %f\0A\00"
define void @writeStats_multifile(i8** nocapture readnone %0, i8* %1, double* nocapture %2, double* nocapture %3, double* nocapture readnone %4, double* nocapture %5, i32 %6, i32 %7, i32 %8, i32* nocapture %9, double %10) {
%12 = tail call dereferenceable_or_null(256) i8* @calloc(i32 256, i32 1)
%13 = tail call i32 @strcpy(i8* %12, i8* %12)
%14 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%16 = icmp sgt i32 %8, 0
br i1 %16, label %17, label %99
17: ; preds = %11
%18 = icmp sgt i32 %7, 0
%19 = sext i32 %7 to i64
%20 = zext i32 %8 to i64
%21 = zext i32 %7 to i64
%22 = add i32 %7, -1
%23 = icmp ult i32 %22, 2
br label %24
24: ; preds = %17, %94
%25 = phi i64 [ 0, %17 ], [ %29, %94 ]
%26 = phi i32 [ 0, %17 ], [ %95, %94 ]
%27 = tail call i32 @strcpy(i8* %15, i8* %1)
%28 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%29 = add nuw nsw i64 %25, 1
%30 = trunc i64 %29 to i32
%31 = tail call i32 @sprintf(i8* dereferenceable(1) %28, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = tail call i32 @strcat(i8* %15, i8* %28)
%33 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%34 = tail call i32 @strcpy(i8* %12, i8* %15)
%35 = tail call i32 @strcat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%36 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%37 = tail call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %41
39: ; preds = %24
%40 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %41
41: ; preds = %39, %24
%42 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %12)
br label %46
46: ; preds = %44, %41
%47 = tail call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i64 19, i64 1, i32* %37)
%48 = tail call i64 @fwrite(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i64 13, i64 1, i32* %42)
%49 = getelementptr inbounds i32, i32* %9, i64 %25
%50 = load i32, i32* %49
%51 = add nsw i32 %50, %26
%52 = icmp sgt i32 %50, 0
br i1 %52, label %53, label %94
53: ; preds = %46
%54 = sub i32 1, %26
%55 = sext i32 %26 to i64
br label %56
56: ; preds = %53, %88
%57 = phi i64 [ %55, %53 ], [ %89, %88 ]
%58 = mul nsw i64 %57, %19
br i1 %18, label %59, label %71
59: ; preds = %56
%60 = getelementptr inbounds double, double* %2, i64 %58
%61 = load double, double* %60
%62 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %61)
br i1 %23, label %71, label %63
63: ; preds = %59, %63
%64 = phi i64 [ %69, %63 ], [ 2, %59 ]
%65 = add nsw i64 %64, %58
%66 = getelementptr inbounds double, double* %2, i64 %65
%67 = load double, double* %66
%68 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %67)
%69 = add nuw nsw i64 %64, 1
%70 = icmp eq i64 %69, %21
br i1 %70, label %71, label %63
71: ; preds = %63, %59, %56
%72 = getelementptr inbounds double, double* %3, i64 %57
%73 = load double, double* %72
%74 = getelementptr inbounds double, double* %5, i64 %57
%75 = load double, double* %74
%76 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), double %73, double %75)
%77 = getelementptr inbounds double, double* %2, i64 %58
%78 = load double, double* %77
%79 = fcmp ogt double %78, %10
br i1 %79, label %80, label %88
80: ; preds = %71
%81 = trunc i64 %57 to i32
%82 = add i32 %54, %81
%83 = add nsw i64 %58, 2
%84 = getelementptr inbounds double, double* %2, i64 %83
%85 = load double, double* %84
%86 = fptosi double %85 to i32
%87 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %82, i32 %86, double %78)
br label %88
88: ; preds = %71, %80
%89 = add nsw i64 %57, 1
%90 = load i32, i32* %49
%91 = add nsw i32 %90, %26
%92 = sext i32 %91 to i64
%93 = icmp slt i64 %89, %92
br i1 %93, label %56, label %94
94: ; preds = %88, %46
%95 = phi i32 [ %51, %46 ], [ %91, %88 ]
%96 = tail call i32 @fclose(i32* %37)
%97 = tail call i32 @fclose(i32* %42)
%98 = icmp eq i64 %29, %20
br i1 %98, label %99, label %24
99: ; preds = %94, %11
ret void
}