#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 *, ...);
int _print_matrix(int **matrix, const int rows, const int cols) {
  if (matrix == NULL) {
    printf("nothing to print...");
    return -1;
  }
  int r, c;
  r, c = 0;
  for (r = 0; r < rows; r++) {
    for (c = 0; c < cols; c++) {
      printf("%i\t", matrix[r][c]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<_print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1147 <_print_matrix+0x37>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <_print_matrix+0xb6>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bf <_print_matrix+0xaf>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a3 <_print_matrix+0x93>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1168 <_print_matrix+0x58>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1155 <_print_matrix+0x45>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
test   %rdi,%rdi
je     1192 <_print_matrix+0x72>
test   %esi,%esi
jle    118e <_print_matrix+0x6e>
mov    %rdi,%r13
mov    %esi,%r15d
mov    0x4(%rsp),%ebp
lea    0xecb(%rip),%r12
xor    %ebx,%ebx
jmp    1163 <_print_matrix+0x43>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
je     118e <_print_matrix+0x6e>
cmpl   $0x0,0x4(%rsp)
jle    1150 <_print_matrix+0x30>
xor    %r14d,%r14d
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rax
mov    (%rax,%r14,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1170 <_print_matrix+0x50>
jmp    1150 <_print_matrix+0x30>
xor    %eax,%eax
jmp    11a5 <_print_matrix+0x85>
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [20 x i8] c"nothing to print...\00"
@.str.1 = [4 x i8] c"%i\09\00"
define i32 @_print_matrix(i32** %0, i32 %1, i32 %2) {
%4 = icmp eq i32** %0, null
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %29
7: ; preds = %5
%8 = icmp sgt i32 %2, 0
%9 = zext i32 %1 to i64
%10 = zext i32 %2 to i64
br label %13
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %29
13: ; preds = %7, %25
%14 = phi i64 [ 0, %7 ], [ %27, %25 ]
br i1 %8, label %15, label %25
15: ; preds = %13
%16 = getelementptr inbounds i32*, i32** %0, i64 %14
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 0, %15 ], [ %23, %17 ]
%19 = load i32*, i32** %16
%20 = getelementptr inbounds i32, i32* %19, i64 %18
%21 = load i32, i32* %20
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %18, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %17
25: ; preds = %17, %13
%26 = tail call i32 @putchar(i32 10)
%27 = add nuw nsw i64 %14, 1
%28 = icmp eq i64 %27, %9
br i1 %28, label %29, label %13
29: ; preds = %25, %5, %11
%30 = phi i32 [ -1, %11 ], [ 0, %5 ], [ 0, %25 ]
ret i32 %30
}