#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 fabs(double);
int find_first_index_has(double *arr, int size, double value) {
  int i;
  for (i = 0; i < size; i++) {
    if (fabs(arr[i] - value) < 2.2204460492503131e-16) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<find_first_index_has>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1170 <find_first_index_has+0x70>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
subsd  -0x20(%rbp),%xmm1
movaps 0xed4(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xeb8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    115d <find_first_index_has+0x5d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <find_first_index_has+0x77>
jmp    1162 <find_first_index_has+0x62>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1117 <find_first_index_has+0x17>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_first_index_has>:
mov    $0xffffffff,%eax
test   %esi,%esi
jle    113c <find_first_index_has+0x3c>
mov    %esi,%edx
xor    %ecx,%ecx
movapd 0xeeb(%rip),%xmm1
movsd  0xef3(%rip),%xmm2
nopl   (%rax)
movsd  (%rdi,%rcx,8),%xmm3
subsd  %xmm0,%xmm3
andpd  %xmm1,%xmm3
ucomisd %xmm3,%xmm2
ja     113d <find_first_index_has+0x3d>
add    $0x1,%rcx
cmp    %rcx,%rdx
jne    1120 <find_first_index_has+0x20>
ret
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @find_first_index_has(double* %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store i32 0, i32* %8
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load double*, double** %5
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = load double, double* %7
%20 = fsub double %18, %19
%21 = call double @llvm.fabs.f64(double %20)
%22 = fcmp olt double %21, 0x3CB0000000000000
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = load i32, i32* %8
store i32 %24, i32* %4
br label %30
25: ; preds = %13
br label %26
26: ; preds = %25
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %9
29: ; preds = %9
store i32 -1, i32* %4
br label %30
30: ; preds = %29, %23
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @find_first_index_has(double* nocapture %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %19
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %7
7: ; preds = %5, %14
%8 = phi i64 [ 0, %5 ], [ %15, %14 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = fsub double %10, %2
%12 = tail call double @llvm.fabs.f64(double %11)
%13 = fcmp olt double %12, 0x3CB0000000000000
br i1 %13, label %17, label %14
14: ; preds = %7
%15 = add nuw nsw i64 %8, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %19, label %7
17: ; preds = %7
%18 = trunc i64 %8 to i32
br label %19
19: ; preds = %14, %17, %3
%20 = phi i32 [ -1, %3 ], [ %18, %17 ], [ -1, %14 ]
ret i32 %20
}