#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 print2DArray(int *array, unsigned int rows, unsigned int columns) {
  unsigned int i, j;
  printf("\n");
  for (i = 0; i < rows; i++) {
    for (j = 0; j < columns; j++)
      printf("%4d", array[i * columns + j]);
    printf("\n\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print2DArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    11a1 <print2DArray+0x91>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1185 <print2DArray+0x75>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x18(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,4),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <print2DArray+0x3a>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <print2DArray+0x27>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print2DArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%rbp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,0xc(%rsp)
test   %ebx,%ebx
je     11cd <print2DArray+0x9d>
mov    %r14d,%eax
mov    %rax,0x10(%rsp)
lea    0xe99(%rip),%rbx
xor    %r12d,%r12d
xor    %r13d,%r13d
mov    %r14d,0x8(%rsp)
jmp    119f <print2DArray+0x6f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe7d(%rip),%rdi
call   1040 <puts@plt>
add    $0x1,%r13d
mov    0x8(%rsp),%r14d
add    %r14d,%r12d
cmp    0xc(%rsp),%r13d
je     11cd <print2DArray+0x9d>
test   %r14d,%r14d
je     1180 <print2DArray+0x50>
mov    0x10(%rsp),%r14
mov    %r12d,%r15d
nopl   0x0(%rax)
mov    %r15d,%eax
mov    0x0(%rbp,%rax,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15d
add    $0xffffffffffffffff,%r14
jne    11b0 <print2DArray+0x80>
jmp    1180 <print2DArray+0x50>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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