#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 */
typedef double *__m128d;

/* Variables and functions */
double NAN;
double *_mm_add_pd(double *, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_mul_pd(double *, double *);
double *_mm_sub_pd(double *, double *);
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};
  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));
    if (i % 4 == 0) {
      if (sum[0] + sum[1] > dist2) {
        return NAN;
      }
    }
  }
  ret = sum[0] + sum[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    $0x60,%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)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    1255 <isFartherThan_l2_m128d+0x105>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1030 <_mm_sub_pd@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1060 <_mm_mul_pd@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
call   1040 <_mm_add_pd@plt>
mov    %rax,-0x40(%rbp)
mov    -0x44(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1242 <isFartherThan_l2_m128d+0xf2>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
addsd  0x8(%rax),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    123d <isFartherThan_l2_m128d+0xed>
mov    0x2dc9(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d0 <isFartherThan_l2_m128d+0x180>
jmp    1242 <isFartherThan_l2_m128d+0xf2>
jmp    1247 <isFartherThan_l2_m128d+0xf7>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1195 <isFartherThan_l2_m128d+0x45>
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x40(%rbp),%rax
addsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x44(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12c1 <isFartherThan_l2_m128d+0x171>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x44(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1274 <isFartherThan_l2_m128d+0x124>
movsd  -0x30(%rbp),%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isFartherThan_l2_m128d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
mov    %edx,%r13d
shr    %r13d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1189 <isFartherThan_l2_m128d+0x39>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     11d4 <isFartherThan_l2_m128d+0x84>
mov    (%r12,%rbx,8),%rdi
mov    (%r14,%rbx,8),%rsi
call   1030 <_mm_sub_pd@plt>
mov    %rax,%rdi
mov    %rax,%rsi
call   1060 <_mm_mul_pd@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <_mm_add_pd@plt>
mov    %rax,%rbp
test   $0x3,%bl
jne    1180 <isFartherThan_l2_m128d+0x30>
movsd  0x0(%rbp),%xmm0
addsd  0x8(%rbp),%xmm0
ucomisd (%rsp),%xmm0
jbe    1180 <isFartherThan_l2_m128d+0x30>
mov    0x2e2d(%rip),%rax
movsd  (%rax),%xmm0
jmp    12ac <isFartherThan_l2_m128d+0x15c>
movsd  0x0(%rbp),%xmm1
addsd  0x8(%rbp),%xmm1
mov    %r15d,%eax
and    $0x7ffffffe,%eax
cmp    %r15d,%eax
jae    129b <isFartherThan_l2_m128d+0x14b>
add    %r13,%r13
mov    %r15d,%ebp
mov    %r13,%rbx
not    %rbx
test   $0x1,%bpl
je     1231 <isFartherThan_l2_m128d+0xe1>
movsd  (%r12,%r13,8),%xmm0
subsd  (%r14,%r13,8),%xmm0
mov    $0x2,%edi
movsd  %xmm1,(%rsp)
call   1050 <pow@plt>
movsd  (%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  %xmm0,%xmm1
or     $0x1,%r13
add    %rbp,%rbx
je     129b <isFartherThan_l2_m128d+0x14b>
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm1,(%rsp)
movsd  (%r12,%r13,8),%xmm0
subsd  (%r14,%r13,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r12,%r13,8),%xmm0
subsd  0x8(%r14,%r13,8),%xmm0
mov    $0x2,%edi
call   1050 <pow@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
addsd  (%rsp),%xmm1
add    $0x2,%r13
cmp    %r13,%rbp
jne    1240 <isFartherThan_l2_m128d+0xf0>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     12bb <isFartherThan_l2_m128d+0x16b>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <sqrt@plt>

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

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