#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_prune(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;
    }
    if (x >= 0.25 || y >= 0.25)
      continue;
    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_prune>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb6(%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_prune+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_prune+0xb8>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     1226 <c_corr_prune+0xc6>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
jmp    12dc <c_corr_prune+0x17c>
movsd  -0x48(%rbp),%xmm0
movsd  0xdcd(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1254 <c_corr_prune+0xf4>
movsd  -0x50(%rbp),%xmm0
movsd  0xdb6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1259 <c_corr_prune+0xf9>
jmp    11c5 <c_corr_prune+0x65>
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_prune+0x65>
movq   -0x40(%rbp),%xmm0
movaps 0xd28(%rip),%xmm1
movaps %xmm1,-0x80(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xd28(%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)
ff
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  0xcac(%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_prune>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0xebe(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
lea    0x38(%rsp),%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
xorpd  %xmm0,%xmm0
cmp    $0x1,%eax
jne    12a4 <c_corr_prune+0x144>
movapd %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
xor    %r12d,%r12d
lea    0x58(%rsp),%r14
lea    0x38(%rsp),%r15
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
jmp    11fe <c_corr_prune+0x9e>
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    12ca <c_corr_prune+0x16a>
mov    %r14,%rdi
mov    $0x8,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    12ca <c_corr_prune+0x16a>
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
jne    12ca <c_corr_prune+0x16a>
movsd  0x38(%rsp),%xmm0
movsd  0xdc5(%rip),%xmm2
ucomisd %xmm2,%xmm0
jae    11e0 <c_corr_prune+0x80>
movsd  0x58(%rsp),%xmm1
ucomisd %xmm2,%xmm1
jae    11e0 <c_corr_prune+0x80>
movapd 0x40(%rsp),%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,0x40(%rsp)
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,%r12
jmp    11e0 <c_corr_prune+0x80>
movapd %xmm0,0x20(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,0x40(%rsp)
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
xorpd  %xmm0,%xmm0
movapd %xmm0,(%rsp)
mov    %rbx,%rdi
call   1040 <fclose@plt>
movq   %r12,%xmm0
punpckldq 0xd31(%rip),%xmm0
subpd  0xd39(%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  0xcc7(%rip),%xmm1
cvttsd2si %xmm1,%rdi
and    %rcx,%rdi
or     %rax,%rdi
call   1080 <sqrt@plt>
movq   %rax,%xmm0
punpckldq 0xcb2(%rip),%xmm0
subpd  0xcba(%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  0xc56(%rip),%xmm1
cvttsd2si %xmm1,%rdi
and    %rcx,%rdi
or     %rax,%rdi
call   1080 <sqrt@plt>
movq   %rax,%xmm0
punpckldq 0xc41(%rip),%xmm0
subpd  0xc49(%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_prune(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, %39, %40
%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 %61
33: ; preds = %26
%34 = load double, double* %10
%35 = fcmp oge double %34, 2.500000e-01
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load double, double* %11
%38 = fcmp oge double %37, 2.500000e-01
br i1 %38, label %39, label %40
39: ; preds = %36, %33
br label %18
40: ; preds = %36
%41 = load double, double* %10
%42 = load double, double* %4
%43 = fadd double %42, %41
store double %43, double* %4
%44 = load double, double* %10
%45 = load double, double* %10
%46 = load double, double* %5
%47 = call double @llvm.fmuladd.f64(double %44, double %45, double %46)
store double %47, double* %5
%48 = load double, double* %11
%49 = load double, double* %6
%50 = fadd double %49, %48
store double %50, double* %6
%51 = load double, double* %10
%52 = load double, double* %11
%53 = load double, double* %8
%54 = call double @llvm.fmuladd.f64(double %51, double %52, double %53)
store double %54, double* %8
%55 = load double, double* %11
%56 = load double, double* %11
%57 = load double, double* %7
%58 = call double @llvm.fmuladd.f64(double %55, double %56, double %57)
store double %58, double* %7
%59 = load i64, i64* %9
%60 = add i64 %59, 1
store i64 %60, i64* %9
br label %18
61: ; preds = %30
%62 = load i64, i64* %9
%63 = uitofp i64 %62 to double
%64 = load double, double* %8
%65 = load double, double* %4
%66 = load double, double* %6
%67 = fmul double %65, %66
%68 = fneg double %67
%69 = call double @llvm.fmuladd.f64(double %63, double %64, double %68)
%70 = load i64, i64* %9
%71 = uitofp i64 %70 to double
%72 = load double, double* %5
%73 = load double, double* %4
%74 = load double, double* %4
%75 = fmul double %73, %74
%76 = fneg double %75
%77 = call double @llvm.fmuladd.f64(double %71, double %72, double %76)
%78 = fptoui double %77 to i64
%79 = call i64 @sqrt(i64 %78)
%80 = uitofp i64 %79 to double
%81 = fdiv double %69, %80
%82 = load i64, i64* %9
%83 = uitofp i64 %82 to double
%84 = load double, double* %7
%85 = load double, double* %6
%86 = load double, double* %6
%87 = fmul double %85, %86
%88 = fneg double %87
%89 = call double @llvm.fmuladd.f64(double %83, double %84, double %88)
%90 = fptoui double %89 to i64
%91 = call i64 @sqrt(i64 %90)
%92 = uitofp i64 %91 to double
%93 = fdiv double %81, %92
ret double %93
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define double @c_corr_prune(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 %45
12: ; preds = %1, %37
%13 = phi i64 [ %41, %37 ], [ 0, %1 ]
%14 = phi double [ %40, %37 ], [ 0.000000e+00, %1 ]
%15 = phi double [ %39, %37 ], [ 0.000000e+00, %1 ]
%16 = phi double [ %38, %37 ], [ 0.000000e+00, %1 ]
%17 = phi <2 x double> [ %42, %37 ], [ 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 %45
20: ; preds = %12
%21 = tail call i64 @feof(i32* %4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %45
23: ; preds = %20
%24 = load double, double* %2
%25 = fcmp oge double %24, 2.500000e-01
%26 = load double, double* %3
%27 = fcmp oge double %26, 2.500000e-01
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %37, label %29
29: ; preds = %23
%30 = fadd double %16, %24
%31 = fadd double %15, %26
%32 = tail call double @llvm.fmuladd.f64(double %24, double %26, double %14)
%33 = insertelement <2 x double> poison, double %24, i64 0
%34 = insertelement <2 x double> %33, double %26, i64 1
%35 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %34, <2 x double> %34, <2 x double> %17)
%36 = add i64 %13, 1
br label %37
37: ; preds = %23, %29
%38 = phi double [ %30, %29 ], [ %16, %23 ]
%39 = phi double [ %31, %29 ], [ %15, %23 ]
%40 = phi double [ %32, %29 ], [ %14, %23 ]
%41 = phi i64 [ %36, %29 ], [ %13, %23 ]
%42 = phi <2 x double> [ %35, %29 ], [ %17, %23 ]
%43 = call i32 @fread(double* %2, i32 8, i32 1, i32* %4)
%44 = icmp eq i32 %43, 1
br i1 %44, label %12, label %45
45: ; preds = %20, %12, %37, %1
%46 = phi double [ 0.000000e+00, %1 ], [ %38, %37 ], [ %16, %12 ], [ %16, %20 ]
%47 = phi double [ 0.000000e+00, %1 ], [ %39, %37 ], [ %15, %12 ], [ %15, %20 ]
%48 = phi double [ 0.000000e+00, %1 ], [ %40, %37 ], [ %14, %12 ], [ %14, %20 ]
%49 = phi i64 [ 0, %1 ], [ %41, %37 ], [ %13, %12 ], [ %13, %20 ]
%50 = phi <2 x double> [ zeroinitializer, %1 ], [ %42, %37 ], [ %17, %12 ], [ %17, %20 ]
%51 = tail call i32 @fclose(i32* %4)
%52 = uitofp i64 %49 to double
%53 = fneg double %46
%54 = fmul double %47, %53
%55 = tail call double @llvm.fmuladd.f64(double %52, double %48, double %54)
%56 = fmul double %46, %53
%57 = extractelement <2 x double> %50, i64 0
%58 = tail call double @llvm.fmuladd.f64(double %52, double %57, double %56)
%59 = fptoui double %58 to i64
%60 = tail call i64 @sqrt(i64 %59)
%61 = uitofp i64 %60 to double
%62 = fdiv double %55, %61
%63 = fneg double %47
%64 = fmul double %47, %63
%65 = extractelement <2 x double> %50, i64 1
%66 = tail call double @llvm.fmuladd.f64(double %52, double %65, double %64)
%67 = fptoui double %66 to i64
%68 = tail call i64 @sqrt(i64 %67)
%69 = uitofp i64 %68 to double
%70 = fdiv double %62, %69
ret double %70
}