#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 matrix_pprint_int_3(const char *name, const int *a, const int rows,
                         const int cols, const int dimz) {
  printf("%s=[\n", name);
  for (int z = 0; z < dimz; z++) {
    for (int r = 0; r < rows; r++) {
      for (int c = 0; c < cols; c++) {
        const int pos = (z * rows * cols) + (r * cols) + c;
        printf("%d ", a[pos]);
      }
      printf("\n");
    }
    printf("---\n");
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<matrix_pprint_int_3>:
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    -0x1c(%rbp),%eax
jge    11ee <matrix_pprint_int_3+0xde>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d2 <matrix_pprint_int_3+0xc2>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b6 <matrix_pprint_int_3+0xa6>
mov    -0x20(%rbp),%eax
imul   -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    -0x24(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    %ecx,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1169 <matrix_pprint_int_3+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 <matrix_pprint_int_3+0x46>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1143 <matrix_pprint_int_3+0x33>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_pprint_int_3>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %edx,0x4(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%rsi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,0xc(%rsp)
test   %ebx,%ebx
jle    122a <matrix_pprint_int_3+0xfa>
mov    0x4(%rsp),%eax
mov    %eax,%ecx
mov    %rcx,0x20(%rsp)
mov    %ebp,%r14d
mov    %ebp,%ecx
imul   %eax,%ecx
mov    %ecx,0x8(%rsp)
lea    0xe7f(%rip),%rbx
movl   $0x0,(%rsp)
xor    %ecx,%ecx
mov    %ebp,0x14(%rsp)
jmp    11c3 <matrix_pprint_int_3+0x93>
cs nopw 0x0(%rax,%rax,1)
lea    0xe65(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%ecx
add    $0x1,%ecx
mov    (%rsp),%eax
add    0x8(%rsp),%eax
mov    %eax,(%rsp)
cmp    0xc(%rsp),%ecx
je     122a <matrix_pprint_int_3+0xfa>
mov    %ecx,0x10(%rsp)
cmpl   $0x0,0x4(%rsp)
jle    11a0 <matrix_pprint_int_3+0x70>
mov    (%rsp),%r15d
xor    %r12d,%r12d
jmp    11fc <matrix_pprint_int_3+0xcc>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
mov    0x14(%rsp),%ebp
add    %ebp,%r15d
cmp    0x20(%rsp),%r12
je     11a0 <matrix_pprint_int_3+0x70>
test   %ebp,%ebp
jle    11e0 <matrix_pprint_int_3+0xb0>
movslq %r15d,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,4),%r13
xor    %ebp,%ebp
xchg   %ax,%ax
mov    0x0(%r13,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1210 <matrix_pprint_int_3+0xe0>
jmp    11e0 <matrix_pprint_int_3+0xb0>
lea    0xdd9(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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