#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*/ write(int, char *, int);
void print_matrix(int x, int y, int **matrix) {
  char c;
  int i;
  int j;
  i = 0;
  while (i < y + 1) {
    j = 0;
    while (j < x + 1) {
      c = '0' + matrix[i][j++];
      write(1, &c, 1);
      write(1, " ", 1);
    }
    write(1, "\n", 1);
    i++;
  }
}


x86 assembly (clang, -O0):
<print_matrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11be <print_matrix+0xae>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    119d <print_matrix+0x8d>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
add    $0x30,%eax
mov    %al,-0x11(%rbp)
mov    $0x1,%edx
lea    -0x11(%rbp),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    $0x1,%edx
lea    0xe6f(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    1141 <print_matrix+0x31>
mov    $0x1,%edx
lea    0xe59(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1129 <print_matrix+0x19>
add    $0x20,%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    %rdi,0x10(%rsp)
mov    %rsi,0x8(%rsp)
test   %esi,%esi
js     11ce <print_matrix+0xbe>
mov    %rdx,%rbx
mov    0x10(%rsp),%rax
lea    0x1(%rax),%r12d
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
xor    %r15d,%r15d
lea    0x7(%rsp),%r13
lea    0xea8(%rip),%rbp
jmp    1181 <print_matrix+0x71>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
lea    0xe96(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%r15
cmp    0x8(%rsp),%r15
je     11ce <print_matrix+0xbe>
cmpl   $0x0,0x10(%rsp)
js     1160 <print_matrix+0x50>
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r15,8),%rax
movzbl (%rax,%r14,4),%eax
add    $0x1,%r14
add    $0x30,%al
mov    %al,0x7(%rsp)
mov    $0x1,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    %r14,%r12
jne    1190 <print_matrix+0x80>
jmp    1160 <print_matrix+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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