#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 *matrix, char matrix_name, int matrix_size) {
  int i, j;
  printf("%c =\n", matrix_name);
  for (i = 0; i < matrix_size; ++i) {
    printf("\t[ ");
    int pos = i * matrix_size;
    for (j = 0; j < matrix_size; ++j) {
      printf("%8i ", matrix[pos + j]);
    }
    printf("]\n");
  }
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %edx,-0x10(%rbp)
movsbl -0x9(%rbp),%esi
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11bd <print_matrix+0xad>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a1 <print_matrix+0x91>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1169 <print_matrix+0x59>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <print_matrix+0x2e>
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,%ebp
mov    %rdi,%rbx
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11af <print_matrix+0x8f>
mov    %ebp,%ebp
lea    0x0(,%rbp,4),%r13
lea    0xeb7(%rip),%r15
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r12,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1180 <print_matrix+0x60>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%r14
add    %r13,%rbx
cmp    %rbp,%r14
jne    1160 <print_matrix+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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