#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__ __isnan(double);
scalar_t__ __isnanf(double);
scalar_t__ __isnanl(double);
double fdim(double x, double 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):
<fdim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    1151 <fdim+0x21>
jmp    116a <fdim+0x3a>
movsd  -0x10(%rbp),%xmm0
call   1050 <__isnanf@plt>
cmp    $0x0,%rax
jne    11a6 <fdim+0x76>
jmp    11b5 <fdim+0x85>
mov    $0x1,%al
test   $0x1,%al
jne    1179 <fdim+0x49>
jmp    1192 <fdim+0x62>
movsd  -0x10(%rbp),%xmm0
call   1030 <__isnan@plt>
cmp    $0x0,%rax
jne    11a6 <fdim+0x76>
jmp    11b5 <fdim+0x85>
movsd  -0x10(%rbp),%xmm0
call   1040 <__isnanl@plt>
cmp    $0x0,%rax
je     11b5 <fdim+0x85>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1263 <fdim+0x133>
xor    %eax,%eax
test   $0x1,%al
jne    11c4 <fdim+0x94>
jmp    11dd <fdim+0xad>
movsd  -0x18(%rbp),%xmm0
call   1050 <__isnanf@plt>
cmp    $0x0,%rax
jne    1219 <fdim+0xe9>
jmp    1228 <fdim+0xf8>
mov    $0x1,%al
test   $0x1,%al
jne    11ec <fdim+0xbc>
jmp    1205 <fdim+0xd5>
movsd  -0x18(%rbp),%xmm0
call   1030 <__isnan@plt>
cmp    $0x0,%rax
jne    1219 <fdim+0xe9>
jmp    1228 <fdim+0xf8>
movsd  -0x18(%rbp),%xmm0
call   1040 <__isnanl@plt>
cmp    $0x0,%rax
je     1228 <fdim+0xf8>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1263 <fdim+0x133>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    124c <fdim+0x11c>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1259 <fdim+0x129>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1259 <fdim+0x129>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdim>:
sub    $0x28,%rsp
movaps %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <__isnan@plt>
test   %rax,%rax
je     1134 <fdim+0x24>
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret
movaps 0x10(%rsp),%xmm0
call   1030 <__isnan@plt>
test   %rax,%rax
je     114d <fdim+0x3d>
movaps 0x10(%rsp),%xmm0
add    $0x28,%rsp
ret
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
movapd 0x10(%rsp),%xmm2
subsd  %xmm2,%xmm0
cmpltsd %xmm1,%xmm2
andpd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

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

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