#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 */
scalar_t__ ftoint(float);
int compare_float(float a, float b) {
  if (ftoint(a) == ftoint(b))
    return 1;
  float diff = (a > b ? (a - b) : (b - a));
  return diff < 0.00001;
}


x86 assembly (clang, -O0):
<compare_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1030 <ftoint@plt>
mov    %rax,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <ftoint@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jne    1156 <compare_float+0x46>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <compare_float+0xa2>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    1179 <compare_float+0x69>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    1188 <compare_float+0x78>
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe5d(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_float>:
push   %rbx
sub    $0x20,%rsp
movapd %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
call   1030 <ftoint@plt>
mov    %rax,%rbx
movaps 0x10(%rsp),%xmm0
call   1030 <ftoint@plt>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    %rcx,%rbx
je     117f <compare_float+0x6f>
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm0
movaps 0x10(%rsp),%xmm2
subss  %xmm2,%xmm0
movaps %xmm2,%xmm1
subss  %xmm3,%xmm1
cmpltss %xmm3,%xmm2
andps  %xmm2,%xmm0
andnps %xmm1,%xmm2
orps   %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movsd  0xe8a(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
seta   %al
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @compare_float(float %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %4
store float %1, float* %5
%7 = load float, float* %4
%8 = call i64 @ftoint(float %7)
%9 = load float, float* %5
%10 = call i64 @ftoint(float %9)
%11 = icmp eq i64 %8, %10
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1, i32* %3
br label %31
13: ; preds = %2
%14 = load float, float* %4
%15 = load float, float* %5
%16 = fcmp ogt float %14, %15
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load float, float* %4
%19 = load float, float* %5
%20 = fsub float %18, %19
br label %25
21: ; preds = %13
%22 = load float, float* %5
%23 = load float, float* %4
%24 = fsub float %22, %23
br label %25
25: ; preds = %21, %17
%26 = phi float [ %20, %17 ], [ %24, %21 ]
store float %26, float* %6
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = fcmp olt double %28, 1.000000e-05
%30 = zext i1 %29 to i32
store i32 %30, i32* %3
br label %31
31: ; preds = %25, %12
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @compare_float(float %0, float %1) {
%3 = tail call i64 @ftoint(float %0)
%4 = tail call i64 @ftoint(float %1)
%5 = icmp eq i64 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = fcmp ogt float %0, %1
%8 = fsub float %0, %1
%9 = fsub float %1, %0
%10 = select i1 %7, float %8, float %9
%11 = fpext float %10 to double
%12 = fcmp olt double %11, 1.000000e-05
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %2, %6
%15 = phi i32 [ %13, %6 ], [ 1, %2 ]
ret i32 %15
}