#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 printMatrix(int **mat, int m, int n) {
  int i, j;
  if (NULL == mat) {
    return -1;
  }
  printf("\n");
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++)
      printf("%d ", mat[i][j]);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    113a <printMatrix+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <printMatrix+0xb0>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b9 <printMatrix+0xa9>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119d <printMatrix+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <printMatrix+0x52>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <printMatrix+0x3f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,0x4(%rsp)
test   %rdi,%rdi
je     11a2 <printMatrix+0x82>
mov    %esi,%ebp
mov    %rdi,%r13
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    119e <printMatrix+0x7e>
mov    %ebp,%r15d
mov    0x4(%rsp),%ebp
lea    0xeab(%rip),%r12
xor    %ebx,%ebx
jmp    1173 <printMatrix+0x53>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
je     119e <printMatrix+0x7e>
cmpl   $0x0,0x4(%rsp)
jle    1160 <printMatrix+0x40>
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    1180 <printMatrix+0x60>
jmp    1160 <printMatrix+0x40>
xor    %eax,%eax
jmp    11a7 <printMatrix+0x87>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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