#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(float);
float __fdimf(float x, float 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;
  float r = x - y;
  if (fpclassify(r) == FP_INFINITE && clsx != FP_INFINITE &&
      clsy != FP_INFINITE)
    __set_errno(ERANGE);
  return r;
}


x86 assembly (clang, -O0):
<__fdimf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <fpclassify@plt>
mov    %eax,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
call   1040 <fpclassify@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
je     1170 <__fdimf+0x50>
mov    -0x14(%rbp),%eax
mov    0x2e80(%rip),%rcx
cmp    (%rcx),%eax
jne    1184 <__fdimf+0x64>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1208 <__fdimf+0xe8>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11a4 <__fdimf+0x84>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1208 <__fdimf+0xe8>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <fpclassify@plt>
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%eax
jne    11fe <__fdimf+0xde>
mov    -0x10(%rbp),%eax
mov    0x2e0a(%rip),%rcx
cmp    (%rcx),%eax
je     11fe <__fdimf+0xde>
mov    -0x14(%rbp),%eax
mov    0x2df8(%rip),%rcx
cmp    (%rcx),%eax
je     11fe <__fdimf+0xde>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__fdimf>:
push   %rbp
push   %rbx
push   %rax
movss  %xmm1,0x4(%rsp)
movss  %xmm0,(%rsp)
call   1040 <fpclassify@plt>
mov    %eax,%ebx
movss  0x4(%rsp),%xmm0
call   1040 <fpclassify@plt>
mov    %eax,%ebp
mov    0x2e9f(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%ebx
je     11a1 <__fdimf+0x81>
cmp    %eax,%ebp
je     11a1 <__fdimf+0x81>
xorps  %xmm0,%xmm0
movss  (%rsp),%xmm1
movss  0x4(%rsp),%xmm2
ucomiss %xmm1,%xmm2
jae    11ac <__fdimf+0x8c>
subss  %xmm2,%xmm1
movss  %xmm1,(%rsp)
movaps %xmm1,%xmm0
call   1040 <fpclassify@plt>
mov    0x2e62(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%eax
jne    119a <__fdimf+0x7a>
cmp    %ecx,%ebx
je     119a <__fdimf+0x7a>
cmp    %ecx,%ebp
je     119a <__fdimf+0x7a>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movss  (%rsp),%xmm0
jmp    11ac <__fdimf+0x8c>
movss  (%rsp),%xmm0
subss  0x4(%rsp),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
define float @__fdimf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store float %0, float* %4
store float %1, float* %5
%9 = load float, float* %4
%10 = call i32 @fpclassify(float %9)
store i32 %10, i32* %6
%11 = load float, float* %5
%12 = call i32 @fpclassify(float %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 float, float* %4
%22 = load float, float* %5
%23 = fsub float %21, %22
store float %23, float* %3
br label %50
24: ; preds = %16
%25 = load float, float* %4
%26 = load float, float* %5
%27 = fcmp ole float %25, %26
br i1 %27, label %28, label %29
28: ; preds = %24
store float 0.000000e+00, float* %3
br label %50
29: ; preds = %24
%30 = load float, float* %4
%31 = load float, float* %5
%32 = fsub float %30, %31
store float %32, float* %8
%33 = load float, float* %8
%34 = call i32 @fpclassify(float %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 float, float* %8
store float %49, float* %3
br label %50
50: ; preds = %48, %28, %20
%51 = load float, float* %3
ret float %51
}

LLVM IR (-O2):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
define float @__fdimf(float %0, float %1) {
%3 = tail call i32 @fpclassify(float %0)
%4 = tail call i32 @fpclassify(float %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 float %0, %1
br label %25
11: ; preds = %2
%12 = fcmp ugt float %0, %1
br i1 %12, label %13, label %25
13: ; preds = %11
%14 = fsub float %0, %1
%15 = tail call i32 @fpclassify(float %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 float [ %10, %9 ], [ 0.000000e+00, %11 ], [ %14, %22 ], [ %14, %13 ]
ret float %26
}