#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 */

/* Variables and functions */
int /*<<< orphan*/ debug(char *, double);
double fabs(double);
double pearson(double *s, double *z, int len, double bsf, double epsilon) {
  double dist = 0;
  while (--len) {
    if (fabs(*z) < epsilon) {
      dist += *s * *s;
    } else {
      dist += ((*s - *z) * (*s - *z)) / *z;
    }
    s++;
    z++;
  }
  debug(" %.6f\n", dist);
  return dist;
}


x86 assembly (clang, -O0):
<pearson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11e3 <pearson+0xd3>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movaps 0xeaa(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1190 <pearson+0x80>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11c6 <pearson+0xb6>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1135 <pearson+0x25>
movsd  -0x30(%rbp),%xmm0
lea    0xe21(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pearson>:
push   %rax
add    $0xffffffff,%edx
je     1166 <pearson+0x56>
mov    %edx,%eax
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
movapd 0xeda(%rip),%xmm4
jmp    1148 <pearson+0x38>
nopl   0x0(%rax,%rax,1)
subsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm2
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm0
add    $0x1,%rcx
cmp    %ecx,%eax
je     116a <pearson+0x5a>
movsd  (%rsi,%rcx,8),%xmm3
movapd %xmm3,%xmm2
andpd  %xmm4,%xmm2
ucomisd %xmm2,%xmm1
movsd  (%rdi,%rcx,8),%xmm2
jbe    1130 <pearson+0x20>
mulsd  %xmm2,%xmm2
jmp    113c <pearson+0x2c>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
lea    0xe9a(%rip),%rdi
call   1030 <debug@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %.6f\0A\00"
define double @pearson(double* %0, double* %1, i32 %2, double %3, double %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store double %3, double* %9
store double %4, double* %10
store double 0.000000e+00, double* %11
br label %12
12: ; preds = %46, %5
%13 = load i32, i32* %8
%14 = add nsw i32 %13, -1
store i32 %14, i32* %8
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %51
16: ; preds = %12
%17 = load double*, double** %7
%18 = load double, double* %17
%19 = call double @llvm.fabs.f64(double %18)
%20 = load double, double* %10
%21 = fcmp olt double %19, %20
br i1 %21, label %22, label %29
22: ; preds = %16
%23 = load double*, double** %6
%24 = load double, double* %23
%25 = load double*, double** %6
%26 = load double, double* %25
%27 = load double, double* %11
%28 = call double @llvm.fmuladd.f64(double %24, double %26, double %27)
store double %28, double* %11
br label %46
29: ; preds = %16
%30 = load double*, double** %6
%31 = load double, double* %30
%32 = load double*, double** %7
%33 = load double, double* %32
%34 = fsub double %31, %33
%35 = load double*, double** %6
%36 = load double, double* %35
%37 = load double*, double** %7
%38 = load double, double* %37
%39 = fsub double %36, %38
%40 = fmul double %34, %39
%41 = load double*, double** %7
%42 = load double, double* %41
%43 = fdiv double %40, %42
%44 = load double, double* %11
%45 = fadd double %44, %43
store double %45, double* %11
br label %46
46: ; preds = %29, %22
%47 = load double*, double** %6
%48 = getelementptr inbounds double, double* %47, i32 1
store double* %48, double** %6
%49 = load double*, double** %7
%50 = getelementptr inbounds double, double* %49, i32 1
store double* %50, double** %7
br label %12
51: ; preds = %12
%52 = load double, double* %11
%53 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %52)
%54 = load double, double* %11
ret double %54
}

LLVM IR (-O2):
@.str = [7 x i8] c" %.6f\0A\00"
define double @pearson(double* nocapture %0, double* nocapture %1, i32 %2, double %3, double %4) {
%6 = add nsw i32 %2, -1
%7 = icmp eq i32 %6, 0
br i1 %7, label %30, label %8
8: ; preds = %5, %24
%9 = phi i32 [ %28, %24 ], [ %6, %5 ]
%10 = phi double [ %25, %24 ], [ 0.000000e+00, %5 ]
%11 = phi double* [ %26, %24 ], [ %0, %5 ]
%12 = phi double* [ %27, %24 ], [ %1, %5 ]
%13 = load double, double* %12
%14 = tail call double @llvm.fabs.f64(double %13)
%15 = fcmp olt double %14, %4
%16 = load double, double* %11
br i1 %15, label %17, label %19
17: ; preds = %8
%18 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %10)
br label %24
19: ; preds = %8
%20 = fsub double %16, %13
%21 = fmul double %20, %20
%22 = fdiv double %21, %13
%23 = fadd double %10, %22
br label %24
24: ; preds = %19, %17
%25 = phi double [ %18, %17 ], [ %23, %19 ]
%26 = getelementptr inbounds double, double* %11, i64 1
%27 = getelementptr inbounds double, double* %12, i64 1
%28 = add nsw i32 %9, -1
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %8
30: ; preds = %24, %5
%31 = phi double [ 0.000000e+00, %5 ], [ %25, %24 ]
%32 = tail call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %31)
ret double %31
}