#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*/ printf(char *, char *, int, double, ...);
void _assertEqualsD(double actual, double expected, double delta, char *file,
                    int line) {
  double diff = actual > expected ? actual - expected : expected - actual;
  if (diff < delta) {
    printf("%s:%d:\033[0;32m %f OK\033[0m\n", file, line, actual);
  } else {
    printf("%s:%d:\033[0;31m expected %f but got %f\033[0m\n", file, line,
           expected, actual);
  }
}


x86 assembly (clang, -O0):
<_assertEqualsD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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
ucomisd -0x10(%rbp),%xmm0
jbe    1152 <_assertEqualsD+0x42>
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    1161 <_assertEqualsD+0x51>
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    119e <_assertEqualsD+0x8e>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x8(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11bd <_assertEqualsD+0xad>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
lea    0xe63(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_assertEqualsD>:
mov    %esi,%edx
mov    %rdi,%rsi
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm0
movapd %xmm1,%xmm4
subsd  %xmm3,%xmm4
movapd %xmm1,%xmm5
cmpltsd %xmm3,%xmm5
andpd  %xmm5,%xmm0
andnpd %xmm4,%xmm5
orpd   %xmm0,%xmm5
ucomisd %xmm5,%xmm2
jbe    1152 <_assertEqualsD+0x42>
lea    0xeb9(%rip),%rdi
movapd %xmm3,%xmm0
mov    $0x1,%al
jmp    1030 <printf@plt>
lea    0xec0(%rip),%rdi
movapd %xmm1,%xmm0
movapd %xmm3,%xmm1
mov    $0x2,%al
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"%s:%d:\1B[0;32m %f OK\1B[0m\0A\00"
@.str.1 = [42 x i8] c"%s:%d:\1B[0;31m expected %f but got %f\1B[0m\0A\00"
define void @_assertEqualsD(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 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
%12 = load double, double* %6
%13 = load double, double* %7
%14 = fcmp ogt double %12, %13
br i1 %14, label %15, label %19
15: ; preds = %5
%16 = load double, double* %6
%17 = load double, double* %7
%18 = fsub double %16, %17
br label %23
19: ; preds = %5
%20 = load double, double* %7
%21 = load double, double* %6
%22 = fsub double %20, %21
br label %23
23: ; preds = %19, %15
%24 = phi double [ %18, %15 ], [ %22, %19 ]
store double %24, double* %11
%25 = load double, double* %11
%26 = load double, double* %8
%27 = fcmp olt double %25, %26
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i8*, i8** %9
%30 = load i32, i32* %10
%31 = load double, double* %6
%32 = call i32 (i8*, i8*, i32, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %29, i32 %30, double %31)
br label %39
33: ; preds = %23
%34 = load i8*, i8** %9
%35 = load i32, i32* %10
%36 = load double, double* %7
%37 = load double, double* %6
%38 = call i32 (i8*, i8*, i32, double, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %34, i32 %35, double %36, double %37)
br label %39
39: ; preds = %33, %28
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"%s:%d:\1B[0;32m %f OK\1B[0m\0A\00"
@.str.1 = [42 x i8] c"%s:%d:\1B[0;31m expected %f but got %f\1B[0m\0A\00"
define void @_assertEqualsD(double %0, double %1, double %2, i8* %3, i32 %4) {
%6 = fcmp ogt double %0, %1
%7 = fsub double %0, %1
%8 = fsub double %1, %0
%9 = select i1 %6, double %7, double %8
%10 = fcmp olt double %9, %2
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = tail call i32 (i8*, i8*, i32, double, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %4, double %0)
br label %15
13: ; preds = %5
%14 = tail call i32 (i8*, i8*, i32, double, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %4, double %1, double %0)
br label %15
15: ; preds = %13, %11
ret void
}