#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 *, ...);
void show_multi_array_ptr(int *matrix) {
  int i = 0;
  printf("__________________\n");
  for (; i < 4; i++) {
    int j = 0;
    printf("|");
    for (; j < 4; j++) {
      int e = matrix[i * 4 + j];
      if (e == 0) {
        printf("  # ");
      } else if (e < 10) {
        printf("  %d ", e);
      } else {
        printf(" %d ", e);
      }
    }
    printf("|\n");
  }
  printf("------------------\n");
}


x86 assembly (clang, -O0):
<show_multi_array_ptr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0xc(%rbp)
jge    11f2 <show_multi_array_ptr+0xe2>
movl   $0x0,-0x10(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0x10(%rbp)
jge    11d6 <show_multi_array_ptr+0xc6>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    118d <show_multi_array_ptr+0x7d>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <show_multi_array_ptr+0xb3>
cmpl   $0xa,-0x14(%rbp)
jge    11ad <show_multi_array_ptr+0x9d>
mov    -0x14(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11be <show_multi_array_ptr+0xae>
mov    -0x14(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <show_multi_array_ptr+0xb3>
jmp    11c8 <show_multi_array_ptr+0xb8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1150 <show_multi_array_ptr+0x40>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <show_multi_array_ptr+0x21>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_multi_array_ptr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%r14
lea    0xed9(%rip),%r15
lea    0xea6(%rip),%r12
lea    0xea0(%rip),%r13
xor    %ebp,%ebp
jmp    1190 <show_multi_array_ptr+0x60>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
add    $0x10,%rbp
cmp    $0x40,%rbp
je     124f <show_multi_array_ptr+0x11f>
mov    $0x7c,%edi
call   1030 <putchar@plt>
mov    (%rbx,%rbp,1),%esi
test   %esi,%esi
je     11b0 <show_multi_array_ptr+0x80>
cmp    $0x9,%esi
jg     11c0 <show_multi_array_ptr+0x90>
mov    %r12,%rdi
jmp    11c3 <show_multi_array_ptr+0x93>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11ca <show_multi_array_ptr+0x9a>
nopl   0x0(%rax)
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx,%rbp,1),%esi
test   %esi,%esi
je     11e0 <show_multi_array_ptr+0xb0>
cmp    $0xa,%esi
jge    11f0 <show_multi_array_ptr+0xc0>
mov    %r12,%rdi
jmp    11f3 <show_multi_array_ptr+0xc3>
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11fa <show_multi_array_ptr+0xca>
nopl   0x0(%rax)
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx,%rbp,1),%esi
test   %esi,%esi
je     1210 <show_multi_array_ptr+0xe0>
cmp    $0xa,%esi
jge    1220 <show_multi_array_ptr+0xf0>
mov    %r12,%rdi
jmp    1223 <show_multi_array_ptr+0xf3>
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    122a <show_multi_array_ptr+0xfa>
nopl   0x0(%rax)
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx,%rbp,1),%esi
test   %esi,%esi
je     1170 <show_multi_array_ptr+0x40>
cmp    $0xa,%esi
jge    1240 <show_multi_array_ptr+0x110>
mov    %r12,%rdi
jmp    1243 <show_multi_array_ptr+0x113>
mov    %r13,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    117a <show_multi_array_ptr+0x4a>
lea    0xdc8(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

LLVM IR (-O2):
@.str.2 = [5 x i8] c" # \00"
@.str.3 = [6 x i8] c" %d \00"
@.str.4 = [5 x i8] c" %d \00"
@str = [19 x i8] c"__________________\00"
@str.7 = [19 x i8] c"------------------\00"
@str.8 = [2 x i8] c"|\00"
define void @show_multi_array_ptr(i32* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %1, %57
%4 = phi i64 [ 0, %1 ], [ %59, %57 ]
%5 = tail call i32 @putchar(i32 124)
%6 = shl nsw i64 %4, 2
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %18
12: ; preds = %3
%13 = icmp slt i32 %8, 10
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %18
16: ; preds = %12
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %8)
br label %18
18: ; preds = %14, %16, %10
%19 = or i64 %6, 1
%20 = getelementptr inbounds i32, i32* %0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %18
%24 = icmp slt i32 %21, 10
br i1 %24, label %27, label %25
25: ; preds = %23
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %31
27: ; preds = %23
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %31
29: ; preds = %18
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %29, %27, %25
%32 = or i64 %6, 2
%33 = getelementptr inbounds i32, i32* %0, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %42, label %36
36: ; preds = %31
%37 = icmp slt i32 %34, 10
br i1 %37, label %40, label %38
38: ; preds = %36
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %34)
br label %44
40: ; preds = %36
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %44
42: ; preds = %31
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %42, %40, %38
%45 = or i64 %6, 3
%46 = getelementptr inbounds i32, i32* %0, i64 %45
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 0
br i1 %48, label %55, label %49
49: ; preds = %44
%50 = icmp slt i32 %47, 10
br i1 %50, label %53, label %51
51: ; preds = %49
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %47)
br label %57
53: ; preds = %49
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %47)
br label %57
55: ; preds = %44
%56 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %57
57: ; preds = %55, %53, %51
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
%59 = add nuw nsw i64 %4, 1
%60 = icmp eq i64 %59, 4
br i1 %60, label %61, label %3
61: ; preds = %57
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
ret void
}