#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 */
int fabs(float const);
int ts_fequals(const float x, const float y) {
  if (fabs(x - y) <= 1e-7) {
    return 1;
  } else {
    const float r = (float)fabs(x) > (float)fabs(y) ? (float)fabs((x - y) / x)
                                                    : (float)fabs((x - y) / y);
    return r <= 1e-5;
  }
}


x86 assembly (clang, -O0):
<ts_fequals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xec3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     1153 <ts_fequals+0x43>
movl   $0x1,-0x4(%rbp)
jmp    11eb <ts_fequals+0xdb>
movss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fabs@plt>
movss  -0x14(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
ucomiss %xmm1,%xmm0
jbe    11a4 <ts_fequals+0x94>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11c1 <ts_fequals+0xb1>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
call   1030 <fabs@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe2c(%rip),%xmm0
ucomisd %xmm1,%xmm0
setae  %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):
<ts_fequals>:
sub    $0x48,%rsp
movaps %xmm0,0x20(%rsp)
movaps %xmm1,0x10(%rsp)
subss  %xmm1,%xmm0
movaps %xmm0,0x30(%rsp)
call   1030 <fabs@plt>
test   %eax,%eax
jle    119e <ts_fequals+0x8e>
movaps 0x20(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0xc(%rsp)
movaps 0x10(%rsp),%xmm0
call   1030 <fabs@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
cmpltss 0xc(%rsp),%xmm1
movaps 0x20(%rsp),%xmm0
andps  %xmm1,%xmm0
andnps 0x10(%rsp),%xmm1
orps   %xmm0,%xmm1
movaps 0x30(%rsp),%xmm0
divss  %xmm1,%xmm0
call   1030 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe70(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
add    $0x48,%rsp
ret
mov    $0x1,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
define i32 @ts_fequals(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 = load float, float* %5
%9 = fsub float %7, %8
%10 = call i32 @fabs(float %9)
%11 = sitofp i32 %10 to double
%12 = fcmp ole double %11, 0x3E7AD7F29ABCAF48
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %44
14: ; preds = %2
%15 = load float, float* %4
%16 = call i32 @fabs(float %15)
%17 = sitofp i32 %16 to float
%18 = load float, float* %5
%19 = call i32 @fabs(float %18)
%20 = sitofp i32 %19 to float
%21 = fcmp ogt float %17, %20
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load float, float* %4
%24 = load float, float* %5
%25 = fsub float %23, %24
%26 = load float, float* %4
%27 = fdiv float %25, %26
%28 = call i32 @fabs(float %27)
%29 = sitofp i32 %28 to float
br label %38
30: ; preds = %14
%31 = load float, float* %4
%32 = load float, float* %5
%33 = fsub float %31, %32
%34 = load float, float* %5
%35 = fdiv float %33, %34
%36 = call i32 @fabs(float %35)
%37 = sitofp i32 %36 to float
br label %38
38: ; preds = %30, %22
%39 = phi float [ %29, %22 ], [ %37, %30 ]
store float %39, float* %6
%40 = load float, float* %6
%41 = fpext float %40 to double
%42 = fcmp ole double %41, 1.000000e-05
%43 = zext i1 %42 to i32
store i32 %43, i32* %3
br label %44
44: ; preds = %38, %13
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
define i32 @ts_fequals(float %0, float %1) {
%3 = fsub float %0, %1
%4 = tail call i32 @fabs(float %3)
%5 = icmp slt i32 %4, 1
br i1 %5, label %19, label %6
6: ; preds = %2
%7 = tail call i32 @fabs(float %0)
%8 = sitofp i32 %7 to float
%9 = tail call i32 @fabs(float %1)
%10 = sitofp i32 %9 to float
%11 = fcmp ogt float %8, %10
%12 = select i1 %11, float %0, float %1
%13 = fdiv float %3, %12
%14 = tail call i32 @fabs(float %13)
%15 = sitofp i32 %14 to float
%16 = fpext float %15 to double
%17 = fcmp ole double %16, 1.000000e-05
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %2, %6
%20 = phi i32 [ %18, %6 ], [ 1, %2 ]
ret i32 %20
}