#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 */
double fabs(double);
double d_bray_curtis(double *f1, double *f2, int n) {
  int i;
  double dist = 0.0f, aux;
  for (i = 0; i < n; i++) {
    aux = f1[i] + f2[i];
    if (aux > 0)
      dist += (fabs(f1[i] - f2[i]) / aux);
  }
  return (dist);
}


x86 assembly (clang, -O0):
<d_bray_curtis>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <d_bray_curtis+0xa2>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    118f <d_bray_curtis+0x8f>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movaps 0xe84(%rip),%xmm1
pand   %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1194 <d_bray_curtis+0x94>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111e <d_bray_curtis+0x1e>
movsd  -0x20(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_bray_curtis>:
test   %edx,%edx
jle    1154 <d_bray_curtis+0x54>
mov    %edx,%eax
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
movapd 0xeec(%rip),%xmm2
xorpd  %xmm0,%xmm0
jmp    1129 <d_bray_curtis+0x29>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rcx,%rax
je     1153 <d_bray_curtis+0x53>
movsd  (%rdi,%rcx,8),%xmm3
movsd  (%rsi,%rcx,8),%xmm5
movapd %xmm3,%xmm4
addsd  %xmm5,%xmm4
ucomisd %xmm1,%xmm4
jbe    1120 <d_bray_curtis+0x20>
subsd  %xmm5,%xmm3
andpd  %xmm2,%xmm3
divsd  %xmm4,%xmm3
addsd  %xmm3,%xmm0
jmp    1120 <d_bray_curtis+0x20>
ret
xorps  %xmm0,%xmm0
ret

LLVM IR (-O0):
define double @d_bray_curtis(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %8
store i32 0, i32* %7
br label %10
10: ; preds = %46, %3
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %49
14: ; preds = %10
%15 = load double*, double** %4
%16 = load i32, i32* %7
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds double, double* %15, i64 %17
%19 = load double, double* %18
%20 = load double*, double** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = fadd double %19, %24
store double %25, double* %9
%26 = load double, double* %9
%27 = fcmp ogt double %26, 0.000000e+00
br i1 %27, label %28, label %45
28: ; preds = %14
%29 = load double*, double** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = load double*, double** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = fsub double %33, %38
%40 = call double @llvm.fabs.f64(double %39)
%41 = load double, double* %9
%42 = fdiv double %40, %41
%43 = load double, double* %8
%44 = fadd double %43, %42
store double %44, double* %8
br label %45
45: ; preds = %28, %14
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %10
49: ; preds = %10
%50 = load double, double* %8
ret double %50
}

LLVM IR (-O2):
define double @d_bray_curtis(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %25
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %21
%8 = phi i64 [ 0, %5 ], [ %23, %21 ]
%9 = phi double [ 0.000000e+00, %5 ], [ %22, %21 ]
%10 = getelementptr inbounds double, double* %0, i64 %8
%11 = load double, double* %10
%12 = getelementptr inbounds double, double* %1, i64 %8
%13 = load double, double* %12
%14 = fadd double %11, %13
%15 = fcmp ogt double %14, 0.000000e+00
br i1 %15, label %16, label %21
16: ; preds = %7
%17 = fsub double %11, %13
%18 = tail call double @llvm.fabs.f64(double %17)
%19 = fdiv double %18, %14
%20 = fadd double %9, %19
br label %21
21: ; preds = %7, %16
%22 = phi double [ %20, %16 ], [ %9, %7 ]
%23 = add nuw nsw i64 %8, 1
%24 = icmp eq i64 %23, %6
br i1 %24, label %25, label %7
25: ; preds = %21, %3
%26 = phi double [ 0.000000e+00, %3 ], [ %22, %21 ]
ret double %26
}