#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 constant_pointers_to_constants(void) {
  printf("\n[4] ----------------------------\n\n");
  printf("Constant pointer to variables:\n");
  const int a = 32, b = 16;
  const int *const c = &(a);
  const int *const d = &(b);
  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):
<constant_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    -0x10(%rbp),%rsi
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<constant_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   $0x10,(%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[4] ----------------------------\0A\0A\00"
@.str.1 = [32 x i8] c"Constant pointer to variables:\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 @constant_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 ([32 x i8], [32 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** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%9 = load i32*, i32** %3
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i32* %12)
%14 = load i32*, i32** %4
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %15)
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[4] ----------------------------\0A\00"
@str.6 = [31 x i8] c"Constant pointer to variables:\00"
define void @constant_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 ([31 x i8], [31 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 16, 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
}