#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 truncdfsf_test(void) {
  volatile 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"
        ") ("
        "double"
        ") NaN",
        isnan(x1) != 0);
  x2 = (float)Inf_var;
  check(" "
        "float"
        " x = ("
        "float"
        ") ("
        "double"
        ") Inf",
        isinf(x2) != 0);
}


x86 assembly (clang, -O0):
<truncdfsf_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeb8(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x24(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe6a(%rip),%rdi
call   1040 <check@plt>
movsd  -0x8(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe5a(%rip),%rdi
call   1040 <check@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<truncdfsf_test>:
sub    $0x28,%rsp
movq   $0x0,0x8(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1030 <isnan@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe71(%rip),%rdi
call   1040 <check@plt>
movsd  0x20(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1050 <isinf@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe6d(%rip),%rdi
add    $0x28,%rsp
jmp    1040 <check@plt>

LLVM IR (-O0):
@.str = [32 x i8] c" float x = (float) (double) NaN\00"
@.str.1 = [32 x i8] c" float x = (float) (double) Inf\00"
define void @truncdfsf_test() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca float
%6 = alloca float
store volatile double 0.000000e+00, double* %3
store volatile double 1.000000e+00, double* %4
%7 = load volatile double, double* %3
%8 = load volatile double, double* %3
%9 = fdiv double %7, %8
store volatile double %9, double* %2
%10 = load volatile double, double* %4
%11 = load volatile double, double* %3
%12 = fdiv double %10, %11
store volatile double %12, double* %1
%13 = load volatile double, double* %2
%14 = fptrunc double %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 ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load volatile double, double* %1
%21 = fptrunc double %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 ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c" float x = (float) (double) NaN\00"
@.str.1 = [32 x i8] c" float x = (float) (double) Inf\00"
define void @truncdfsf_test() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
store volatile double 0.000000e+00, double* %3
store volatile double 1.000000e+00, double* %4
%9 = load volatile double, double* %3
%10 = load volatile double, double* %3
%11 = fdiv double %9, %10
store volatile double %11, double* %2
%12 = load volatile double, double* %4
%13 = load volatile double, double* %3
%14 = fdiv double %12, %13
store volatile double %14, double* %1
%15 = load volatile double, double* %2
%16 = fptrunc double %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 ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load volatile double, double* %1
%22 = fptrunc double %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 ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}