int main() {
  volatile float nan = __builtin_nanf("");
  volatile float a = 0.1;
  if (__builtin_isnan(__builtin_fmaxf(nan, a))) {
    return 1;
  }
  if (__builtin_isnan(__builtin_fmaxf(a, nan))) {
    return 1;
  }
  if (!__builtin_isnan(__builtin_fmaxf(nan, nan))) {
    return 1;
  }
  volatile float b = 0.2;
  if (__builtin_fmaxf(a, b) != 0.2) {
    return 1;
  }
  if (__builtin_fmaxf(b, a) != 0.2) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movss  0xef1(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  0xee0(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0x8(%rbp),%xmm3
movss  -0xc(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordss %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxss  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
ucomiss %xmm0,%xmm0
jnp    1162 <main+0x62>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x19a>
movss  -0xc(%rbp),%xmm3
movss  -0x8(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordss %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxss  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
ucomiss %xmm0,%xmm0
jnp    119f <main+0x9f>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x19a>
movss  -0x8(%rbp),%xmm3
movss  -0x8(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordss %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxss  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
ucomiss %xmm0,%xmm0
jp     11dc <main+0xdc>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x19a>
movss  0xe24(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm3
movss  -0x10(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordss %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxss  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdf3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1232 <main+0x132>
jp     1232 <main+0x132>
jmp    123e <main+0x13e>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x19a>
movss  -0x10(%rbp),%xmm3
movss  -0xc(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordss %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
maxss  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd9e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1287 <main+0x187>
jp     1287 <main+0x187>
jmp    1293 <main+0x193>
movl   $0x1,-0x4(%rbp)
jmp    129a <main+0x19a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movl   $0x7fc00000,-0x8(%rsp)
7f
movl   $0x3dcccccd,-0xc(%rsp)
3d
movss  -0x8(%rsp),%xmm0
movss  -0xc(%rsp),%xmm1
movaps %xmm0,%xmm2
cmpunordss %xmm0,%xmm2
movaps %xmm2,%xmm3
andps  %xmm1,%xmm3
maxss  %xmm0,%xmm1
andnps %xmm1,%xmm2
orps   %xmm3,%xmm2
mov    $0x1,%eax
ucomiss %xmm2,%xmm2
jp     1190 <main+0x90>
movss  -0xc(%rsp),%xmm0
movss  -0x8(%rsp),%xmm1
movaps %xmm0,%xmm2
cmpunordss %xmm0,%xmm2
movaps %xmm2,%xmm3
andps  %xmm1,%xmm3
maxss  %xmm0,%xmm1
andnps %xmm1,%xmm2
orps   %xmm3,%xmm2
ucomiss %xmm2,%xmm2
jp     1190 <main+0x90>
movss  -0x8(%rsp),%xmm0
movss  -0x8(%rsp),%xmm1
movaps %xmm0,%xmm2
cmpunordss %xmm0,%xmm2
movaps %xmm2,%xmm3
andps  %xmm1,%xmm3
maxss  %xmm0,%xmm1
andnps %xmm1,%xmm2
orps   %xmm3,%xmm2
ucomiss %xmm2,%xmm2
jp     1191 <main+0x91>
ret
movl   $0x3e4ccccd,-0x4(%rsp)
3e
movss  -0xc(%rsp),%xmm0
movss  -0x4(%rsp),%xmm1
movaps %xmm0,%xmm2
cmpunordss %xmm0,%xmm2
movaps %xmm2,%xmm3
andps  %xmm1,%xmm3
maxss  %xmm0,%xmm1
andnps %xmm1,%xmm2
orps   %xmm3,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
mov    $0x1,%eax
ucomisd 0xe2f(%rip),%xmm0
jne    1190 <main+0x90>
jp     1190 <main+0x90>
movss  -0x4(%rsp),%xmm0
movss  -0xc(%rsp),%xmm1
movaps %xmm0,%xmm2
cmpunordss %xmm0,%xmm2
movaps %xmm2,%xmm3
andps  %xmm1,%xmm3
maxss  %xmm0,%xmm1
andnps %xmm1,%xmm2
orps   %xmm3,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
cmpneqsd 0xdf7(%rip),%xmm0
movq   %xmm0,%rax
and    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store volatile float 0x7FF8000000000000, float* %2
store volatile float 0x3FB99999A0000000, float* %3
%5 = load volatile float, float* %2
%6 = load volatile float, float* %3
%7 = call float @llvm.maxnum.f32(float %5, float %6)
%8 = fcmp uno float %7, %7
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %37
10: ; preds = %0
%11 = load volatile float, float* %3
%12 = load volatile float, float* %2
%13 = call float @llvm.maxnum.f32(float %11, float %12)
%14 = fcmp uno float %13, %13
br i1 %14, label %15, label %16
15: ; preds = %10
store i32 1, i32* %1
br label %37
16: ; preds = %10
%17 = load volatile float, float* %2
%18 = load volatile float, float* %2
%19 = call float @llvm.maxnum.f32(float %17, float %18)
%20 = fcmp uno float %19, %19
br i1 %20, label %22, label %21
21: ; preds = %16
store i32 1, i32* %1
br label %37
22: ; preds = %16
store volatile float 0x3FC99999A0000000, float* %4
%23 = load volatile float, float* %3
%24 = load volatile float, float* %4
%25 = call float @llvm.maxnum.f32(float %23, float %24)
%26 = fpext float %25 to double
%27 = fcmp une double %26, 2.000000e-01
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 1, i32* %1
br label %37
29: ; preds = %22
%30 = load volatile float, float* %4
%31 = load volatile float, float* %3
%32 = call float @llvm.maxnum.f32(float %30, float %31)
%33 = fpext float %32 to double
%34 = fcmp une double %33, 2.000000e-01
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 1, i32* %1
br label %37
36: ; preds = %29
store i32 0, i32* %1
br label %37
37: ; preds = %36, %35, %28, %21, %15, %9
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %1 to i8*
store volatile float 0x7FF8000000000000, float* %1
%5 = bitcast float* %2 to i8*
store volatile float 0x3FB99999A0000000, float* %2
%6 = load volatile float, float* %1
%7 = load volatile float, float* %2
%8 = tail call float @llvm.maxnum.f32(float %6, float %7)
%9 = fcmp uno float %8, 0.000000e+00
br i1 %9, label %36, label %10
10: ; preds = %0
%11 = load volatile float, float* %2
%12 = load volatile float, float* %1
%13 = tail call float @llvm.maxnum.f32(float %11, float %12)
%14 = fcmp uno float %13, 0.000000e+00
br i1 %14, label %36, label %15
15: ; preds = %10
%16 = load volatile float, float* %1
%17 = load volatile float, float* %1
%18 = tail call float @llvm.maxnum.f32(float %16, float %17)
%19 = fcmp uno float %18, 0.000000e+00
br i1 %19, label %20, label %36
20: ; preds = %15
%21 = bitcast float* %3 to i8*
store volatile float 0x3FC99999A0000000, float* %3
%22 = load volatile float, float* %2
%23 = load volatile float, float* %3
%24 = tail call float @llvm.maxnum.f32(float %22, float %23)
%25 = fpext float %24 to double
%26 = fcmp une double %25, 2.000000e-01
br i1 %26, label %34, label %27
27: ; preds = %20
%28 = load volatile float, float* %3
%29 = load volatile float, float* %2
%30 = tail call float @llvm.maxnum.f32(float %28, float %29)
%31 = fpext float %30 to double
%32 = fcmp une double %31, 2.000000e-01
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %27, %20
%35 = phi i32 [ 1, %20 ], [ %33, %27 ]
br label %36
36: ; preds = %15, %10, %0, %34
%37 = phi i32 [ %35, %34 ], [ 1, %0 ], [ 1, %10 ], [ 1, %15 ]
ret i32 %37
}