#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 */
typedef struct TYPE_12__ TYPE_1__;

/* Type definitions */
struct TYPE_12__ {
  int /*<<< orphan*/ member_1;
  int /*<<< orphan*/ member_0;
};
typedef TYPE_1__ __m128d;

/* Variables and functions */
double NAN;
TYPE_1__ _mm_add_pd(TYPE_1__, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_mul_pd(TYPE_1__, TYPE_1__);
int /*<<< orphan*/ _mm_store_pd(double *, TYPE_1__);
TYPE_1__ _mm_sub_pd(TYPE_1__, TYPE_1__);
scalar_t__ pow(double, int);
double sqrt(double);
double isFartherThan_l2_m128d(__m128d *p1, __m128d *p2, int len, double dist) {
  double ret = 0;
  double dist2 = dist * dist;
  __m128d sum = {0, 0};
  double fsum[2];
  int i = 0;
  for (i = 0; i < len / 2; i++) {
    __m128d diff;
    diff = _mm_sub_pd(p1[i], p2[i]);
    sum = _mm_add_pd(sum, _mm_mul_pd(diff, diff));
    _mm_store_pd(fsum, sum);
    if (i % 4 == 0) {
      if (fsum[0] + fsum[1] > dist2) {
        return NAN;
      }
    }
  }
  ret = fsum[0] + fsum[1];
  for (i *= 2; i < len; i++) {
    ret += pow(((double *)p1)[i] - ((double *)p2)[i], 2);
  }
  return sqrt(ret);
}


x86 assembly (clang, -O0):
<isFartherThan_l2_m128d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
cmp    %ecx,%eax
jge    128e <isFartherThan_l2_m128d+0x11e>
mov    -0x10(%rbp),%rdx
movslq -0x54(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rdx,%rsi,8),%rdi
mov    (%rax,%rcx,8),%rsi
call   1040 <_mm_sub_pd@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1080 <_mm_mul_pd@plt>
mov    %eax,%esi
mov    -0x40(%rbp),%rdi
call   1060 <_mm_add_pd@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <_mm_store_pd@plt>
mov    -0x54(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    127b <isFartherThan_l2_m128d+0x10b>
movsd  -0x50(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1276 <isFartherThan_l2_m128d+0x106>
mov    0x2d90(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1302 <isFartherThan_l2_m128d+0x192>
jmp    127b <isFartherThan_l2_m128d+0x10b>
jmp    1280 <isFartherThan_l2_m128d+0x110>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11c0 <isFartherThan_l2_m128d+0x50>
movsd  -0x50(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12f3 <isFartherThan_l2_m128d+0x183>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1070 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12a6 <isFartherThan_l2_m128d+0x136>
movsd  -0x30(%rbp),%xmm0
call   1090 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isFartherThan_l2_m128d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
cmp    $0x2,%edx
jl     1212 <isFartherThan_l2_m128d+0xb2>
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    %edx,%eax
shr    $0x1f,%eax
mov    %edx,0xc(%rsp)
add    %edx,%eax
sar    %eax
mov    %rax,0x20(%rsp)
mov    %eax,%r15d
xor    %r13d,%r13d
lea    0x10(%rsp),%r12
xor    %ebp,%ebp
jmp    11b9 <isFartherThan_l2_m128d+0x59>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
cmp    %r13,%r15
je     1216 <isFartherThan_l2_m128d+0xb6>
mov    (%rbx,%r13,8),%rdi
mov    (%r14,%r13,8),%rsi
call   1040 <_mm_sub_pd@plt>
mov    %rax,%rdi
mov    %rax,%rsi
call   1070 <_mm_mul_pd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1050 <_mm_add_pd@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <_mm_store_pd@plt>
test   $0x3,%r13b
jne    11b0 <isFartherThan_l2_m128d+0x50>
movsd  0x10(%rsp),%xmm0
addsd  0x18(%rsp),%xmm0
ucomisd (%rsp),%xmm0
jbe    11b0 <isFartherThan_l2_m128d+0x50>
mov    0x2def(%rip),%rax
movsd  (%rax),%xmm0
jmp    12f5 <isFartherThan_l2_m128d+0x195>
xor    %ecx,%ecx
jmp    122b <isFartherThan_l2_m128d+0xcb>
movsd  0x10(%rsp),%xmm1
addsd  0x18(%rsp),%xmm1
mov    0xc(%rsp),%edx
mov    0x20(%rsp),%rcx
lea    (%rcx,%rcx,1),%eax
cmp    %edx,%eax
jge    12d9 <isFartherThan_l2_m128d+0x179>
mov    %ecx,%ebp
add    %rbp,%rbp
mov    %edx,%r15d
mov    %rbp,%r12
not    %r12
test   $0x1,%r15b
je     1279 <isFartherThan_l2_m128d+0x119>
movsd  (%rbx,%rbp,8),%xmm0
subsd  (%r14,%rbp,8),%xmm0
mov    $0x2,%edi
movsd  %xmm1,(%rsp)
call   1060 <pow@plt>
movsd  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
or     $0x1,%rbp
add    %r15,%r12
je     12d9 <isFartherThan_l2_m128d+0x179>
xchg   %ax,%ax
movsd  %xmm1,(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
subsd  (%r14,%rbp,8),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%rbx,%rbp,8),%xmm0
subsd  0x8(%r14,%rbp,8),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  (%rsp),%xmm1
add    $0x2,%rbp
cmp    %rbp,%r15
jne    1280 <isFartherThan_l2_m128d+0x120>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     12ec <isFartherThan_l2_m128d+0x18c>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    12f5 <isFartherThan_l2_m128d+0x195>
movapd %xmm1,%xmm0
call   1080 <sqrt@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_12__ = type { i32, i32 }
@NAN = global double 0.000000e+00
define double @isFartherThan_l2_m128d(%struct.TYPE_12__* %0, %struct.TYPE_12__* %1, i32 %2, double %3) {
%5 = alloca double
%6 = alloca %struct.TYPE_12__*
%7 = alloca %struct.TYPE_12__*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca %struct.TYPE_12__
%13 = alloca [2 x double]
%14 = alloca i32
%15 = alloca %struct.TYPE_12__
%16 = alloca %struct.TYPE_12__
%17 = alloca %struct.TYPE_12__
store %struct.TYPE_12__* %0, %struct.TYPE_12__** %6
store %struct.TYPE_12__* %1, %struct.TYPE_12__** %7
store i32 %2, i32* %8
store double %3, double* %9
store double 0.000000e+00, double* %10
%18 = load double, double* %9
%19 = load double, double* %9
%20 = fmul double %18, %19
store double %20, double* %11
%21 = bitcast %struct.TYPE_12__* %12 to i8*
store i32 0, i32* %14
store i32 0, i32* %14
br label %22
22: ; preds = %74, %4
%23 = load i32, i32* %14
%24 = load i32, i32* %8
%25 = sdiv i32 %24, 2
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %77
27: ; preds = %22
%28 = load %struct.TYPE_12__*, %struct.TYPE_12__** %6
%29 = load i32, i32* %14
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %28, i64 %30
%32 = load %struct.TYPE_12__*, %struct.TYPE_12__** %7
%33 = load i32, i32* %14
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %32, i64 %34
%36 = bitcast %struct.TYPE_12__* %31 to i64*
%37 = load i64, i64* %36
%38 = bitcast %struct.TYPE_12__* %35 to i64*
%39 = load i64, i64* %38
%40 = call i64 @_mm_sub_pd(i64 %37, i64 %39)
%41 = bitcast %struct.TYPE_12__* %16 to i64*
store i64 %40, i64* %41
%42 = bitcast %struct.TYPE_12__* %15 to i8*
%43 = bitcast %struct.TYPE_12__* %16 to i8*
%44 = bitcast %struct.TYPE_12__* %15 to i64*
%45 = load i64, i64* %44
%46 = bitcast %struct.TYPE_12__* %15 to i64*
%47 = load i64, i64* %46
%48 = call i32 @_mm_mul_pd(i64 %45, i64 %47)
%49 = bitcast %struct.TYPE_12__* %12 to i64*
%50 = load i64, i64* %49
%51 = call i64 @_mm_add_pd(i64 %50, i32 %48)
%52 = bitcast %struct.TYPE_12__* %17 to i64*
store i64 %51, i64* %52
%53 = bitcast %struct.TYPE_12__* %12 to i8*
%54 = bitcast %struct.TYPE_12__* %17 to i8*
%55 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%56 = bitcast %struct.TYPE_12__* %12 to i64*
%57 = load i64, i64* %56
%58 = call i32 @_mm_store_pd(double* %55, i64 %57)
%59 = load i32, i32* %14
%60 = srem i32 %59, 4
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %73
62: ; preds = %27
%63 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%64 = load double, double* %63
%65 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 1
%66 = load double, double* %65
%67 = fadd double %64, %66
%68 = load double, double* %11
%69 = fcmp ogt double %67, %68
br i1 %69, label %70, label %72
70: ; preds = %62
%71 = load double, double* @NAN
store double %71, double* %5
br label %113
72: ; preds = %62
br label %73
73: ; preds = %72, %27
br label %74
74: ; preds = %73
%75 = load i32, i32* %14
%76 = add nsw i32 %75, 1
store i32 %76, i32* %14
br label %22
77: ; preds = %22
%78 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 0
%79 = load double, double* %78
%80 = getelementptr inbounds [2 x double], [2 x double]* %13, i64 0, i64 1
%81 = load double, double* %80
%82 = fadd double %79, %81
store double %82, double* %10
%83 = load i32, i32* %14
%84 = mul nsw i32 %83, 2
store i32 %84, i32* %14
br label %85
85: ; preds = %107, %77
%86 = load i32, i32* %14
%87 = load i32, i32* %8
%88 = icmp slt i32 %86, %87
br i1 %88, label %89, label %110
89: ; preds = %85
%90 = load %struct.TYPE_12__*, %struct.TYPE_12__** %6
%91 = bitcast %struct.TYPE_12__* %90 to double*
%92 = load i32, i32* %14
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %91, i64 %93
%95 = load double, double* %94
%96 = load %struct.TYPE_12__*, %struct.TYPE_12__** %7
%97 = bitcast %struct.TYPE_12__* %96 to double*
%98 = load i32, i32* %14
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %97, i64 %99
%101 = load double, double* %100
%102 = fsub double %95, %101
%103 = call i64 @pow(double %102, i32 2)
%104 = sitofp i64 %103 to double
%105 = load double, double* %10
%106 = fadd double %105, %104
store double %106, double* %10
br label %107
107: ; preds = %89
%108 = load i32, i32* %14
%109 = add nsw i32 %108, 1
store i32 %109, i32* %14
br label %85
110: ; preds = %85
%111 = load double, double* %10
%112 = call double @sqrt(double %111)
store double %112, double* %5
br label %113
113: ; preds = %110, %70
%114 = load double, double* %5
ret double %114
}

LLVM IR (-O2):
%struct.TYPE_12__ = type { i32, i32 }
@NAN = global double 0.000000e+00
define double @isFartherThan_l2_m128d(%struct.TYPE_12__* nocapture %0, %struct.TYPE_12__* nocapture %1, i32 %2, double %3) {
%5 = alloca [2 x double]
%6 = fmul double %3, %3
%7 = bitcast [2 x double]* %5 to i8*
%8 = sdiv i32 %2, 2
%9 = icmp sgt i32 %2, 1
br i1 %9, label %10, label %43
10: ; preds = %4
%11 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 0
%12 = getelementptr inbounds [2 x double], [2 x double]* %5, i64 0, i64 1
%13 = zext i32 %8 to i64
br label %14
14: ; preds = %10, %36
%15 = phi i64 [ 0, %10 ], [ %37, %36 ]
%16 = phi i64 [ 0, %10 ], [ %25, %36 ]
%17 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 %15
%18 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %1, i64 %15
%19 = bitcast %struct.TYPE_12__* %17 to i64*
%20 = load i64, i64* %19
%21 = bitcast %struct.TYPE_12__* %18 to i64*
%22 = load i64, i64* %21
%23 = call i64 @_mm_sub_pd(i64 %20, i64 %22)
%24 = call i32 @_mm_mul_pd(i64 %23, i64 %23)
%25 = call i64 @_mm_add_pd(i64 %16, i32 %24)
%26 = call i32 @_mm_store_pd(double* %11, i64 %25)
%27 = and i64 %15, 3
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %14
%30 = load double, double* %11
%31 = load double, double* %12
%32 = fadd double %30, %31
%33 = fcmp ogt double %32, %6
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load double, double* @NAN
br label %102
36: ; preds = %29, %14
%37 = add nuw nsw i64 %15, 1
%38 = icmp eq i64 %37, %13
br i1 %38, label %39, label %14
39: ; preds = %36
%40 = load double, double* %11
%41 = load double, double* %12
%42 = fadd double %40, %41
br label %43
43: ; preds = %39, %4
%44 = phi i32 [ 0, %4 ], [ %8, %39 ]
%45 = phi double [ undef, %4 ], [ %42, %39 ]
%46 = shl nuw nsw i32 %44, 1
%47 = icmp slt i32 %46, %2
br i1 %47, label %48, label %99
48: ; preds = %43
%49 = zext i32 %44 to i64
%50 = shl nuw nsw i64 %49, 1
%51 = zext i32 %2 to i64
%52 = xor i64 %50, -1
%53 = and i64 %51, 1
%54 = icmp eq i64 %53, 0
br i1 %54, label %67, label %55
55: ; preds = %48
%56 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 %50
%57 = bitcast %struct.TYPE_12__* %56 to double*
%58 = load double, double* %57
%59 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %1, i64 %50
%60 = bitcast %struct.TYPE_12__* %59 to double*
%61 = load double, double* %60
%62 = fsub double %58, %61
%63 = call i64 @pow(double %62, i32 2)
%64 = sitofp i64 %63 to double
%65 = fadd double %45, %64
%66 = or i64 %50, 1
br label %67
67: ; preds = %55, %48
%68 = phi double [ undef, %48 ], [ %65, %55 ]
%69 = phi i64 [ %50, %48 ], [ %66, %55 ]
%70 = phi double [ %45, %48 ], [ %65, %55 ]
%71 = sub nsw i64 0, %51
%72 = icmp eq i64 %52, %71
br i1 %72, label %99, label %73
73: ; preds = %67, %73
%74 = phi i64 [ %97, %73 ], [ %69, %67 ]
%75 = phi double [ %96, %73 ], [ %70, %67 ]
%76 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 %74
%77 = bitcast %struct.TYPE_12__* %76 to double*
%78 = load double, double* %77
%79 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %1, i64 %74
%80 = bitcast %struct.TYPE_12__* %79 to double*
%81 = load double, double* %80
%82 = fsub double %78, %81
%83 = call i64 @pow(double %82, i32 2)
%84 = sitofp i64 %83 to double
%85 = fadd double %75, %84
%86 = add nuw nsw i64 %74, 1
%87 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 %86
%88 = bitcast %struct.TYPE_12__* %87 to double*
%89 = load double, double* %88
%90 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %1, i64 %86
%91 = bitcast %struct.TYPE_12__* %90 to double*
%92 = load double, double* %91
%93 = fsub double %89, %92
%94 = call i64 @pow(double %93, i32 2)
%95 = sitofp i64 %94 to double
%96 = fadd double %85, %95
%97 = add nuw nsw i64 %74, 2
%98 = icmp eq i64 %97, %51
br i1 %98, label %99, label %73
99: ; preds = %67, %73, %43
%100 = phi double [ %45, %43 ], [ %68, %67 ], [ %96, %73 ]
%101 = call double @sqrt(double %100)
br label %102
102: ; preds = %34, %99
%103 = phi double [ %35, %34 ], [ %101, %99 ]
ret double %103
}