#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 printMatrix(int len, int mat[len][len]) {
  for (int i = 0; i < len; ++i) {
    for (int j = 0; j < len; ++j) {
      if (j == 0)
        printf("%d", mat[i][j]);
      else
        printf(" %d", mat[i][j]);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e2 <printMatrix+0xd2>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c6 <printMatrix+0xb6>
cmpl   $0x0,-0x18(%rbp)
jne    1187 <printMatrix+0x77>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b3 <printMatrix+0xa3>
mov    -0x20(%rbp),%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b8 <printMatrix+0xa8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1140 <printMatrix+0x30>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <printMatrix+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x8(%rsp)
test   %edi,%edi
jle    11c9 <printMatrix+0xa9>
mov    %edi,%r12d
mov    %edi,%ebp
lea    0x0(,%rbp,4),%rax
mov    %rax,0x10(%rsp)
lea    0xeac(%rip),%rbx
mov    0x8(%rsp),%r15
xor    %r14d,%r14d
jmp    1178 <printMatrix+0x58>
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
add    0x10(%rsp),%r15
cmp    %rbp,%r14
je     11c9 <printMatrix+0xa9>
mov    %r14,%rax
imul   %rbp,%rax
mov    0x8(%rsp),%rcx
mov    (%rcx,%rax,4),%esi
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x1,%r12d
je     1160 <printMatrix+0x40>
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%r13,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
cmp    %r13,%rbp
jne    11b0 <printMatrix+0x90>
jmp    1160 <printMatrix+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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