#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 equalWithinTolerance(double target, double value) {
  double difference;
  difference = fabs(target - value);
  if (difference > 0.0009765625) {
    if (target != 0.0) {
      if ((difference / fabs(target)) > 0.004) {
        return 0;
      }
    } else {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<equalWithinTolerance>:
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  -0x20(%rbp),%xmm0
movsd  0xecb(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a9 <equalWithinTolerance+0xa9>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115c <equalWithinTolerance+0x5c>
jp     115c <equalWithinTolerance+0x5c>
jmp    1198 <equalWithinTolerance+0x98>
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movaps 0xea3(%rip),%xmm2
pand   %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe8b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1193 <equalWithinTolerance+0x93>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <equalWithinTolerance+0xb0>
jmp    11a4 <equalWithinTolerance+0xa4>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <equalWithinTolerance+0xb0>
jmp    11a9 <equalWithinTolerance+0xa9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<equalWithinTolerance>:
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd 0xef0(%rip),%xmm1
andpd  %xmm2,%xmm1
ucomisd 0xef4(%rip),%xmm1
jbe    1142 <equalWithinTolerance+0x42>
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    112c <equalWithinTolerance+0x2c>
jnp    1147 <equalWithinTolerance+0x47>
divsd  %xmm0,%xmm2
andpd  0xec8(%rip),%xmm2
ucomisd 0xed8(%rip),%xmm2
ja     1147 <equalWithinTolerance+0x47>
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @equalWithinTolerance(double %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = load double, double* %5
%9 = fsub double %7, %8
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %6
%11 = load double, double* %6
%12 = fcmp ogt double %11, 0x3F50000000000000
br i1 %12, label %13, label %26
13: ; preds = %2
%14 = load double, double* %4
%15 = fcmp une double %14, 0.000000e+00
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load double, double* %6
%18 = load double, double* %4
%19 = call double @llvm.fabs.f64(double %18)
%20 = fdiv double %17, %19
%21 = fcmp ogt double %20, 4.000000e-03
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 0, i32* %3
br label %27
23: ; preds = %16
br label %25
24: ; preds = %13
store i32 0, i32* %3
br label %27
25: ; preds = %23
br label %26
26: ; preds = %25, %2
store i32 1, i32* %3
br label %27
27: ; preds = %26, %24, %22
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @equalWithinTolerance(double %0, double %1) {
%3 = fsub double %0, %1
%4 = tail call double @llvm.fabs.f64(double %3)
%5 = fcmp ogt double %4, 0x3F50000000000000
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = fcmp une double %0, 0.000000e+00
br i1 %7, label %8, label %13
8: ; preds = %6
%9 = fdiv double %3, %0
%10 = tail call double @llvm.fabs.f64(double %9)
%11 = fcmp ogt double %10, 4.000000e-03
br i1 %11, label %13, label %12
12: ; preds = %8, %2
br label %13
13: ; preds = %6, %8, %12
%14 = phi i32 [ 1, %12 ], [ 0, %8 ], [ 0, %6 ]
ret i32 %14
}