#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 *, double, ...);
void dfcast(double a) {
  float fa;
  double da;
  long double la;
  int ia;
  unsigned int ua;
  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: "
         "%f"
         "\n",
         b);
  b = ua;
  printf("utof: "
         "%f"
         "\n",
         b);
}


x86 assembly (clang, -O0):
<dfcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
fldl   -0x8(%rbp)
fstpt  -0x30(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x18(%rbp),%xmm1
fldt   -0x30(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xea8(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cvttsd2si -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
cvttsd2si -0x8(%rbp),%rax
mov    %eax,-0x38(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm0
mov    -0x38(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x1,%al
mov    %al,-0x41(%rbp)
call   1030 <printf@plt>
mov    -0x41(%rbp),%al
movl   $0xfffffb2e,-0x34(%rbp)
movl   $0x81234500,-0x38(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
lea    0xe5a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dfcast>:
sub    $0x38,%rsp
cvtsd2ss %xmm0,%xmm2
movsd  %xmm0,0x18(%rsp)
movaps %xmm0,%xmm1
movaps %xmm0,0x20(%rsp)
fldl   0x18(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
fstpt  (%rsp)
lea    0xed5(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movapd 0x20(%rsp),%xmm0
cvttsd2si %xmm0,%rsi
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
lea    0xec5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
movsd  0xe8e(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
movsd  0xe80(%rip),%xmm0
mov    $0x1,%al
add    $0x38,%rsp
jmp    1030 <printf@plt>

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 = [10 x i8] c"itof: %f\0A\00"
@.str.3 = [10 x i8] c"utof: %f\0A\00"
define void @dfcast(double %0) {
%2 = alloca double
%3 = alloca float
%4 = alloca double
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
store double %0, double* %2
%9 = load double, double* %2
%10 = fptrunc double %9 to float
store float %10, float* %3
%11 = load double, double* %2
store double %11, double* %4
%12 = load double, double* %2
%13 = fpext double %12 to x86_fp80
store x86_fp80 %13, x86_fp80* %5
%14 = load float, float* %3
%15 = fpext float %14 to double
%16 = load double, double* %4
%17 = load x86_fp80, x86_fp80* %5
%18 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %15, double %16, x86_fp80 %17)
%19 = load double, double* %2
%20 = fptosi double %19 to i32
store i32 %20, i32* %6
%21 = load double, double* %2
%22 = fptoui double %21 to i32
store i32 %22, i32* %7
%23 = load i32, i32* %6
%24 = sitofp i32 %23 to double
%25 = load i32, i32* %7
%26 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %24, i32 %25)
store i32 -1234, i32* %6
store i32 -2128395008, i32* %7
%27 = load i32, i32* %6
%28 = sitofp i32 %27 to double
store double %28, double* %8
%29 = load double, double* %8
%30 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = load i32, i32* %7
%32 = uitofp i32 %31 to double
store double %32, double* %8
%33 = load double, double* %8
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double %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 = [10 x i8] c"itof: %f\0A\00"
@.str.3 = [10 x i8] c"utof: %f\0A\00"
define void @dfcast(double %0) {
%2 = fptrunc double %0 to float
%3 = fpext double %0 to x86_fp80
%4 = fpext float %2 to double
%5 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %4, double %0, x86_fp80 %3)
%6 = fptosi double %0 to i32
%7 = fptoui double %0 to i32
%8 = sitofp i32 %6 to double
%9 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %8, i32 %7)
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), double -1.234000e+03)
%11 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), double 0x41E02468A0000000)
ret void
}