#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 */
void *calloc(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void writeResults(char *fileName, double *matrix, double *BF, double *PO,
                  int nSNP, int K, double err, double alpha, double *C2,
                  double *sigma2_F, int *order_v) {
  int i, j;
  int nrow = nSNP, ncol = K + 1;
  double *qval = calloc(nSNP, sizeof(double));
  FILE *resultFile;
  char *fileName_ext = calloc(256, sizeof(char));
  strcpy(fileName_ext, fileName);
  strcat(fileName_ext, ".stats");
  printf("Opening file %s...\n", fileName_ext);
  if ((resultFile = fopen(fileName_ext, "w")) == NULL)
    printf("ERROR, unable to open %s\n", fileName_ext);
  fprintf(resultFile, "error: %f\n", err);
  fprintf(resultFile, "pi: %f\n", alpha);
  fprintf(resultFile, "c2: ");
  for (i = 0; i < K; i++)
    fprintf(resultFile, "%f ", C2[order_v[i]]);
  fprintf(resultFile, "\n");
  fprintf(resultFile, "rho2:\n");
  for (i = 0; i < ncol - 1; i++)
    fprintf(resultFile, "%lf ", sigma2_F[order_v[i]]);
  fclose(resultFile);
  printf("Opening file %s...\n", fileName);
  if ((resultFile = fopen(fileName, "w")) == NULL)
    printf("ERROR, unable to open %s\n", fileName);
  fprintf(resultFile, "logBF\tlogPO\t");
  for (i = 1; i < ncol; i++)
    fprintf(resultFile, "P(Z = %d|O)\t", i);
  fprintf(resultFile, "\n");
  for (i = 0; i < nrow; i++) {
    double c = .0;
    for (j = 1; j < ncol; j++)
      c += matrix[i * ncol + j];
    fprintf(resultFile, "%f\t%f\t", BF[i], PO[i]);
    for (j = 1; j < ncol; j++) {
      fprintf(resultFile, "%f\t", matrix[i * ncol + order_v[j - 1] + 1] / c);
    }
    fprintf(resultFile, "\n");
  }
  fclose(resultFile);
  free(qval);
}


x86 assembly (clang, -O0):
<writeResults>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x8,%esi
call   1070 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x60(%rbp),%rdi
lea    0xdff(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x60(%rbp),%rsi
lea    0xdf6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x60(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1244 <writeResults+0xc4>
mov    -0x60(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
movsd  -0x30(%rbp),%xmm0
lea    0xde3(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
movsd  -0x38(%rbp),%xmm0
lea    0xdd7(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
lea    0xdcd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12cc <writeResults+0x14c>
mov    -0x58(%rbp),%rdi
mov    0x10(%rbp),%rax
mov    0x20(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd98(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    128b <writeResults+0x10b>
mov    -0x58(%rbp),%rdi
lea    0xd42(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x58(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x48(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    133d <writeResults+0x1bd>
mov    -0x58(%rbp),%rdi
mov    0x18(%rbp),%rax
mov    0x20(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd32(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12f7 <writeResults+0x177>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x8(%rbp),%rsi
lea    0xcb6(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xcba(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
jne    1384 <writeResults+0x204>
mov    -0x8(%rbp),%rsi
lea    0xc9e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x58(%rbp),%rdi
lea    0xcd0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    13cc <writeResults+0x24c>
mov    -0x58(%rbp),%rdi
mov    -0x3c(%rbp),%edx
lea    0xcb5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    139d <writeResults+0x21d>
mov    -0x58(%rbp),%rdi
lea    0xc42(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    14e4 <writeResults+0x364>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    143a <writeResults+0x2ba>
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x48(%rbp),%ecx
add    -0x40(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1400 <writeResults+0x280>
mov    -0x58(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xc1a(%rip),%rsi
mov    $0x2,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    14c4 <writeResults+0x344>
mov    -0x58(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x48(%rbp),%ecx
mov    0x20(%rbp),%rdx
mov    -0x40(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
add    (%rdx,%rsi,4),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x68(%rbp),%xmm0
lea    0xbcd(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    146d <writeResults+0x2ed>
mov    -0x58(%rbp),%rdi
lea    0xb4a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13e5 <writeResults+0x265>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeResults>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %r9d,%r14d
mov    %rcx,0x50(%rsp)
mov    %rdx,0x48(%rsp)
mov    %rsi,0x40(%rsp)
mov    %rdi,%rbx
mov    0xd0(%rsp),%rbp
mov    0xc8(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    0xc0(%rsp),%r12
mov    %r8d,0x30(%rsp)
mov    %r8d,%edi
mov    $0x8,%esi
call   1080 <calloc@plt>
mov    %rax,0x58(%rsp)
mov    $0x100,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
mov    %rbx,0x28(%rsp)
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xdd1(%rip),%rsi
mov    %r13,%rdi
call   10b0 <strcat@plt>
lea    0xdc9(%rip),%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
lea    0xdce(%rip),%rsi
mov    %r13,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    126c <writeResults+0xcc>
lea    0xdb9(%rip),%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
lea    0xdc4(%rip),%rsi
mov    %r15,%rdi
movsd  0x20(%rsp),%xmm0
mov    $0x1,%al
call   1090 <fprintf@plt>
lea    0xdb8(%rip),%rsi
mov    %r15,%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1090 <fprintf@plt>
lea    0xda9(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10c0 <fwrite@plt>
test   %r14d,%r14d
mov    %r14,0x8(%rsp)
jle    1352 <writeResults+0x1b2>
mov    %r14d,%ebx
xor    %r14d,%r14d
lea    0xd81(%rip),%r13
xchg   %ax,%ax
movslq 0x0(%rbp,%r14,4),%rax
movsd  (%r12,%rax,8),%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1090 <fprintf@plt>
add    $0x1,%r14
cmp    %r14,%rbx
jne    12d0 <writeResults+0x130>
mov    $0xa,%edi
mov    %r15,%rsi
call   1070 <fputc@plt>
lea    0xd4e(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10c0 <fwrite@plt>
cmpl   $0x0,0x8(%rsp)
mov    %rbp,%r12
mov    0x18(%rsp),%r14
jle    137b <writeResults+0x1db>
xor    %ebp,%ebp
lea    0xd2b(%rip),%r13
nop
movslq (%r12,%rbp,4),%rax
movsd  (%r14,%rax,8),%xmm0
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1090 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1330 <writeResults+0x190>
jmp    137b <writeResults+0x1db>
mov    $0xa,%edi
mov    %r15,%rsi
call   1070 <fputc@plt>
lea    0xced(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10c0 <fwrite@plt>
mov    %rbp,%r12
mov    %r12,0x78(%rsp)
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xc78(%rip),%rdi
mov    0x28(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <printf@plt>
lea    0xc78(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    13c2 <writeResults+0x222>
lea    0xc63(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
lea    0xc96(%rip),%rdi
mov    $0xc,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   10c0 <fwrite@plt>
cmpl   $0x0,0x8(%rsp)
jle    1421 <writeResults+0x281>
mov    0x8(%rsp),%rbx
neg    %ebx
mov    $0x1,%ebp
lea    0xc77(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1400 <writeResults+0x260>
mov    $0xa,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    0x30(%rsp),%eax
test   %eax,%eax
mov    0x8(%rsp),%rbx
jle    1607 <writeResults+0x467>
lea    0x1(%rbx),%ecx
mov    %ecx,0x3c(%rsp)
movslq %ecx,%rcx
mov    %eax,%eax
mov    %rax,0x80(%rsp)
mov    %ecx,%eax
lea    -0x1(%rax),%rdx
add    $0xfffffffffffffffe,%rax
mov    %rax,0x70(%rsp)
mov    %edx,%eax
and    $0x3,%eax
mov    %rax,0x68(%rsp)
mov    %rdx,%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,0x60(%rsp)
mov    0x40(%rsp),%rax
lea    0x20(%rax),%r15
shl    $0x3,%rcx
mov    %rcx,0x18(%rsp)
xor    %esi,%esi
mov    %rax,%rdi
mov    %rdx,0x28(%rsp)
mov    0x40(%rsp),%r13
mov    0x78(%rsp),%rbp
jmp    14fe <writeResults+0x35e>
mov    0x48(%rsp),%rax
movsd  (%rax,%rsi,8),%xmm0
mov    0x50(%rsp),%rax
movsd  (%rax,%rsi,8),%xmm1
mov    %r12,%rdi
lea    0xbbb(%rip),%rsi
mov    $0x2,%al
call   1090 <fprintf@plt>
mov    $0xa,%edi
mov    %r12,%rsi
call   1070 <fputc@plt>
mov    0x10(%rsp),%rsi
add    $0x1,%rsi
mov    0x18(%rsp),%rax
add    %rax,%r15
mov    0x20(%rsp),%rdi
add    %rax,%rdi
cmp    0x80(%rsp),%rsi
mov    0x8(%rsp),%rbx
je     1607 <writeResults+0x467>
test   %ebx,%ebx
mov    %rsi,0x10(%rsp)
mov    %rdi,0x20(%rsp)
jle    14a0 <writeResults+0x300>
cmpq   $0x3,0x70(%rsp)
jae    1520 <writeResults+0x380>
xorpd  %xmm0,%xmm0
mov    $0x1,%eax
jmp    1558 <writeResults+0x3b8>
nop
xorpd  %xmm0,%xmm0
xor    %eax,%eax
mov    0x60(%rsp),%rcx
nopl   0x0(%rax,%rax,1)
addsd  -0x18(%r15,%rax,8),%xmm0
addsd  -0x10(%r15,%rax,8),%xmm0
addsd  -0x8(%r15,%rax,8),%xmm0
addsd  (%r15,%rax,8),%xmm0
add    $0x4,%rax
cmp    %rax,%rcx
jne    1530 <writeResults+0x390>
add    $0x1,%rax
mov    0x68(%rsp),%rdx
test   %rdx,%rdx
je     157e <writeResults+0x3de>
lea    (%rdi,%rax,8),%rax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
addsd  (%rax,%rcx,8),%xmm0
add    $0x1,%rcx
cmp    %rcx,%rdx
jne    1570 <writeResults+0x3d0>
movsd  %xmm0,0x30(%rsp)
mov    0x48(%rsp),%rax
movsd  (%rax,%rsi,8),%xmm0
mov    0x50(%rsp),%rax
movsd  (%rax,%rsi,8),%xmm1
mov    %r12,%rdi
lea    0xad7(%rip),%rsi
mov    $0x2,%al
call   1090 <fprintf@plt>
test   %ebx,%ebx
jle    14c5 <writeResults+0x325>
mov    0x3c(%rsp),%r14d
imul   0x10(%rsp),%r14d
add    $0x1,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%rbp,%rbx,4),%eax
add    %r14d,%eax
cltq
movsd  0x0(%r13,%rax,8),%xmm0
divsd  0x30(%rsp),%xmm0
mov    %r12,%rdi
lea    0xa8c(%rip),%rsi
mov    $0x1,%al
call   1090 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,0x28(%rsp)
jne    15d0 <writeResults+0x430>
jmp    14c5 <writeResults+0x325>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x58(%rsp),%rdi
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [7 x i8] c".stats\00"
@.str.1 = [20 x i8] c"Opening file %s...\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [26 x i8] c"ERROR, unable to open %s\0A\00"
@.str.4 = [11 x i8] c"error: %f\0A\00"
@.str.5 = [8 x i8] c"pi: %f\0A\00"
@.str.6 = [5 x i8] c"c2: \00"
@.str.7 = [4 x i8] c"%f \00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [7 x i8] c"rho2:\0A\00"
@.str.10 = [5 x i8] c"%lf \00"
@.str.11 = [13 x i8] c"logBF\09logPO\09\00"
@.str.12 = [13 x i8] c"P(Z = %d|O)\09\00"
@.str.13 = [7 x i8] c"%f\09%f\09\00"
@.str.14 = [4 x i8] c"%f\09\00"
define void @writeResults(i8* %0, double* %1, double* %2, double* %3, i32 %4, i32 %5, double %6, double %7, double* %8, double* %9, i32* %10) {
%12 = alloca i8*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double*
%21 = alloca double*
%22 = alloca i32*
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca double*
%28 = alloca i32*
%29 = alloca i8*
%30 = alloca double
store i8* %0, i8** %12
store double* %1, double** %13
store double* %2, double** %14
store double* %3, double** %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store double %6, double* %18
store double %7, double* %19
store double* %8, double** %20
store double* %9, double** %21
store i32* %10, i32** %22
%31 = load i32, i32* %16
store i32 %31, i32* %25
%32 = load i32, i32* %17
%33 = add nsw i32 %32, 1
store i32 %33, i32* %26
%34 = load i32, i32* %16
%35 = call i8* @calloc(i32 %34, i32 8)
%36 = bitcast i8* %35 to double*
store double* %36, double** %27
%37 = call i8* @calloc(i32 256, i32 1)
store i8* %37, i8** %29
%38 = load i8*, i8** %29
%39 = load i8*, i8** %12
%40 = call i32 @strcpy(i8* %38, i8* %39)
%41 = load i8*, i8** %29
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%43 = load i8*, i8** %29
%44 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %29
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %46, i32** %28
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %51
48: ; preds = %11
%49 = load i8*, i8** %29
%50 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48, %11
%52 = load i32*, i32** %28
%53 = load double, double* %18
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %53)
%55 = load i32*, i32** %28
%56 = load double, double* %19
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %56)
%58 = load i32*, i32** %28
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %23
br label %60
60: ; preds = %76, %51
%61 = load i32, i32* %23
%62 = load i32, i32* %17
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %79
64: ; preds = %60
%65 = load i32*, i32** %28
%66 = load double*, double** %20
%67 = load i32*, i32** %22
%68 = load i32, i32* %23
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds double, double* %66, i64 %72
%74 = load double, double* %73
%75 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %74)
br label %76
76: ; preds = %64
%77 = load i32, i32* %23
%78 = add nsw i32 %77, 1
store i32 %78, i32* %23
br label %60
79: ; preds = %60
%80 = load i32*, i32** %28
%81 = call i32 (i32*, i8*, ...) @fprintf(i32* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%82 = load i32*, i32** %28
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %23
br label %84
84: ; preds = %101, %79
%85 = load i32, i32* %23
%86 = load i32, i32* %26
%87 = sub nsw i32 %86, 1
%88 = icmp slt i32 %85, %87
br i1 %88, label %89, label %104
89: ; preds = %84
%90 = load i32*, i32** %28
%91 = load double*, double** %21
%92 = load i32*, i32** %22
%93 = load i32, i32* %23
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
%96 = load i32, i32* %95
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds double, double* %91, i64 %97
%99 = load double, double* %98
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), double %99)
br label %101
101: ; preds = %89
%102 = load i32, i32* %23
%103 = add nsw i32 %102, 1
store i32 %103, i32* %23
br label %84
104: ; preds = %84
%105 = load i32*, i32** %28
%106 = call i32 @fclose(i32* %105)
%107 = load i8*, i8** %12
%108 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %107)
%109 = load i8*, i8** %12
%110 = call i32* @fopen(i8* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %110, i32** %28
%111 = icmp eq i32* %110, null
br i1 %111, label %112, label %115
112: ; preds = %104
%113 = load i8*, i8** %12
%114 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %113)
br label %115
115: ; preds = %112, %104
%116 = load i32*, i32** %28
%117 = call i32 (i32*, i8*, ...) @fprintf(i32* %116, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %23
br label %118
118: ; preds = %126, %115
%119 = load i32, i32* %23
%120 = load i32, i32* %26
%121 = icmp slt i32 %119, %120
br i1 %121, label %122, label %129
122: ; preds = %118
%123 = load i32*, i32** %28
%124 = load i32, i32* %23
%125 = call i32 (i32*, i8*, ...) @fprintf(i32* %123, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %124)
br label %126
126: ; preds = %122
%127 = load i32, i32* %23
%128 = add nsw i32 %127, 1
store i32 %128, i32* %23
br label %118
129: ; preds = %118
%130 = load i32*, i32** %28
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %130, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %23
br label %132
132: ; preds = %199, %129
%133 = load i32, i32* %23
%134 = load i32, i32* %25
%135 = icmp slt i32 %133, %134
br i1 %135, label %136, label %202
136: ; preds = %132
store double 0.000000e+00, double* %30
store i32 1, i32* %24
br label %137
137: ; preds = %153, %136
%138 = load i32, i32* %24
%139 = load i32, i32* %26
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %156
141: ; preds = %137
%142 = load double*, double** %13
%143 = load i32, i32* %23
%144 = load i32, i32* %26
%145 = mul nsw i32 %143, %144
%146 = load i32, i32* %24
%147 = add nsw i32 %145, %146
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds double, double* %142, i64 %148
%150 = load double, double* %149
%151 = load double, double* %30
%152 = fadd double %151, %150
store double %152, double* %30
br label %153
153: ; preds = %141
%154 = load i32, i32* %24
%155 = add nsw i32 %154, 1
store i32 %155, i32* %24
br label %137
156: ; preds = %137
%157 = load i32*, i32** %28
%158 = load double*, double** %14
%159 = load i32, i32* %23
%160 = sext i32 %159 to i64
%161 = getelementptr inbounds double, double* %158, i64 %160
%162 = load double, double* %161
%163 = load double*, double** %15
%164 = load i32, i32* %23
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds double, double* %163, i64 %165
%167 = load double, double* %166
%168 = call i32 (i32*, i8*, ...) @fprintf(i32* %157, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), double %162, double %167)
store i32 1, i32* %24
br label %169
169: ; preds = %193, %156
%170 = load i32, i32* %24
%171 = load i32, i32* %26
%172 = icmp slt i32 %170, %171
br i1 %172, label %173, label %196
173: ; preds = %169
%174 = load i32*, i32** %28
%175 = load double*, double** %13
%176 = load i32, i32* %23
%177 = load i32, i32* %26
%178 = mul nsw i32 %176, %177
%179 = load i32*, i32** %22
%180 = load i32, i32* %24
%181 = sub nsw i32 %180, 1
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i32, i32* %179, i64 %182
%184 = load i32, i32* %183
%185 = add nsw i32 %178, %184
%186 = add nsw i32 %185, 1
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds double, double* %175, i64 %187
%189 = load double, double* %188
%190 = load double, double* %30
%191 = fdiv double %189, %190
%192 = call i32 (i32*, i8*, ...) @fprintf(i32* %174, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), double %191)
br label %193
193: ; preds = %173
%194 = load i32, i32* %24
%195 = add nsw i32 %194, 1
store i32 %195, i32* %24
br label %169
196: ; preds = %169
%197 = load i32*, i32** %28
%198 = call i32 (i32*, i8*, ...) @fprintf(i32* %197, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %199
199: ; preds = %196
%200 = load i32, i32* %23
%201 = add nsw i32 %200, 1
store i32 %201, i32* %23
br label %132
202: ; preds = %132
%203 = load i32*, i32** %28
%204 = call i32 @fclose(i32* %203)
%205 = load double*, double** %27
%206 = call i32 @free(double* %205)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c".stats\00"
@.str.1 = [20 x i8] c"Opening file %s...\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [26 x i8] c"ERROR, unable to open %s\0A\00"
@.str.4 = [11 x i8] c"error: %f\0A\00"
@.str.5 = [8 x i8] c"pi: %f\0A\00"
@.str.6 = [5 x i8] c"c2: \00"
@.str.7 = [4 x i8] c"%f \00"
@.str.9 = [7 x i8] c"rho2:\0A\00"
@.str.10 = [5 x i8] c"%lf \00"
@.str.11 = [13 x i8] c"logBF\09logPO\09\00"
@.str.12 = [13 x i8] c"P(Z = %d|O)\09\00"
@.str.13 = [7 x i8] c"%f\09%f\09\00"
@.str.14 = [4 x i8] c"%f\09\00"
define void @writeResults(i8* %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, i32 %4, i32 %5, double %6, double %7, double* nocapture %8, double* nocapture %9, i32* nocapture %10) {
%12 = add i32 %5, 1
%13 = tail call i8* @calloc(i32 %4, i32 8)
%14 = tail call dereferenceable_or_null(256) i8* @calloc(i32 256, i32 1)
%15 = tail call i32 @strcpy(i8* %14, i8* %0)
%16 = tail call i32 @strcat(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%18 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %22
22: ; preds = %20, %11
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %6)
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %7)
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i64 4, i64 1, i32* %18)
%26 = icmp sgt i32 %5, 0
br i1 %26, label %27, label %54
27: ; preds = %22
%28 = zext i32 %5 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 0, %27 ], [ %37, %29 ]
%31 = getelementptr inbounds i32, i32* %10, i64 %30
%32 = load i32, i32* %31
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %8, i64 %33
%35 = load double, double* %34
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %35)
%37 = add nuw nsw i64 %30, 1
%38 = icmp eq i64 %37, %28
br i1 %38, label %39, label %29
39: ; preds = %29
%40 = tail call i32 @fputc(i32 10, i32* %18)
%41 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i64 6, i64 1, i32* %18)
br i1 %26, label %42, label %57
42: ; preds = %39
%43 = zext i32 %5 to i64
br label %44
44: ; preds = %42, %44
%45 = phi i64 [ 0, %42 ], [ %52, %44 ]
%46 = getelementptr inbounds i32, i32* %10, i64 %45
%47 = load i32, i32* %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %9, i64 %48
%50 = load double, double* %49
%51 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), double %50)
%52 = add nuw nsw i64 %45, 1
%53 = icmp eq i64 %52, %43
br i1 %53, label %57, label %44
54: ; preds = %22
%55 = tail call i32 @fputc(i32 10, i32* %18)
%56 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i64 6, i64 1, i32* %18)
br label %57
57: ; preds = %44, %54, %39
%58 = tail call i32 @fclose(i32* %18)
%59 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%60 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%61 = icmp eq i32* %60, null
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %64
64: ; preds = %62, %57
%65 = tail call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0), i64 12, i64 1, i32* %60)
%66 = icmp slt i32 %5, 1
br i1 %66, label %72, label %67
67: ; preds = %64, %67
%68 = phi i32 [ %70, %67 ], [ 1, %64 ]
%69 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0), i32 %68)
%70 = add nuw i32 %68, 1
%71 = icmp eq i32 %68, %5
br i1 %71, label %72, label %67
72: ; preds = %67, %64
%73 = tail call i32 @fputc(i32 10, i32* %60)
%74 = icmp sgt i32 %4, 0
br i1 %74, label %75, label %165
75: ; preds = %72
%76 = sext i32 %12 to i64
%77 = zext i32 %4 to i64
%78 = zext i32 %12 to i64
%79 = zext i32 %12 to i64
%80 = add nsw i64 %78, -1
%81 = add nsw i64 %78, -2
%82 = and i64 %80, 3
%83 = icmp ult i64 %81, 3
%84 = and i64 %80, -4
%85 = icmp eq i64 %82, 0
br label %86
86: ; preds = %75, %161
%87 = phi i64 [ 0, %75 ], [ %163, %161 ]
br i1 %66, label %88, label %94
88: ; preds = %86
%89 = getelementptr inbounds double, double* %2, i64 %87
%90 = load double, double* %89
%91 = getelementptr inbounds double, double* %3, i64 %87
%92 = load double, double* %91
%93 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), double %90, double %92)
br label %161
94: ; preds = %86
%95 = mul nsw i64 %87, %76
br i1 %83, label %122, label %96
96: ; preds = %94, %96
%97 = phi i64 [ %119, %96 ], [ 1, %94 ]
%98 = phi double [ %118, %96 ], [ 0.000000e+00, %94 ]
%99 = phi i64 [ %120, %96 ], [ 0, %94 ]
%100 = add nsw i64 %97, %95
%101 = getelementptr inbounds double, double* %1, i64 %100
%102 = load double, double* %101
%103 = fadd double %98, %102
%104 = add nuw nsw i64 %97, 1
%105 = add nsw i64 %104, %95
%106 = getelementptr inbounds double, double* %1, i64 %105
%107 = load double, double* %106
%108 = fadd double %103, %107
%109 = add nuw nsw i64 %97, 2
%110 = add nsw i64 %109, %95
%111 = getelementptr inbounds double, double* %1, i64 %110
%112 = load double, double* %111
%113 = fadd double %108, %112
%114 = add nuw nsw i64 %97, 3
%115 = add nsw i64 %114, %95
%116 = getelementptr inbounds double, double* %1, i64 %115
%117 = load double, double* %116
%118 = fadd double %113, %117
%119 = add nuw nsw i64 %97, 4
%120 = add nuw i64 %99, 4
%121 = icmp eq i64 %120, %84
br i1 %121, label %122, label %96
122: ; preds = %96, %94
%123 = phi double [ undef, %94 ], [ %118, %96 ]
%124 = phi i64 [ 1, %94 ], [ %119, %96 ]
%125 = phi double [ 0.000000e+00, %94 ], [ %118, %96 ]
br i1 %85, label %137, label %126
126: ; preds = %122, %126
%127 = phi i64 [ %134, %126 ], [ %124, %122 ]
%128 = phi double [ %133, %126 ], [ %125, %122 ]
%129 = phi i64 [ %135, %126 ], [ 0, %122 ]
%130 = add nsw i64 %127, %95
%131 = getelementptr inbounds double, double* %1, i64 %130
%132 = load double, double* %131
%133 = fadd double %128, %132
%134 = add nuw nsw i64 %127, 1
%135 = add i64 %129, 1
%136 = icmp eq i64 %135, %82
br i1 %136, label %137, label %126
137: ; preds = %126, %122
%138 = phi double [ %123, %122 ], [ %133, %126 ]
%139 = getelementptr inbounds double, double* %2, i64 %87
%140 = load double, double* %139
%141 = getelementptr inbounds double, double* %3, i64 %87
%142 = load double, double* %141
%143 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0), double %140, double %142)
br i1 %66, label %161, label %144
144: ; preds = %137
%145 = trunc i64 %87 to i32
%146 = mul i32 %12, %145
%147 = add i32 %146, 1
br label %148
148: ; preds = %144, %148
%149 = phi i64 [ 1, %144 ], [ %159, %148 ]
%150 = add nsw i64 %149, -1
%151 = getelementptr inbounds i32, i32* %10, i64 %150
%152 = load i32, i32* %151
%153 = add i32 %147, %152
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %1, i64 %154
%156 = load double, double* %155
%157 = fdiv double %156, %138
%158 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), double %157)
%159 = add nuw nsw i64 %149, 1
%160 = icmp eq i64 %159, %79
br i1 %160, label %161, label %148
161: ; preds = %148, %88, %137
%162 = tail call i32 @fputc(i32 10, i32* %60)
%163 = add nuw nsw i64 %87, 1
%164 = icmp eq i64 %163, %77
br i1 %164, label %165, label %86
165: ; preds = %161, %72
%166 = bitcast i8* %13 to double*
%167 = tail call i32 @fclose(i32* %60)
%168 = tail call i32 @free(double* %166)
ret void
}