#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 *, ...);
void pointers_to_constants(void) {
  printf("\n[2] ----------------------------\n\n");
  printf("Pointers to constants:\n");
  const int a = 32, b = 16;
  const int *c = &(a);
  int *d = &(b);
  *d = 8;
  printf("Memory Address of 'a': %p\n", c);
  printf("Value of 'a': %i\n\n", *c);
  printf("Memory Address of 'b': %p\n", d);
  printf("Value of 'b': %i\n\n", *d);
}


x86 assembly (clang, -O0):
<pointers_to_constants>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x20,-0x4(%rbp)
movl   $0x10,-0x8(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x8,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointers_to_constants>:
push   %rax
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x20,0x4(%rsp)
movl   $0x8,(%rsp)
lea    0xeb1(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%esi
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [36 x i8] c"\0A[2] ----------------------------\0A\0A\00"
@.str.1 = [24 x i8] c"Pointers to constants:\0A\00"
@.str.2 = [27 x i8] c"Memory Address of 'a': %p\0A\00"
@.str.3 = [19 x i8] c"Value of 'a': %i\0A\0A\00"
@.str.4 = [27 x i8] c"Memory Address of 'b': %p\0A\00"
@.str.5 = [19 x i8] c"Value of 'b': %i\0A\0A\00"
define void @pointers_to_constants() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 32, i32* %1
store i32 16, i32* %2
store i32* %1, i32** %3
store i32* %2, i32** %4
%7 = load i32*, i32** %4
store i32 8, i32* %7
%8 = load i32*, i32** %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%10 = load i32*, i32** %3
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = load i32*, i32** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32* %13)
%15 = load i32*, i32** %4
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %16)
ret void
}

LLVM IR (-O2):
@.str.2 = [27 x i8] c"Memory Address of 'a': %p\0A\00"
@.str.3 = [19 x i8] c"Value of 'a': %i\0A\0A\00"
@.str.4 = [27 x i8] c"Memory Address of 'b': %p\0A\00"
@.str.5 = [19 x i8] c"Value of 'b': %i\0A\0A\00"
@str = [35 x i8] c"\0A[2] ----------------------------\0A\00"
@str.6 = [23 x i8] c"Pointers to constants:\00"
define void @pointers_to_constants() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.6, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
store i32 32, i32* %1
%6 = bitcast i32* %2 to i8*
store i32 8, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %11)
ret void
}