#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 */
struct clad_test {
  int dummy;
};

/* Variables and functions */
struct clad_test *clad_test_assert(struct clad_test *, int, char *, double,
                                   double, char const *);
double fabs(double);
struct clad_test *clad_test_doubleeq(struct clad_test *test, double d1,
                                     double d2, const char *explain) {
  double delta = fabs(d2 - d1);
  return clad_test_assert(test, delta < 0.0000000001,
                          "Doubles should be equal: %f %f; %s ", d1, d2,
                          explain);
}


x86 assembly (clang, -O0):
<clad_test_doubleeq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xed5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movsd  0xeb0(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%esi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    -0x20(%rbp),%rcx
lea    0xeae(%rip),%rdx
call   1030 <clad_test_assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clad_test_doubleeq>:
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
andpd  0xee0(%rip),%xmm2
movsd  0xee8(%rip),%xmm3
xor    %eax,%eax
ucomisd %xmm2,%xmm3
mov    %rsi,%rcx
seta   %al
lea    0xedd(%rip),%rdx
mov    %eax,%esi
jmp    1030 <clad_test_assert@plt>

LLVM IR (-O0):
%struct.clad_test = type { i32 }
@.str = [36 x i8] c"Doubles should be equal: %f %f; %s \00"
define %struct.clad_test* @clad_test_doubleeq(%struct.clad_test* %0, double %1, double %2, i8* %3) {
%5 = alloca %struct.clad_test*
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
%9 = alloca double
store %struct.clad_test* %0, %struct.clad_test** %5
store double %1, double* %6
store double %2, double* %7
store i8* %3, i8** %8
%10 = load double, double* %7
%11 = load double, double* %6
%12 = fsub double %10, %11
%13 = call double @llvm.fabs.f64(double %12)
store double %13, double* %9
%14 = load %struct.clad_test*, %struct.clad_test** %5
%15 = load double, double* %9
%16 = fcmp olt double %15, 1.000000e-10
%17 = zext i1 %16 to i32
%18 = load double, double* %6
%19 = load double, double* %7
%20 = load i8*, i8** %8
%21 = call %struct.clad_test* @clad_test_assert(%struct.clad_test* %14, i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), double %18, double %19, i8* %20)
ret %struct.clad_test* %21
}

LLVM IR (-O2):
%struct.clad_test = type { i32 }
@.str = [36 x i8] c"Doubles should be equal: %f %f; %s \00"
define %struct.clad_test* @clad_test_doubleeq(%struct.clad_test* %0, double %1, double %2, i8* %3) {
%5 = fsub double %2, %1
%6 = tail call double @llvm.fabs.f64(double %5)
%7 = fcmp olt double %6, 1.000000e-10
%8 = zext i1 %7 to i32
%9 = tail call %struct.clad_test* @clad_test_assert(%struct.clad_test* %0, i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), double %1, double %2, i8* %3)
ret %struct.clad_test* %9
}