#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 */
scalar_t__ isnan(float);
float fdimf(float x, float y) {
  if (isnan(x))
    return (x);
  if (isnan(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)
movss  -0x8(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1145 <fdimf+0x35>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11aa <fdimf+0x9a>
movss  -0xc(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1168 <fdimf+0x58>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11aa <fdimf+0x9a>
movss  -0x8(%rbp),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    118f <fdimf+0x7f>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119c <fdimf+0x8c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    119c <fdimf+0x8c>
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 <isnan@plt>
test   %rax,%rax
je     1134 <fdimf+0x24>
movss  0xc(%rsp),%xmm0
add    $0x28,%rsp
ret
movaps 0x10(%rsp),%xmm0
call   1030 <isnan@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
%6 = load float, float* %4
%7 = call i64 @isnan(float %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load float, float* %4
store float %10, float* %3
br label %30
11: ; preds = %2
%12 = load float, float* %5
%13 = call i64 @isnan(float %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load float, float* %5
store float %16, float* %3
br label %30
17: ; preds = %11
%18 = load float, float* %4
%19 = load float, float* %5
%20 = fcmp ogt float %18, %19
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load float, float* %4
%23 = load float, float* %5
%24 = fsub float %22, %23
%25 = fpext float %24 to double
br label %27
26: ; preds = %17
br label %27
27: ; preds = %26, %21
%28 = phi double [ %25, %21 ], [ 0.000000e+00, %26 ]
%29 = fptrunc double %28 to float
store float %29, float* %3
br label %30
30: ; preds = %27, %15, %9
%31 = load float, float* %3
ret float %31
}

LLVM IR (-O2):
define float @fdimf(float %0, float %1) {
%3 = tail call i64 @isnan(float %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = tail call i64 @isnan(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
}