#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 IsEqual(double a, double b) {
  double absDiff = fabs(a - b);
  double precision = 0.0001;
  double max = a > b ? a : b;
  double maxPrecision = max * precision;
  if (fabs(a) <= precision && fabs(b) <= precision)
    return 1;
  if (absDiff <= precision || absDiff < maxPrecision)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<IsEqual>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xef1(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1154 <IsEqual+0x54>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    115e <IsEqual+0x5e>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
movaps 0xe8d(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11c1 <IsEqual+0xc1>
movsd  -0x18(%rbp),%xmm1
movaps 0xe6e(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     11c1 <IsEqual+0xc1>
movl   $0x1,-0x4(%rbp)
jmp    11fc <IsEqual+0xfc>
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    11e9 <IsEqual+0xe9>
movsd  -0x20(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f5 <IsEqual+0xf5>
movl   $0x1,-0x4(%rbp)
jmp    11fc <IsEqual+0xfc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsEqual>:
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd 0xef0(%rip),%xmm3
andpd  %xmm3,%xmm2
movapd %xmm0,%xmm4
maxsd  %xmm1,%xmm4
movsd  0xeec(%rip),%xmm5
mulsd  %xmm5,%xmm4
andpd  %xmm3,%xmm0
ucomisd %xmm0,%xmm5
setae  %al
andpd  %xmm3,%xmm1
ucomisd %xmm1,%xmm5
setae  %cl
and    %al,%cl
ucomisd %xmm2,%xmm5
setae  %al
ucomisd %xmm2,%xmm4
seta   %dl
or     %cl,%al
or     %dl,%al
movzbl %al,%eax
ret

LLVM IR (-O0):
define i32 @IsEqual(double %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
%10 = load double, double* %4
%11 = load double, double* %5
%12 = fsub double %10, %11
%13 = call double @llvm.fabs.f64(double %12)
store double %13, double* %6
store double 1.000000e-04, double* %7
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fcmp ogt double %14, %15
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load double, double* %4
br label %21
19: ; preds = %2
%20 = load double, double* %5
br label %21
21: ; preds = %19, %17
%22 = phi double [ %18, %17 ], [ %20, %19 ]
store double %22, double* %8
%23 = load double, double* %8
%24 = load double, double* %7
%25 = fmul double %23, %24
store double %25, double* %9
%26 = load double, double* %4
%27 = call double @llvm.fabs.f64(double %26)
%28 = load double, double* %7
%29 = fcmp ole double %27, %28
br i1 %29, label %30, label %36
30: ; preds = %21
%31 = load double, double* %5
%32 = call double @llvm.fabs.f64(double %31)
%33 = load double, double* %7
%34 = fcmp ole double %32, %33
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 1, i32* %3
br label %46
36: ; preds = %30, %21
%37 = load double, double* %6
%38 = load double, double* %7
%39 = fcmp ole double %37, %38
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load double, double* %6
%42 = load double, double* %9
%43 = fcmp olt double %41, %42
br i1 %43, label %44, label %45
44: ; preds = %40, %36
store i32 1, i32* %3
br label %46
45: ; preds = %40
store i32 0, i32* %3
br label %46
46: ; preds = %45, %44, %35
%47 = load i32, i32* %3
ret i32 %47
}

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