#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 */
scalar_t__ DBL_EPSILON;
scalar_t__ isinf(double);
scalar_t__ isnan(double);
int /*<<< orphan*/ unit_error(char *, char const *, int, double, ...);
void assert_dbl_near(double exp, double real, double tol, char const *caller,
                     int line) {
  if (isnan(exp)) {
    if (!isnan(real)) {
      unit_error("%s:%d expected NAN, got %0.3e", caller, line, real);
    }
  } else if (isnan(real)) {
    unit_error("%s:%d expected %0.3e, got NAN", caller, line, exp);
  }
  if (isinf(exp)) {
    if (!isinf(real)) {
      unit_error("%s:%d expected INFINITY, got %0.3e", caller, line, real);
    }
  } else if (isinf(real)) {
    unit_error("%s:%d expected %0.3e, got INFINITY", caller, line, exp);
  }
  double diff = exp - real;
  tol += DBL_EPSILON;
  double absdiff = (diff < 0.) ? -diff : diff;
  if (absdiff > tol) {
    unit_error("%s:%d expected %0.3e, got %0.3e (diff %0.3e, tol %0.3e)",
               caller, line, exp, real, diff, tol);
  }
}


x86 assembly (clang, -O0):
<assert_dbl_near>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     1195 <assert_dbl_near+0x65>
movsd  -0x10(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    1190 <assert_dbl_near+0x60>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
lea    0xe77(%rip),%rdi
mov    $0x1,%al
call   1030 <unit_error@plt>
jmp    11c8 <assert_dbl_near+0x98>
movsd  -0x10(%rbp),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
je     11c3 <assert_dbl_near+0x93>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1030 <unit_error@plt>
jmp    11c8 <assert_dbl_near+0x98>
movsd  -0x8(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     120f <assert_dbl_near+0xdf>
movsd  -0x10(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
jne    120a <assert_dbl_near+0xda>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
lea    0xe39(%rip),%rdi
mov    $0x1,%al
call   1030 <unit_error@plt>
jmp    1242 <assert_dbl_near+0x112>
movsd  -0x10(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
je     123d <assert_dbl_near+0x10d>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
lea    0xe29(%rip),%rdi
mov    $0x1,%al
call   1030 <unit_error@plt>
jmp    1242 <assert_dbl_near+0x112>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    0x2d90(%rip),%rax
cvtsi2sdq (%rax),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    129b <assert_dbl_near+0x16b>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12a5 <assert_dbl_near+0x175>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    12e8 <assert_dbl_near+0x1b8>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
lea    0xda1(%rip),%rdi
mov    $0x4,%al
call   1030 <unit_error@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assert_dbl_near>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1040 <isnan@plt>
mov    %rax,%rbp
movsd  0x8(%rsp),%xmm0
call   1040 <isnan@plt>
test   %rbp,%rbp
je     1182 <assert_dbl_near+0x52>
test   %rax,%rax
jne    11a1 <assert_dbl_near+0x71>
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
movsd  0x8(%rsp),%xmm0
jmp    119a <assert_dbl_near+0x6a>
test   %rax,%rax
je     11a1 <assert_dbl_near+0x71>
lea    0xea0(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <unit_error@plt>
movsd  0x10(%rsp),%xmm0
call   1050 <isinf@plt>
mov    %rax,%rbp
movsd  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
test   %rbp,%rbp
je     11d9 <assert_dbl_near+0xa9>
test   %rax,%rax
jne    11f8 <assert_dbl_near+0xc8>
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
movsd  0x8(%rsp),%xmm0
jmp    11f1 <assert_dbl_near+0xc1>
test   %rax,%rax
je     11f8 <assert_dbl_near+0xc8>
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <unit_error@plt>
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm2
mov    0x2dd5(%rip),%rax
cvtsi2sdq (%rax),%xmm3
addsd  0x18(%rsp),%xmm3
movapd 0xdda(%rip),%xmm6
xorpd  %xmm2,%xmm6
xorpd  %xmm5,%xmm5
movapd %xmm2,%xmm4
cmpltsd %xmm5,%xmm4
andpd  %xmm4,%xmm6
andnpd %xmm2,%xmm4
orpd   %xmm6,%xmm4
ucomisd %xmm3,%xmm4
jbe    1265 <assert_dbl_near+0x135>
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
mov    $0x4,%al
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <unit_error@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"%s:%d expected NAN, got %0.3e\00"
@.str.1 = [30 x i8] c"%s:%d expected %0.3e, got NAN\00"
@.str.2 = [35 x i8] c"%s:%d expected INFINITY, got %0.3e\00"
@.str.3 = [35 x i8] c"%s:%d expected %0.3e, got INFINITY\00"
@DBL_EPSILON = global i64 0
@.str.4 = [56 x i8] c"%s:%d expected %0.3e, got %0.3e (diff %0.3e, tol %0.3e)\00"
define void @assert_dbl_near(double %0, double %1, double %2, i8* %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i8*
%10 = alloca i32
%11 = alloca double
%12 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = load double, double* %6
%14 = call i64 @isnan(double %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %5
%17 = load double, double* %7
%18 = call i64 @isnan(double %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i8*, i8** %9
%22 = load i32, i32* %10
%23 = load double, double* %7
%24 = call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %22, double %23)
br label %25
25: ; preds = %20, %16
br label %36
26: ; preds = %5
%27 = load double, double* %7
%28 = call i64 @isnan(double %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = load i8*, i8** %9
%32 = load i32, i32* %10
%33 = load double, double* %6
%34 = call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %31, i32 %32, double %33)
br label %35
35: ; preds = %30, %26
br label %36
36: ; preds = %35, %25
%37 = load double, double* %6
%38 = call i64 @isinf(double %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %50
40: ; preds = %36
%41 = load double, double* %7
%42 = call i64 @isinf(double %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %40
%45 = load i8*, i8** %9
%46 = load i32, i32* %10
%47 = load double, double* %7
%48 = call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %45, i32 %46, double %47)
br label %49
49: ; preds = %44, %40
br label %60
50: ; preds = %36
%51 = load double, double* %7
%52 = call i64 @isinf(double %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = load i8*, i8** %9
%56 = load i32, i32* %10
%57 = load double, double* %6
%58 = call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %55, i32 %56, double %57)
br label %59
59: ; preds = %54, %50
br label %60
60: ; preds = %59, %49
%61 = load double, double* %6
%62 = load double, double* %7
%63 = fsub double %61, %62
store double %63, double* %11
%64 = load i64, i64* @DBL_EPSILON
%65 = sitofp i64 %64 to double
%66 = load double, double* %8
%67 = fadd double %66, %65
store double %67, double* %8
%68 = load double, double* %11
%69 = fcmp olt double %68, 0.000000e+00
br i1 %69, label %70, label %73
70: ; preds = %60
%71 = load double, double* %11
%72 = fneg double %71
br label %75
73: ; preds = %60
%74 = load double, double* %11
br label %75
75: ; preds = %73, %70
%76 = phi double [ %72, %70 ], [ %74, %73 ]
store double %76, double* %12
%77 = load double, double* %12
%78 = load double, double* %8
%79 = fcmp ogt double %77, %78
br i1 %79, label %80, label %88
80: ; preds = %75
%81 = load i8*, i8** %9
%82 = load i32, i32* %10
%83 = load double, double* %6
%84 = load double, double* %7
%85 = load double, double* %11
%86 = load double, double* %8
%87 = call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8* %81, i32 %82, double %83, double %84, double %85, double %86)
br label %88
88: ; preds = %80, %75
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"%s:%d expected NAN, got %0.3e\00"
@.str.1 = [30 x i8] c"%s:%d expected %0.3e, got NAN\00"
@.str.2 = [35 x i8] c"%s:%d expected INFINITY, got %0.3e\00"
@.str.3 = [35 x i8] c"%s:%d expected %0.3e, got INFINITY\00"
@DBL_EPSILON = global i64 0
@.str.4 = [56 x i8] c"%s:%d expected %0.3e, got %0.3e (diff %0.3e, tol %0.3e)\00"
define void @assert_dbl_near(double %0, double %1, double %2, i8* %3, i32 %4) {
%6 = tail call i64 @isnan(double %0)
%7 = icmp eq i64 %6, 0
%8 = tail call i64 @isnan(double %1)
%9 = icmp eq i64 %8, 0
br i1 %7, label %13, label %10
10: ; preds = %5
br i1 %9, label %11, label %16
11: ; preds = %10
%12 = tail call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %4, double %1)
br label %16
13: ; preds = %5
br i1 %9, label %16, label %14
14: ; preds = %13
%15 = tail call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %4, double %0)
br label %16
16: ; preds = %13, %14, %10, %11
%17 = tail call i64 @isinf(double %0)
%18 = icmp eq i64 %17, 0
%19 = tail call i64 @isinf(double %1)
%20 = icmp eq i64 %19, 0
br i1 %18, label %24, label %21
21: ; preds = %16
br i1 %20, label %22, label %27
22: ; preds = %21
%23 = tail call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 %4, double %1)
br label %27
24: ; preds = %16
br i1 %20, label %27, label %25
25: ; preds = %24
%26 = tail call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %4, double %0)
br label %27
27: ; preds = %24, %25, %21, %22
%28 = fsub double %0, %1
%29 = load i64, i64* @DBL_EPSILON
%30 = sitofp i64 %29 to double
%31 = fadd double %30, %2
%32 = fcmp olt double %28, 0.000000e+00
%33 = fneg double %28
%34 = select i1 %32, double %33, double %28
%35 = fcmp ogt double %34, %31
br i1 %35, label %36, label %38
36: ; preds = %27
%37 = tail call i32 (i8*, i8*, i32, double, ...) @unit_error(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.4, i64 0, i64 0), i8* %3, i32 %4, double %0, double %1, double %28, double %31)
br label %38
38: ; preds = %36, %27
ret void
}