#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 */
int /*<<< orphan*/ printf(char *, float, char *);
int stdlib_base_is_nanf(float);
int main() {
  float x[] = {3.14, -3.14, 0.0, 0.0 / 0.0};
  bool b;
  int i;
  for (i = 0; i < 4; i++) {
    b = stdlib_base_is_nanf(x[i]);
    printf("Value: %f. Is NaN? %s.\n", x[i], (b) ? "True" : "False");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    11a4 <main+0x84>
movslq -0x28(%rbp),%rax
movss  -0x20(%rbp,%rax,4),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
mov    %eax,-0x24(%rbp)
movslq -0x28(%rbp),%rax
movss  -0x20(%rbp,%rax,4),%xmm0
mov    -0x24(%rbp),%ecx
lea    0xeb1(%rip),%rsi
lea    0xea5(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114c <main+0x2c>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
movss  0xed3(%rip),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
test   %eax,%eax
lea    0xeee(%rip),%r15
lea    0xee2(%rip),%rbx
mov    %rbx,%rsi
cmove  %r15,%rsi
lea    0xebc(%rip),%r14
mov    %r14,%rdi
movss  0xea5(%rip),%xmm0
call   1030 <printf@plt>
movss  0xe9c(%rip),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
movss  0xe83(%rip),%xmm0
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
call   1040 <stdlib_base_is_nanf@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %r15,%rsi
xorps  %xmm0,%xmm0
mov    %r14,%rdi
call   1030 <printf@plt>
movss  0xe5e(%rip),%xmm0
call   1040 <stdlib_base_is_nanf@plt>
test   %eax,%eax
cmove  %r15,%rbx
mov    %r14,%rdi
movss  0xe48(%rip),%xmm0
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.x = [4 x float] [float 0x40091EB860000000, float 0xC0091EB860000000, float 0.000000e+00, float 0x7FF8000000000000]
@.str = [24 x i8] c"Value: %f. Is NaN? %s.\0A\00"
@.str.1 = [5 x i8] c"True\00"
@.str.2 = [6 x i8] c"False\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4 x float]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [4 x float]* %2 to i8*
store i32 0, i32* %4
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x float], [4 x float]* %2, i64 0, i64 %11
%13 = load float, float* %12
%14 = call i32 @stdlib_base_is_nanf(float %13)
store i32 %14, i32* %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [4 x float], [4 x float]* %2, i64 0, i64 %16
%18 = load float, float* %17
%19 = load i32, i32* %3
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), float %18, i8* %22)
br label %24
24: ; preds = %9
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %6
27: ; preds = %6
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [24 x i8] c"Value: %f. Is NaN? %s.\0A\00"
@.str.1 = [5 x i8] c"True\00"
@.str.2 = [6 x i8] c"False\00"
define i32 @main() {
%1 = tail call i32 @stdlib_base_is_nanf(float 0x40091EB860000000)
%2 = icmp eq i32 %1, 0
%3 = select i1 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), float 0x40091EB860000000, i8* %3)
%5 = tail call i32 @stdlib_base_is_nanf(float 0xC0091EB860000000)
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), float 0xC0091EB860000000, i8* %7)
%9 = tail call i32 @stdlib_base_is_nanf(float 0.000000e+00)
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), float 0.000000e+00, i8* %11)
%13 = tail call i32 @stdlib_base_is_nanf(float 0x7FF8000000000000)
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), float 0x7FF8000000000000, i8* %15)
ret i32 0
}