#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 *,
                                           unsigned int);
void stic_assert_float_equal(float expected, float actual, float delta,
                             const char *function, 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, line);
}


x86 assembly (clang, -O0):
<stic_assert_float_equal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186d0,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x186c4(%rbp)
ff
lea    -0x186c0(%rbp),%rdi
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
lea    0xe95(%rip),%rsi
call   1040 <sprintf@plt>
movss  -0x186c4(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    119c <stic_assert_float_equal+0x7c>
xorps  %xmm0,%xmm0
subss  -0x186c4(%rbp),%xmm0
ff
movss  %xmm0,-0x186c4(%rbp)
ff
movss  -0x186c4(%rbp),%xmm1
ff
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
lea    -0x186c0(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <stic_simple_test_result@plt>
add    $0x186d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stic_assert_float_equal>:
push   %rbp
push   %r14
push   %rbx
sub    $0x186c0,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
movss  %xmm2,0xc(%rsp)
movaps %xmm0,%xmm2
subss  %xmm1,%xmm2
movaps %xmm2,0x10(%rsp)
lea    0xeb7(%rip),%rsi
lea    0x20(%rsp),%r14
mov    %r14,%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    %r14,%rsi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1030 <stic_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 @stic_assert_float_equal(float %0, float %1, float %2, i8* %3, i32 %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [100000 x i8]
%12 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%13 = load float, float* %6
%14 = load float, float* %7
%15 = fsub float %13, %14
store float %15, float* %12
%16 = getelementptr inbounds [100000 x i8], [100000 x i8]* %11, i64 0, i64 0
%17 = load float, float* %6
%18 = load float, float* %7
%19 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), float %17, float %18)
%20 = load float, float* %12
%21 = fpext float %20 to double
%22 = fcmp olt double %21, 0.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %5
%24 = load float, float* %12
%25 = fsub float 0.000000e+00, %24
store float %25, float* %12
br label %26
26: ; preds = %23, %5
%27 = load float, float* %12
%28 = load float, float* %8
%29 = fcmp ole float %27, %28
%30 = zext i1 %29 to i32
%31 = getelementptr inbounds [100000 x i8], [100000 x i8]* %11, i64 0, i64 0
%32 = load i8*, i8** %9
%33 = load i32, i32* %10
%34 = call i32 @stic_simple_test_result(i32 %30, i8* %31, i8* %32, i32 %33)
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, i32 %4) {
%6 = alloca [100000 x i8]
%7 = getelementptr inbounds [100000 x i8], [100000 x i8]* %6, i64 0, i64 0
%8 = fsub float %0, %1
%9 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), float %0, float %1)
%10 = fcmp olt float %8, 0.000000e+00
%11 = fsub float 0.000000e+00, %8
%12 = select i1 %10, float %11, float %8
%13 = fcmp ole float %12, %2
%14 = zext i1 %13 to i32
%15 = call i32 @stic_simple_test_result(i32 %14, i8* %7, i8* %3, i32 %4)
ret void
}