#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 isNearlyEqual(double x, double y) {
  const double fx = fabs(x);
  const double fy = fabs(y);
  double cmp = fx > fy ? fx : fy;
  if (cmp < (1e-10)) {
    cmp = (1e-10);
  }
  cmp *= (1e-10);
  return fabs(y - x) < cmp;
}


x86 assembly (clang, -O0):
<isNearlyEqual>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xee6(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xed1(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1157 <isNearlyEqual+0x57>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1161 <isNearlyEqual+0x61>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9d(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    118b <isNearlyEqual+0x8b>
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe7d(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x8(%rbp),%xmm1
movaps 0xe52(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isNearlyEqual>:
movapd 0xef8(%rip),%xmm2
movapd %xmm1,%xmm3
subsd  %xmm0,%xmm1
andpd  %xmm2,%xmm0
andpd  %xmm2,%xmm3
maxsd  %xmm3,%xmm0
movsd  0xeec(%rip),%xmm3
movapd %xmm3,%xmm4
maxsd  %xmm0,%xmm4
mulsd  %xmm3,%xmm4
andpd  %xmm2,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm4
seta   %al
ret

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

LLVM IR (-O2):
define i32 @isNearlyEqual(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = tail call double @llvm.fabs.f64(double %1)
%5 = fcmp ogt double %3, %4
%6 = select i1 %5, double %3, double %4
%7 = fcmp olt double %6, 1.000000e-10
%8 = select i1 %7, double 1.000000e-10, double %6
%9 = fmul double %8, 1.000000e-10
%10 = fsub double %1, %0
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fcmp olt double %11, %9
%13 = zext i1 %12 to i32
ret i32 %13
}