#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(double);
scalar_t__ isnan(double);
void trunctfdf_test(void) {
  volatile long double Inf_var, NaN_var, zero_var, one_var;
  double 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 = (double)NaN_var;
  check(" "
        "double"
        " x = ("
        "double"
        ") ("
        "long double"
        ") NaN",
        isnan(x1) != 0);
  x2 = (double)Inf_var;
  check(" "
        "double"
        " x = ("
        "double"
        ") ("
        "long double"
        ") Inf",
        isinf(x2) != 0);
}


x86 assembly (clang, -O0):
<trunctfdf_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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)
fstpl  -0x48(%rbp)
movsd  -0x48(%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)
fstpl  -0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <isinf@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%esi
lea    0xe7d(%rip),%rdi
call   1040 <check@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trunctfdf_test>:
sub    $0x58,%rsp
fldz
fstpt  (%rsp)
fld1
fstpt  0x20(%rsp)
fldt   (%rsp)
fldt   (%rsp)
fdivrp %st,%st(1)
fstpt  0x30(%rsp)
fldt   0x20(%rsp)
fldt   (%rsp)
fdivrp %st,%st(1)
fstpt  0x40(%rsp)
fldt   0x30(%rsp)
fstpl  0x18(%rsp)
movsd  0x18(%rsp),%xmm0
call   1030 <isnan@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe85(%rip),%rdi
call   1040 <check@plt>
fldt   0x40(%rsp)
fstpl  0x10(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <isinf@plt>
xor    %esi,%esi
test   %rax,%rax
setne  %sil
lea    0xe84(%rip),%rdi
add    $0x58,%rsp
jmp    1040 <check@plt>

LLVM IR (-O0):
@.str = [39 x i8] c" double x = (double) (long double) NaN\00"
@.str.1 = [39 x i8] c" double x = (double) (long double) Inf\00"
define void @trunctfdf_test() {
%1 = alloca x86_fp80
%2 = alloca x86_fp80
%3 = alloca x86_fp80
%4 = alloca x86_fp80
%5 = alloca double
%6 = alloca double
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 double
store double %14, double* %5
%15 = load double, double* %5
%16 = call i64 @isnan(double %15)
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @check(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load volatile x86_fp80, x86_fp80* %1
%21 = fptrunc x86_fp80 %20 to double
store double %21, double* %6
%22 = load double, double* %6
%23 = call i64 @isinf(double %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @check(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c" double x = (double) (long double) NaN\00"
@.str.1 = [39 x i8] c" double x = (double) (long double) Inf\00"
define void @trunctfdf_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 double
%17 = tail call i64 @isnan(double %16)
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @check(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load volatile x86_fp80, x86_fp80* %1
%22 = fptrunc x86_fp80 %21 to double
%23 = tail call i64 @isinf(double %22)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
%26 = tail call i32 @check(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %25)
ret void
}