#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 M, size_t N, int matrix[M][N]) {
  size_t i, j;
  for (i = 0; i < M; i++) {
    printf("%u", matrix[i][0]);
    for (j = 1; j < N; j++) {
      printf(" | %u", 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    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11cf <print_matrix+0xbf>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11b0 <print_matrix+0xa0>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
imul   -0x20(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1168 <print_matrix+0x58>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1134 <print_matrix+0x24>
add    $0x30,%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    %rdx,0x8(%rsp)
test   %rdi,%rdi
je     11b9 <print_matrix+0x99>
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0x0(,%rsi,4),%rax
mov    %rax,0x10(%rsp)
lea    0xeaa(%rip),%r13
mov    0x8(%rsp),%r14
xor    %r12d,%r12d
jmp    1178 <print_matrix+0x58>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
add    0x10(%rsp),%r14
cmp    %r15,%r12
je     11b9 <print_matrix+0x99>
mov    %r12,%rax
imul   %rbx,%rax
mov    0x8(%rsp),%rcx
mov    (%rcx,%rax,4),%esi
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x2,%rbx
jb     1160 <print_matrix+0x40>
mov    $0x1,%ebp
mov    (%r14,%rbp,4),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    11a0 <print_matrix+0x80>
jmp    1160 <print_matrix+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"%u\00"
@.str.1 = [6 x i8] c" | %u\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_matrix(i64 %0, i64 %1, i32* %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i32* %2, i32** %6
%9 = load i64, i64* %4
%10 = load i64, i64* %5
store i64 0, i64* %7
br label %11
11: ; preds = %41, %3
%12 = load i64, i64* %7
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %44
15: ; preds = %11
%16 = load i32*, i32** %6
%17 = load i64, i64* %7
%18 = mul nsw i64 %17, %10
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %21)
store i64 1, i64* %8
br label %23
23: ; preds = %36, %15
%24 = load i64, i64* %8
%25 = load i64, i64* %5
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %39
27: ; preds = %23
%28 = load i32*, i32** %6
%29 = load i64, i64* %7
%30 = mul nsw i64 %29, %10
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i64, i64* %8
%33 = getelementptr inbounds i32, i32* %31, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %27
%37 = load i64, i64* %8
%38 = add i64 %37, 1
store i64 %38, i64* %8
br label %23
39: ; preds = %23
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %39
%42 = load i64, i64* %7
%43 = add i64 %42, 1
store i64 %43, i64* %7
br label %11
44: ; preds = %11
ret void
}

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