#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 /*<<< orphan*/ assert(int);
double fabsl(double);
int /*<<< orphan*/ printf(char *, double, double, double);
void assertFuzzyEquals(double act, double exp) {
  bool inrange;
  double merr = 1e-6;
  double e;
  if (exp == 0.0)
    e = fabsl(act);
  else
    e = fabsl((act - exp) / exp);
  inrange = (e <= merr);
  if (inrange == false)
    printf("Error: Expected should be near: %.16f , but got: %.16f. Error -> "
           "%.16f\n",
           exp, act, e);
  assert(inrange == 1);
}


x86 assembly (clang, -O0):
<assertFuzzyEquals>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117b <assertFuzzyEquals+0x4b>
jp     117b <assertFuzzyEquals+0x4b>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabsl@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1194 <assertFuzzyEquals+0x64>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
call   1030 <fabsl@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11d2 <assertFuzzyEquals+0xa2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assertFuzzyEquals>:
movapd %xmm0,%xmm3
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm3,%xmm2
jne    1134 <assertFuzzyEquals+0x14>
jnp    1140 <assertFuzzyEquals+0x20>
movapd %xmm3,%xmm2
subsd  %xmm1,%xmm2
divsd  %xmm1,%xmm2
sub    $0x18,%rsp
andpd  0xeb4(%rip),%xmm2
movsd  0xebc(%rip),%xmm0
ucomisd %xmm2,%xmm0
jae    1180 <assertFuzzyEquals+0x60>
lea    0xeb7(%rip),%rdi
movapd %xmm1,%xmm0
movapd %xmm3,%xmm1
movapd %xmm2,(%rsp)
call   1030 <printf@plt>
movsd  0xe95(%rip),%xmm0
movapd (%rsp),%xmm2
xor    %edi,%edi
ucomisd %xmm2,%xmm0
setae  %dil
add    $0x18,%rsp
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [72 x i8] c"Error: Expected should be near: %.16f , but got: %.16f. Error -> %.16f\0A\00"
define void @assertFuzzyEquals(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
store double 0x3EB0C6F7A0B5ED8D, double* %6
%8 = load double, double* %4
%9 = fcmp oeq double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load double, double* %3
%12 = call double @fabsl(double %11)
store double %12, double* %7
br label %20
13: ; preds = %2
%14 = load double, double* %3
%15 = load double, double* %4
%16 = fsub double %14, %15
%17 = load double, double* %4
%18 = fdiv double %16, %17
%19 = call double @fabsl(double %18)
store double %19, double* %7
br label %20
20: ; preds = %13, %10
%21 = load double, double* %7
%22 = load double, double* %6
%23 = fcmp ole double %21, %22
%24 = zext i1 %23 to i32
store i32 %24, i32* %5
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %20
%28 = load double, double* %4
%29 = load double, double* %3
%30 = load double, double* %7
%31 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), double %28, double %29, double %30)
br label %32
32: ; preds = %27, %20
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 1
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
ret void
}

LLVM IR (-O2):
@.str = [72 x i8] c"Error: Expected should be near: %.16f , but got: %.16f. Error -> %.16f\0A\00"
define void @assertFuzzyEquals(double %0, double %1) {
%3 = fcmp oeq double %1, 0.000000e+00
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = fsub double %0, %1
%6 = fdiv double %5, %1
br label %7
7: ; preds = %2, %4
%8 = phi double [ %6, %4 ], [ %0, %2 ]
%9 = tail call double @llvm.fabs.f64(double %8)
%10 = fcmp ole double %9, 0x3EB0C6F7A0B5ED8D
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str, i64 0, i64 0), double %1, double %0, double %9)
br label %13
13: ; preds = %11, %7
%14 = zext i1 %10 to i32
%15 = tail call i32 @assert(i32 %14)
ret void
}