main() {
  int x, *p, **q, ***r;
  x = 5;
  p = &x;
  q = &p;
  r = &q;
  printf("%d\t%d\t%d\t%d\n", *r, q, &p, x);
  printf("%d\t%d\t%d\t%d\n", **q, &r, &x, p);
  printf("%d\t%d\t%d\t%d\n", **r, *p, *&q, &q);
  printf("%d\t%d\t%d\t%d\n", ***r, ***&q, *&r, *&x);
  printf("%d\t%d\t%d\t%d\n", p, q, r, x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0x4(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x4(%rbp),%r8d
lea    0xeb3(%rip),%rdi
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%r8
lea    0xe94(%rip),%rdi
lea    -0x20(%rbp),%rdx
lea    -0x4(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rcx
lea    0xe6a(%rip),%rdi
lea    -0x18(%rbp),%r8
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rcx
mov    -0x4(%rbp),%r8d
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x4(%rbp),%r8d
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
movl   $0x5,0x4(%rsp)
lea    0x4(%rsp),%r15
mov    %r15,0x18(%rsp)
lea    0x18(%rsp),%rcx
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,0x10(%rsp)
lea    0xeba(%rip),%rbx
mov    %rbx,%rdi
mov    %rcx,%rsi
mov    %rcx,%rdx
mov    $0x5,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    0x18(%rsp),%r8
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%rax
mov    (%rax),%rax
mov    (%rax),%rsi
mov    0x18(%rsp),%rax
mov    (%rax),%edx
mov    0x8(%rsp),%rcx
mov    %rbx,%rdi
mov    %r14,%r8
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%rcx
mov    (%rcx),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    0x8(%rsp),%rax
mov    (%rax),%rax
mov    (%rax),%edx
mov    0x4(%rsp),%r8d
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x18(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    0x4(%rsp),%r8d
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%d\09%d\09%d\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32**
%4 = alloca i32***
store i32 5, i32* %1
store i32* %1, i32** %2
store i32** %2, i32*** %3
store i32*** %3, i32**** %4
%5 = load i32***, i32**** %4
%6 = load i32**, i32*** %5
%7 = load i32**, i32*** %3
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %6, i32** %7, i32** %2, i32 %8)
%10 = load i32**, i32*** %3
%11 = load i32*, i32** %10
%12 = load i32, i32* %11
%13 = load i32*, i32** %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %12, i32**** %4, i32* %1, i32* %13)
%15 = load i32***, i32**** %4
%16 = load i32**, i32*** %15
%17 = load i32*, i32** %16
%18 = load i32*, i32** %2
%19 = load i32, i32* %18
%20 = load i32**, i32*** %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %17, i32 %19, i32** %20, i32*** %3)
%22 = load i32***, i32**** %4
%23 = load i32**, i32*** %22
%24 = load i32*, i32** %23
%25 = load i32, i32* %24
%26 = load i32**, i32*** %3
%27 = load i32*, i32** %26
%28 = load i32, i32* %27
%29 = load i32***, i32**** %4
%30 = load i32, i32* %1
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %28, i32*** %29, i32 %30)
%32 = load i32*, i32** %2
%33 = load i32**, i32*** %3
%34 = load i32***, i32**** %4
%35 = load i32, i32* %1
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %32, i32** %33, i32*** %34, i32 %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d\09%d\09%d\09%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32**
%4 = alloca i32***
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32** %2 to i8*
%7 = bitcast i32*** %3 to i8*
%8 = bitcast i32**** %4 to i8*
store i32 5, i32* %1
store i32* %1, i32** %2
store i32** %2, i32*** %3
store i32*** %3, i32**** %4
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32** %2, i32** %2, i32** %2, i32 5)
%10 = load i32**, i32*** %3
%11 = load i32*, i32** %10
%12 = load i32, i32* %11
%13 = load i32*, i32** %2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %12, i32**** %4, i32* %1, i32* %13)
%15 = load i32***, i32**** %4
%16 = load i32**, i32*** %15
%17 = load i32*, i32** %16
%18 = load i32*, i32** %2
%19 = load i32, i32* %18
%20 = load i32**, i32*** %3
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %17, i32 %19, i32** %20, i32*** %3)
%22 = load i32***, i32**** %4
%23 = load i32**, i32*** %22
%24 = load i32*, i32** %23
%25 = load i32, i32* %24
%26 = load i32**, i32*** %3
%27 = load i32*, i32** %26
%28 = load i32, i32* %27
%29 = load i32, i32* %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %25, i32 %28, i32*** %22, i32 %29)
%31 = load i32*, i32** %2
%32 = load i32**, i32*** %3
%33 = load i32***, i32**** %4
%34 = load i32, i32* %1
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32* %31, i32** %32, i32*** %33, i32 %34)
ret i32 0
}