#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*/ multi_dim(int **, int, int);
int /*<<< orphan*/ printf(char *, int *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ single_dim(int *, int);
int main(void) {
  int array[5] = {1, 2, 3, 4, 5};
  int *p = array;
  int marray[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  int **q = marray;
  puts("Transfer an array:");
  single_dim(array, 4);
  puts("Transfer an pointer:");
  single_dim(p, 4);
  puts("Transfer an array:");
  multi_dim(marray, 2, 2);
  int i, j;
  for (i = 0; i < 3; ++i)
    for (j = 0; j < 3; ++j) {
      printf(" ADDR:%p", &marray[i][j]);
    }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe95(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1070 <single_dim@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    -0x28(%rbp),%rdi
mov    $0x4,%esi
call   1070 <single_dim@plt>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
lea    -0x50(%rbp),%rdi
mov    $0x2,%edx
mov    %edx,%esi
call   1060 <multi_dim@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x3,-0x5c(%rbp)
jge    125c <main+0x10c>
movl   $0x0,-0x60(%rbp)
cmpl   $0x3,-0x60(%rbp)
jge    1249 <main+0xf9>
movslq -0x5c(%rbp),%rax
lea    -0x50(%rbp),%rsi
imul   $0xc,%rax,%rax
add    %rax,%rsi
movslq -0x60(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    120b <main+0xbb>
jmp    124e <main+0xfe>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11fa <main+0xaa>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    0xebf(%rip),%eax
mov    %eax,0x40(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0xed9(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea2(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xeb1(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <single_dim@plt>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <single_dim@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1050 <multi_dim@plt>
lea    0xe82(%rip),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.array = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.marray = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@.str = [19 x i8] c"Transfer an array:\00"
@.str.1 = [21 x i8] c"Transfer an pointer:\00"
@.str.2 = [9 x i8] c" ADDR:%p\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32*
%4 = alloca [3 x [3 x i32]]
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [5 x i32]* %2 to i8*
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
store i32* %9, i32** %3
%10 = bitcast [3 x [3 x i32]]* %4 to i8*
%11 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%12 = bitcast [3 x i32]* %11 to i32**
store i32** %12, i32*** %5
%13 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%15 = call i32 @single_dim(i32* %14, i32 4)
%16 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32*, i32** %3
%18 = call i32 @single_dim(i32* %17, i32 4)
%19 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 0
%21 = bitcast [3 x i32]* %20 to i32**
%22 = call i32 @multi_dim(i32** %21, i32 2, i32 2)
store i32 0, i32* %6
br label %23
23: ; preds = %42, %0
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 3
br i1 %25, label %26, label %45
26: ; preds = %23
store i32 0, i32* %7
br label %27
27: ; preds = %38, %26
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 3
br i1 %29, label %30, label %41
30: ; preds = %27
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %4, i64 0, i64 %32
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [3 x i32], [3 x i32]* %33, i64 0, i64 %35
%37 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %36)
br label %38
38: ; preds = %30
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %27
41: ; preds = %27
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %23
45: ; preds = %23
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@__const.main.array = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.marray = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@.str = [19 x i8] c"Transfer an array:\00"
@.str.1 = [21 x i8] c"Transfer an pointer:\00"
@.str.2 = [9 x i8] c" ADDR:%p\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca [3 x [3 x i32]]
%3 = bitcast [5 x i32]* %1 to i8*
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%5 = bitcast [3 x [3 x i32]]* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @single_dim(i32* %4, i32 4)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @single_dim(i32* %4, i32 4)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = bitcast [3 x [3 x i32]]* %2 to i32**
%12 = call i32 @multi_dim(i32** %11, i32 2, i32 2)
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0, i64 1
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0, i64 2
%18 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 1, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 1, i64 1
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 1, i64 2
%24 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %25)
%27 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2, i64 1
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %27)
%29 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2, i64 2
%30 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32* %29)
ret i32 0
}