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


x86 assembly (clang, -O0):
<sorensen>:
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)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11d7 <sorensen+0xb7>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <fabs@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <fabs@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
add    %rcx,%rax
cvtsi2sd %rax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    114d <sorensen+0x2d>
movsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
lea    0xe18(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sorensen>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
add    $0xffffffff,%edx
je     11bf <sorensen+0x9f>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xchg   %ax,%ax
movsd  %xmm1,0x8(%rsp)
movsd  (%r15,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
call   1040 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%r15,%rbx,8),%xmm0
call   1040 <fabs@plt>
mov    %rax,%r13
movsd  (%r14,%rbx,8),%xmm0
call   1040 <fabs@plt>
movsd  0x8(%rsp),%xmm1
add    %r13,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1150 <sorensen+0x30>
movsd  (%rsp),%xmm0
divsd  %xmm1,%xmm0
jmp    11c7 <sorensen+0xa7>
movsd  0xe39(%rip),%xmm0
lea    0xe3a(%rip),%rdi
movsd  %xmm0,(%rsp)
call   1030 <debug@plt>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %.6f\0A\00"
define double @sorensen(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
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
store double 0.000000e+00, double* %12
br label %13
13: ; preds = %17, %5
%14 = load i32, i32* %8
%15 = add nsw i32 %14, -1
store i32 %15, i32* %8
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %41
17: ; preds = %13
%18 = load double*, double** %6
%19 = load double, double* %18
%20 = load double*, double** %7
%21 = load double, double* %20
%22 = fsub double %19, %21
%23 = call i64 @fabs(double %22)
%24 = sitofp i64 %23 to double
%25 = load double, double* %11
%26 = fadd double %25, %24
store double %26, double* %11
%27 = load double*, double** %6
%28 = load double, double* %27
%29 = call i64 @fabs(double %28)
%30 = load double*, double** %7
%31 = load double, double* %30
%32 = call i64 @fabs(double %31)
%33 = add nsw i64 %29, %32
%34 = sitofp i64 %33 to double
%35 = load double, double* %12
%36 = fadd double %35, %34
store double %36, double* %12
%37 = load double*, double** %6
%38 = getelementptr inbounds double, double* %37, i32 1
store double* %38, double** %6
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i32 1
store double* %40, double** %7
br label %13
41: ; preds = %13
%42 = load double, double* %11
%43 = load double, double* %12
%44 = fdiv double %42, %43
%45 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %44)
%46 = load double, double* %11
%47 = load double, double* %12
%48 = fdiv double %46, %47
ret double %48
}

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