#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 *, float, ...);
void ffcast(float a) {
  float fa;
  double da;
  long double la;
  int ia;
  unsigned int ua;
  float 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):
<ffcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
flds   -0x4(%rbp)
fstpt  -0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xeac(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
cvttss2si -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
cvttss2si -0x4(%rbp),%rax
mov    %eax,-0x28(%rbp)
cvtsi2ssl -0x24(%rbp),%xmm0
mov    -0x28(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x1,%al
mov    %al,-0x2d(%rbp)
call   1030 <printf@plt>
mov    -0x2d(%rbp),%al
movl   $0xfffffb2e,-0x24(%rbp)
movl   $0x81234500,-0x28(%rbp)
cvtsi2ssl -0x24(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffcast>:
sub    $0x38,%rsp
cvtss2sd %xmm0,%xmm1
movss  %xmm0,0x1c(%rsp)
movaps %xmm0,0x20(%rsp)
flds   0x1c(%rsp)
fstpt  (%rsp)
lea    0xed7(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movaps 0x20(%rsp),%xmm0
cvttss2si %xmm0,%rsi
cvttps2dq %xmm0,%xmm0
cvtdq2ps %xmm0,%xmm0
lea    0xec9(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
movss  0xe9a(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
movss  0xe88(%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 @ffcast(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca double
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store float %0, float* %2
%9 = load float, float* %2
store float %9, float* %3
%10 = load float, float* %2
%11 = fpext float %10 to double
store double %11, double* %4
%12 = load float, float* %2
%13 = fpext float %12 to x86_fp80
store x86_fp80 %13, x86_fp80* %5
%14 = load float, float* %3
%15 = load double, double* %4
%16 = load x86_fp80, x86_fp80* %5
%17 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), float %14, double %15, x86_fp80 %16)
%18 = load float, float* %2
%19 = fptosi float %18 to i32
store i32 %19, i32* %6
%20 = load float, float* %2
%21 = fptoui float %20 to i32
store i32 %21, i32* %7
%22 = load i32, i32* %6
%23 = sitofp i32 %22 to float
%24 = load i32, i32* %7
%25 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %23, i32 %24)
store i32 -1234, i32* %6
store i32 -2128395008, i32* %7
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to float
store float %27, float* %8
%28 = load float, float* %8
%29 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), float %28)
%30 = load i32, i32* %7
%31 = uitofp i32 %30 to float
store float %31, float* %8
%32 = load float, float* %8
%33 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), float %32)
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 @ffcast(float %0) {
%2 = fpext float %0 to double
%3 = fpext float %0 to x86_fp80
%4 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), float %0, double %2, x86_fp80 %3)
%5 = fptosi float %0 to i32
%6 = fptoui float %0 to i32
%7 = sitofp i32 %5 to float
%8 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), float %7, i32 %6)
%9 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), float -1.234000e+03)
%10 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), float 0x41E02468A0000000)
ret void
}