#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 print_3D_array(char *label, int ***array, int pages, int rows, int cols) {
  int i, j, k;
  printf("%s:\n", label);
  for (i = 0; i < pages; i++) {
    for (j = 0; j < rows; j++) {
      for (k = 0; k < cols; k++) {
        printf("%d ", array[i][j][k]);
      }
      printf("\n");
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_3D_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e4 <print_3D_array+0xd4>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11c8 <print_3D_array+0xb8>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ac <print_3D_array+0x9c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1169 <print_3D_array+0x59>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1156 <print_3D_array+0x46>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1143 <print_3D_array+0x33>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_3D_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,0x4(%rsp)
mov    %ecx,(%rsp)
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %rdi,%rsi
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11e2 <print_3D_array+0xc2>
mov    %ebx,%eax
mov    %rax,0x8(%rsp)
mov    (%rsp),%eax
mov    %rax,0x10(%rsp)
mov    0x4(%rsp),%r14d
lea    0xe96(%rip),%rbx
xor    %r12d,%r12d
jmp    1195 <print_3D_array+0x75>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
cmp    0x8(%rsp),%r12
je     11e2 <print_3D_array+0xc2>
cmpl   $0x0,(%rsp)
jle    1180 <print_3D_array+0x60>
xor    %r15d,%r15d
jmp    11b5 <print_3D_array+0x95>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    0x10(%rsp),%r15
je     1180 <print_3D_array+0x60>
cmpl   $0x0,0x4(%rsp)
jle    11a0 <print_3D_array+0x80>
xor    %r13d,%r13d
nop
mov    0x0(%rbp,%r12,8),%rax
mov    (%rax,%r15,8),%rax
mov    (%rax,%r13,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    11c0 <print_3D_array+0xa0>
jmp    11a0 <print_3D_array+0x80>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define void @print_3D_array(i8* %0, i32*** nocapture %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %38
8: ; preds = %5
%9 = icmp sgt i32 %3, 0
%10 = icmp sgt i32 %4, 0
%11 = zext i32 %2 to i64
%12 = zext i32 %3 to i64
%13 = zext i32 %4 to i64
br label %14
14: ; preds = %8, %34
%15 = phi i64 [ 0, %8 ], [ %36, %34 ]
br i1 %9, label %16, label %34
16: ; preds = %14
%17 = getelementptr inbounds i32**, i32*** %1, i64 %15
br label %18
18: ; preds = %16, %30
%19 = phi i64 [ 0, %16 ], [ %32, %30 ]
br i1 %10, label %20, label %30
20: ; preds = %18, %20
%21 = phi i64 [ %28, %20 ], [ 0, %18 ]
%22 = load i32**, i32*** %17
%23 = getelementptr inbounds i32*, i32** %22, i64 %19
%24 = load i32*, i32** %23
%25 = getelementptr inbounds i32, i32* %24, i64 %21
%26 = load i32, i32* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = add nuw nsw i64 %21, 1
%29 = icmp eq i64 %28, %13
br i1 %29, label %30, label %20
30: ; preds = %20, %18
%31 = tail call i32 @putchar(i32 10)
%32 = add nuw nsw i64 %19, 1
%33 = icmp eq i64 %32, %12
br i1 %33, label %34, label %18
34: ; preds = %30, %14
%35 = tail call i32 @putchar(i32 10)
%36 = add nuw nsw i64 %15, 1
%37 = icmp eq i64 %36, %11
br i1 %37, label %38, label %14
38: ; preds = %34, %5
%39 = tail call i32 @putchar(i32 10)
ret void
}