#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *const);
scalar_t__ feof(int /*<<< orphan*/ *const);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(double *, int, int, int /*<<< orphan*/ *const);
size_t sqrt(size_t);
double c_corr(const char f_name[]) {
  FILE *const pf = fopen(f_name, "rb");
  assert(pf != NULL);
  double sx = 0, sxx = 0, sy = 0, syy = 0, sxy = 0;
  size_t n = 0;
  while (1) {
    double x, y;
    if (fread(&x, sizeof(double), 1, pf) != 1 ||
        fread(&y, sizeof(double), 1, pf) != 1 || feof(pf)) {
      fclose(pf);
      break;
    }
    sx += x;
    sxx += x * x;
    sy += y;
    sxy += x * y;
    syy += y * y;
    ++n;
  }
  return (n * sxy - sx * sy) / sqrt(n * sxx - sx * sx) /
         sqrt(n * syy - sy * sy);
}


x86 assembly (clang, -O0):
<c_corr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x48(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1218 <c_corr+0xb8>
mov    -0x10(%rbp),%rcx
lea    -0x50(%rbp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1218 <c_corr+0xb8>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     1226 <c_corr+0xc6>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12a9 <c_corr+0x149>
movsd  -0x48(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11c5 <c_corr+0x65>
movq   -0x40(%rbp),%xmm0
movaps 0xd4b(%rip),%xmm1
movaps %xmm1,-0x80(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xd4b(%rip),%xmm1
movaps %xmm1,-0x70(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x38(%rbp),%xmm4
movsd  -0x18(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movaps %xmm1,%xmm3
mulsd  %xmm2,%xmm3
movaps %xmm0,%xmm2
mulsd  %xmm4,%xmm2
subsd  %xmm3,%xmm2
movsd  %xmm2,-0x90(%rbp)
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm1,%xmm1
mulsd  %xmm2,%xmm0
subsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
movsd  0xcf7(%rip),%xmm1
movsd  %xmm1,-0x88(%rbp)
ff
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1080 <sqrt@plt>
movsd  -0x90(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm1
ff
movaps -0x80(%rbp),%xmm3
movaps -0x70(%rbp),%xmm2
movq   %rax,%xmm4
punpckldq %xmm3,%xmm4
subpd  %xmm2,%xmm4
movaps %xmm4,%xmm5
unpckhpd %xmm4,%xmm4
addsd  %xmm5,%xmm4
divsd  %xmm4,%xmm0
movsd  %xmm0,-0x58(%rbp)
movq   -0x40(%rbp),%xmm0
punpckldq %xmm3,%xmm0
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm2
unpckhpd %xmm0,%xmm0
addsd  %xmm2,%xmm0
movsd  -0x30(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm2
mulsd  %xmm2,%xmm2
mulsd  %xmm3,%xmm0
subsd  %xmm2,%xmm0
movaps %xmm0,%xmm2
cvttsd2si %xmm2,%rdi
mov    %rdi,%rcx
sar    $0x3f,%rcx
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
and    %rcx,%rax
or     %rax,%rdi
call   1080 <sqrt@plt>
movaps -0x80(%rbp),%xmm3
movaps -0x70(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm0
movq   %rax,%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_corr>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xeb6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
lea    0x38(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
xorpd  %xmm0,%xmm0
cmp    $0x1,%eax
jne    128d <c_corr+0x12d>
movapd %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
xor    %ebx,%ebx
lea    0x58(%rsp),%r14
lea    0x38(%rsp),%r15
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    12b2 <c_corr+0x152>
mov    %r12,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12b2 <c_corr+0x152>
movsd  0x38(%rsp),%xmm0
movapd 0x40(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x40(%rsp)
movsd  0x58(%rsp),%xmm1
movapd 0x10(%rsp),%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
movapd (%rsp),%xmm3
addsd  %xmm2,%xmm3
movapd %xmm3,(%rsp)
unpcklpd %xmm1,%xmm0
mulpd  %xmm0,%xmm0
movapd 0x20(%rsp),%xmm1
addpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
add    $0x1,%rbx
mov    %r15,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
je     11e0 <c_corr+0x80>
jmp    12b2 <c_corr+0x152>
movapd %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
mov    %r12,%rdi
call   1040 <fclose@plt>
movq   %rbx,%xmm0
punpckldq 0xd39(%rip),%xmm0
subpd  0xd41(%rip),%xmm0
movapd %xmm0,%xmm3
unpckhpd %xmm0,%xmm3
addsd  %xmm0,%xmm3
movapd %xmm3,0x60(%rsp)
movapd 0x10(%rsp),%xmm0
movapd 0x40(%rsp),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm2
movapd %xmm3,%xmm1
mulsd  0x20(%rsp),%xmm1
subsd  %xmm2,%xmm1
movapd (%rsp),%xmm2
mulsd  %xmm3,%xmm2
cvttsd2si %xmm1,%rax
subsd  %xmm0,%xmm2
movapd %xmm2,(%rsp)
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xcf7(%rip),%xmm1
cvttsd2si %xmm1,%rdi
and    %rcx,%rdi
or     %rax,%rdi
call   1080 <sqrt@plt>
movq   %rax,%xmm0
punpckldq 0xcba(%rip),%xmm0
subpd  0xcc2(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd (%rsp),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movapd 0x20(%rsp),%xmm1
unpckhpd %xmm1,%xmm1
mulsd  0x60(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rcx
sar    $0x3f,%rcx
subsd  0xc86(%rip),%xmm1
cvttsd2si %xmm1,%rdi
and    %rcx,%rdi
or     %rax,%rdi
call   1080 <sqrt@plt>
movq   %rax,%xmm0
punpckldq 0xc49(%rip),%xmm0
subpd  0xc51(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd (%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define double @c_corr(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i64
%10 = alloca double
%11 = alloca double
store i8* %0, i8** %2
%12 = load i8*, i8** %2
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %3
%14 = load i32*, i32** %3
%15 = icmp ne i32* %14, null
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
store i64 0, i64* %9
br label %18
18: ; preds = %1, %33
%19 = load i32*, i32** %3
%20 = call i32 @fread(double* %10, i32 8, i32 1, i32* %19)
%21 = icmp ne i32 %20, 1
br i1 %21, label %30, label %22
22: ; preds = %18
%23 = load i32*, i32** %3
%24 = call i32 @fread(double* %11, i32 8, i32 1, i32* %23)
%25 = icmp ne i32 %24, 1
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i32*, i32** %3
%28 = call i64 @feof(i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26, %22, %18
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
br label %54
33: ; preds = %26
%34 = load double, double* %10
%35 = load double, double* %4
%36 = fadd double %35, %34
store double %36, double* %4
%37 = load double, double* %10
%38 = load double, double* %10
%39 = load double, double* %5
%40 = call double @llvm.fmuladd.f64(double %37, double %38, double %39)
store double %40, double* %5
%41 = load double, double* %11
%42 = load double, double* %6
%43 = fadd double %42, %41
store double %43, double* %6
%44 = load double, double* %10
%45 = load double, double* %11
%46 = load double, double* %8
%47 = call double @llvm.fmuladd.f64(double %44, double %45, double %46)
store double %47, double* %8
%48 = load double, double* %11
%49 = load double, double* %11
%50 = load double, double* %7
%51 = call double @llvm.fmuladd.f64(double %48, double %49, double %50)
store double %51, double* %7
%52 = load i64, i64* %9
%53 = add i64 %52, 1
store i64 %53, i64* %9
br label %18
54: ; preds = %30
%55 = load i64, i64* %9
%56 = uitofp i64 %55 to double
%57 = load double, double* %8
%58 = load double, double* %4
%59 = load double, double* %6
%60 = fmul double %58, %59
%61 = fneg double %60
%62 = call double @llvm.fmuladd.f64(double %56, double %57, double %61)
%63 = load i64, i64* %9
%64 = uitofp i64 %63 to double
%65 = load double, double* %5
%66 = load double, double* %4
%67 = load double, double* %4
%68 = fmul double %66, %67
%69 = fneg double %68
%70 = call double @llvm.fmuladd.f64(double %64, double %65, double %69)
%71 = fptoui double %70 to i64
%72 = call i64 @sqrt(i64 %71)
%73 = uitofp i64 %72 to double
%74 = fdiv double %62, %73
%75 = load i64, i64* %9
%76 = uitofp i64 %75 to double
%77 = load double, double* %7
%78 = load double, double* %6
%79 = load double, double* %6
%80 = fmul double %78, %79
%81 = fneg double %80
%82 = call double @llvm.fmuladd.f64(double %76, double %77, double %81)
%83 = fptoui double %82 to i64
%84 = call i64 @sqrt(i64 %83)
%85 = uitofp i64 %84 to double
%86 = fdiv double %74, %85
ret double %86
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define double @c_corr(i8* nocapture %0) {
%2 = alloca double
%3 = alloca double
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32* %4, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = bitcast double* %2 to i8*
%9 = bitcast double* %3 to i8*
%10 = call i32 @fread(double* %2, i32 8, i32 1, i32* %4)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %35
12: ; preds = %1, %23
%13 = phi i64 [ %32, %23 ], [ 0, %1 ]
%14 = phi double [ %28, %23 ], [ 0.000000e+00, %1 ]
%15 = phi double [ %27, %23 ], [ 0.000000e+00, %1 ]
%16 = phi double [ %25, %23 ], [ 0.000000e+00, %1 ]
%17 = phi <2 x double> [ %31, %23 ], [ zeroinitializer, %1 ]
%18 = call i32 @fread(double* %3, i32 8, i32 1, i32* %4)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %35
20: ; preds = %12
%21 = tail call i64 @feof(i32* %4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load double, double* %2
%25 = fadd double %16, %24
%26 = load double, double* %3
%27 = fadd double %15, %26
%28 = tail call double @llvm.fmuladd.f64(double %24, double %26, double %14)
%29 = insertelement <2 x double> poison, double %24, i64 0
%30 = insertelement <2 x double> %29, double %26, i64 1
%31 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %30, <2 x double> %30, <2 x double> %17)
%32 = add i64 %13, 1
%33 = call i32 @fread(double* %2, i32 8, i32 1, i32* %4)
%34 = icmp eq i32 %33, 1
br i1 %34, label %12, label %35
35: ; preds = %20, %12, %23, %1
%36 = phi double [ 0.000000e+00, %1 ], [ %25, %23 ], [ %16, %12 ], [ %16, %20 ]
%37 = phi double [ 0.000000e+00, %1 ], [ %27, %23 ], [ %15, %12 ], [ %15, %20 ]
%38 = phi double [ 0.000000e+00, %1 ], [ %28, %23 ], [ %14, %12 ], [ %14, %20 ]
%39 = phi i64 [ 0, %1 ], [ %32, %23 ], [ %13, %12 ], [ %13, %20 ]
%40 = phi <2 x double> [ zeroinitializer, %1 ], [ %31, %23 ], [ %17, %12 ], [ %17, %20 ]
%41 = tail call i32 @fclose(i32* %4)
%42 = uitofp i64 %39 to double
%43 = fneg double %36
%44 = fmul double %37, %43
%45 = tail call double @llvm.fmuladd.f64(double %42, double %38, double %44)
%46 = fmul double %36, %43
%47 = extractelement <2 x double> %40, i64 0
%48 = tail call double @llvm.fmuladd.f64(double %42, double %47, double %46)
%49 = fptoui double %48 to i64
%50 = tail call i64 @sqrt(i64 %49)
%51 = uitofp i64 %50 to double
%52 = fdiv double %45, %51
%53 = fneg double %37
%54 = fmul double %37, %53
%55 = extractelement <2 x double> %40, i64 1
%56 = tail call double @llvm.fmuladd.f64(double %42, double %55, double %54)
%57 = fptoui double %56 to i64
%58 = tail call i64 @sqrt(i64 %57)
%59 = uitofp i64 %58 to double
%60 = fdiv double %52, %59
ret double %60
}