#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen_write(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void write_data_tracyWidom(char *output_file, int M, double *values,
                           double *pvalues, double *twstat, double *effectn,
                           double *percentage) {
  FILE *file = NULL;
  int i;
  file = fopen_write(output_file);
  fprintf(file, "N\teigenvalues\ttwstats\t\tpvalues\teffectn\tpercentage\n");
  for (i = 0; i < M; i++) {
    fprintf(file, "%d\t%3.4G\t\t%3.4G\t\t%3.4G\t\t%3.8G\t%3.4G\n", i + 1,
            values[i], twstat[i], pvalues[i], effectn[i], percentage[i]);
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<write_data_tracyWidom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <fopen_write@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f4 <write_data_tracyWidom+0xc4>
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm4
lea    0xe54(%rip),%rsi
mov    $0x5,%al
call   1050 <fprintf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1181 <write_data_tracyWidom+0x51>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_data_tracyWidom>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %esi,%ebp
mov    0x50(%rsp),%r14
call   1040 <fopen_write@plt>
mov    %rax,%rbx
lea    0xe8c(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1060 <fwrite@plt>
test   %ebp,%ebp
jle    11d6 <write_data_tracyWidom+0x96>
mov    %ebp,%r15d
xor    %eax,%eax
nop
lea    0x1(%rax),%rbp
movsd  0x0(%r13,%rax,8),%xmm0
mov    0x8(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm1
movsd  (%r12,%rax,8),%xmm2
mov    0x10(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm3
movsd  (%r14,%rax,8),%xmm4
mov    %rbx,%rdi
lea    0xe6e(%rip),%rsi
mov    %ebp,%edx
mov    $0x5,%al
call   1050 <fprintf@plt>
mov    %rbp,%rax
cmp    %rbp,%r15
jne    1190 <write_data_tracyWidom+0x50>
mov    %rbx,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"N\09eigenvalues\09twstats\09\09pvalues\09effectn\09percentage\0A\00"
@.str.1 = [37 x i8] c"%d\09%3.4G\09\09%3.4G\09\09%3.4G\09\09%3.8G\09%3.4G\0A\00"
define void @write_data_tracyWidom(i8* %0, i32 %1, double* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32*
%16 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
store i32* null, i32** %15
%17 = load i8*, i8** %8
%18 = call i32* @fopen_write(i8* %17)
store i32* %18, i32** %15
%19 = load i32*, i32** %15
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %16
br label %21
21: ; preds = %55, %7
%22 = load i32, i32* %16
%23 = load i32, i32* %9
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %58
25: ; preds = %21
%26 = load i32*, i32** %15
%27 = load i32, i32* %16
%28 = add nsw i32 %27, 1
%29 = load double*, double** %10
%30 = load i32, i32* %16
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %12
%35 = load i32, i32* %16
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = load double*, double** %11
%40 = load i32, i32* %16
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = load double*, double** %13
%45 = load i32, i32* %16
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds double, double* %44, i64 %46
%48 = load double, double* %47
%49 = load double*, double** %14
%50 = load i32, i32* %16
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %49, i64 %51
%53 = load double, double* %52
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %28, double %33, double %38, double %43, double %48, double %53)
br label %55
55: ; preds = %25
%56 = load i32, i32* %16
%57 = add nsw i32 %56, 1
store i32 %57, i32* %16
br label %21
58: ; preds = %21
%59 = load i32*, i32** %15
%60 = call i32 @fclose(i32* %59)
ret void
}

LLVM IR (-O2):
@.str = [51 x i8] c"N\09eigenvalues\09twstats\09\09pvalues\09effectn\09percentage\0A\00"
@.str.1 = [37 x i8] c"%d\09%3.4G\09\09%3.4G\09\09%3.4G\09\09%3.8G\09%3.4G\0A\00"
define void @write_data_tracyWidom(i8* %0, i32 %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture %6) {
%8 = tail call i32* @fopen_write(i8* %0)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i64 50, i64 1, i32* %8)
%10 = icmp sgt i32 %1, 0
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %15, %13 ]
%15 = add nuw nsw i64 %14, 1
%16 = getelementptr inbounds double, double* %2, i64 %14
%17 = load double, double* %16
%18 = getelementptr inbounds double, double* %4, i64 %14
%19 = load double, double* %18
%20 = getelementptr inbounds double, double* %3, i64 %14
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %5, i64 %14
%23 = load double, double* %22
%24 = getelementptr inbounds double, double* %6, i64 %14
%25 = load double, double* %24
%26 = trunc i64 %15 to i32
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %26, double %17, double %19, double %21, double %23, double %25)
%28 = icmp eq i64 %15, %12
br i1 %28, label %29, label %13
29: ; preds = %13, %7
%30 = tail call i32 @fclose(i32* %8)
ret void
}