#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 */
size_t m_idx(size_t, size_t, size_t);
int /*<<< orphan*/ printf(char *, int);
void printMat(int *arr, size_t rows, size_t columns) {
  for (size_t i = 1; i <= rows; i++) {
    for (size_t j = 1; j < columns; j++)
      printf("%d\t", arr[m_idx(i, j, columns)]);
    printf("%d\n", arr[m_idx(i, columns, columns)]);
  }
}


x86 assembly (clang, -O0):
<printMat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     11e0 <printMat+0xc0>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11a0 <printMat+0x80>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <m_idx@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    (%rax,%rcx,4),%esi
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1152 <printMat+0x32>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <m_idx@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    (%rax,%rcx,4),%esi
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <printMat+0x1c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     11b5 <printMat+0x95>
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1,%r12d
lea    0xeb6(%rip),%r13
jmp    1177 <printMat+0x57>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1030 <m_idx@plt>
mov    (%r15,%rax,4),%esi
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r14,%r12
ja     11b5 <printMat+0x95>
cmp    $0x2,%rbx
jb     1150 <printMat+0x30>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1030 <m_idx@plt>
mov    (%r15,%rax,4),%esi
mov    %r13,%rdi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1190 <printMat+0x70>
jmp    1150 <printMat+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\09\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define void @printMat(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i64 1, i64* %7
br label %9
9: ; preds = %39, %3
%10 = load i64, i64* %7
%11 = load i64, i64* %5
%12 = icmp ule i64 %10, %11
br i1 %12, label %13, label %42
13: ; preds = %9
store i64 1, i64* %8
br label %14
14: ; preds = %27, %13
%15 = load i64, i64* %8
%16 = load i64, i64* %6
%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* %7
%21 = load i64, i64* %8
%22 = load i64, i64* %6
%23 = call i64 @m_idx(i64 %20, i64 %21, i64 %22)
%24 = getelementptr inbounds i32, i32* %19, i64 %23
%25 = load i32, i32* %24
%26 = call i32 @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* %8
%29 = add i64 %28, 1
store i64 %29, i64* %8
br label %14
30: ; preds = %14
%31 = load i32*, i32** %4
%32 = load i64, i64* %7
%33 = load i64, i64* %6
%34 = load i64, i64* %6
%35 = call i64 @m_idx(i64 %32, i64 %33, i64 %34)
%36 = getelementptr inbounds i32, i32* %31, i64 %35
%37 = load i32, i32* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %30
%40 = load i64, i64* %7
%41 = add i64 %40, 1
store i64 %41, i64* %7
br label %9
42: ; preds = %9
ret void
}

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