#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 error_epsilon) {
  double difference;
  difference = fabs(target - value);
  if (error_epsilon < 0.0030517578125) {
    error_epsilon = 0.0030517578125;
  }
  if (difference > error_epsilon) {
    if (target != 0.0) {
      if ((difference / fabs(target)) > 0.0002) {
        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  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movaps 0xeec(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    114d <equalWithinTolerance+0x4d>
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11c7 <equalWithinTolerance+0xc7>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117a <equalWithinTolerance+0x7a>
jp     117a <equalWithinTolerance+0x7a>
jmp    11b6 <equalWithinTolerance+0xb6>
movsd  -0x28(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movaps 0xe85(%rip),%xmm2
pand   %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe6d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11b1 <equalWithinTolerance+0xb1>
movl   $0x0,-0x4(%rbp)
jmp    11ce <equalWithinTolerance+0xce>
jmp    11c2 <equalWithinTolerance+0xc2>
movl   $0x0,-0x4(%rbp)
jmp    11ce <equalWithinTolerance+0xce>
jmp    11c7 <equalWithinTolerance+0xc7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<equalWithinTolerance>:
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
movapd 0xef0(%rip),%xmm1
andpd  %xmm3,%xmm1
movsd  0xef4(%rip),%xmm4
maxsd  %xmm2,%xmm4
ucomisd %xmm4,%xmm1
jbe    114a <equalWithinTolerance+0x4a>
xor    %eax,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1134 <equalWithinTolerance+0x34>
jnp    114f <equalWithinTolerance+0x4f>
divsd  %xmm0,%xmm3
andpd  0xec0(%rip),%xmm3
ucomisd 0xed0(%rip),%xmm3
ja     114f <equalWithinTolerance+0x4f>
mov    $0x1,%eax
ret

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

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