#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 *, unsigned int, unsigned int, unsigned int,
                          unsigned int, unsigned int, int);
void test_coercion(float f) {
  double d = (double)f;
  float q = (float)d;
  unsigned int i = (unsigned int)d;
  signed int j = (signed int)q;
  printf("Coerce: %08X %08X%08X %08X %08X %08X\n", *((unsigned int *)&f),
         *((unsigned int *)&d), *(((unsigned int *)&d) + 1),
         *((unsigned int *)&q), i, j);
}


x86 assembly (clang, -O0):
<test_coercion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
cvttsd2si -0x10(%rbp),%rax
mov    %eax,-0x18(%rbp)
cvttss2si -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xe9b(%rip),%rdi
mov    %eax,(%rsp)
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_coercion>:
push   %rax
cvttss2si %xmm0,%r9
cvttss2si %xmm0,%eax
cvtss2sd %xmm0,%xmm1
movd   %xmm0,%esi
movq   %xmm1,%rdx
mov    %rdx,%rcx
shr    $0x20,%rcx
mov    %eax,(%rsp)
lea    0xec8(%rip),%rdi
mov    %esi,%r8d
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Coerce: %08X %08X%08X %08X %08X %08X\0A\00"
define void @test_coercion(float %0) {
%2 = alloca float
%3 = alloca double
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
store float %0, float* %2
%7 = load float, float* %2
%8 = fpext float %7 to double
store double %8, double* %3
%9 = load double, double* %3
%10 = fptrunc double %9 to float
store float %10, float* %4
%11 = load double, double* %3
%12 = fptoui double %11 to i32
store i32 %12, i32* %5
%13 = load float, float* %4
%14 = fptosi float %13 to i32
store i32 %14, i32* %6
%15 = bitcast float* %2 to i32*
%16 = load i32, i32* %15
%17 = bitcast double* %3 to i32*
%18 = load i32, i32* %17
%19 = bitcast double* %3 to i32*
%20 = getelementptr inbounds i32, i32* %19, i64 1
%21 = load i32, i32* %20
%22 = bitcast float* %4 to i32*
%23 = load i32, i32* %22
%24 = load i32, i32* %5
%25 = load i32, i32* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18, i32 %21, i32 %23, i32 %24, i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Coerce: %08X %08X%08X %08X %08X %08X\0A\00"
define void @test_coercion(float %0) {
%2 = fpext float %0 to double
%3 = fptoui float %0 to i32
%4 = fptosi float %0 to i32
%5 = bitcast float %0 to i32
%6 = bitcast double %2 to i64
%7 = trunc i64 %6 to i32
%8 = lshr i64 %6, 32
%9 = trunc i64 %8 to i32
%10 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i32 %9, i32 %5, i32 %3, i32 %4)
ret void
}