#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 *, int, float);
int main(void) {
  float f1 = 123.125, f2;
  int i1, i2 = -150;
  char c = 'a';
  i1 = f1;
  printf("%f assigned to an int produces %i\n", f1, i1);
  f1 = i2;
  printf("%i assigned to float produces %f\n", i2, f1);
  f1 = i2 / 100;
  printf("%i divided by 100 produces %f\n", i2, f1);
  f2 = i2 / 100.0;
  printf("%i divided by 100.0 produces %f\n", i2, f2);
  f2 = (float)i2 / 100;
  printf("(float) %i divided by 100 produces %f\n", i2, f2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xee4(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movl   $0xffffff6a,-0x10(%rbp)
movb   $0x61,-0x11(%rbp)
cvttss2si -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
cvttss2si -0x4(%rbp),%esi
cvtsi2ssl -0xc(%rbp),%xmm0
lea    0xec7(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x4(%rbp),%xmm0
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x4(%rbp),%xmm0
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe67(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x8(%rbp),%xmm0
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x10(%rbp),%xmm0
movss  0xe31(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%esi
movss  -0x8(%rbp),%xmm0
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xef8(%rip),%rdi
movss  0xee0(%rip),%xmm0
mov    $0x7b,%esi
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
movss  0xecb(%rip),%xmm0
mov    $0xffffff6a,%esi
call   1030 <printf@plt>
lea    0xf34(%rip),%rdi
movss  0xeb6(%rip),%xmm0
mov    $0xffffff6a,%esi
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
movss  0xea1(%rip),%xmm0
mov    $0xffffff6a,%esi
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0xffffff6a,%esi
movss  0xe83(%rip),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"%f assigned to an int produces %i\0A\00"
@.str.1 = [34 x i8] c"%i assigned to float produces %f\0A\00"
@.str.2 = [31 x i8] c"%i divided by 100 produces %f\0A\00"
@.str.3 = [33 x i8] c"%i divided by 100.0 produces %f\0A\00"
@.str.4 = [39 x i8] c"(float) %i divided by 100 produces %f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store float 1.231250e+02, float* %1
store i32 -150, i32* %4
store i8 97, i8* %5
%6 = load float, float* %1
%7 = fptosi float %6 to i32
store i32 %7, i32* %3
%8 = load float, float* %1
%9 = fptosi float %8 to i32
%10 = load i32, i32* %3
%11 = sitofp i32 %10 to float
%12 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %9, float %11)
%13 = load i32, i32* %4
%14 = sitofp i32 %13 to float
store float %14, float* %1
%15 = load i32, i32* %4
%16 = load float, float* %1
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %15, float %16)
%18 = load i32, i32* %4
%19 = sdiv i32 %18, 100
%20 = sitofp i32 %19 to float
store float %20, float* %1
%21 = load i32, i32* %4
%22 = load float, float* %1
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %21, float %22)
%24 = load i32, i32* %4
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 1.000000e+02
%27 = fptrunc double %26 to float
store float %27, float* %2
%28 = load i32, i32* %4
%29 = load float, float* %2
%30 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %28, float %29)
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to float
%33 = fdiv float %32, 1.000000e+02
store float %33, float* %2
%34 = load i32, i32* %4
%35 = load float, float* %2
%36 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %34, float %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"%f assigned to an int produces %i\0A\00"
@.str.1 = [34 x i8] c"%i assigned to float produces %f\0A\00"
@.str.2 = [31 x i8] c"%i divided by 100 produces %f\0A\00"
@.str.3 = [33 x i8] c"%i divided by 100.0 produces %f\0A\00"
@.str.4 = [39 x i8] c"(float) %i divided by 100 produces %f\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 123, float 1.230000e+02)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 -150, float -1.500000e+02)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 -150, float -1.000000e+00)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 -150, float -1.500000e+00)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 -150, float -1.500000e+00)
ret i32 0
}