void main() {
  float x, y;
  float *fp, *fp2;
  x = 6.5;
  printf("Value of x is %g, address of x %x\n", x, &x);
  fp = &x;
  printf("Vaule in memory location fp is %g\n", *fp);
  *fp = 9.2;
  printf("New value of x is %g = %g \n", *fp, x);
  *fp = *fp + 1.5;
  printf("Final value of x is %g = %g\n", *fp, x);
  y = *fp;
  fp2 = fp;
  printf("Transfered value into y = %g and fp2 = %g \n", y, *fp2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xeec(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xedb(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xed8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movss  0xe9a(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xec8(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe57(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe9d(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe82(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x40d00000,0x4(%rsp)
40
lea    0xef4(%rip),%rdi
movsd  0xed8(%rip),%xmm0
lea    0x4(%rsp),%rsi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xef2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x41133333,0x4(%rsp)
41
lea    0xeff(%rip),%rdi
movsd  0xea5(%rip),%xmm0
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
addss  0xe95(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xeea(%rip),%rdi
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeec(%rip),%rdi
movaps %xmm0,%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Value of x is %g, address of x %x\0A\00"
@.str.1 = [35 x i8] c"Vaule in memory location fp is %g\0A\00"
@.str.2 = [28 x i8] c"New value of x is %g = %g \0A\00"
@.str.3 = [29 x i8] c"Final value of x is %g = %g\0A\00"
@.str.4 = [44 x i8] c"Transfered value into y = %g and fp2 = %g \0A\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float*
%4 = alloca float*
store float 6.500000e+00, float* %1
%5 = load float, float* %1
%6 = fpext float %5 to double
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double %6, float* %1)
store float* %1, float** %3
%8 = load float*, float** %3
%9 = load float, float* %8
%10 = fpext float %9 to double
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = load float*, float** %3
store float 0x4022666660000000, float* %12
%13 = load float*, float** %3
%14 = load float, float* %13
%15 = fpext float %14 to double
%16 = load float, float* %1
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), double %15, double %17)
%19 = load float*, float** %3
%20 = load float, float* %19
%21 = fpext float %20 to double
%22 = fadd double %21, 1.500000e+00
%23 = fptrunc double %22 to float
%24 = load float*, float** %3
store float %23, float* %24
%25 = load float*, float** %3
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = load float, float* %1
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %27, double %29)
%31 = load float*, float** %3
%32 = load float, float* %31
store float %32, float* %2
%33 = load float*, float** %3
store float* %33, float** %4
%34 = load float, float* %2
%35 = fpext float %34 to double
%36 = load float*, float** %4
%37 = load float, float* %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), double %35, double %38)
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"Value of x is %g, address of x %x\0A\00"
@.str.1 = [35 x i8] c"Vaule in memory location fp is %g\0A\00"
@.str.2 = [28 x i8] c"New value of x is %g = %g \0A\00"
@.str.3 = [29 x i8] c"Final value of x is %g = %g\0A\00"
@.str.4 = [44 x i8] c"Transfered value into y = %g and fp2 = %g \0A\00"
define void @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
store float 6.500000e+00, float* %1
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), double 6.500000e+00, float* %1)
%4 = load float, float* %1
%5 = fpext float %4 to double
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), double %5)
store float 0x4022666660000000, float* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), double 0x4022666660000000, double 0x4022666660000000)
%8 = load float, float* %1
%9 = fadd float %8, 1.500000e+00
store float %9, float* %1
%10 = fpext float %9 to double
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %10, double %10)
%12 = load float, float* %1
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), double %13, double %13)
ret void
}