#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, int *);
int main(void) {
  int arr[2][2] = {
      {1, 2},
      {3, 4},
  };
  int *p1;
  int **p2;
  int(*p)[2];
  int i, j;
  p = arr;
  for (i = 0; i < 2; i++) {
    printf("p[%d] = %p\n", i, p[i]);
    printf("arr[%d] = %p\n", i, arr[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jge    1198 <main+0x88>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rdx
movslq -0x3c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdx
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
movslq -0x3c(%rbp),%rax
lea    -0x20(%rbp),%rdx
shl    $0x3,%rax
add    %rax,%rdx
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1144 <main+0x34>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xee5(%rip),%r14
mov    %rsp,%rbx
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0xeda(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
lea    0x8(%rsp),%rbx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.arr = [2 x [2 x i32]] [[2 x i32] [i32 1, i32 2], [2 x i32] [i32 3, i32 4]]
@.str = [12 x i8] c"p[%d] = %p\0A\00"
@.str.1 = [14 x i8] c"arr[%d] = %p\0A\00"
define i32 @main() {
%1 = alloca [2 x [2 x i32]]
%2 = bitcast [2 x [2 x i32]]* %1 to i8*
%3 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %1, i64 0, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0, i32* %3)
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0, i32* %3)
%6 = getelementptr inbounds [2 x [2 x i32]], [2 x [2 x i32]]* %1, i64 0, i64 1, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 1, i32* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 1, i32* %6)
ret i32 0
}