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


x86 assembly (clang, -O0):
<jeffrey>:
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     11fa <jeffrey+0xda>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movaps 0xe88(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11dd <jeffrey+0xbd>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11dd <jeffrey+0xbd>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%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    1145 <jeffrey+0x25>
movsd  -0x30(%rbp),%xmm0
lea    0xe0a(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jeffrey>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
add    $0xffffffff,%edx
je     11d0 <jeffrey+0xb0>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
movapd 0xeb9(%rip),%xmm6
xorpd  %xmm5,%xmm5
movsd  %xmm1,0x8(%rsp)
jmp    1169 <jeffrey+0x49>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %ebx,%r12d
je     11d4 <jeffrey+0xb4>
movsd  (%r15,%rbx,8),%xmm0
movsd  (%r14,%rbx,8),%xmm4
movapd %xmm0,%xmm2
mulsd  %xmm4,%xmm2
movapd %xmm2,%xmm3
andpd  %xmm6,%xmm3
ucomisd %xmm1,%xmm3
jbe    1160 <jeffrey+0x40>
ucomisd 0xe7d(%rip),%xmm2
jbe    1160 <jeffrey+0x40>
movapd %xmm0,%xmm2
subsd  %xmm4,%xmm2
movsd  %xmm2,0x10(%rsp)
divsd  %xmm4,%xmm0
movsd  %xmm5,(%rsp)
call   1040 <log@plt>
movapd 0xe47(%rip),%xmm6
movsd  (%rsp),%xmm5
movsd  0x8(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm0
addsd  %xmm0,%xmm5
jmp    1160 <jeffrey+0x40>
xorpd  %xmm5,%xmm5
movsd  %xmm5,(%rsp)
lea    0xe38(%rip),%rdi
movapd %xmm5,%xmm0
call   1030 <debug@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" %.6f\0A\00"
define double @jeffrey(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
br label %13
13: ; preds = %44, %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 %49
17: ; preds = %13
%18 = load double*, double** %6
%19 = load double, double* %18
%20 = load double*, double** %7
%21 = load double, double* %20
%22 = fmul double %19, %21
store double %22, double* %12
%23 = load double, double* %12
%24 = call double @llvm.fabs.f64(double %23)
%25 = load double, double* %10
%26 = fcmp ogt double %24, %25
br i1 %26, label %27, label %44
27: ; preds = %17
%28 = load double, double* %12
%29 = fcmp ogt double %28, 0.000000e+00
br i1 %29, label %30, label %44
30: ; preds = %27
%31 = load double*, double** %6
%32 = load double, double* %31
%33 = load double*, double** %7
%34 = load double, double* %33
%35 = fsub double %32, %34
%36 = load double*, double** %6
%37 = load double, double* %36
%38 = load double*, double** %7
%39 = load double, double* %38
%40 = fdiv double %37, %39
%41 = call double @log(double %40)
%42 = load double, double* %11
%43 = call double @llvm.fmuladd.f64(double %35, double %41, double %42)
store double %43, double* %11
br label %44
44: ; preds = %30, %27, %17
%45 = load double*, double** %6
%46 = getelementptr inbounds double, double* %45, i32 1
store double* %46, double** %6
%47 = load double*, double** %7
%48 = getelementptr inbounds double, double* %47, i32 1
store double* %48, double** %7
br label %13
49: ; preds = %13
%50 = load double, double* %11
%51 = call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %50)
%52 = load double, double* %11
ret double %52
}

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