#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);
long double fabsl(double);
int /*<<< orphan*/ printf(char *, double, double);
void assertFuzzyEquals(double act, double exp) {
  bool inrange;
  double merr = 1e-12;
  long double e;
  if (exp == 0.0) {
    e = fabsl(act);
  } else {
    e = fabsl((act - exp) / exp);
  }
  inrange = (e <= merr);
  if (inrange == false) {
    printf("Expected should be near: %1.16e , but got: %1.16e\n", exp, act);
  }
  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    1179 <assertFuzzyEquals+0x49>
jp     1179 <assertFuzzyEquals+0x49>
movsd  -0x8(%rbp),%xmm0
call   1030 <fabsl@plt>
fstpt  -0x30(%rbp)
jmp    1193 <assertFuzzyEquals+0x63>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
call   1030 <fabsl@plt>
fstpt  -0x30(%rbp)
fldt   -0x30(%rbp)
fldl   -0x20(%rbp)
fucomip %st(1),%st
fstp   %st(0)
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11c8 <assertFuzzyEquals+0x98>
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
lea    0xe45(%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,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
movapd %xmm2,%xmm0
jne    1144 <assertFuzzyEquals+0x14>
jnp    1150 <assertFuzzyEquals+0x20>
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm2,0x18(%rsp)
call   1030 <fabsl@plt>
fldl   0xe95(%rip)
fucomi %st(1),%st
jae    119b <assertFuzzyEquals+0x6b>
lea    0xe92(%rip),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
fxch   %st(1)
fstpt  0x18(%rsp)
fstpt  0x8(%rsp)
call   1040 <printf@plt>
fldt   0x8(%rsp)
fldt   0x18(%rsp)
fxch   %st(1)
xor    %edi,%edi
fucomip %st(1),%st
fstp   %st(0)
setae  %dil
add    $0x28,%rsp
jmp    1050 <assert@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"Expected should be near: %1.16e , but got: %1.16e\0A\00"
define void @assertFuzzyEquals(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca x86_fp80
store double %0, double* %3
store double %1, double* %4
store double 0x3D719799812DEA11, 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 x86_fp80 @fabsl(double %11)
store x86_fp80 %12, x86_fp80* %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 x86_fp80 @fabsl(double %18)
store x86_fp80 %19, x86_fp80* %7
br label %20
20: ; preds = %13, %10
%21 = load x86_fp80, x86_fp80* %7
%22 = load double, double* %6
%23 = fpext double %22 to x86_fp80
%24 = fcmp ole x86_fp80 %21, %23
%25 = zext i1 %24 to i32
store i32 %25, i32* %5
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %20
%29 = load double, double* %4
%30 = load double, double* %3
%31 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %29, double %30)
br label %32
32: ; preds = %28, %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 = [51 x i8] c"Expected should be near: %1.16e , but got: %1.16e\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 x86_fp80 @fabsl(double %8)
%10 = fcmp ole x86_fp80 %9, 0xK3FD78CBCCC096F508800
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), double %1, double %0)
br label %13
13: ; preds = %11, %7
%14 = zext i1 %10 to i32
%15 = tail call i32 @assert(i32 %14)
ret void
}