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


x86 assembly (clang, -O0):
<_gsl_fcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1050 <fabs@plt>
mov    %rax,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <fabs@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jle    117e <_gsl_fcmp+0x4e>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1188 <_gsl_fcmp+0x58>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    -0x1c(%rbp),%rdi
call   1040 <frexp@plt>
movsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <ldexp@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11dd <_gsl_fcmp+0xad>
movl   $0x1,-0x20(%rbp)
jmp    1220 <_gsl_fcmp+0xf0>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1214 <_gsl_fcmp+0xe4>
movl   $0xffffffff,-0x20(%rbp)
jmp    121b <_gsl_fcmp+0xeb>
movl   $0x0,-0x20(%rbp)
jmp    1220 <_gsl_fcmp+0xf0>
mov    -0x20(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @_gsl_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
}