int main() {
  volatile float a = __builtin_nanf("");
  if (__builtin_isfinite(a)) {
    return 1;
  }
  volatile float b = __builtin_inff();
  if (__builtin_isfinite(b)) {
    return 1;
  }
  volatile double c = __builtin_nan("");
  if (__builtin_isfinite(c)) {
    return 1;
  }
  volatile double d = __builtin_inf();
  if (__builtin_isfinite(d)) {
    return 1;
  }
  volatile float g = 0;
  if (!__builtin_isfinite(g)) {
    return 1;
  }
  volatile double h = 0;
  if (!__builtin_isfinite(h)) {
    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  -0x8(%rbp),%xmm0
movaps 0xeec(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xed0(%rip),%xmm1
ucomiss %xmm1,%xmm0
je     1145 <main+0x45>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x167>
movss  0xeb3(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movaps 0xeb2(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xe96(%rip),%xmm1
ucomiss %xmm1,%xmm0
je     117f <main+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x167>
movsd  0xeb1(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movaps 0xe88(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe8c(%rip),%xmm1
ucomisd %xmm1,%xmm0
je     11ba <main+0xba>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x167>
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movaps 0xe4d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe51(%rip),%xmm1
ucomisd %xmm1,%xmm0
je     11f5 <main+0xf5>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x167>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
movaps 0xe07(%rip),%xmm1
pand   %xmm1,%xmm0
movss  0xdeb(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    122a <main+0x12a>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x167>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movaps 0xde2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xde6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1260 <main+0x160>
movl   $0x1,-0x4(%rbp)
jmp    1267 <main+0x167>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movl   $0x7fc00000,-0x1c(%rsp)
7f
movss  -0x1c(%rsp),%xmm0
andps  0xeeb(%rip),%xmm0
mov    $0x1,%eax
ucomiss 0xeff(%rip),%xmm0
je     1124 <main+0x24>
ret
movl   $0x7f800000,-0x20(%rsp)
7f
movss  -0x20(%rsp),%xmm0
andps  0xec7(%rip),%xmm0
mov    $0x1,%eax
ucomiss 0xedb(%rip),%xmm0
jne    1123 <main+0x23>
movabs $0x7ff8000000000000,%rax
mov    %rax,-0x8(%rsp)
movsd  -0x8(%rsp),%xmm0
andpd  0xeac(%rip),%xmm0
mov    $0x1,%eax
ucomisd 0xeb7(%rip),%xmm0
jne    1123 <main+0x23>
movabs $0x7ff0000000000000,%rax
mov    %rax,-0x10(%rsp)
movsd  -0x10(%rsp),%xmm0
andpd  0xe80(%rip),%xmm0
mov    $0x1,%eax
ucomisd 0xe8b(%rip),%xmm0
jne    1123 <main+0x23>
movl   $0x0,-0x24(%rsp)
movss  -0x24(%rsp),%xmm0
andps  0xe4c(%rip),%xmm0
ucomiss 0xe65(%rip),%xmm0
je     11e2 <main+0xe2>
movq   $0x0,-0x18(%rsp)
movsd  -0x18(%rsp),%xmm0
andpd  0xe3c(%rip),%xmm0
xor    %eax,%eax
ucomisd 0xe4a(%rip),%xmm0
sete   %al
ret
mov    $0x1,%eax
ret

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

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