int main() {
  printf("\nLEARNING THE BASICS OF POINTERS IN C\n\n");
  int number = 10;
  int *int_pointer;
  printf("Address of variable \'number\'.: %x\n", &number);
  int_pointer = &number;
  printf("Value stored in \'int_pointer\': %x\n\n", int_pointer);
  printf("Value that variable \'number\' holds: %d\n", number);
  printf("*int_pointer holds the same value.: %d\n\n", *int_pointer);
  *int_pointer = 20;
  printf("Changed value of *int_pointer, printing \'number\': %d\n", number);
  printf("\nThat\'s all folks!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x8(%rbp)
lea    0xeed(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xef2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xf19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x14,(%rax)
mov    -0x8(%rbp),%esi
lea    0xf27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xfa2(%rip),%rdi
call   1030 <puts@plt>
movl   $0xa,0xc(%rsp)
lea    0xec0(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xef2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x14,0xc(%rsp)
lea    0xf05(%rip),%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0ALEARNING THE BASICS OF POINTERS IN C\0A\0A\00"
@.str.1 = [35 x i8] c"Address of variable 'number'.: %x\0A\00"
@.str.2 = [36 x i8] c"Value stored in 'int_pointer': %x\0A\0A\00"
@.str.3 = [40 x i8] c"Value that variable 'number' holds: %d\0A\00"
@.str.4 = [41 x i8] c"*int_pointer holds the same value.: %d\0A\0A\00"
@.str.5 = [54 x i8] c"Changed value of *int_pointer, printing 'number': %d\0A\00"
@.str.6 = [20 x i8] c"\0AThat's all folks!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
store i32 10, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32* %2, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = load i32*, i32** %3
store i32 20, i32* %13
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [35 x i8] c"Address of variable 'number'.: %x\0A\00"
@.str.2 = [36 x i8] c"Value stored in 'int_pointer': %x\0A\0A\00"
@.str.3 = [40 x i8] c"Value that variable 'number' holds: %d\0A\00"
@.str.4 = [41 x i8] c"*int_pointer holds the same value.: %d\0A\0A\00"
@.str.5 = [54 x i8] c"Changed value of *int_pointer, printing 'number': %d\0A\00"
@str = [39 x i8] c"\0ALEARNING THE BASICS OF POINTERS IN C\0A\00"
@str.7 = [19 x i8] c"\0AThat's all folks!\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
store i32 10, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %8)
store i32 20, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i32 20)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
ret i32 0
}