#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 *, int, ...);
void main() {
  int A[][3] = {1, 12, 23, 34, 45, 56, 67, 78, 89};
  int(*p)[3] = A;
  int i = 0;
  printf("p [ 0 ] [ 2 ] = %d;\n", p[0][2]);
  printf("* ( * ( p + 0 ) + 2 ) = %d;\n\n", *(*(p + 0) + 2));
  printf("* ( * ( A + 0 ) + 2 ) = %d;\n", *(*(A + 0) + 2));
  printf("* ( * ( A + 1 ) + 2 ) = %d;\n", *(*(A + 1) + 2));
  printf("* ( * ( A + 2 ) + 2 ) = %d;\n", *(*(A + 2) + 2));
  printf("* ( * ( A + 3 ) + 2 ) = %d;\n\n", *(*(A + 3) + 2));
  for (i = 0; i < 7; i++) {
    printf("* ( * ( A + ( i = %d ) ) + 2 ) = %d;\n", i, *(*(A + i) + 2));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xee3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x7,-0x3c(%rbp)
jge    11fc <main+0xdc>
mov    -0x3c(%rbp),%esi
lea    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edx
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11c1 <main+0xa1>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rdi
mov    $0x17,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeea(%rip),%rdi
mov    $0x17,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
mov    $0x17,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x38,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
mov    $0x59,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf23(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x17,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x38,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x59,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.main.A = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 12, i32 23], [3 x i32] [i32 34, i32 45, i32 56], [3 x i32] [i32 67, i32 78, i32 89]]
@.str = [21 x i8] c"p [ 0 ] [ 2 ] = %d;\0A\00"
@.str.1 = [30 x i8] c"* ( * ( p + 0 ) + 2 ) = %d;\0A\0A\00"
@.str.2 = [29 x i8] c"* ( * ( A + 0 ) + 2 ) = %d;\0A\00"
@.str.3 = [29 x i8] c"* ( * ( A + 1 ) + 2 ) = %d;\0A\00"
@.str.4 = [29 x i8] c"* ( * ( A + 2 ) + 2 ) = %d;\0A\00"
@.str.5 = [30 x i8] c"* ( * ( A + 3 ) + 2 ) = %d;\0A\0A\00"
@.str.6 = [38 x i8] c"* ( * ( A + ( i = %d ) ) + 2 ) = %d;\0A\00"
define void @main() {
%1 = alloca [3 x [3 x i32]]
%2 = alloca [3 x i32]*
%3 = alloca i32
%4 = bitcast [3 x [3 x i32]]* %1 to i8*
%5 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
store [3 x i32]* %5, [3 x i32]** %2
store i32 0, i32* %3
%6 = load [3 x i32]*, [3 x i32]** %2
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 2
%9 = load i32, i32* %8
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load [3 x i32]*, [3 x i32]** %2
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 0
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = load i32, i32* %14
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %18, i64 0, i64 0
%20 = getelementptr inbounds i32, i32* %19, i64 2
%21 = load i32, i32* %20
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %23, i64 1
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %24, i64 0, i64 0
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = load i32, i32* %26
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %29, i64 2
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %30, i64 0, i64 0
%32 = getelementptr inbounds i32, i32* %31, i64 2
%33 = load i32, i32* %32
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%36 = getelementptr inbounds [3 x i32], [3 x i32]* %35, i64 3
%37 = getelementptr inbounds [3 x i32], [3 x i32]* %36, i64 0, i64 0
%38 = getelementptr inbounds i32, i32* %37, i64 2
%39 = load i32, i32* %38
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %54, %0
%42 = load i32, i32* %3
%43 = icmp slt i32 %42, 7
br i1 %43, label %44, label %57
44: ; preds = %41
%45 = load i32, i32* %3
%46 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %1, i64 0, i64 0
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [3 x i32], [3 x i32]* %46, i64 %48
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %49, i64 0, i64 0
%51 = getelementptr inbounds i32, i32* %50, i64 2
%52 = load i32, i32* %51
%53 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 %45, i32 %52)
br label %54
54: ; preds = %44
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %41
57: ; preds = %41
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"p [ 0 ] [ 2 ] = %d;\0A\00"
@.str.1 = [30 x i8] c"* ( * ( p + 0 ) + 2 ) = %d;\0A\0A\00"
@.str.2 = [29 x i8] c"* ( * ( A + 0 ) + 2 ) = %d;\0A\00"
@.str.3 = [29 x i8] c"* ( * ( A + 1 ) + 2 ) = %d;\0A\00"
@.str.4 = [29 x i8] c"* ( * ( A + 2 ) + 2 ) = %d;\0A\00"
@.str.5 = [30 x i8] c"* ( * ( A + 3 ) + 2 ) = %d;\0A\0A\00"
@.str.6 = [38 x i8] c"* ( * ( A + ( i = %d ) ) + 2 ) = %d;\0A\00"
define void @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 23)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 23)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 23)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 56)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 89)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 undef)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 23)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 56)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 2, i32 89)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 undef)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 4, i32 undef)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 5, i32 undef)
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i32 6, i32 undef)
ret void
}