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


x86 assembly (clang, -O0):
<stic_assert_float_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186e0,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x186d4(%rbp)
ff
lea    -0x186d0(%rbp),%rdi
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
lea    0xe91(%rip),%rsi
call   1040 <sprintf@plt>
movss  -0x186d4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    11a0 <stic_assert_float_equal+0x80>
xorps  %xmm0,%xmm0
subss  -0x186d4(%rbp),%xmm0
ff
movss  %xmm0,-0x186d4(%rbp)
ff
movss  -0x186d4(%rbp),%xmm1
ff
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
lea    -0x186d0(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1030 <stic_simple_test_result@plt>
add    $0x186e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stic_assert_float_equal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x186c8,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
movss  %xmm2,0xc(%rsp)
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
movaps %xmm2,0x10(%rsp)
lea    0xeb1(%rip),%rsi
lea    0x20(%rsp),%r15
mov    %r15,%rdi
call   1040 <sprintf@plt>
xorps  %xmm0,%xmm0
movaps 0x10(%rsp),%xmm2
movaps %xmm2,%xmm1
cmpltss %xmm0,%xmm1
subss  %xmm2,%xmm0
andps  %xmm1,%xmm0
andnps %xmm2,%xmm1
orps   %xmm0,%xmm1
xor    %edi,%edi
movss  0xc(%rsp),%xmm0
ucomiss %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_float_equal(float %0, float %1, float %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca [100000 x i8]
%14 = alloca float
store float %0, float* %7
store float %1, float* %8
store float %2, float* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%15 = load float, float* %7
%16 = load float, float* %8
%17 = fsub float %15, %16
store float %17, float* %14
%18 = getelementptr inbounds [100000 x i8], [100000 x i8]* %13, i64 0, i64 0
%19 = load float, float* %7
%20 = load float, float* %8
%21 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), float %19, float %20)
%22 = load float, float* %14
%23 = fpext float %22 to double
%24 = fcmp olt double %23, 0.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %6
%26 = load float, float* %14
%27 = fsub float 0.000000e+00, %26
store float %27, float* %14
br label %28
28: ; preds = %25, %6
%29 = load float, float* %14
%30 = load float, float* %9
%31 = fcmp ole float %29, %30
%32 = zext i1 %31 to i32
%33 = getelementptr inbounds [100000 x i8], [100000 x i8]* %13, i64 0, i64 0
%34 = load i8*, i8** %10
%35 = load i8*, i8** %11
%36 = load i32, i32* %12
%37 = call i32 @stic_simple_test_result(i32 %32, i8* %33, i8* %34, i8* %35, i32 %36)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"Expected %f but was %f\00"
define void @stic_assert_float_equal(float %0, float %1, float %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 float %0, %1
%10 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), float %0, float %1)
%11 = fcmp olt float %9, 0.000000e+00
%12 = fsub float 0.000000e+00, %9
%13 = select i1 %11, float %12, float %9
%14 = fcmp ole float %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
}