#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 squared_chi(double *s, double *z, int len, double bsf, double epsilon) {
  double dist = 0;
  double num, den;
  while (--len) {
    num = (*s - *z) * (*s - *z);
    den = *s + *z;
    if (fabs(den) < epsilon) {
      dist += num;
    } else {
      dist += num / den;
    }
    s++;
    z++;
  }
  debug(" %.6f\n", dist);
  return dist;
}


x86 assembly (clang, -O0):
<squared_chi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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     11e9 <squared_chi+0xd9>
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
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movaps 0xe6f(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b8 <squared_chi+0xa8>
movsd  -0x38(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11cc <squared_chi+0xbc>
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%rbp),%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 <squared_chi+0x25>
movsd  -0x30(%rbp),%xmm0
lea    0xe1b(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squared_chi>:
push   %rax
add    $0xffffffff,%edx
je     1179 <squared_chi+0x69>
mov    %edx,%eax
xorpd  %xmm0,%xmm0
xor    %ecx,%ecx
movapd 0xeda(%rip),%xmm7
movsd  0xee2(%rip),%xmm2
xchg   %ax,%ax
movsd  (%rdi,%rcx,8),%xmm3
movsd  (%rsi,%rcx,8),%xmm4
movapd %xmm3,%xmm5
subsd  %xmm4,%xmm5
mulsd  %xmm5,%xmm5
addsd  %xmm4,%xmm3
movapd %xmm3,%xmm4
andpd  %xmm7,%xmm4
cmpltsd %xmm1,%xmm4
movapd %xmm4,%xmm6
andnpd %xmm3,%xmm6
andpd  %xmm2,%xmm4
orpd   %xmm6,%xmm4
divsd  %xmm4,%xmm5
addsd  %xmm5,%xmm0
add    $0x1,%rcx
cmp    %ecx,%eax
jne    1130 <squared_chi+0x20>
jmp    117d <squared_chi+0x6d>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
lea    0xe8f(%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 @squared_chi(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
%12 = alloca double
%13 = 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 %14
14: ; preds = %49, %5
%15 = load i32, i32* %8
%16 = add nsw i32 %15, -1
store i32 %16, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %54
18: ; preds = %14
%19 = load double*, double** %6
%20 = load double, double* %19
%21 = load double*, double** %7
%22 = load double, double* %21
%23 = fsub double %20, %22
%24 = load double*, double** %6
%25 = load double, double* %24
%26 = load double*, double** %7
%27 = load double, double* %26
%28 = fsub double %25, %27
%29 = fmul double %23, %28
store double %29, double* %12
%30 = load double*, double** %6
%31 = load double, double* %30
%32 = load double*, double** %7
%33 = load double, double* %32
%34 = fadd double %31, %33
store double %34, double* %13
%35 = load double, double* %13
%36 = call double @llvm.fabs.f64(double %35)
%37 = load double, double* %10
%38 = fcmp olt double %36, %37
br i1 %38, label %39, label %43
39: ; preds = %18
%40 = load double, double* %12
%41 = load double, double* %11
%42 = fadd double %41, %40
store double %42, double* %11
br label %49
43: ; preds = %18
%44 = load double, double* %12
%45 = load double, double* %13
%46 = fdiv double %44, %45
%47 = load double, double* %11
%48 = fadd double %47, %46
store double %48, double* %11
br label %49
49: ; preds = %43, %39
%50 = load double*, double** %6
%51 = getelementptr inbounds double, double* %50, i32 1
store double* %51, double** %6
%52 = load double*, double** %7
%53 = getelementptr inbounds double, double* %52, i32 1
store double* %53, double** %7
br label %14
54: ; preds = %14
%55 = load double, double* %11
%56 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %55)
%57 = load double, double* %11
ret double %57
}

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