#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 pointerArray2() {
  int a[5] = {1, 2, 4, 5, 6};
  int *pa[5] = {&a[0], &a[1], &a[2], &a[3], &a[4]};
  int **p = pa;
  for (int i = 0; i < 5; ++i) {
    printf("%d ", **p);
    p++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<pointerArray2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedc(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x48(%rbp)
lea    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
lea    -0x20(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x30(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
cmpl   $0x5,-0x5c(%rbp)
jge    11b9 <pointerArray2+0xa9>
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    117e <pointerArray2+0x6e>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointerArray2>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
pop    %rbx
ret

LLVM IR (-O0):
@__const.pointerArray2.a = [5 x i32] [i32 1, i32 2, i32 4, i32 5, i32 6]
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @pointerArray2() {
%1 = alloca [5 x i32]
%2 = alloca [5 x i32*]
%3 = alloca i32**
%4 = alloca i32
%5 = bitcast [5 x i32]* %1 to i8*
%6 = getelementptr inbounds [5 x i32*], [5 x i32*]* %2, i64 0, i64 0
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
store i32* %7, i32** %6
%8 = getelementptr inbounds i32*, i32** %6, i64 1
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
store i32* %9, i32** %8
%10 = getelementptr inbounds i32*, i32** %8, i64 1
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
store i32* %11, i32** %10
%12 = getelementptr inbounds i32*, i32** %10, i64 1
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
store i32* %13, i32** %12
%14 = getelementptr inbounds i32*, i32** %12, i64 1
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
store i32* %15, i32** %14
%16 = getelementptr inbounds [5 x i32*], [5 x i32*]* %2, i64 0, i64 0
store i32** %16, i32*** %3
store i32 0, i32* %4
br label %17
17: ; preds = %27, %0
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 5
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = load i32**, i32*** %3
%22 = load i32*, i32** %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32**, i32*** %3
%26 = getelementptr inbounds i32*, i32** %25, i32 1
store i32** %26, i32*** %3
br label %27
27: ; preds = %20
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %17
30: ; preds = %17
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @pointerArray2() {
%1 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1)
%2 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 5)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%6 = call i32 @putchar(i32 10)
ret void
}