#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int const, ...);
int /*<<< orphan*/ puts(char *);
int main(void) {
  puts("Puntatore a costante");
  int num = 327;
  int *ptr;
  const int cnum = 89;
  const int *cptr;
  ptr = &num;
  cptr = &cnum;
  printf("%d\n", *cptr);
  cptr = &num;
  printf("%d\n", *cptr);
  puts("Costante puntatore");
  int num_int = 2000;
  int *const ptrc = &num_int;
  printf("%d\n", *ptrc);
  *ptrc = 2013;
  printf("%d\n", *ptrc);
  puts("Costante puntatore a costante");
  int numint = 111;
  const int val = 222;
  const int *const ptr_cst = &val;
  const int *const ptr_cst2 = &num;
  printf("%d - %d\n", *ptr_cst, *ptr_cst2);
  puts("Puntatore a: costante puntatore a costante");
  const int *const ptrcst = &val;
  const int *const *ptrpc = &ptrcst;
  printf("%d\n", *ptrcst);
  printf("%d\n", **ptrpc);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
movl   $0x147,-0x8(%rbp)
movl   $0x59,-0x14(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
movl   $0x7d0,-0x24(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
movl   $0x7dd,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
call   1030 <puts@plt>
movl   $0x6f,-0x34(%rbp)
movl   $0xde,-0x38(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
mov    -0x48(%rbp),%rax
mov    (%rax),%edx
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
lea    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
mov    (%rax),%esi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xf17(%rip),%rbx
mov    %rbx,%rdi
mov    $0x59,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x147,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x7d0,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7dd,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb7(%rip),%rdi
mov    $0xde,%esi
mov    $0x147,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xde,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xde,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Puntatore a costante\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [19 x i8] c"Costante puntatore\00"
@.str.3 = [30 x i8] c"Costante puntatore a costante\00"
@.str.4 = [9 x i8] c"%d - %d\0A\00"
@.str.5 = [43 x i8] c"Puntatore a: costante puntatore a costante\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32**
store i32 0, i32* %1
%14 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 327, i32* %2
store i32 89, i32* %4
store i32* %2, i32** %3
store i32* %4, i32** %5
%15 = load i32*, i32** %5
%16 = load i32, i32* %15
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
store i32* %2, i32** %5
%18 = load i32*, i32** %5
%19 = load i32, i32* %18
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 2000, i32* %6
store i32* %6, i32** %7
%22 = load i32*, i32** %7
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32*, i32** %7
store i32 2013, i32* %25
%26 = load i32*, i32** %7
%27 = load i32, i32* %26
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
store i32 111, i32* %8
store i32 222, i32* %9
store i32* %9, i32** %10
store i32* %2, i32** %11
%30 = load i32*, i32** %10
%31 = load i32, i32* %30
%32 = load i32*, i32** %11
%33 = load i32, i32* %32
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %31, i32 %33)
%35 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
store i32* %9, i32** %12
store i32** %12, i32*** %13
%36 = load i32*, i32** %12
%37 = load i32, i32* %36
%38 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = load i32**, i32*** %13
%40 = load i32*, i32** %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = load i32, i32* @EXIT_SUCCESS
ret i32 %43
}

LLVM IR (-O2):
@.str = [21 x i8] c"Puntatore a costante\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [19 x i8] c"Costante puntatore\00"
@.str.3 = [30 x i8] c"Costante puntatore a costante\00"
@.str.4 = [9 x i8] c"%d - %d\0A\00"
@.str.5 = [43 x i8] c"Puntatore a: costante puntatore a costante\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 89)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 327)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2000)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 2013)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 222, i32 327)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 222)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 222)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
}