#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__ fabs(double);
int /*<<< orphan*/ frexp(double, int *);
double ldexp(double, int);
int fcmp(double x1, double x2, double epsilon) {
  int exponent;
  double delta;
  double difference;
  frexp(fabs(x1) > fabs(x2) ? x1 : x2, &exponent);
  delta = ldexp(epsilon, exponent);
  difference = x1 - x2;
  if (difference > delta)
    return 1;
  else if (difference < -delta)
    return -1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<fcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <fabs@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <fabs@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jle    117e <fcmp+0x4e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1188 <fcmp+0x58>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    -0x24(%rbp),%rdi
call   1040 <frexp@plt>
movsd  -0x20(%rbp),%xmm0
mov    -0x24(%rbp),%edi
call   1030 <ldexp@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11d3 <fcmp+0xa3>
movl   $0x1,-0x4(%rbp)
jmp    1211 <fcmp+0xe1>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    120a <fcmp+0xda>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <fcmp+0xe1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcmp>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1050 <fabs@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
call   1050 <fabs@plt>
movsd  0x10(%rsp),%xmm0
cmp    %rax,%rbx
jg     1168 <fcmp+0x38>
movsd  (%rsp),%xmm0
lea    0xc(%rsp),%rdi
call   1040 <frexp@plt>
mov    0xc(%rsp),%edi
movsd  0x18(%rsp),%xmm0
call   1030 <ldexp@plt>
movsd  0x10(%rsp),%xmm2
subsd  (%rsp),%xmm2
movapd 0xe6c(%rip),%xmm1
xorpd  %xmm0,%xmm1
xor    %ecx,%ecx
ucomisd %xmm2,%xmm1
seta   %cl
neg    %ecx
ucomisd %xmm0,%xmm2
mov    $0x1,%eax
cmovbe %ecx,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @fcmp(double %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca double
%10 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%11 = load double, double* %5
%12 = call i64 @fabs(double %11)
%13 = load double, double* %6
%14 = call i64 @fabs(double %13)
%15 = icmp sgt i64 %12, %14
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load double, double* %5
br label %20
18: ; preds = %3
%19 = load double, double* %6
br label %20
20: ; preds = %18, %16
%21 = phi double [ %17, %16 ], [ %19, %18 ]
%22 = call i32 @frexp(double %21, i32* %8)
%23 = load double, double* %7
%24 = load i32, i32* %8
%25 = call double @ldexp(double %23, i32 %24)
store double %25, double* %9
%26 = load double, double* %5
%27 = load double, double* %6
%28 = fsub double %26, %27
store double %28, double* %10
%29 = load double, double* %10
%30 = load double, double* %9
%31 = fcmp ogt double %29, %30
br i1 %31, label %32, label %33
32: ; preds = %20
store i32 1, i32* %4
br label %40
33: ; preds = %20
%34 = load double, double* %10
%35 = load double, double* %9
%36 = fneg double %35
%37 = fcmp olt double %34, %36
br i1 %37, label %38, label %39
38: ; preds = %33
store i32 -1, i32* %4
br label %40
39: ; preds = %33
store i32 0, i32* %4
br label %40
40: ; preds = %39, %38, %32
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @fcmp(double %0, double %1, double %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = tail call i64 @fabs(double %0)
%7 = tail call i64 @fabs(double %1)
%8 = icmp sgt i64 %6, %7
%9 = select i1 %8, double %0, double %1
%10 = call i32 @frexp(double %9, i32* %4)
%11 = load i32, i32* %4
%12 = tail call double @ldexp(double %2, i32 %11)
%13 = fsub double %0, %1
%14 = fcmp ogt double %13, %12
%15 = fneg double %12
%16 = fcmp olt double %13, %15
%17 = sext i1 %16 to i32
%18 = select i1 %14, i32 1, i32 %17
ret i32 %18
}