#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 */
double fabs(double);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
double log10(double);
int /*<<< orphan*/ print_error_global(char *, char *, int /*<<< orphan*/);
double zscore2pvalue(double);
void write_zscore_double(char *file_data, int M, double *zscore) {
  FILE *file = NULL;
  int j;
  double pvalue;
  file = fopen(file_data, "w");
  if (!file)
    print_error_global("open", file_data, 0);
  for (j = 0; j < M; j++) {
    pvalue = zscore2pvalue(fabs(zscore[j]));
    fprintf(file, "%G %G %G ", fabs(zscore[j]), -log10(pvalue), pvalue);
    fprintf(file, "\n");
  }
  fclose(file);
}


x86 assembly (clang, -O0):
<write_zscore_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ac <write_zscore_double+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xe6d(%rip),%rdi
xor    %edx,%edx
call   1080 <print_error_global@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1266 <write_zscore_double+0x106>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe2d(%rip),%xmm1
pand   %xmm1,%xmm0
call   1040 <zscore2pvalue@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe03(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1070 <log10@plt>
mov    -0x40(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  -0x30(%rbp),%xmm2
lea    0xdd8(%rip),%rsi
mov    $0x3,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b3 <write_zscore_double+0x53>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_zscore_double>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbp
lea    0xe94(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11a3 <write_zscore_double+0x33>
test   %r15d,%r15d
jg     11bd <write_zscore_double+0x4d>
jmp    123a <write_zscore_double+0xca>
lea    0xe78(%rip),%rdi
mov    %rbp,%rsi
xor    %edx,%edx
call   1090 <print_error_global@plt>
test   %r15d,%r15d
jle    123a <write_zscore_double+0xca>
mov    %r15d,%r12d
xor    %ebp,%ebp
lea    0xe5e(%rip),%r15
nopl   0x0(%rax)
movsd  (%r14,%rbp,8),%xmm0
movaps 0xe23(%rip),%xmm1
andps  %xmm1,%xmm0
call   1050 <zscore2pvalue@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%r14,%rbp,8),%xmm1
andps  0xe08(%rip),%xmm1
movaps %xmm1,0x10(%rsp)
call   1080 <log10@plt>
movaps %xmm0,%xmm1
xorps  0xe04(%rip),%xmm1
mov    %rbx,%rdi
mov    %r15,%rsi
movaps 0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    11d0 <write_zscore_double+0x60>
mov    %rbx,%rdi
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [10 x i8] c"%G %G %G \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @write_zscore_double(i8* %0, i32 %1, double* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca double
store i8* %0, i8** %4
store i32 %1, i32* %5
store double* %2, double** %6
store i32* null, i32** %7
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32 0)
br label %17
17: ; preds = %14, %3
store i32 0, i32* %8
br label %18
18: ; preds = %44, %17
%19 = load i32, i32* %8
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %47
22: ; preds = %18
%23 = load double*, double** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %23, i64 %25
%27 = load double, double* %26
%28 = call double @llvm.fabs.f64(double %27)
%29 = call double @zscore2pvalue(double %28)
store double %29, double* %9
%30 = load i32*, i32** %7
%31 = load double*, double** %6
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
%35 = load double, double* %34
%36 = call double @llvm.fabs.f64(double %35)
%37 = load double, double* %9
%38 = call double @log10(double %37)
%39 = fneg double %38
%40 = load double, double* %9
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %36, double %39, double %40)
%42 = load i32*, i32** %7
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %22
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %18
47: ; preds = %18
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [10 x i8] c"%G %G %G \00"
define void @write_zscore_double(i8* %0, i32 %1, double* nocapture %2) {
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @print_error_global(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 0)
br label %8
8: ; preds = %6, %3
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %26
10: ; preds = %8
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %24, %12 ]
%14 = getelementptr inbounds double, double* %2, i64 %13
%15 = load double, double* %14
%16 = tail call double @llvm.fabs.f64(double %15)
%17 = tail call double @zscore2pvalue(double %16)
%18 = load double, double* %14
%19 = tail call double @llvm.fabs.f64(double %18)
%20 = tail call double @log10(double %17)
%21 = fneg double %20
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %19, double %21, double %17)
%23 = tail call i32 @fputc(i32 10, i32* %4)
%24 = add nuw nsw i64 %13, 1
%25 = icmp eq i64 %24, %11
br i1 %25, label %26, label %12
26: ; preds = %12, %8
%27 = tail call i32 @fclose(i32* %4)
ret void
}