#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 array_of_pointers(void) {
  printf("\nArray of pointers\n");
  printf("--------------------------------\n");
  int a = 0, b = 1, c = 2;
  int *z[3] = {&a, &b, &c};
  int *(y[3]) = {&c, &b, &a};
  printf("Originals:\t Z = [ ");
  for (int i = 0; i < 2; i++) {
    printf("%i, ", *(z[i]));
  }
  printf("%i ]\n", *(z[2]));
  printf("\t\t Y = [ ");
  for (int i = 0; i < 2; i++) {
    printf("%i, ", *(y[i]));
  }
  printf("%i ]\n\n", *(y[2]));
  a *= 2;
  b *= 2;
  c *= 2;
  printf("Doubled:\t Z = [ ");
  for (int i = 0; i < 2; i++) {
    printf("%i, ", *(z[i]));
  }
  printf("%i ]\n", *(z[2]));
  printf("\t\t Y = [ ");
  for (int i = 0; i < 2; i++) {
    printf("%i, ", *(y[i]));
  }
  printf("%i ]\n\n", *(y[2]));
}


x86 assembly (clang, -O0):
<array_of_pointers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x4(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x2,-0x54(%rbp)
jge    11bf <array_of_pointers+0xaf>
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    118e <array_of_pointers+0x7e>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x58(%rbp)
cmpl   $0x2,-0x58(%rbp)
jge    1219 <array_of_pointers+0x109>
movslq -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    (%rax),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11e8 <array_of_pointers+0xd8>
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x2,-0x5c(%rbp)
jge    128e <array_of_pointers+0x17e>
movslq -0x5c(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rax
mov    (%rax),%esi
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    125d <array_of_pointers+0x14d>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x60(%rbp)
cmpl   $0x2,-0x60(%rbp)
jge    12e8 <array_of_pointers+0x1d8>
movslq -0x60(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rax
mov    (%rax),%esi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12b7 <array_of_pointers+0x1a7>
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_of_pointers>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%r14
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe91(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe6c(%rip),%r12
mov    %r12,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"\0AArray of pointers\0A\00"
@.str.1 = [34 x i8] c"--------------------------------\0A\00"
@.str.2 = [19 x i8] c"Originals:\09 Z = [ \00"
@.str.3 = [5 x i8] c"%i, \00"
@.str.4 = [6 x i8] c"%i ]\0A\00"
@.str.5 = [10 x i8] c"\09\09 Y = [ \00"
@.str.6 = [7 x i8] c"%i ]\0A\0A\00"
@.str.7 = [17 x i8] c"Doubled:\09 Z = [ \00"
define void @array_of_pointers() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i32*]
%5 = alloca [3 x i32*]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
%12 = getelementptr inbounds [3 x i32*], [3 x i32*]* %4, i64 0, i64 0
store i32* %1, i32** %12
%13 = getelementptr inbounds i32*, i32** %12, i64 1
store i32* %2, i32** %13
%14 = getelementptr inbounds i32*, i32** %13, i64 1
store i32* %3, i32** %14
%15 = getelementptr inbounds [3 x i32*], [3 x i32*]* %5, i64 0, i64 0
store i32* %3, i32** %15
%16 = getelementptr inbounds i32*, i32** %15, i64 1
store i32* %2, i32** %16
%17 = getelementptr inbounds i32*, i32** %16, i64 1
store i32* %1, i32** %17
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %19
19: ; preds = %29, %0
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x i32*], [3 x i32*]* %4, i64 0, i64 %24
%26 = load i32*, i32** %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %22
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %19
32: ; preds = %19
%33 = getelementptr inbounds [3 x i32*], [3 x i32*]* %4, i64 0, i64 2
%34 = load i32*, i32** %33
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %38
38: ; preds = %48, %32
%39 = load i32, i32* %7
%40 = icmp slt i32 %39, 2
br i1 %40, label %41, label %51
41: ; preds = %38
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x i32*], [3 x i32*]* %5, i64 0, i64 %43
%45 = load i32*, i32** %44
%46 = load i32, i32* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %41
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %38
51: ; preds = %38
%52 = getelementptr inbounds [3 x i32*], [3 x i32*]* %5, i64 0, i64 2
%53 = load i32*, i32** %52
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %1
%57 = mul nsw i32 %56, 2
store i32 %57, i32* %1
%58 = load i32, i32* %2
%59 = mul nsw i32 %58, 2
store i32 %59, i32* %2
%60 = load i32, i32* %3
%61 = mul nsw i32 %60, 2
store i32 %61, i32* %3
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %8
br label %63
63: ; preds = %73, %51
%64 = load i32, i32* %8
%65 = icmp slt i32 %64, 2
br i1 %65, label %66, label %76
66: ; preds = %63
%67 = load i32, i32* %8
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [3 x i32*], [3 x i32*]* %4, i64 0, i64 %68
%70 = load i32*, i32** %69
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %8
%75 = add nsw i32 %74, 1
store i32 %75, i32* %8
br label %63
76: ; preds = %63
%77 = getelementptr inbounds [3 x i32*], [3 x i32*]* %4, i64 0, i64 2
%78 = load i32*, i32** %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %79)
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %9
br label %82
82: ; preds = %92, %76
%83 = load i32, i32* %9
%84 = icmp slt i32 %83, 2
br i1 %84, label %85, label %95
85: ; preds = %82
%86 = load i32, i32* %9
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [3 x i32*], [3 x i32*]* %5, i64 0, i64 %87
%89 = load i32*, i32** %88
%90 = load i32, i32* %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %85
%93 = load i32, i32* %9
%94 = add nsw i32 %93, 1
store i32 %94, i32* %9
br label %82
95: ; preds = %82
%96 = getelementptr inbounds [3 x i32*], [3 x i32*]* %5, i64 0, i64 2
%97 = load i32*, i32** %96
%98 = load i32, i32* %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %98)
ret void
}

LLVM IR (-O2):
@.str.2 = [19 x i8] c"Originals:\09 Z = [ \00"
@.str.3 = [5 x i8] c"%i, \00"
@.str.4 = [6 x i8] c"%i ]\0A\00"
@.str.5 = [10 x i8] c"\09\09 Y = [ \00"
@.str.6 = [7 x i8] c"%i ]\0A\0A\00"
@.str.7 = [17 x i8] c"Doubled:\09 Z = [ \00"
@str = [19 x i8] c"\0AArray of pointers\00"
@str.8 = [33 x i8] c"--------------------------------\00"
define void @array_of_pointers() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.8, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 1)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 2)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 0)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 0)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 2)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 2)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 0)
ret void
}