#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 *, long double, ...);
void ldfcast(long double a) {
  float fa;
  double da;
  long double la;
  int ia;
  unsigned int ua;
  long double b;
  fa = a;
  da = a;
  la = a;
  printf("ftof: %f %f %Lf\n", fa, da, la);
  ia = (int)a;
  ua = (unsigned int)a;
  printf("ftoi: %d %u\n", ia, ua);
  ia = -1234;
  ua = 0x81234500;
  b = ia;
  printf("itof: "
         "%Lf"
         "\n",
         b);
  b = ua;
  printf("utof: "
         "%Lf"
         "\n",
         b);
}


x86 assembly (clang, -O0):
<ldfcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
fstps  -0x14(%rbp)
fldt   -0x10(%rbp)
fstpl  -0x20(%rbp)
fldt   -0x10(%rbp)
fstpt  -0x30(%rbp)
flds   -0x14(%rbp)
movsd  -0x20(%rbp),%xmm0
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  0x10(%rax)
fstpt  (%rax)
lea    0xeb3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
fldt   -0x10(%rbp)
fnstcw -0x72(%rbp)
movzwl -0x72(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x74(%rbp)
fldcw  -0x74(%rbp)
fistpl -0x64(%rbp)
fldcw  -0x72(%rbp)
mov    -0x64(%rbp),%eax
mov    %eax,-0x34(%rbp)
fldt   -0x10(%rbp)
fnstcw -0x76(%rbp)
movzwl -0x76(%rbp),%eax
or     $0xc00,%eax
mov    %ax,-0x78(%rbp)
fldcw  -0x78(%rbp)
fistpll -0x60(%rbp)
fldcw  -0x76(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x58(%rbp)
fildl  -0x58(%rbp)
mov    -0x38(%rbp),%esi
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe61(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x79(%rbp)
call   1030 <printf@plt>
mov    -0x79(%rbp),%al
movl   $0xfffffb2e,-0x34(%rbp)
movl   $0x81234500,-0x38(%rbp)
mov    -0x34(%rbp),%ecx
mov    %ecx,-0x54(%rbp)
fildl  -0x54(%rbp)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rcx
fstpt  (%rcx)
lea    0xe38(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
mov    %rax,-0x70(%rbp)
fildll -0x70(%rbp)
fstpt  -0x50(%rbp)
fldt   -0x50(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe22(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ldfcast>:
sub    $0x58,%rsp
fldt   0x60(%rsp)
fld    %st(0)
fstpt  0x4c(%rsp)
fsts   0x2c(%rsp)
movss  0x2c(%rsp),%xmm1
fstl   0x38(%rsp)
movsd  0x38(%rsp),%xmm0
movss  %xmm1,0x28(%rsp)
flds   0x28(%rsp)
fxch   %st(1)
fstpt  0x10(%rsp)
fstpt  (%rsp)
lea    0xebc(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
fnstcw 0x22(%rsp)
movzwl 0x22(%rsp),%eax
or     $0xc00,%eax
mov    %ax,0x26(%rsp)
fldcw  0x26(%rsp)
fldt   0x4c(%rsp)
fistl  0x30(%rsp)
fldcw  0x22(%rsp)
mov    0x30(%rsp),%eax
fnstcw 0x20(%rsp)
movzwl 0x20(%rsp),%ecx
or     $0xc00,%ecx
mov    %cx,0x24(%rsp)
fldcw  0x24(%rsp)
fistpll 0x40(%rsp)
fldcw  0x20(%rsp)
mov    0x40(%rsp),%esi
mov    %eax,0x34(%rsp)
fildl  0x34(%rsp)
fstpt  (%rsp)
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
flds   0xe43(%rip)
fstpt  (%rsp)
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
flds   0xe30(%rip)
fstpt  (%rsp)
lea    0xe53(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x58,%rsp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"ftof: %f %f %Lf\0A\00"
@.str.1 = [13 x i8] c"ftoi: %d %u\0A\00"
@.str.2 = [11 x i8] c"itof: %Lf\0A\00"
@.str.3 = [11 x i8] c"utof: %Lf\0A\00"
define void @ldfcast(x86_fp80 %0) {
%2 = alloca x86_fp80
%3 = alloca float
%4 = alloca double
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %2
%9 = load x86_fp80, x86_fp80* %2
%10 = fptrunc x86_fp80 %9 to float
store float %10, float* %3
%11 = load x86_fp80, x86_fp80* %2
%12 = fptrunc x86_fp80 %11 to double
store double %12, double* %4
%13 = load x86_fp80, x86_fp80* %2
store x86_fp80 %13, x86_fp80* %5
%14 = load float, float* %3
%15 = fpext float %14 to x86_fp80
%16 = load double, double* %4
%17 = load x86_fp80, x86_fp80* %5
%18 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), x86_fp80 %15, double %16, x86_fp80 %17)
%19 = load x86_fp80, x86_fp80* %2
%20 = fptosi x86_fp80 %19 to i32
store i32 %20, i32* %6
%21 = load x86_fp80, x86_fp80* %2
%22 = fptoui x86_fp80 %21 to i32
store i32 %22, i32* %7
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to x86_fp80
%25 = load i32, i32* %7
%26 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %24, i32 %25)
store i32 -1234, i32* %6
store i32 -2128395008, i32* %7
%27 = load i32, i32* %6
%28 = sitofp i32 %27 to x86_fp80
store x86_fp80 %28, x86_fp80* %8
%29 = load x86_fp80, x86_fp80* %8
%30 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), x86_fp80 %29)
%31 = load i32, i32* %7
%32 = uitofp i32 %31 to x86_fp80
store x86_fp80 %32, x86_fp80* %8
%33 = load x86_fp80, x86_fp80* %8
%34 = call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), x86_fp80 %33)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"ftof: %f %f %Lf\0A\00"
@.str.1 = [13 x i8] c"ftoi: %d %u\0A\00"
@.str.2 = [11 x i8] c"itof: %Lf\0A\00"
@.str.3 = [11 x i8] c"utof: %Lf\0A\00"
define void @ldfcast(x86_fp80 %0) {
%2 = fptrunc x86_fp80 %0 to float
%3 = fptrunc x86_fp80 %0 to double
%4 = fpext float %2 to x86_fp80
%5 = tail call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), x86_fp80 %4, double %3, x86_fp80 %0)
%6 = fptosi x86_fp80 %0 to i32
%7 = fptoui x86_fp80 %0 to i32
%8 = sitofp i32 %6 to x86_fp80
%9 = tail call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %8, i32 %7)
%10 = tail call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), x86_fp80 0xKC0099A40000000000000)
%11 = tail call i32 (i8*, x86_fp80, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), x86_fp80 0xK401E8123450000000000)
ret void
}