#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdout;
void printMatrix(int rows, int cols, int matrix[rows][cols]) {
  fputs("Your matrix is:\n", stdout);
  for (int i = 0; i < rows; ++i) {
    for (int j = 0; j < cols; ++j) {
      printf("%5i", matrix[i][j]);
    }
    fputs("\n", stdout);
  }
  fputs("\n", stdout);
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
lea    0xeb7(%rip),%rdi
call   1040 <fputs@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11cf <printMatrix+0xaf>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ac <printMatrix+0x8c>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1168 <printMatrix+0x48>
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
lea    0xe53(%rip),%rdi
call   1040 <fputs@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <printMatrix+0x35>
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
lea    0xe30(%rip),%rdi
call   1040 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %esi,0xc(%rsp)
mov    %edi,%r15d
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdi
call   1040 <fputs@plt>
test   %r15d,%r15d
jle    11c7 <printMatrix+0xa7>
mov    0xc(%rsp),%ebp
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
lea    0x0(,%rbp,4),%r15
xor    %r14d,%r14d
lea    0xea1(%rip),%r13
jmp    11a3 <printMatrix+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
lea    0xe7f(%rip),%rdi
call   1040 <fputs@plt>
add    $0x1,%r14
add    %r15,%rbx
cmp    0x10(%rsp),%r14
je     11c7 <printMatrix+0xa7>
cmpl   $0x0,0xc(%rsp)
jle    1180 <printMatrix+0x60>
xor    %r12d,%r12d
nopl   (%rax)
mov    (%rbx,%r12,4),%esi
mov    %r13,%rdi
call   1030 <printf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    11b0 <printMatrix+0x90>
jmp    1180 <printMatrix+0x60>
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
lea    0xe38(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputs@plt>

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

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