#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(int ROW, int COL, char a[][COL]) {
  int i, k;
  for (i = 0; i < ROW; i++) {
    printf("|");
    int k;
    for (k = 0; k < COL; k++) {
      printf("%c", a[i][k]);
    }
    printf("|\n");
  }
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11b0 <print_matrix+0xa0>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1194 <print_matrix+0x84>
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <print_matrix+0x41>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <print_matrix+0x20>
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
test   %edi,%edi
jle    1185 <print_matrix+0x65>
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %esi,%ebp
mov    %edi,%r12d
xor    %r13d,%r13d
jmp    1158 <print_matrix+0x38>
nop
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r13
add    %rbp,%rbx
cmp    %r12,%r13
je     1185 <print_matrix+0x65>
mov    $0x7c,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    1140 <print_matrix+0x20>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%r14,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1170 <print_matrix+0x50>
jmp    1140 <print_matrix+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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