#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 */
int /*<<< orphan*/ assert(int);
int double_almost_equal_v2(double x, double y, double epsilon) {
  double delta;
  assert(epsilon >= 0.0);
  if (x == y)
    return 1;
  delta = x > y ? x - y : y - x;
  return delta <= epsilon;
}


x86 assembly (clang, -O0):
<double_almost_equal_v2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1162 <double_almost_equal_v2+0x52>
jp     1162 <double_almost_equal_v2+0x52>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <double_almost_equal_v2+0xa8>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1186 <double_almost_equal_v2+0x76>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1195 <double_almost_equal_v2+0x85>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
setae  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<double_almost_equal_v2>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
xor    %edi,%edi
movsd  %xmm2,(%rsp)
ucomisd %xmm0,%xmm2
setae  %dil
call   1030 <assert@plt>
movsd  0x8(%rsp),%xmm3
movapd 0x10(%rsp),%xmm2
mov    $0x1,%eax
ucomisd %xmm2,%xmm3
jne    1155 <double_almost_equal_v2+0x45>
jp     1155 <double_almost_equal_v2+0x45>
add    $0x28,%rsp
ret
movapd %xmm3,%xmm0
subsd  %xmm2,%xmm0
movapd %xmm2,%xmm1
subsd  %xmm3,%xmm1
cmpltsd %xmm3,%xmm2
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
xor    %eax,%eax
movsd  (%rsp),%xmm0
ucomisd %xmm2,%xmm0
setae  %al
add    $0x28,%rsp
ret

LLVM IR (-O0):
define i32 @double_almost_equal_v2(double %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
%9 = load double, double* %7
%10 = fcmp oge double %9, 0.000000e+00
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = load double, double* %5
%14 = load double, double* %6
%15 = fcmp oeq double %13, %14
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 1, i32* %4
br label %35
17: ; preds = %3
%18 = load double, double* %5
%19 = load double, double* %6
%20 = fcmp ogt double %18, %19
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load double, double* %5
%23 = load double, double* %6
%24 = fsub double %22, %23
br label %29
25: ; preds = %17
%26 = load double, double* %6
%27 = load double, double* %5
%28 = fsub double %26, %27
br label %29
29: ; preds = %25, %21
%30 = phi double [ %24, %21 ], [ %28, %25 ]
store double %30, double* %8
%31 = load double, double* %8
%32 = load double, double* %7
%33 = fcmp ole double %31, %32
%34 = zext i1 %33 to i32
store i32 %34, i32* %4
br label %35
35: ; preds = %29, %16
%36 = load i32, i32* %4
ret i32 %36
}

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