#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*/ check(char *, int);
scalar_t__ isinf(float);
scalar_t__ isnan(float);
void trunctfsf_test(void) {
  volatile long double Inf_var, NaN_var, zero_var, one_var;
  float x1, x2;
  zero_var = 0.0;
  one_var = 1.0;
  NaN_var = zero_var / zero_var;
  Inf_var = one_var / zero_var;
  (void)&NaN_var;
  (void)&Inf_var;
  x1 = (float)NaN_var;
  check(" "
        "float"
        " x = ("
        "float"
        ") ("
        "long double"
        ") NaN",
        isnan(x1) != 0);
  x2 = (float)Inf_var;
  check(" "
        "float"
        " x = ("
        "float"
        ") ("
        "long double"
        ") Inf",
        isinf(x2) != 0);
}


x86 assembly (clang, -O0):
<trunctfsf_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
fldz
fstpt  -0x30(%rbp)
fld1
fstpt  -0x40(%rbp)
fldt   -0x30(%rbp)
fldt   -0x30(%rbp)
fdivrp %st,%st(1)
fstpt  -0x20(%rbp)
fldt   -0x40(%rbp)
fldt   -0x30(%rbp)
fdivrp %st,%st(1)
fstpt  -0x10(%rbp)
fldt   -0x20(%rbp)
fstps  -0x44(%rbp)
movss  -0x44(%rbp),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
setne  %al
movzbl %al,%esi
lea    0xe88(%rip),%rdi
call   1040 <check@plt>
fldt   -0x10(%rbp)
fstps  -0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x48(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe7b(%rip),%rdi
call   1040 <check@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trunctfsf_test>:
sub    $0x58,%rsp
fldz
fstpt  0x10(%rsp)
fld1
fstpt  0x20(%rsp)
fldt   0x10(%rsp)
fldt   0x10(%rsp)
fdivrp %st,%st(1)
fstpt  0x30(%rsp)
fldt   0x20(%rsp)
fldt   0x10(%rsp)
fdivrp %st,%st(1)
fstpt  0x40(%rsp)
fldt   0x30(%rsp)
fstps  0xc(%rsp)
movss  0xc(%rsp),%xmm0
call   1030 <isnan@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe81(%rip),%rdi
call   1040 <check@plt>
fldt   0x40(%rsp)
fstps  0x8(%rsp)
movss  0x8(%rsp),%xmm0
call   1050 <isinf@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe7e(%rip),%rdi
add    $0x58,%rsp
jmp    1040 <check@plt>

LLVM IR (-O0):
@.str = [37 x i8] c" float x = (float) (long double) NaN\00"
@.str.1 = [37 x i8] c" float x = (float) (long double) Inf\00"
define void @trunctfsf_test() {
%1 = alloca x86_fp80
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca float
%6 = alloca float
store volatile x86_fp80 0xK00000000000000000000, x86_fp80* %3
store volatile x86_fp80 0xK3FFF8000000000000000, x86_fp80* %4
%7 = load volatile x86_fp80, x86_fp80* %3
%8 = load volatile x86_fp80, x86_fp80* %3
%9 = fdiv x86_fp80 %7, %8
store volatile x86_fp80 %9, x86_fp80* %2
%10 = load volatile x86_fp80, x86_fp80* %4
%11 = load volatile x86_fp80, x86_fp80* %3
%12 = fdiv x86_fp80 %10, %11
store volatile x86_fp80 %12, x86_fp80* %1
%13 = load volatile x86_fp80, x86_fp80* %2
%14 = fptrunc x86_fp80 %13 to float
store float %14, float* %5
%15 = load float, float* %5
%16 = call i64 @isnan(float %15)
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @check(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load volatile x86_fp80, x86_fp80* %1
%21 = fptrunc x86_fp80 %20 to float
store float %21, float* %6
%22 = load float, float* %6
%23 = call i64 @isinf(float %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @check(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c" float x = (float) (long double) NaN\00"
@.str.1 = [37 x i8] c" float x = (float) (long double) Inf\00"
define void @trunctfsf_test() {
%1 = alloca x86_fp80
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = bitcast x86_fp80* %1 to i8*
%6 = bitcast x86_fp80* %2 to i8*
%7 = bitcast x86_fp80* %3 to i8*
%8 = bitcast x86_fp80* %4 to i8*
store volatile x86_fp80 0xK00000000000000000000, x86_fp80* %3
store volatile x86_fp80 0xK3FFF8000000000000000, x86_fp80* %4
%9 = load volatile x86_fp80, x86_fp80* %3
%10 = load volatile x86_fp80, x86_fp80* %3
%11 = fdiv x86_fp80 %9, %10
store volatile x86_fp80 %11, x86_fp80* %2
%12 = load volatile x86_fp80, x86_fp80* %4
%13 = load volatile x86_fp80, x86_fp80* %3
%14 = fdiv x86_fp80 %12, %13
store volatile x86_fp80 %14, x86_fp80* %1
%15 = load volatile x86_fp80, x86_fp80* %2
%16 = fptrunc x86_fp80 %15 to float
%17 = tail call i64 @isnan(float %16)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @check(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load volatile x86_fp80, x86_fp80* %1
%22 = fptrunc x86_fp80 %21 to float
%23 = tail call i64 @isinf(float %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = tail call i32 @check(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}