#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);
int /*<<< orphan*/ putchar(char);
void print_matrix(size_t rows, size_t cols, int matrix[rows][cols]) {
  size_t i, j;
  for (i = 0; i < rows; i++) {
    for (j = 0; j < cols; j++) {
      printf("%d\t", matrix[i][j]);
    }
    putchar('\n');
  }
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11bb <print_matrix+0x9b>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11a0 <print_matrix+0x80>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115a <print_matrix+0x3a>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1144 <print_matrix+0x24>
add    $0x30,%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    %rdi,(%rsp)
test   %rdi,%rdi
je     1187 <print_matrix+0x67>
mov    %rdx,%rbx
mov    %rsi,%r14
lea    0x0(,%rsi,4),%r13
xor    %ebp,%ebp
lea    0xeb5(%rip),%r12
jmp    1167 <print_matrix+0x47>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    %r13,%rbx
cmp    (%rsp),%rbp
je     1187 <print_matrix+0x67>
test   %r14,%r14
je     1150 <print_matrix+0x30>
xor    %r15d,%r15d
nop
mov    (%rbx,%r15,4),%esi
mov    %r12,%rdi
call   1040 <printf@plt>
add    $0x1,%r15
cmp    %r15,%r14
jne    1170 <print_matrix+0x50>
jmp    1150 <print_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\09\00"
define void @print_matrix(i64 %0, i64 %1, i32* %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i32* %2, i32** %6
%9 = load i64, i64* %4
%10 = load i64, i64* %5
store i64 0, i64* %7
br label %11
11: ; preds = %34, %3
%12 = load i64, i64* %7
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %37
15: ; preds = %11
store i64 0, i64* %8
br label %16
16: ; preds = %29, %15
%17 = load i64, i64* %8
%18 = load i64, i64* %5
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %32
20: ; preds = %16
%21 = load i32*, i32** %6
%22 = load i64, i64* %7
%23 = mul nsw i64 %22, %10
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i64, i64* %8
%26 = getelementptr inbounds i32, i32* %24, i64 %25
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %20
%30 = load i64, i64* %8
%31 = add i64 %30, 1
store i64 %31, i64* %8
br label %16
32: ; preds = %16
%33 = call i32 @putchar(i8 signext 10)
br label %34
34: ; preds = %32
%35 = load i64, i64* %7
%36 = add i64 %35, 1
store i64 %36, i64* %7
br label %11
37: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\09\00"
define void @print_matrix(i64 %0, i64 %1, i32* nocapture %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = icmp eq i64 %1, 0
br label %7
7: ; preds = %5, %19
%8 = phi i64 [ 0, %5 ], [ %21, %19 ]
br i1 %6, label %19, label %9
9: ; preds = %7
%10 = mul nsw i64 %8, %1
%11 = getelementptr inbounds i32, i32* %2, i64 %10
br label %12
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %17, %12 ]
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nuw i64 %13, 1
%18 = icmp eq i64 %17, %1
br i1 %18, label %19, label %12
19: ; preds = %12, %7
%20 = tail call i32 @putchar(i8 signext 10)
%21 = add nuw i64 %8, 1
%22 = icmp eq i64 %21, %0
br i1 %22, label %23, label %7
23: ; preds = %19, %3
ret void
}