#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 */
double fabs(double);
int rpn_dequals(double d1, double d2, double precision) {
  double eps1 = fabs(d1), eps2 = fabs(d2), eps;
  eps = (eps1 > eps2) ? eps1 : eps2;
  if (eps == 0.0)
    return 1;
  eps *= precision;
  return (fabs(d1 - d2) < eps);
}


x86 assembly (clang, -O0):
<rpn_dequals>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee1(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xecc(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    115c <rpn_dequals+0x5c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1166 <rpn_dequals+0x66>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1194 <rpn_dequals+0x94>
jp     1194 <rpn_dequals+0x94>
movl   $0x1,-0x4(%rbp)
jmp    11cc <rpn_dequals+0xcc>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm1
subsd  -0x18(%rbp),%xmm1
movaps 0xe4c(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rpn_dequals>:
movapd 0xef8(%rip),%xmm4
movapd %xmm0,%xmm3
andpd  %xmm4,%xmm3
andpd  %xmm1,%xmm4
maxsd  %xmm4,%xmm3
mov    $0x1,%eax
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm3
jne    112a <rpn_dequals+0x2a>
jp     112a <rpn_dequals+0x2a>
ret
mulsd  %xmm2,%xmm3
subsd  %xmm1,%xmm0
andpd  0xec6(%rip),%xmm0
xor    %eax,%eax
ucomisd %xmm0,%xmm3
seta   %al
ret

LLVM IR (-O0):
define i32 @rpn_dequals(double %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%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 double @llvm.fabs.f64(double %11)
store double %12, double* %8
%13 = load double, double* %6
%14 = call double @llvm.fabs.f64(double %13)
store double %14, double* %9
%15 = load double, double* %8
%16 = load double, double* %9
%17 = fcmp ogt double %15, %16
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = load double, double* %8
br label %22
20: ; preds = %3
%21 = load double, double* %9
br label %22
22: ; preds = %20, %18
%23 = phi double [ %19, %18 ], [ %21, %20 ]
store double %23, double* %10
%24 = load double, double* %10
%25 = fcmp oeq double %24, 0.000000e+00
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 1, i32* %4
br label %38
27: ; preds = %22
%28 = load double, double* %7
%29 = load double, double* %10
%30 = fmul double %29, %28
store double %30, double* %10
%31 = load double, double* %5
%32 = load double, double* %6
%33 = fsub double %31, %32
%34 = call double @llvm.fabs.f64(double %33)
%35 = load double, double* %10
%36 = fcmp olt double %34, %35
%37 = zext i1 %36 to i32
store i32 %37, i32* %4
br label %38
38: ; preds = %27, %26
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
define i32 @rpn_dequals(double %0, double %1, double %2) {
%4 = tail call double @llvm.fabs.f64(double %0)
%5 = tail call double @llvm.fabs.f64(double %1)
%6 = fcmp ogt double %4, %5
%7 = select i1 %6, double %4, double %5
%8 = fcmp oeq double %7, 0.000000e+00
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = fmul double %7, %2
%11 = fsub double %0, %1
%12 = tail call double @llvm.fabs.f64(double %11)
%13 = fcmp olt double %12, %10
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %3, %9
%16 = phi i32 [ %14, %9 ], [ 1, %3 ]
ret i32 %16
}