#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 print_matrix(char *str1, char *str2, int str1size, int str2size,
                 int **matrix) {
  int x, y;
  printf("\n\n   | ");
  for (y = 0; y < str2size; y++) {
    printf("%c ", str2[y]);
  }
  printf("\n---+-");
  for (y = 0; y < str2size; y++) {
    printf("--");
  }
  for (x = 0; x < str1size; x++) {
    printf("\n %c | ", str1[x]);
    for (y = 0; y < str2size; y++) {
      printf("%i ", matrix[x][y]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1173 <print_matrix+0x63>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    113f <print_matrix+0x2f>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b0 <print_matrix+0xa0>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1188 <print_matrix+0x78>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1232 <print_matrix+0x122>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    121f <print_matrix+0x10f>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e4 <print_matrix+0xd4>
jmp    1224 <print_matrix+0x114>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b7 <print_matrix+0xa7>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_matrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %ecx,%ebp
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,0x10(%rsp)
lea    0xecb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%r14d
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
jle    11a6 <print_matrix+0x96>
lea    0xeba(%rip),%r13
xor    %ebp,%ebp
movsbl (%r12,%rbp,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1150 <print_matrix+0x40>
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    119f <print_matrix+0x8f>
lea    0xe8f(%rip),%r12
mov    0xc(%rsp),%ebp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    1190 <print_matrix+0x80>
test   %r15d,%r15d
jg     11b9 <print_matrix+0xa9>
jmp    121d <print_matrix+0x10d>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r15d,%r15d
jle    121d <print_matrix+0x10d>
mov    %r15d,%r13d
lea    0xe5b(%rip),%rbp
xor    %r15d,%r15d
jmp    11d9 <print_matrix+0xc9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    %r13,%r15
je     121d <print_matrix+0x10d>
mov    0x10(%rsp),%rax
movsbl (%rax,%r15,1),%esi
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11d0 <print_matrix+0xc0>
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r15,8),%rax
mov    (%rax,%r12,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    1200 <print_matrix+0xf0>
jmp    11d0 <print_matrix+0xc0>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\0A\0A | \00"
@.str.1 = [4 x i8] c"%c \00"
@.str.2 = [7 x i8] c"\0A---+-\00"
@.str.3 = [3 x i8] c"--\00"
@.str.4 = [8 x i8] c"\0A %c | \00"
@.str.5 = [4 x i8] c"%i \00"
define i32 @print_matrix(i8* %0, i8* %1, i32 %2, i32 %3, i32** %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32** %4, i32*** %10
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %12
br label %14
14: ; preds = %26, %5
%15 = load i32, i32* %12
%16 = load i32, i32* %9
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = load i8*, i8** %7
%20 = load i32, i32* %12
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %12
%28 = add nsw i32 %27, 1
store i32 %28, i32* %12
br label %14
29: ; preds = %14
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %12
br label %31
31: ; preds = %37, %29
%32 = load i32, i32* %12
%33 = load i32, i32* %9
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %35
%38 = load i32, i32* %12
%39 = add nsw i32 %38, 1
store i32 %39, i32* %12
br label %31
40: ; preds = %31
store i32 0, i32* %11
br label %41
41: ; preds = %72, %40
%42 = load i32, i32* %11
%43 = load i32, i32* %8
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %75
45: ; preds = %41
%46 = load i8*, i8** %6
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %51)
store i32 0, i32* %12
br label %53
53: ; preds = %68, %45
%54 = load i32, i32* %12
%55 = load i32, i32* %9
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %71
57: ; preds = %53
%58 = load i32**, i32*** %10
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i32*, i32** %58, i64 %60
%62 = load i32*, i32** %61
%63 = load i32, i32* %12
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i32, i32* %62, i64 %64
%66 = load i32, i32* %65
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %57
%69 = load i32, i32* %12
%70 = add nsw i32 %69, 1
store i32 %70, i32* %12
br label %53
71: ; preds = %53
br label %72
72: ; preds = %71
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %41
75: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"\0A\0A | \00"
@.str.1 = [4 x i8] c"%c \00"
@.str.2 = [7 x i8] c"\0A---+-\00"
@.str.3 = [3 x i8] c"--\00"
@.str.4 = [8 x i8] c"\0A %c | \00"
@.str.5 = [4 x i8] c"%i \00"
define i32 @print_matrix(i8* nocapture %0, i8* nocapture %1, i32 %2, i32 %3, i32** nocapture %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = icmp sgt i32 %3, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %22
10: ; preds = %5
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %18, %12 ]
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br i1 %7, label %27, label %22
22: ; preds = %27, %8, %20
%23 = icmp sgt i32 %2, 0
br i1 %23, label %24, label %51
24: ; preds = %22
%25 = zext i32 %2 to i64
%26 = zext i32 %3 to i64
br label %32
27: ; preds = %20, %27
%28 = phi i32 [ %30, %27 ], [ 0, %20 ]
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%30 = add nuw nsw i32 %28, 1
%31 = icmp eq i32 %30, %3
br i1 %31, label %22, label %27
32: ; preds = %24, %48
%33 = phi i64 [ 0, %24 ], [ %49, %48 ]
%34 = getelementptr inbounds i8, i8* %0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br i1 %7, label %38, label %48
38: ; preds = %32
%39 = getelementptr inbounds i32*, i32** %4, i64 %33
br label %40
40: ; preds = %38, %40
%41 = phi i64 [ 0, %38 ], [ %46, %40 ]
%42 = load i32*, i32** %39
%43 = getelementptr inbounds i32, i32* %42, i64 %41
%44 = load i32, i32* %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = add nuw nsw i64 %41, 1
%47 = icmp eq i64 %46, %26
br i1 %47, label %48, label %40
48: ; preds = %40, %32
%49 = add nuw nsw i64 %33, 1
%50 = icmp eq i64 %49, %25
br i1 %50, label %51, label %32
51: ; preds = %48, %22
ret i32 0
}