#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*/ sprintf(char *, char *, double, double);
int /*<<< orphan*/ stic_simple_test_result(int, char *, char const *,
                                           char const *, unsigned int);
void stic_assert_double_equal(double expected, double actual, double delta,
                              const char *function, const char file[],
                              unsigned int line) {
  char s[100000];
  double result = expected - actual;
  sprintf(s, "Expected %f but was %f", expected, actual);
  if (result < 0.0)
    result = 0.0 - result;
  stic_simple_test_result(result <= delta, s, function, file, line);
}


x86 assembly (clang, -O0):
<stic_assert_double_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186e0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %edx,-0x2c(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x186d8(%rbp)
ff
lea    -0x186d0(%rbp),%rdi
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xe91(%rip),%rsi
call   1040 <sprintf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x186d8(%rbp),%xmm0
ff
jbe    1198 <stic_assert_double_equal+0x78>
xorps  %xmm0,%xmm0
subsd  -0x186d8(%rbp),%xmm0
ff
movsd  %xmm0,-0x186d8(%rbp)
ff
movsd  -0x186d8(%rbp),%xmm1
ff
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
lea    -0x186d0(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1030 <stic_simple_test_result@plt>
add    $0x186e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stic_assert_double_equal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x186c8,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
movsd  %xmm2,0x8(%rsp)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
lea    0xeaf(%rip),%rsi
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1040 <sprintf@plt>
xorpd  %xmm0,%xmm0
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm1
cmpltsd %xmm0,%xmm1
subsd  %xmm2,%xmm0
andpd  %xmm1,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
xor    %edi,%edi
movsd  0x8(%rsp),%xmm0
ucomisd %xmm1,%xmm0
setae  %dil
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1030 <stic_simple_test_result@plt>
add    $0x186c8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Expected %f but was %f\00"
define void @stic_assert_double_equal(double %0, double %1, double %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca [100000 x i8]
%14 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%15 = load double, double* %7
%16 = load double, double* %8
%17 = fsub double %15, %16
store double %17, double* %14
%18 = getelementptr inbounds [100000 x i8], [100000 x i8]* %13, i64 0, i64 0
%19 = load double, double* %7
%20 = load double, double* %8
%21 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %19, double %20)
%22 = load double, double* %14
%23 = fcmp olt double %22, 0.000000e+00
br i1 %23, label %24, label %27
24: ; preds = %6
%25 = load double, double* %14
%26 = fsub double 0.000000e+00, %25
store double %26, double* %14
br label %27
27: ; preds = %24, %6
%28 = load double, double* %14
%29 = load double, double* %9
%30 = fcmp ole double %28, %29
%31 = zext i1 %30 to i32
%32 = getelementptr inbounds [100000 x i8], [100000 x i8]* %13, i64 0, i64 0
%33 = load i8*, i8** %10
%34 = load i8*, i8** %11
%35 = load i32, i32* %12
%36 = call i32 @stic_simple_test_result(i32 %31, i8* %32, i8* %33, i8* %34, i32 %35)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Expected %f but was %f\00"
define void @stic_assert_double_equal(double %0, double %1, double %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca [100000 x i8]
%8 = getelementptr inbounds [100000 x i8], [100000 x i8]* %7, i64 0, i64 0
%9 = fsub double %0, %1
%10 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %0, double %1)
%11 = fcmp olt double %9, 0.000000e+00
%12 = fsub double 0.000000e+00, %9
%13 = select i1 %11, double %12, double %9
%14 = fcmp ole double %13, %2
%15 = zext i1 %14 to i32
%16 = call i32 @stic_simple_test_result(i32 %15, i8* %8, i8* %3, i8* %4, i32 %5)
ret void
}