#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*/ free(int **);
int **malloc(int);
int /*<<< orphan*/ printArray(int **, int, int);
int main() {
  int nRows = 3;
  int nCols = 2;
  int a[3][16] = {{0, 1}, {2, 3}, {4, 5}};
  printArray(a, nRows, nCols);
  int(*b)[16] = malloc(nRows * sizeof(int[16]));
  int n = 0;
  for (int i = 0; i < nRows; i++)
    for (int j = 0; j < nCols; j++)
      b[i][j] = n++;
  printArray(b, nRows, nCols);
  if (b)
    free(b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc0,%edx
call   1040 <memset@plt>
movl   $0x1,-0xcc(%rbp)
movl   $0x2,-0x90(%rbp)
movl   $0x3,-0x8c(%rbp)
movl   $0x4,-0x50(%rbp)
movl   $0x5,-0x4c(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <printArray@plt>
movslq -0x8(%rbp),%rax
shl    $0x6,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0xd8(%rbp)
movl   $0x0,-0xdc(%rbp)
movl   $0x0,-0xe0(%rbp)
mov    -0xe0(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1260 <main+0x120>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1247 <main+0x107>
mov    -0xdc(%rbp),%edx
mov    %edx,%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
mov    -0xd8(%rbp),%rax
movslq -0xe0(%rbp),%rcx
shl    $0x6,%rcx
add    %rcx,%rax
movslq -0xe4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    11f4 <main+0xb4>
jmp    124c <main+0x10c>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    11db <main+0x9b>
mov    -0xd8(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <printArray@plt>
cmpq   $0x0,-0xd8(%rbp)
je     128c <main+0x14c>
mov    -0xd8(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xc0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x1,0x4(%rsp)
movabs $0x300000002,%r14
mov    %r14,0x40(%rsp)
movabs $0x500000004,%r15
mov    %r15,0x80(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
call   1050 <printArray@plt>
mov    $0xc0,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
movabs $0x100000000,%rax
mov    %rax,(%rbx)
mov    %r14,0x40(%rbx)
mov    %r15,0x80(%rbx)
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x2,%edx
call   1050 <printArray@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x [16 x i32]]
%5 = alloca [16 x i32]*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 2, i32* %3
%9 = bitcast [3 x [16 x i32]]* %4 to i8*
%10 = bitcast i8* %9 to [3 x <{ i32, i32, [14 x i32] }>]*
%11 = getelementptr inbounds [3 x <{ i32, i32, [14 x i32] }>], [3 x <{ i32, i32, [14 x i32] }>]* %10, i32 0, i32 0
%12 = getelementptr inbounds <{ i32, i32, [14 x i32] }>, <{ i32, i32, [14 x i32] }>* %11, i32 0, i32 1
store i32 1, i32* %12
%13 = getelementptr inbounds [3 x <{ i32, i32, [14 x i32] }>], [3 x <{ i32, i32, [14 x i32] }>]* %10, i32 0, i32 1
%14 = getelementptr inbounds <{ i32, i32, [14 x i32] }>, <{ i32, i32, [14 x i32] }>* %13, i32 0, i32 0
store i32 2, i32* %14
%15 = getelementptr inbounds <{ i32, i32, [14 x i32] }>, <{ i32, i32, [14 x i32] }>* %13, i32 0, i32 1
store i32 3, i32* %15
%16 = getelementptr inbounds [3 x <{ i32, i32, [14 x i32] }>], [3 x <{ i32, i32, [14 x i32] }>]* %10, i32 0, i32 2
%17 = getelementptr inbounds <{ i32, i32, [14 x i32] }>, <{ i32, i32, [14 x i32] }>* %16, i32 0, i32 0
store i32 4, i32* %17
%18 = getelementptr inbounds <{ i32, i32, [14 x i32] }>, <{ i32, i32, [14 x i32] }>* %16, i32 0, i32 1
store i32 5, i32* %18
%19 = getelementptr inbounds [3 x [16 x i32]], [3 x [16 x i32]]* %4, i64 0, i64 0
%20 = bitcast [16 x i32]* %19 to i32**
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = call i32 @printArray(i32** %20, i32 %21, i32 %22)
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = mul i64 %25, 64
%27 = trunc i64 %26 to i32
%28 = call i32** @malloc(i32 %27)
%29 = bitcast i32** %28 to [16 x i32]*
store [16 x i32]* %29, [16 x i32]** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %30
30: ; preds = %53, %0
%31 = load i32, i32* %7
%32 = load i32, i32* %2
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %56
34: ; preds = %30
store i32 0, i32* %8
br label %35
35: ; preds = %49, %34
%36 = load i32, i32* %8
%37 = load i32, i32* %3
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %52
39: ; preds = %35
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
%42 = load [16 x i32]*, [16 x i32]** %5
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [16 x i32], [16 x i32]* %42, i64 %44
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [16 x i32], [16 x i32]* %45, i64 0, i64 %47
store i32 %40, i32* %48
br label %49
49: ; preds = %39
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %35
52: ; preds = %35
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %30
56: ; preds = %30
%57 = load [16 x i32]*, [16 x i32]** %5
%58 = bitcast [16 x i32]* %57 to i32**
%59 = load i32, i32* %2
%60 = load i32, i32* %3
%61 = call i32 @printArray(i32** %58, i32 %59, i32 %60)
%62 = load [16 x i32]*, [16 x i32]** %5
%63 = icmp ne [16 x i32]* %62, null
br i1 %63, label %64, label %68
64: ; preds = %56
%65 = load [16 x i32]*, [16 x i32]** %5
%66 = bitcast [16 x i32]* %65 to i32**
%67 = call i32 @free(i32** %66)
br label %68
68: ; preds = %64, %56
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [3 x [16 x i32]]
%2 = bitcast [3 x [16 x i32]]* %1 to i8*
%3 = getelementptr inbounds [3 x [16 x i32]], [3 x [16 x i32]]* %1, i64 0, i64 0, i64 1
store i32 1, i32* %3
%4 = getelementptr inbounds [3 x [16 x i32]], [3 x [16 x i32]]* %1, i64 0, i64 1, i64 0
store i32 2, i32* %4
%5 = getelementptr inbounds [3 x [16 x i32]], [3 x [16 x i32]]* %1, i64 0, i64 1, i64 1
store i32 3, i32* %5
%6 = getelementptr inbounds [3 x [16 x i32]], [3 x [16 x i32]]* %1, i64 0, i64 2, i64 0
store i32 4, i32* %6
%7 = getelementptr inbounds [3 x [16 x i32]], [3 x [16 x i32]]* %1, i64 0, i64 2, i64 1
store i32 5, i32* %7
%8 = bitcast [3 x [16 x i32]]* %1 to i32**
%9 = call i32 @printArray(i32** %8, i32 3, i32 2)
%10 = call i32** @malloc(i32 192)
%11 = bitcast i32** %10 to [16 x i32]*
%12 = bitcast i32** %10 to i32*
store i32 0, i32* %12
%13 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 0, i64 1
store i32 1, i32* %13
%14 = getelementptr inbounds i32*, i32** %10, i64 8
%15 = bitcast i32** %14 to i32*
store i32 2, i32* %15
%16 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 1, i64 1
store i32 3, i32* %16
%17 = getelementptr inbounds i32*, i32** %10, i64 16
%18 = bitcast i32** %17 to i32*
store i32 4, i32* %18
%19 = getelementptr inbounds [16 x i32], [16 x i32]* %11, i64 2, i64 1
store i32 5, i32* %19
%20 = call i32 @printArray(i32** %10, i32 3, i32 2)
%21 = call i32 @free(i32** %10)
ret i32 0
}