#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 */
scalar_t__ DBL_EPSILON;
scalar_t__ fabs(double);
int double_compare(const double *lhs, const double *rhs) {
  double diff = *rhs - *lhs;
  if (fabs(diff) <= DBL_EPSILON) {
    return 0;
  } else if (*lhs < *rhs) {
    return -1;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<double_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1030 <fabs@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
jg     115b <double_compare+0x4b>
movl   $0x0,-0x4(%rbp)
jmp    1188 <double_compare+0x78>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1181 <double_compare+0x71>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <double_compare+0x78>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_compare>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movsd  (%rsi),%xmm0
subsd  (%rdi),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    0x2eb7(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
jle    114b <double_compare+0x3b>
movsd  (%rbx),%xmm0
xor    %eax,%eax
ucomisd (%r14),%xmm0
setbe  %al
add    %eax,%eax
add    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@DBL_EPSILON = global i64 0
define i32 @double_compare(double* %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca double*
%6 = alloca double
store double* %0, double** %4
store double* %1, double** %5
%7 = load double*, double** %5
%8 = load double, double* %7
%9 = load double*, double** %4
%10 = load double, double* %9
%11 = fsub double %8, %10
store double %11, double* %6
%12 = load double, double* %6
%13 = call i64 @fabs(double %12)
%14 = load i64, i64* @DBL_EPSILON
%15 = icmp sle i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 0, i32* %3
br label %25
17: ; preds = %2
%18 = load double*, double** %4
%19 = load double, double* %18
%20 = load double*, double** %5
%21 = load double, double* %20
%22 = fcmp olt double %19, %21
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 -1, i32* %3
br label %25
24: ; preds = %17
store i32 1, i32* %3
br label %25
25: ; preds = %24, %23, %16
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@DBL_EPSILON = global i64 0
define i32 @double_compare(double* nocapture %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = load double, double* %0
%5 = fsub double %3, %4
%6 = tail call i64 @fabs(double %5)
%7 = load i64, i64* @DBL_EPSILON
%8 = icmp sgt i64 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load double, double* %0
%11 = load double, double* %1
%12 = fcmp olt double %10, %11
%13 = select i1 %12, i32 -1, i32 1
br label %14
14: ; preds = %9, %2
%15 = phi i32 [ 0, %2 ], [ %13, %9 ]
ret i32 %15
}