#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*/ ERANGE;
int FP_INFINITE;
int FP_NAN;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int fpclassify(long double);
long double __fdiml(long double x, long double y) {
  int clsx = fpclassify(x);
  int clsy = fpclassify(y);
  if (clsx == FP_NAN || clsy == FP_NAN)
    return x - y;
  if (x <= y)
    return 0.0f;
  long double r = x - y;
  if (fpclassify(r) == FP_INFINITE && clsx != FP_INFINITE &&
      clsy != FP_INFINITE)
    __set_errno(ERANGE);
  return r;
}


x86 assembly (clang, -O0):
<__fdiml>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
fldt   0x20(%rbp)
fldt   0x10(%rbp)
fstpt  -0x20(%rbp)
fstpt  -0x30(%rbp)
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fpclassify@plt>
mov    %eax,-0x34(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fpclassify@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     1178 <__fdiml+0x58>
mov    -0x38(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    1188 <__fdiml+0x68>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fsubrp %st,%st(1)
fstpt  -0x10(%rbp)
jmp    1206 <__fdiml+0xe6>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fucomip %st(1),%st
fstp   %st(0)
jb     11a7 <__fdiml+0x87>
jmp    119d <__fdiml+0x7d>
fldz
fstpt  -0x10(%rbp)
jmp    1206 <__fdiml+0xe6>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fsubrp %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1040 <fpclassify@plt>
mov    0x2e1a(%rip),%rcx
cmp    (%rcx),%eax
jne    1200 <__fdiml+0xe0>
mov    -0x34(%rbp),%eax
mov    0x2e08(%rip),%rcx
cmp    (%rcx),%eax
je     1200 <__fdiml+0xe0>
mov    -0x38(%rbp),%eax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%eax
je     1200 <__fdiml+0xe0>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
fldt   -0x50(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fdiml>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
fldt   0x50(%rsp)
fstpt  0x10(%rsp)
fldt   0x40(%rsp)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
call   1040 <fpclassify@plt>
mov    %eax,%ebx
fldt   0x10(%rsp)
fstpt  (%rsp)
call   1040 <fpclassify@plt>
mov    %eax,%ebp
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%ebx
je     11ae <__fdiml+0x8e>
cmp    %eax,%ebp
je     11ae <__fdiml+0x8e>
fldz
fldt   0x10(%rsp)
fldt   0x1c(%rsp)
fxch   %st(1)
fucomi %st(1),%st
fxch   %st(1)
jae    11bc <__fdiml+0x9c>
fstp   %st(2)
fsubrp %st,%st(1)
fld    %st(0)
fstpt  0x10(%rsp)
fstpt  (%rsp)
call   1040 <fpclassify@plt>
mov    0x2e54(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%eax
jne    11a8 <__fdiml+0x88>
cmp    %ecx,%ebx
je     11a8 <__fdiml+0x88>
cmp    %ecx,%ebp
je     11a8 <__fdiml+0x88>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
fldt   0x10(%rsp)
jmp    11b8 <__fdiml+0x98>
fldt   0x10(%rsp)
fldt   0x1c(%rsp)
fsubp  %st,%st(1)
fldz
fldz
fstp   %st(1)
fstp   %st(0)
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
define x86_fp80 @__fdiml(x86_fp80 %0, x86_fp80 %1) {
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %4
store x86_fp80 %1, x86_fp80* %5
%9 = load x86_fp80, x86_fp80* %4
%10 = call i32 @fpclassify(x86_fp80 %9)
store i32 %10, i32* %6
%11 = load x86_fp80, x86_fp80* %5
%12 = call i32 @fpclassify(x86_fp80 %11)
store i32 %12, i32* %7
%13 = load i32, i32* %6
%14 = load i32, i32* @FP_NAN
%15 = icmp eq i32 %13, %14
br i1 %15, label %20, label %16
16: ; preds = %2
%17 = load i32, i32* %7
%18 = load i32, i32* @FP_NAN
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16, %2
%21 = load x86_fp80, x86_fp80* %4
%22 = load x86_fp80, x86_fp80* %5
%23 = fsub x86_fp80 %21, %22
store x86_fp80 %23, x86_fp80* %3
br label %50
24: ; preds = %16
%25 = load x86_fp80, x86_fp80* %4
%26 = load x86_fp80, x86_fp80* %5
%27 = fcmp ole x86_fp80 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %50
29: ; preds = %24
%30 = load x86_fp80, x86_fp80* %4
%31 = load x86_fp80, x86_fp80* %5
%32 = fsub x86_fp80 %30, %31
store x86_fp80 %32, x86_fp80* %8
%33 = load x86_fp80, x86_fp80* %8
%34 = call i32 @fpclassify(x86_fp80 %33)
%35 = load i32, i32* @FP_INFINITE
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %48
37: ; preds = %29
%38 = load i32, i32* %6
%39 = load i32, i32* @FP_INFINITE
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %48
41: ; preds = %37
%42 = load i32, i32* %7
%43 = load i32, i32* @FP_INFINITE
%44 = icmp ne i32 %42, %43
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* @ERANGE
%47 = call i32 @__set_errno(i32 %46)
br label %48
48: ; preds = %45, %41, %37, %29
%49 = load x86_fp80, x86_fp80* %8
store x86_fp80 %49, x86_fp80* %3
br label %50
50: ; preds = %48, %28, %20
%51 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %51
}

LLVM IR (-O2):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
define x86_fp80 @__fdiml(x86_fp80 %0, x86_fp80 %1) {
%3 = tail call i32 @fpclassify(x86_fp80 %0)
%4 = tail call i32 @fpclassify(x86_fp80 %1)
%5 = load i32, i32* @FP_NAN
%6 = icmp eq i32 %3, %5
%7 = icmp eq i32 %4, %5
%8 = select i1 %6, i1 true, i1 %7
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = fsub x86_fp80 %0, %1
br label %25
11: ; preds = %2
%12 = fcmp ugt x86_fp80 %0, %1
br i1 %12, label %13, label %25
13: ; preds = %11
%14 = fsub x86_fp80 %0, %1
%15 = tail call i32 @fpclassify(x86_fp80 %14)
%16 = load i32, i32* @FP_INFINITE
%17 = icmp ne i32 %15, %16
%18 = icmp eq i32 %3, %16
%19 = select i1 %17, i1 true, i1 %18
%20 = icmp eq i32 %4, %16
%21 = select i1 %19, i1 true, i1 %20
br i1 %21, label %25, label %22
22: ; preds = %13
%23 = load i32, i32* @ERANGE
%24 = tail call i32 @__set_errno(i32 %23)
br label %25
25: ; preds = %13, %22, %11, %9
%26 = phi x86_fp80 [ %10, %9 ], [ 0xK00000000000000000000, %11 ], [ %14, %22 ], [ %14, %13 ]
ret x86_fp80 %26
}