#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*/ print_elem(int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
void print_mat(int **mat, int size) {
  for (int i = 0; i < size; i++) {
    printf("    |");
    for (int j = 0; j < size; j++) {
      print_elem(mat[i][j], 5);
    }
    printf("|");
    if (i == size / 2)
      puts(" = A");
    else
      puts("");
  }
}


x86 assembly (clang, -O0):
<print_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f6 <print_mat+0xc6>
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    119c <print_mat+0x6c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    $0x5,%esi
call   1030 <print_elem@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <print_mat+0x35>
lea    0xe61(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jne    11d7 <print_mat+0xa7>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
jmp    11e3 <print_mat+0xb3>
lea    0xe2c(%rip),%rdi
call   1040 <puts@plt>
jmp    11e8 <print_mat+0xb8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <print_mat+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11c9 <print_mat+0x89>
mov    %esi,%r14d
mov    %rdi,%r13
mov    %esi,%ebx
shr    %r14d
xor    %ebp,%ebp
lea    0xe9d(%rip),%r15
jmp    1183 <print_mat+0x43>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbx,%rbp
je     11c9 <print_mat+0x89>
mov    %r15,%rdi
call   1060 <printf@plt>
xor    %r12d,%r12d
xchg   %ax,%ax
mov    0x0(%r13,%rbp,8),%rax
mov    (%rax,%r12,4),%edi
mov    $0x5,%esi
call   1040 <print_elem@plt>
add    $0x1,%r12
cmp    %r12,%rbx
jne    1190 <print_mat+0x50>
mov    $0x7c,%edi
call   1030 <putchar@plt>
cmp    %r14,%rbp
jne    1170 <print_mat+0x30>
lea    0xe44(%rip),%rdi
call   1050 <puts@plt>
jmp    117a <print_mat+0x3a>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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