#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_finitef(float);
int main() {
  float x[] = {3.14f, -3.14f, 1.0f / 0.0f, 0.0f / 0.0f};
  bool b;
  int i;
  for (i = 0; i < 4; i++) {
    b = stdlib_base_is_finitef(x[i]);
    printf("Value: %f. Is finite? %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   1030 <stdlib_base_is_finitef@plt>
mov    %eax,-0x24(%rbp)
movslq -0x28(%rbp),%rax
movss  -0x20(%rbp,%rax,4),%xmm0
mov    -0x24(%rbp),%ecx
lea    0xeb4(%rip),%rsi
lea    0xea8(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe7f(%rip),%rdi
call   1040 <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   1030 <stdlib_base_is_finitef@plt>
test   %eax,%eax
lea    0xef5(%rip),%r15
lea    0xee9(%rip),%rbx
mov    %rbx,%rsi
cmove  %r15,%rsi
lea    0xec0(%rip),%r14
mov    %r14,%rdi
movss  0xea5(%rip),%xmm0
call   1040 <printf@plt>
movss  0xe9c(%rip),%xmm0
call   1030 <stdlib_base_is_finitef@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
movss  0xe83(%rip),%xmm0
call   1040 <printf@plt>
movss  0xe7a(%rip),%xmm0
call   1030 <stdlib_base_is_finitef@plt>
test   %eax,%eax
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
movss  0xe61(%rip),%xmm0
call   1040 <printf@plt>
movss  0xe58(%rip),%xmm0
call   1030 <stdlib_base_is_finitef@plt>
test   %eax,%eax
cmove  %r15,%rbx
mov    %r14,%rdi
movss  0xe42(%rip),%xmm0
mov    %rbx,%rsi
call   1040 <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 0x7FF0000000000000, float 0x7FF8000000000000]
@.str = [27 x i8] c"Value: %f. Is finite? %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_finitef(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 ([27 x i8], [27 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 = [27 x i8] c"Value: %f. Is finite? %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_finitef(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 ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), float 0x40091EB860000000, i8* %3)
%5 = tail call i32 @stdlib_base_is_finitef(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 ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), float 0xC0091EB860000000, i8* %7)
%9 = tail call i32 @stdlib_base_is_finitef(float 0x7FF0000000000000)
%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 ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), float 0x7FF0000000000000, i8* %11)
%13 = tail call i32 @stdlib_base_is_finitef(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 ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), float 0x7FF8000000000000, i8* %15)
ret i32 0
}