#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  int data[2][3] = {
      {10, 20, 30},
      {40, 50, 60},
  };
  int(*p)[3] = data;
  printf("old: %d\n", *((*p) + 0));
  (*p)[0] = 123;
  printf("new: %d\n", *((*p) + 0));
  printf("old: %d\n", *((*p) + 1));
  (*p)[1] = 768;
  printf("new: %d\n", *((*p) + 1));
  printf("old: %d\n", *((*p) + 3));
  p[1][0] = 999;
  printf("new: %d\n", *((*p) + 3));
  printf("old: %d\n", *((*p) + 5));
  p[1][2] = 2016;
  printf("new: %d\n", *((*p) + 5));
  for (int i = 0; i < 6; i++) {
    if ((i % 3) == 0)
      puts(" ");
    printf("%4d, ", (*p)[i]);
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0x7b,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0x300,0x4(%rax)
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0x3e7,0xc(%rax)
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0x7e0,0x14(%rax)
mov    -0x28(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    126f <main+0x14f>
mov    -0x2c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    124a <main+0x12a>
lea    0xde9(%rip),%rdi
call   1030 <puts@plt>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdce(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1220 <main+0x100>
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <printf@plt>
lea    0xeca(%rip),%rbx
mov    %rbx,%rdi
mov    $0x7b,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x14,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x300,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x28,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e7,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x3c,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7e0,%esi
call   1040 <printf@plt>
lea    0xe75(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe62(%rip),%rbx
mov    %rbx,%rdi
mov    $0x7b,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x300,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1e,%esi
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x3e7,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x32,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7e0,%esi
call   1040 <printf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"old: %d\0A\00"
@.str.1 = [9 x i8] c"new: %d\0A\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [6 x i8] c"%4d, \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 10)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 123)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 20)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 768)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 40)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 999)
%7 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 60)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 2016)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 123)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 768)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 30)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 999)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 50)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 2016)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}