#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 get_distance(double const *const, double const *const, int);
int index_of_nearest_point(double const *const *, int, int, int);
int index_of_nearest_point_in_epsilon_neighborhood(const double *const *data,
                                                   int I, int t, int n,
                                                   double epsilon) {
  int J = index_of_nearest_point(data, I, t, n);
  if (get_distance(data[I], data[J], n) > epsilon)
    return -1;
  return J;
}


x86 assembly (clang, -O0):
<index_of_nearest_point_in_epsilon_neighborhood>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <index_of_nearest_point@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <get_distance@plt>
ucomisd -0x28(%rbp),%xmm0
jbe    1186 <index_of_nearest_point_in_epsilon_neighborhood+0x66>
movl   $0xffffffff,-0x4(%rbp)
jmp    118c <index_of_nearest_point_in_epsilon_neighborhood+0x6c>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<index_of_nearest_point_in_epsilon_neighborhood>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %ecx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <index_of_nearest_point@plt>
movslq %ebp,%rcx
mov    (%rbx,%rcx,8),%rdi
movslq %eax,%rbp
mov    (%rbx,%rbp,8),%rsi
mov    %r14d,%edx
call   1030 <get_distance@plt>
ucomisd 0x8(%rsp),%xmm0
mov    $0xffffffff,%eax
cmova  %eax,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @index_of_nearest_point_in_epsilon_neighborhood(double** %0, i32 %1, i32 %2, i32 %3, double %4) {
%6 = alloca i32
%7 = alloca double**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca i32
store double** %0, double*** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store double %4, double* %11
%13 = load double**, double*** %7
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = load i32, i32* %10
%17 = call i32 @index_of_nearest_point(double** %13, i32 %14, i32 %15, i32 %16)
store i32 %17, i32* %12
%18 = load double**, double*** %7
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double*, double** %18, i64 %20
%22 = load double*, double** %21
%23 = load double**, double*** %7
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double*, double** %23, i64 %25
%27 = load double*, double** %26
%28 = load i32, i32* %10
%29 = call double @get_distance(double* %22, double* %27, i32 %28)
%30 = load double, double* %11
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %33
32: ; preds = %5
store i32 -1, i32* %6
br label %35
33: ; preds = %5
%34 = load i32, i32* %12
store i32 %34, i32* %6
br label %35
35: ; preds = %33, %32
%36 = load i32, i32* %6
ret i32 %36
}

LLVM IR (-O2):
define i32 @index_of_nearest_point_in_epsilon_neighborhood(double** %0, i32 %1, i32 %2, i32 %3, double %4) {
%6 = tail call i32 @index_of_nearest_point(double** %0, i32 %1, i32 %2, i32 %3)
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds double*, double** %0, i64 %7
%9 = load double*, double** %8
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds double*, double** %0, i64 %10
%12 = load double*, double** %11
%13 = tail call double @get_distance(double* %9, double* %12, i32 %3)
%14 = fcmp ogt double %13, %4
%15 = select i1 %14, i32 -1, i32 %6
ret i32 %15
}