#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;
  i1 = f1;
  printf("%f assigned to an int produces %i\n", f1, i1);
  f1 = i2;
  printf("%i assigned to a 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);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movss  0xedd(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0xffffff6a,-0x14(%rbp)
cvttss2si -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cvttss2si -0x8(%rbp),%esi
cvtsi2ssl -0x10(%rbp),%xmm0
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x14(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x14(%rbp),%esi
movss  -0x8(%rbp),%xmm0
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x14(%rbp),%esi
movss  -0x8(%rbp),%xmm0
lea    0xeee(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe64(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x14(%rbp),%esi
movss  -0xc(%rbp),%xmm0
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
cvtsi2ssl -0x14(%rbp),%xmm0
movss  0xe2e(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x14(%rbp),%esi
movss  -0xc(%rbp),%xmm0
lea    0xe8e(%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    0xf36(%rip),%rdi
movss  0xeb6(%rip),%xmm0
mov    $0xffffff6a,%esi
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
movss  0xea1(%rip),%xmm0
mov    $0xffffff6a,%esi
call   1030 <printf@plt>
lea    0xefc(%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 = [36 x i8] c"%i assigned to a 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 i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store float 1.231250e+02, float* %2
store i32 -150, i32* %5
%6 = load float, float* %2
%7 = fptosi float %6 to i32
store i32 %7, i32* %4
%8 = load float, float* %2
%9 = fptosi float %8 to i32
%10 = load i32, i32* %4
%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* %5
%14 = sitofp i32 %13 to float
store float %14, float* %2
%15 = load i32, i32* %5
%16 = load float, float* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %15, float %16)
%18 = load i32, i32* %5
%19 = sdiv i32 %18, 100
%20 = sitofp i32 %19 to float
store float %20, float* %2
%21 = load i32, i32* %5
%22 = load float, float* %2
%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* %5
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 1.000000e+02
%27 = fptrunc double %26 to float
store float %27, float* %3
%28 = load i32, i32* %5
%29 = load float, float* %3
%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* %5
%32 = sitofp i32 %31 to float
%33 = fdiv float %32, 1.000000e+02
store float %33, float* %3
%34 = load i32, i32* %5
%35 = load float, float* %3
%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 = [36 x i8] c"%i assigned to a 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 ([36 x i8], [36 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
}