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


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11ad <print_matrix+0x9d>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    118e <print_matrix+0x7e>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1146 <print_matrix+0x36>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%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   %rdi,%rdi
je     118c <print_matrix+0x6c>
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x0(,%rdi,4),%r12
lea    0xebb(%rip),%r15
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rbp,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1160 <print_matrix+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    %r12,%rbx
cmp    %r14,%r13
jne    1150 <print_matrix+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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