#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*/ error_open_file(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void write_CF(char *fname, double *corr, double *ercorr,
              unsigned long long *DD) {
  FILE *fo;
  int ii;
  fo = fopen(fname, "w");
  if (fo == NULL) {
    char oname[64] = "output_CUTE.dat";
    fprintf(stderr, "CUTE: Error opening output file %s", fname);
    fprintf(stderr, ", using ./output_CUTE.dat");
    fo = fopen(oname, "w");
    if (fo == NULL)
      error_open_file(oname);
  }
  for (ii = 0; ii < 256; ii++) {
    double rr;
    rr = (ii + 0.5) / (256 * 0.005);
    fprintf(fo, "%lE %lE %lE %llu \n", rr, corr[ii], ercorr[ii], DD[ii]);
  }
  fclose(fo);
  printf("\n");
}


x86 assembly (clang, -O0):
<write_CF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1210 <write_CF+0xb0>
lea    -0x70(%rbp),%rdi
lea    0xecb(%rip),%rsi
mov    $0x40,%edx
call   1070 <memcpy@plt>
mov    0x2e2a(%rip),%rax
movslq (%rax),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe4e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2e0e(%rip),%rax
movslq (%rax),%rdi
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe22(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120b <write_CF+0xab>
lea    -0x70(%rbp),%rdi
call   1040 <error_open_file@plt>
jmp    1210 <write_CF+0xb0>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x100,-0x2c(%rbp)
jge    1291 <write_CF+0x131>
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xdc3(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
mov    -0x28(%rbp),%rdi
movsd  -0x78(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdd3(%rip),%rsi
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1217 <write_CF+0xb7>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdbf(%rip),%rdi
call   1050 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_CF>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1216 <write_CF+0xb6>
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movapd 0xeb2(%rip),%xmm0
movapd %xmm0,(%rsp)
mov    0x2e16(%rip),%rbx
movslq (%rbx),%rdi
lea    0xe3e(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
movslq (%rbx),%rcx
lea    0xe4d(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
lea    0xe12(%rip),%rsi
mov    %rsp,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1216 <write_CF+0xb6>
mov    %rsp,%rdi
call   1050 <error_open_file@plt>
xor    %ebp,%ebp
lea    0xe30(%rip),%r13
nop
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
addsd  0xdd1(%rip),%xmm0
divsd  0xdd1(%rip),%xmm0
movsd  (%r12,%rbp,8),%xmm1
movsd  (%r15,%rbp,8),%xmm2
mov    (%r14,%rbp,8),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x3,%al
call   1060 <fprintf@plt>
add    $0x1,%rbp
cmp    $0x100,%rbp
jne    1220 <write_CF+0xc0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@__const.write_CF.oname = [64 x i8] c"output_CUTE.dat\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"CUTE: Error opening output file %s\00"
@.str.2 = [26 x i8] c", using ./output_CUTE.dat\00"
@.str.3 = [19 x i8] c"%lE %lE %lE %llu \0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @write_CF(i8* %0, double* %1, double* %2, i64* %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i64*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca [64 x i8]
%12 = alloca double
store i8* %0, i8** %5
store double* %1, double** %6
store double* %2, double** %7
store i64* %3, i64** %8
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %9
%15 = load i32*, i32** %9
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %36
17: ; preds = %4
%18 = bitcast [64 x i8]* %11 to i8*
%19 = load i32, i32* @stderr
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = load i8*, i8** %5
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @stderr
%25 = sext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%28 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%29 = call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %29, i32** %9
%30 = load i32*, i32** %9
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %17
%33 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%34 = call i32 @error_open_file(i8* %33)
br label %35
35: ; preds = %32, %17
br label %36
36: ; preds = %35, %4
store i32 0, i32* %10
br label %37
37: ; preds = %63, %36
%38 = load i32, i32* %10
%39 = icmp slt i32 %38, 256
br i1 %39, label %40, label %66
40: ; preds = %37
%41 = load i32, i32* %10
%42 = sitofp i32 %41 to double
%43 = fadd double %42, 5.000000e-01
%44 = fdiv double %43, 1.280000e+00
store double %44, double* %12
%45 = load i32*, i32** %9
%46 = load double, double* %12
%47 = load double*, double** %6
%48 = load i32, i32* %10
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
%51 = load double, double* %50
%52 = load double*, double** %7
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
%56 = load double, double* %55
%57 = load i64*, i64** %8
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i64, i64* %57, i64 %59
%61 = load i64, i64* %60
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %45, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %46, double %51, double %56, i64 %61)
br label %63
63: ; preds = %40
%64 = load i32, i32* %10
%65 = add nsw i32 %64, 1
store i32 %65, i32* %10
br label %37
66: ; preds = %37
%67 = load i32*, i32** %9
%68 = call i32 @fclose(i32* %67)
%69 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@__const.write_CF.oname = [64 x i8] c"output_CUTE.dat\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"CUTE: Error opening output file %s\00"
@.str.2 = [26 x i8] c", using ./output_CUTE.dat\00"
@.str.3 = [19 x i8] c"%lE %lE %lE %llu \0A\00"
define void @write_CF(i8* %0, double* nocapture %1, double* nocapture %2, i64* nocapture %3) {
%5 = alloca [64 x i8]
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @stderr
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%14 = load i32, i32* @stderr
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i64 25, i64 1, i32* %16)
%18 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %8
%21 = call i32 @error_open_file(i8* %9)
br label %22
22: ; preds = %20, %8
br label %23
23: ; preds = %22, %4
%24 = phi i32* [ %18, %22 ], [ %6, %4 ]
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %38, %25 ]
%27 = trunc i64 %26 to i32
%28 = sitofp i32 %27 to double
%29 = fadd double %28, 5.000000e-01
%30 = fdiv double %29, 1.280000e+00
%31 = getelementptr inbounds double, double* %1, i64 %26
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %2, i64 %26
%34 = load double, double* %33
%35 = getelementptr inbounds i64, i64* %3, i64 %26
%36 = load i64, i64* %35
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), double %30, double %32, double %34, i64 %36)
%38 = add nuw nsw i64 %26, 1
%39 = icmp eq i64 %38, 256
br i1 %39, label %40, label %25
40: ; preds = %25
%41 = call i32 @fclose(i32* %24)
%42 = call i32 @putchar(i32 10)
ret void
}