#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 */
typedef int /*<<< orphan*/ y;
typedef int /*<<< orphan*/ x;

/* Variables and functions */
scalar_t__ __isnanl(float);
scalar_t__ isnan(float);
scalar_t__ isnanf(float);
float fdimf(float x, float y) {
  if (((sizeof(x) == sizeof(float))    ? isnanf(x)
       : (sizeof(x) == sizeof(double)) ? isnan(x)
                                       : __isnanl(x)))
    return (x);
  if (((sizeof(y) == sizeof(float))    ? isnanf(y)
       : (sizeof(y) == sizeof(double)) ? isnan(y)
                                       : __isnanl(y)))
    return (y);
  return (x > y ? x - y : 0.0);
}


x86 assembly (clang, -O0):
<fdimf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1151 <fdimf+0x21>
jmp    116a <fdimf+0x3a>
movss  -0x8(%rbp),%xmm0
call   1030 <isnanf@plt>
cmp    $0x0,%rax
jne    11a6 <fdimf+0x76>
jmp    11b5 <fdimf+0x85>
xor    %eax,%eax
test   $0x1,%al
jne    1179 <fdimf+0x49>
jmp    1192 <fdimf+0x62>
movss  -0x8(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
jne    11a6 <fdimf+0x76>
jmp    11b5 <fdimf+0x85>
movss  -0x8(%rbp),%xmm0
call   1040 <__isnanl@plt>
cmp    $0x0,%rax
je     11b5 <fdimf+0x85>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    126a <fdimf+0x13a>
mov    $0x1,%al
test   $0x1,%al
jne    11c4 <fdimf+0x94>
jmp    11dd <fdimf+0xad>
movss  -0xc(%rbp),%xmm0
call   1030 <isnanf@plt>
cmp    $0x0,%rax
jne    1219 <fdimf+0xe9>
jmp    1228 <fdimf+0xf8>
xor    %eax,%eax
test   $0x1,%al
jne    11ec <fdimf+0xbc>
jmp    1205 <fdimf+0xd5>
movss  -0xc(%rbp),%xmm0
call   1050 <isnan@plt>
cmp    $0x0,%rax
jne    1219 <fdimf+0xe9>
jmp    1228 <fdimf+0xf8>
movss  -0xc(%rbp),%xmm0
call   1040 <__isnanl@plt>
cmp    $0x0,%rax
je     1228 <fdimf+0xf8>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    126a <fdimf+0x13a>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    124f <fdimf+0x11f>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    125c <fdimf+0x12c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    125c <fdimf+0x12c>
movsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdimf>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
call   1030 <isnanf@plt>
test   %rax,%rax
je     1134 <fdimf+0x24>
movss  0xc(%rsp),%xmm0
add    $0x28,%rsp
ret
movaps 0x10(%rsp),%xmm0
call   1030 <isnanf@plt>
test   %rax,%rax
je     114d <fdimf+0x3d>
movaps 0x10(%rsp),%xmm0
add    $0x28,%rsp
ret
movss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
movaps 0x10(%rsp),%xmm2
subss  %xmm2,%xmm0
cmpltss %xmm1,%xmm2
andps  %xmm0,%xmm2
movaps %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define float @fdimf(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
br i1 true, label %6, label %10
6: ; preds = %2
%7 = load float, float* %4
%8 = call i64 @isnanf(float %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %19, label %21
10: ; preds = %2
br i1 false, label %11, label %15
11: ; preds = %10
%12 = load float, float* %4
%13 = call i64 @isnan(float %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %19, label %21
15: ; preds = %10
%16 = load float, float* %4
%17 = call i64 @__isnanl(float %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15, %11, %6
%20 = load float, float* %4
store float %20, float* %3
br label %50
21: ; preds = %15, %11, %6
br i1 true, label %22, label %26
22: ; preds = %21
%23 = load float, float* %5
%24 = call i64 @isnanf(float %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %35, label %37
26: ; preds = %21
br i1 false, label %27, label %31
27: ; preds = %26
%28 = load float, float* %5
%29 = call i64 @isnan(float %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %35, label %37
31: ; preds = %26
%32 = load float, float* %5
%33 = call i64 @__isnanl(float %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31, %27, %22
%36 = load float, float* %5
store float %36, float* %3
br label %50
37: ; preds = %31, %27, %22
%38 = load float, float* %4
%39 = load float, float* %5
%40 = fcmp ogt float %38, %39
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load float, float* %4
%43 = load float, float* %5
%44 = fsub float %42, %43
%45 = fpext float %44 to double
br label %47
46: ; preds = %37
br label %47
47: ; preds = %46, %41
%48 = phi double [ %45, %41 ], [ 0.000000e+00, %46 ]
%49 = fptrunc double %48 to float
store float %49, float* %3
br label %50
50: ; preds = %47, %35, %19
%51 = load float, float* %3
ret float %51
}

LLVM IR (-O2):
define float @fdimf(float %0, float %1) {
%3 = tail call i64 @isnanf(float %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i64 @isnanf(float %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = fcmp ogt float %0, %1
%10 = fsub float %0, %1
%11 = select i1 %9, float %10, float 0.000000e+00
br label %12
12: ; preds = %5, %2, %8
%13 = phi float [ %11, %8 ], [ %0, %2 ], [ %1, %5 ]
ret float %13
}