#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(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double, double,
                           double);
double sqrt(double);
void output(int max_variations, int number_cycles, double delta_correlation,
            double lowest_correlation, double *cumulative_e,
            double *cumulative_e2) {
  int i;
  double correlation, variance, error;
  FILE *output_file1;
  output_file1 = fopen("out_test.dat", "w");
  correlation = 0;
  for (i = 1; i <= max_variations; i++) {
    correlation += delta_correlation;
    variance = cumulative_e2[i] - cumulative_e[i] * cumulative_e[i];
    error = sqrt(variance / number_cycles);
    fprintf(output_file1, "%12.5E %12.5E %12.5E %12.5E \n", correlation,
            cumulative_e[i], variance, error);
  }
  fclose(output_file1);
}


x86 assembly (clang, -O0):
<output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    0xe99(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     123e <output+0xfe>
movsd  -0x10(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1060 <sqrt@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x50(%rbp),%rdi
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
lea    0xde4(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1186 <output+0x46>
mov    -0x50(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
movsd  %xmm0,0x20(%rsp)
mov    %esi,%ebp
mov    %edi,%r15d
lea    0xea2(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r12
test   %r15d,%r15d
jle    1220 <output+0xe0>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x18(%rsp)
add    $0x1,%r15d
mov    $0x1,%ebp
lea    0xe7c(%rip),%r13
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    11f0 <output+0xb0>
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm2
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  (%rbx,%rbp,8),%xmm1
mov    %r12,%rdi
mov    %r13,%rsi
movsd  %xmm0,0x8(%rsp)
call   1040 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
je     1220 <output+0xe0>
movsd  (%r14,%rbp,8),%xmm2
movsd  (%rbx,%rbp,8),%xmm0
mulsd  %xmm0,%xmm0
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
divsd  0x18(%rsp),%xmm0
ucomisd 0xdeb(%rip),%xmm0
jb     11b0 <output+0x70>
xorps  %xmm3,%xmm3
sqrtsd %xmm0,%xmm3
jmp    11c5 <output+0x85>
mov    %r12,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"out_test.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"%12.5E %12.5E %12.5E %12.5E \0A\00"
define void @output(i32 %0, i32 %1, double %2, double %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32*
store i32 %0, i32* %7
store i32 %1, i32* %8
store double %2, double* %9
store double %3, double* %10
store double* %4, double** %11
store double* %5, double** %12
%18 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %17
store double 0.000000e+00, double* %14
store i32 1, i32* %13
br label %19
19: ; preds = %59, %6
%20 = load i32, i32* %13
%21 = load i32, i32* %7
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %62
23: ; preds = %19
%24 = load double, double* %9
%25 = load double, double* %14
%26 = fadd double %25, %24
store double %26, double* %14
%27 = load double*, double** %12
%28 = load i32, i32* %13
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %11
%33 = load i32, i32* %13
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
%36 = load double, double* %35
%37 = load double*, double** %11
%38 = load i32, i32* %13
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
%41 = load double, double* %40
%42 = fneg double %36
%43 = call double @llvm.fmuladd.f64(double %42, double %41, double %31)
store double %43, double* %15
%44 = load double, double* %15
%45 = load i32, i32* %8
%46 = sitofp i32 %45 to double
%47 = fdiv double %44, %46
%48 = call double @sqrt(double %47)
store double %48, double* %16
%49 = load i32*, i32** %17
%50 = load double, double* %14
%51 = load double*, double** %11
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double, double* %15
%57 = load double, double* %16
%58 = call i32 @fprintf(i32* %49, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %50, double %55, double %56, double %57)
br label %59
59: ; preds = %23
%60 = load i32, i32* %13
%61 = add nsw i32 %60, 1
store i32 %61, i32* %13
br label %19
62: ; preds = %19
%63 = load i32*, i32** %17
%64 = call i32 @fclose(i32* %63)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"out_test.dat\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [30 x i8] c"%12.5E %12.5E %12.5E %12.5E \0A\00"
define void @output(i32 %0, i32 %1, double %2, double %3, double* nocapture %4, double* nocapture %5) {
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp slt i32 %0, 1
br i1 %8, label %29, label %9
9: ; preds = %6
%10 = sitofp i32 %1 to double
%11 = add nuw i32 %0, 1
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %9, %13
%14 = phi i64 [ 1, %9 ], [ %27, %13 ]
%15 = phi double [ 0.000000e+00, %9 ], [ %16, %13 ]
%16 = fadd double %15, %2
%17 = getelementptr inbounds double, double* %5, i64 %14
%18 = load double, double* %17
%19 = getelementptr inbounds double, double* %4, i64 %14
%20 = load double, double* %19
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double %20, double %18)
%23 = fdiv double %22, %10
%24 = tail call double @sqrt(double %23)
%25 = load double, double* %19
%26 = tail call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %16, double %25, double %22, double %24)
%27 = add nuw nsw i64 %14, 1
%28 = icmp eq i64 %27, %12
br i1 %28, label %29, label %13
29: ; preds = %13, %6
%30 = tail call i32 @fclose(i32* %7)
ret void
}