int kd_node_node_euclidean(void *userdata, int ndims, double *realmin,
                           double *realmax, double *distmin, double *distmax) {
  int i;
  *distmin = 0;
  *distmax = 0;
  for (i = 0; i < ndims; i++) {
    *distmin += realmin[i] * realmin[i];
    *distmax += realmax[i] * realmax[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<kd_node_node_euclidean>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ae <kd_node_node_euclidean+0xae>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1138 <kd_node_node_euclidean+0x38>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<kd_node_node_euclidean>:
movq   $0x0,(%r8)
movq   $0x0,(%r9)
test   %esi,%esi
jle    11b1 <kd_node_node_euclidean+0xb1>
mov    %esi,%eax
cmp    $0x1,%esi
jne    1121 <kd_node_node_euclidean+0x21>
xor    %esi,%esi
jmp    1187 <kd_node_node_euclidean+0x87>
mov    %eax,%edi
and    $0xfffffffe,%edi
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r8),%xmm0
movsd  %xmm0,(%r8)
movsd  (%rcx,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r9),%xmm0
movsd  %xmm0,(%r9)
movsd  0x8(%rdx,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r8),%xmm0
movsd  %xmm0,(%r8)
movsd  0x8(%rcx,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r9),%xmm0
movsd  %xmm0,(%r9)
add    $0x2,%rsi
cmp    %rsi,%rdi
jne    1130 <kd_node_node_euclidean+0x30>
test   $0x1,%al
je     11b1 <kd_node_node_euclidean+0xb1>
movsd  (%rdx,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r8),%xmm0
movsd  %xmm0,(%r8)
movsd  (%rcx,%rsi,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r9),%xmm0
movsd  %xmm0,(%r9)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @kd_node_node_euclidean(i8* nocapture readnone %0, i32 %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5) {
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %49
8: ; preds = %6
%9 = zext i32 %1 to i64
%10 = and i64 %9, 1
%11 = icmp eq i32 %1, 1
br i1 %11, label %37, label %12
12: ; preds = %8
%13 = and i64 %9, 4294967294
br label %14
14: ; preds = %14, %12
%15 = phi i64 [ 0, %12 ], [ %34, %14 ]
%16 = phi i64 [ 0, %12 ], [ %35, %14 ]
%17 = getelementptr inbounds double, double* %2, i64 %15
%18 = load double, double* %17
%19 = load double, double* %4
%20 = tail call double @llvm.fmuladd.f64(double %18, double %18, double %19)
store double %20, double* %4
%21 = getelementptr inbounds double, double* %3, i64 %15
%22 = load double, double* %21
%23 = load double, double* %5
%24 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %23)
store double %24, double* %5
%25 = or i64 %15, 1
%26 = getelementptr inbounds double, double* %2, i64 %25
%27 = load double, double* %26
%28 = load double, double* %4
%29 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %28)
store double %29, double* %4
%30 = getelementptr inbounds double, double* %3, i64 %25
%31 = load double, double* %30
%32 = load double, double* %5
%33 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %32)
store double %33, double* %5
%34 = add nuw nsw i64 %15, 2
%35 = add i64 %16, 2
%36 = icmp eq i64 %35, %13
br i1 %36, label %37, label %14
37: ; preds = %14, %8
%38 = phi i64 [ 0, %8 ], [ %34, %14 ]
%39 = icmp eq i64 %10, 0
br i1 %39, label %49, label %40
40: ; preds = %37
%41 = getelementptr inbounds double, double* %2, i64 %38
%42 = load double, double* %41
%43 = load double, double* %4
%44 = tail call double @llvm.fmuladd.f64(double %42, double %42, double %43)
store double %44, double* %4
%45 = getelementptr inbounds double, double* %3, i64 %38
%46 = load double, double* %45
%47 = load double, double* %5
%48 = tail call double @llvm.fmuladd.f64(double %46, double %46, double %47)
store double %48, double* %5
br label %49
49: ; preds = %40, %37, %6
ret i32 0
}