#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__ FLT_GT(double, double, double);
int /*<<< orphan*/ debug(char *, double);
double euclidean2(double *s, double *z, int len, double bsf, double epsilon) {
  double dist = 0;
  while (--len) {
    dist += (*s - *z) * (*s - *z);
    s++;
    z++;
    if (FLT_GT(dist, bsf, epsilon)) {
      debug(" %.6f (early abandoned)\n", dist);
      return dist;
    }
  }
  debug(" %.6f\n", dist);
  return dist;
}


x86 assembly (clang, -O0):
<euclidean2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     11e4 <euclidean2+0xc4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
call   1040 <FLT_GT@plt>
cmp    $0x0,%rax
je     11df <euclidean2+0xbf>
movsd  -0x38(%rbp),%xmm0
lea    0xe35(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ff <euclidean2+0xdf>
jmp    1145 <euclidean2+0x25>
movsd  -0x38(%rbp),%xmm0
lea    0xe29(%rip),%rdi
call   1030 <debug@plt>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<euclidean2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
add    $0xffffffff,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %ebx,%ebx
nop
cmp    %ebx,%r12d
je     1196 <euclidean2+0x76>
movsd  (%r15,%rbx,8),%xmm1
subsd  (%r14,%rbx,8),%xmm1
mulsd  %xmm1,%xmm1
movsd  (%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1040 <FLT_GT@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1150 <euclidean2+0x30>
lea    0xe6c(%rip),%rdi
jmp    119d <euclidean2+0x7d>
lea    0xe7c(%rip),%rdi
movsd  (%rsp),%xmm0
call   1030 <debug@plt>
movsd  (%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [25 x i8] c" %.6f (early abandoned)\0A\00"
@.str.1 = [7 x i8] c" %.6f\0A\00"
define double @euclidean2(double* nocapture %0, double* nocapture %1, i32 %2, double %3, double %4) {
br label %6
6: ; preds = %13, %5
%7 = phi double* [ %1, %5 ], [ %19, %13 ]
%8 = phi i32 [ %2, %5 ], [ %11, %13 ]
%9 = phi double* [ %0, %5 ], [ %18, %13 ]
%10 = phi double [ 0.000000e+00, %5 ], [ %17, %13 ]
%11 = add nsw i32 %8, -1
%12 = icmp eq i32 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %6
%14 = load double, double* %9
%15 = load double, double* %7
%16 = fsub double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %10)
%18 = getelementptr inbounds double, double* %9, i64 1
%19 = getelementptr inbounds double, double* %7, i64 1
%20 = tail call i64 @FLT_GT(double %17, double %3, double %4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %6, label %22
22: ; preds = %13
%23 = tail call i32 @debug(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %17)
br label %26
24: ; preds = %6
%25 = tail call i32 @debug(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %26
26: ; preds = %24, %22
%27 = phi double [ %17, %22 ], [ %10, %24 ]
ret double %27
}