#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*/ seatest_simple_test_result(int, char *, char const *,
                                              unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, double, double);
void seatest_assert_double_equal(double expected, double actual, double delta,
                                 const char *function, 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;
  seatest_simple_test_result(result <= delta, s, function, line);
}


x86 assembly (clang, -O0):
<seatest_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    %esi,-0x24(%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    0xe95(%rip),%rsi
call   1040 <sprintf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x186d8(%rbp),%xmm0
ff
jbe    1194 <seatest_assert_double_equal+0x74>
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    -0x24(%rbp),%ecx
call   1030 <seatest_simple_test_result@plt>
add    $0x186e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seatest_assert_double_equal>:
push   %rbp
push   %r14
push   %rbx
sub    $0x186c0,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
movsd  %xmm2,0x8(%rsp)
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
movapd %xmm2,0x10(%rsp)
lea    0xeb5(%rip),%rsi
lea    0x20(%rsp),%r14
mov    %r14,%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    %r14,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1030 <seatest_simple_test_result@plt>
add    $0x186c0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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