int main() {
  int *p;
  int x = 5;
  int a, b, c;
  p = &x;
  printf("p = %d, x = %d\n", p, x);
  a = *p;
  printf("p = %d,*p = %d,  a = %d\n", p, *p, a);
  b = (int)&p;
  printf("p = %d, &p = %d,  b = %d\n", p, &p, b);
  c = (int)p;
  printf("p = %d,  c = %d\n", p, c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5,-0x14(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%ecx
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
lea    0xead(%rip),%rdi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x5,0x4(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,0x8(%rsp)
lea    0xed2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%ecx
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rcx
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
mov    %rcx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rdx
lea    0xeca(%rip),%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"p = %d, x = %d\0A\00"
@.str.1 = [25 x i8] c"p = %d,*p = %d, a = %d\0A\00"
@.str.2 = [26 x i8] c"p = %d, &p = %d, b = %d\0A\00"
@.str.3 = [17 x i8] c"p = %d, c = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 5, i32* %3
store i32* %3, i32** %2
%7 = load i32*, i32** %2
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %7, i32 %8)
%10 = load i32*, i32** %2
%11 = load i32, i32* %10
store i32 %11, i32* %4
%12 = load i32*, i32** %2
%13 = load i32*, i32** %2
%14 = load i32, i32* %13
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32* %12, i32 %14, i32 %15)
%17 = ptrtoint i32** %2 to i32
store i32 %17, i32* %5
%18 = load i32*, i32** %2
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32* %18, i32** %2, i32 %19)
%21 = load i32*, i32** %2
%22 = ptrtoint i32* %21 to i32
store i32 %22, i32* %6
%23 = load i32*, i32** %2
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32* %23, i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"p = %d, x = %d\0A\00"
@.str.1 = [25 x i8] c"p = %d,*p = %d, a = %d\0A\00"
@.str.2 = [26 x i8] c"p = %d, &p = %d, b = %d\0A\00"
@.str.3 = [17 x i8] c"p = %d, c = %d\0A\00"
define i32 @main() {
%1 = alloca i32*
%2 = alloca i32
%3 = bitcast i32** %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 5, i32* %2
store i32* %2, i32** %1
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %2, i32 5)
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32 %6, i32 %6)
%8 = ptrtoint i32** %1 to i64
%9 = trunc i64 %8 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32** %1, i32 %9)
%11 = load i32*, i32** %1
%12 = ptrtoint i32* %11 to i64
%13 = trunc i64 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32* %11, i32 %13)
ret i32 0
}