#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 print_matrix(char *matrix, int row_len, int col_len) {
  for (int i = 0; i < row_len * col_len; ++i) {
    if (i != 0 && i % row_len == 0) {
      printf("\n%c ", matrix[i]);
    } else {
      printf("%c ", matrix[i]);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
imul   -0x10(%rbp),%ecx
cmp    %ecx,%eax
jge    11a1 <print_matrix+0x91>
cmpl   $0x0,-0x14(%rbp)
je     1174 <print_matrix+0x64>
mov    -0x14(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1174 <print_matrix+0x64>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118e <print_matrix+0x7e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <print_matrix+0x83>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <print_matrix+0x19>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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,%ebx
imul   %esi,%ebx
test   %ebx,%ebx
jle    1153 <print_matrix+0x33>
mov    %esi,%r12d
mov    %rdi,%r14
movsbl (%rdi),%esi
lea    0xebd(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%ebx
jne    116b <print_matrix+0x4b>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
mov    %ebx,%ebp
mov    $0x1,%ebx
lea    0xe87(%rip),%r13
jmp    1195 <print_matrix+0x75>
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
je     1153 <print_matrix+0x33>
mov    %ebx,%eax
cltd
idiv   %r12d
mov    %r13,%rdi
test   %edx,%edx
je     1180 <print_matrix+0x60>
mov    %r15,%rdi
jmp    1180 <print_matrix+0x60>

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

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