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


x86 assembly (clang, -O0):
<dump>:
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    11b1 <dump+0xa1>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1192 <dump+0x82>
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    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    114a <dump+0x3a>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1134 <dump+0x24>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1189 <dump+0x69>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x0(,%rsi,4),%rax
mov    %rax,(%rsp)
lea    0xeb4(%rip),%r12
xor    %ebp,%ebp
jmp    1167 <dump+0x47>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
add    (%rsp),%rbx
cmp    %r15,%rbp
je     1189 <dump+0x69>
test   %r14,%r14
je     1150 <dump+0x30>
xor    %r13d,%r13d
nop
mov    (%rbx,%r13,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r14
jne    1170 <dump+0x50>
jmp    1150 <dump+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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