#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 const fabs(double const);
int /*<<< orphan*/ msg_abort(char *, char const *, unsigned int const,
                             double const, double const, double, double const);
void msg_assert_double(const char file[], const unsigned int line,
                       const double x, const double x_expected,
                       const double eps) {
  double rel_error = fabs(x - x_expected) / x_expected;
  if (rel_error >= eps) {
    msg_abort("Assesion error at %s %u: %e != %e, %e error > %e required\n",
              file, line, x, x_expected, rel_error, eps);
  }
}


x86 assembly (clang, -O0):
<msg_assert_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     118e <msg_assert_double+0x6e>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
lea    0xe77(%rip),%rdi
call   1040 <msg_abort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_assert_double>:
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
andpd  0xee0(%rip),%xmm3
divsd  %xmm1,%xmm3
ucomisd %xmm2,%xmm3
jae    112b <msg_assert_double+0x1b>
ret
movapd %xmm2,%xmm4
mov    %esi,%edx
mov    %rdi,%rsi
lea    0xed5(%rip),%rdi
movapd %xmm3,%xmm2
movapd %xmm4,%xmm3
jmp    1030 <msg_abort@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"Assesion error at %s %u: %e != %e, %e error > %e required\0A\00"
define void @msg_assert_double(i8* %0, i32 %1, double %2, double %3, double %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store i8* %0, i8** %6
store i32 %1, i32* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%12 = load double, double* %8
%13 = load double, double* %9
%14 = fsub double %12, %13
%15 = call double @fabs(double %14)
%16 = load double, double* %9
%17 = fdiv double %15, %16
store double %17, double* %11
%18 = load double, double* %11
%19 = load double, double* %10
%20 = fcmp oge double %18, %19
br i1 %20, label %21, label %29
21: ; preds = %5
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = load double, double* %8
%25 = load double, double* %9
%26 = load double, double* %11
%27 = load double, double* %10
%28 = call i32 @msg_abort(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %23, double %24, double %25, double %26, double %27)
br label %29
29: ; preds = %21, %5
ret void
}

LLVM IR (-O2):
@.str = [59 x i8] c"Assesion error at %s %u: %e != %e, %e error > %e required\0A\00"
define void @msg_assert_double(i8* %0, i32 %1, double %2, double %3, double %4) {
%6 = fsub double %2, %3
%7 = tail call double @llvm.fabs.f64(double %6)
%8 = fdiv double %7, %3
%9 = fcmp ult double %8, %4
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = tail call i32 @msg_abort(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, double %2, double %3, double %8, double %4)
br label %12
12: ; preds = %10, %5
ret void
}