#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*/ errno;
int fpclassify(long double);
long double fdiml(long double x, long double y) {
  int cx = fpclassify(x), cy = fpclassify(y);
  long double r;
  if (cx == FP_NAN || cy == FP_NAN ||
      (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
    return x - y;
  if (x <= y)
    return 0.0;
  r = x - y;
  if (fpclassify(r) == FP_INFINITE)
    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   1030 <fpclassify@plt>
mov    %eax,-0x34(%rbp)
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <fpclassify@plt>
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     11a0 <fdiml+0x90>
mov    -0x38(%rbp),%eax
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
je     11a0 <fdiml+0x90>
fldt   -0x30(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    11b0 <fdiml+0xa0>
jmp    117c <fdiml+0x6c>
mov    -0x34(%rbp),%eax
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%eax
jne    11b0 <fdiml+0xa0>
mov    -0x38(%rbp),%eax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%eax
jne    11b0 <fdiml+0xa0>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fsubrp %st,%st(1)
fstpt  -0x10(%rbp)
jmp    120e <fdiml+0xfe>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fucomip %st(1),%st
fstp   %st(0)
jb     11cf <fdiml+0xbf>
jmp    11c5 <fdiml+0xb5>
fldz
fstpt  -0x10(%rbp)
jmp    120e <fdiml+0xfe>
fldt   -0x20(%rbp)
fldt   -0x30(%rbp)
fsubrp %st,%st(1)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <fpclassify@plt>
mov    0x2df2(%rip),%rcx
cmp    (%rcx),%eax
jne    1208 <fdiml+0xf8>
mov    0x2ddb(%rip),%rax
mov    (%rax),%ecx
mov    0x2dc2(%rip),%rax
mov    %ecx,(%rax)
fldt   -0x50(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdiml>:
push   %rbx
sub    $0x30,%rsp
fldt   0x50(%rsp)
fstpt  0x18(%rsp)
fldt   0x40(%rsp)
fld    %st(0)
fstpt  0x24(%rsp)
fstpt  (%rsp)
call   1030 <fpclassify@plt>
mov    %eax,%ebx
fldt   0x18(%rsp)
fstpt  (%rsp)
call   1030 <fpclassify@plt>
fldt   0x18(%rsp)
mov    0x2ea0(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%ebx
fldz
je     1171 <fdiml+0x61>
fstp   %st(0)
cmp    %ecx,%eax
fldz
je     1171 <fdiml+0x61>
fstp   %st(0)
fldz
fucomi %st(1),%st
jbe    117b <fdiml+0x6b>
mov    0x2e79(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%ebx
jne    117b <fdiml+0x6b>
cmp    %ecx,%eax
jne    117b <fdiml+0x6b>
fstp   %st(0)
fldt   0x24(%rsp)
fsubp  %st,%st(1)
jmp    11bc <fdiml+0xac>
fldt   0x24(%rsp)
fxch   %st(2)
fucomi %st(2),%st
fxch   %st(1)
fxch   %st(2)
jae    11c0 <fdiml+0xb0>
fstp   %st(2)
fsubrp %st,%st(1)
fld    %st(0)
fstpt  0x18(%rsp)
fstpt  (%rsp)
call   1030 <fpclassify@plt>
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%eax
jne    11b8 <fdiml+0xa8>
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
mov    0x2e12(%rip),%rcx
mov    %eax,(%rcx)
fldt   0x18(%rsp)
fldz
fldz
fstp   %st(1)
fstp   %st(0)
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
@errno = 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 %31, 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 %31, label %20
20: ; preds = %16
%21 = load x86_fp80, x86_fp80* %5
%22 = fcmp olt x86_fp80 %21, 0xK00000000000000000000
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %6
%25 = load i32, i32* @FP_INFINITE
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = load i32, i32* %7
%29 = load i32, i32* @FP_INFINITE
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27, %16, %2
%32 = load x86_fp80, x86_fp80* %4
%33 = load x86_fp80, x86_fp80* %5
%34 = fsub x86_fp80 %32, %33
store x86_fp80 %34, x86_fp80* %3
br label %52
35: ; preds = %27, %23, %20
%36 = load x86_fp80, x86_fp80* %4
%37 = load x86_fp80, x86_fp80* %5
%38 = fcmp ole x86_fp80 %36, %37
br i1 %38, label %39, label %40
39: ; preds = %35
store x86_fp80 0xK00000000000000000000, x86_fp80* %3
br label %52
40: ; preds = %35
%41 = load x86_fp80, x86_fp80* %4
%42 = load x86_fp80, x86_fp80* %5
%43 = fsub x86_fp80 %41, %42
store x86_fp80 %43, x86_fp80* %8
%44 = load x86_fp80, x86_fp80* %8
%45 = call i32 @fpclassify(x86_fp80 %44)
%46 = load i32, i32* @FP_INFINITE
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %40
%49 = load i32, i32* @ERANGE
store i32 %49, i32* @errno
br label %50
50: ; preds = %48, %40
%51 = load x86_fp80, x86_fp80* %8
store x86_fp80 %51, x86_fp80* %3
br label %52
52: ; preds = %50, %39, %31
%53 = load x86_fp80, x86_fp80* %3
ret x86_fp80 %53
}

LLVM IR (-O2):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
@errno = 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 %16, label %9
9: ; preds = %2
%10 = fcmp olt x86_fp80 %1, 0xK00000000000000000000
br i1 %10, label %11, label %18
11: ; preds = %9
%12 = load i32, i32* @FP_INFINITE
%13 = icmp eq i32 %3, %12
%14 = icmp eq i32 %4, %12
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %18
16: ; preds = %11, %2
%17 = fsub x86_fp80 %0, %1
br label %27
18: ; preds = %11, %9
%19 = fcmp ugt x86_fp80 %0, %1
br i1 %19, label %20, label %27
20: ; preds = %18
%21 = fsub x86_fp80 %0, %1
%22 = tail call i32 @fpclassify(x86_fp80 %21)
%23 = load i32, i32* @FP_INFINITE
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = load i32, i32* @ERANGE
store i32 %26, i32* @errno
br label %27
27: ; preds = %20, %25, %18, %16
%28 = phi x86_fp80 [ %17, %16 ], [ 0xK00000000000000000000, %18 ], [ %21, %25 ], [ %21, %20 ]
ret x86_fp80 %28
}