#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 */
scalar_t__ pow(double, int);
double sqrtf(double);
double d_squared_chord(double *f1, double *f2, int n) {
  int i;
  double dist = 0.0f, aux1, aux2;
  for (i = 0; i < n; i++) {
    aux1 = sqrtf(f1[i]);
    aux2 = sqrtf(f2[i]);
    if ((aux1 >= 0) && (aux2 >= 0))
      dist += pow(aux1 - aux2, 2);
  }
  return (dist);
}


x86 assembly (clang, -O0):
<d_squared_chord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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    11d6 <d_squared_chord+0xb6>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrtf@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrtf@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c3 <d_squared_chord+0xa3>
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11c3 <d_squared_chord+0xa3>
movsd  -0x28(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c8 <d_squared_chord+0xa8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <d_squared_chord+0x22>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_squared_chord>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %edx,%edx
jle    1208 <d_squared_chord+0xe8>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    115d <d_squared_chord+0x3d>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r12
je     1212 <d_squared_chord+0xf2>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1180 <d_squared_chord+0x60>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    118d <d_squared_chord+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <sqrtf@plt>
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11b0 <d_squared_chord+0x90>
sqrtsd %xmm0,%xmm0
ucomisd %xmm1,%xmm2
jae    11cb <d_squared_chord+0xab>
jmp    1150 <d_squared_chord+0x30>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm2,0x10(%rsp)
call   1030 <sqrtf@plt>
movsd  0x10(%rsp),%xmm2
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jb     1150 <d_squared_chord+0x30>
ucomisd %xmm1,%xmm0
jb     1150 <d_squared_chord+0x30>
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
mov    $0x2,%edi
call   1040 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  %xmm1,%xmm1
jmp    1150 <d_squared_chord+0x30>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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