#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(float);
float fdimf(float x, float y) {
  int cx = fpclassify(x), cy = fpclassify(y);
  float r;
  if (cx == FP_NAN || cy == FP_NAN ||
      (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
    return x - y;
  if (x <= y)
    return 0.0f;
  r = x - y;
  if (fpclassify(r) == FP_INFINITE)
    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   1030 <fpclassify@plt>
mov    %eax,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
je     1191 <fdimf+0x81>
mov    -0x14(%rbp),%eax
mov    0x2e90(%rip),%rcx
cmp    (%rcx),%eax
je     1191 <fdimf+0x81>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    11a5 <fdimf+0x95>
mov    -0x10(%rbp),%eax
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%eax
jne    11a5 <fdimf+0x95>
mov    -0x14(%rbp),%eax
mov    0x2e57(%rip),%rcx
cmp    (%rcx),%eax
jne    11a5 <fdimf+0x95>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1209 <fdimf+0xf9>
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     11c5 <fdimf+0xb5>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1209 <fdimf+0xf9>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    0x2dfb(%rip),%rcx
cmp    (%rcx),%eax
jne    11ff <fdimf+0xef>
mov    0x2de4(%rip),%rax
mov    (%rax),%ecx
mov    0x2dcb(%rip),%rax
mov    %ecx,(%rax)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdimf>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm1,0xc(%rsp)
movss  %xmm0,0x8(%rsp)
call   1030 <fpclassify@plt>
mov    %eax,%ebx
movss  0xc(%rsp),%xmm0
call   1030 <fpclassify@plt>
movss  0xc(%rsp),%xmm2
mov    0x2ea8(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%ebx
je     1163 <fdimf+0x53>
cmp    %ecx,%eax
je     1163 <fdimf+0x53>
xorps  %xmm0,%xmm0
ucomiss %xmm2,%xmm0
jbe    116f <fdimf+0x5f>
mov    0x2e87(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%ebx
jne    116f <fdimf+0x5f>
cmp    %ecx,%eax
jne    116f <fdimf+0x5f>
movss  0x8(%rsp),%xmm0
subss  %xmm2,%xmm0
jmp    11af <fdimf+0x9f>
movss  0x8(%rsp),%xmm1
ucomiss %xmm1,%xmm2
jae    11af <fdimf+0x9f>
subss  %xmm2,%xmm1
movss  %xmm1,0x8(%rsp)
movaps %xmm1,%xmm0
call   1030 <fpclassify@plt>
mov    0x2e4d(%rip),%rcx
cmp    (%rcx),%eax
jne    11a9 <fdimf+0x99>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    0x2e21(%rip),%rcx
mov    %eax,(%rcx)
movss  0x8(%rsp),%xmm0
add    $0x10,%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 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 %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 float, float* %5
%22 = fcmp olt float %21, 0.000000e+00
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 float, float* %4
%33 = load float, float* %5
%34 = fsub float %32, %33
store float %34, float* %3
br label %52
35: ; preds = %27, %23, %20
%36 = load float, float* %4
%37 = load float, float* %5
%38 = fcmp ole float %36, %37
br i1 %38, label %39, label %40
39: ; preds = %35
store float 0.000000e+00, float* %3
br label %52
40: ; preds = %35
%41 = load float, float* %4
%42 = load float, float* %5
%43 = fsub float %41, %42
store float %43, float* %8
%44 = load float, float* %8
%45 = call i32 @fpclassify(float %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 float, float* %8
store float %51, float* %3
br label %52
52: ; preds = %50, %39, %31
%53 = load float, float* %3
ret float %53
}

LLVM IR (-O2):
@FP_NAN = global i32 0
@FP_INFINITE = global i32 0
@ERANGE = global i32 0
@errno = 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 %16, label %9
9: ; preds = %2
%10 = fcmp olt float %1, 0.000000e+00
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 float %0, %1
br label %27
18: ; preds = %11, %9
%19 = fcmp ugt float %0, %1
br i1 %19, label %20, label %27
20: ; preds = %18
%21 = fsub float %0, %1
%22 = tail call i32 @fpclassify(float %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 float [ %17, %16 ], [ 0.000000e+00, %18 ], [ %21, %25 ], [ %21, %20 ]
ret float %28
}