#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, ...);
void main() {
  int i, j;
  int arr[3][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
  int(*ptr)[4];
  for (i = 0; i < 3; i++)
    for (j = 0; j < 4; j++)
      printf("arr[%d][%d] = %d\n", i, j, arr[i][j]);
  for (ptr = arr, i = 0; ptr < arr + 3; ptr++, i++)
    for (j = 0; j < 4; j++)
      printf("ptr[%d][%d] = %p, %d\n", i, j, *ptr + j, *(*ptr + j));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x40(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x30,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    11aa <main+0x8a>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    1197 <main+0x77>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
movslq -0x4(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1155 <main+0x35>
jmp    119c <main+0x7c>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1144 <main+0x24>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x48(%rbp),%rax
lea    -0x40(%rbp),%rcx
add    $0x30,%rcx
cmp    %rcx,%rax
jae    123b <main+0x11b>
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    121c <main+0xfc>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x48(%rbp),%rcx
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rcx
mov    -0x48(%rbp),%rax
movslq -0x8(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d5 <main+0xb5>
jmp    1221 <main+0x101>
mov    -0x48(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x48(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11b9 <main+0x99>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
movaps 0xf00(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xee4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xee3(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x4,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x5,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x6,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
mov    $0x7,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x8,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
mov    $0x9,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    $0xa,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0xb,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
mov    $0xc,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdd7(%rip),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rcx
mov    0x4(%rsp),%r8d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rcx
mov    0x8(%rsp),%r8d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rcx
mov    0xc(%rsp),%r8d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    %r15,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x14(%rsp),%rcx
mov    0x14(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x18(%rsp),%rcx
mov    0x18(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1c(%rsp),%rcx
mov    0x1c(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x20(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x24(%rsp),%rcx
mov    0x24(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x28(%rsp),%rcx
mov    0x28(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x2c(%rsp),%rcx
mov    0x2c(%rsp),%r8d
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.arr = [3 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 5, i32 6, i32 7, i32 8], [4 x i32] [i32 9, i32 10, i32 11, i32 12]]
@.str = [18 x i8] c"arr[%d][%d] = %d\0A\00"
@.str.1 = [22 x i8] c"ptr[%d][%d] = %p, %d\0A\00"
define void @main() {
%1 = alloca [3 x [4 x i32]]
%2 = bitcast [3 x [4 x i32]]* %1 to i8*
%3 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32 1)
%4 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 0, i32 1, i32 2)
%5 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 0, i32 2, i32 3)
%6 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 0, i32 3, i32 4)
%7 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 1, i32 0, i32 5)
%8 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 1, i32 1, i32 6)
%9 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 1, i32 2, i32 7)
%10 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 1, i32 3, i32 8)
%11 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 2, i32 0, i32 9)
%12 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 2, i32 1, i32 10)
%13 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 2, i32 2, i32 11)
%14 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 2, i32 3, i32 12)
%15 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 0, i64 0
%16 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32* %15, i32 1)
%17 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 0, i64 1
%18 = load i32, i32* %17
%19 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 1, i32* %17, i32 %18)
%20 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 0, i64 2
%21 = load i32, i32* %20
%22 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 2, i32* %20, i32 %21)
%23 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 0, i64 3
%24 = load i32, i32* %23
%25 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 3, i32* %23, i32 %24)
%26 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 1, i64 0
%27 = load i32, i32* %26
%28 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 0, i32* %26, i32 %27)
%29 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 1, i64 1
%30 = load i32, i32* %29
%31 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 1, i32* %29, i32 %30)
%32 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 1, i64 2
%33 = load i32, i32* %32
%34 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 2, i32* %32, i32 %33)
%35 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 1, i64 3
%36 = load i32, i32* %35
%37 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 3, i32* %35, i32 %36)
%38 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 2, i64 0
%39 = load i32, i32* %38
%40 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 0, i32* %38, i32 %39)
%41 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 2, i64 1
%42 = load i32, i32* %41
%43 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 1, i32* %41, i32 %42)
%44 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 2, i64 2
%45 = load i32, i32* %44
%46 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 2, i32* %44, i32 %45)
%47 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 2, i64 3
%48 = load i32, i32* %47
%49 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 3, i32* %47, i32 %48)
ret void
}