#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 NAN;
scalar_t__ pow(double, int);
double sqrt(double);
double isFartherThan_l2_double(double *p1, double *p2, int len, double dist) {
  double ret = 0;
  double dist2 = dist * dist;
  int i = 0;
  for (i = 0; i < len; i++) {
    ret += pow((p1[i] - p2[i]), 2);
    if (ret > dist2)
      return NAN;
  }
  return sqrt(ret);
}


x86 assembly (clang, -O0):
<isFartherThan_l2_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d4 <isFartherThan_l2_double+0xb4>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11c1 <isFartherThan_l2_double+0xa1>
mov    0x2e45(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e3 <isFartherThan_l2_double+0xc3>
jmp    11c6 <isFartherThan_l2_double+0xa6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115d <isFartherThan_l2_double+0x3d>
movsd  -0x30(%rbp),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isFartherThan_l2_double>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
test   %edx,%edx
jle    119b <isFartherThan_l2_double+0x7b>
mov    %rsi,%r14
mov    %rdi,%r15
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %edx,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x10(%rsp)
movsd  (%r15,%rbx,8),%xmm0
subsd  (%r14,%rbx,8),%xmm0
mov    $0x2,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x10(%rsp),%xmm0
ucomisd 0x8(%rsp),%xmm0
ja     11ab <isFartherThan_l2_double+0x8b>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <isFartherThan_l2_double+0x40>
ucomisd 0xe5d(%rip),%xmm0
jb     11c2 <isFartherThan_l2_double+0xa2>
sqrtsd %xmm0,%xmm0
jmp    11b6 <isFartherThan_l2_double+0x96>
mov    0x2e46(%rip),%rax
movsd  (%rax),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <sqrt@plt>

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

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