#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printMatrix(int **, int, int);
int **reconstructQueue(int **, int, int, int *);
int main(void) {
  int **arr;
  arr = (int **)malloc(6 * sizeof(int *));
  for (int i = 0; i < 6; i++) {
    arr[i] = (int *)malloc(2 * sizeof(int));
  }
  arr[0][0] = 7;
  arr[1][0] = 4;
  arr[2][0] = 7;
  arr[3][0] = 5;
  arr[4][0] = 6;
  arr[5][0] = 5;
  arr[0][1] = 0;
  arr[1][1] = 4;
  arr[2][1] = 1;
  arr[3][1] = 0;
  arr[4][1] = 1;
  arr[5][1] = 2;
  int returnSize = 6;
  int **queue = reconstructQueue(arr, 6, 2, &returnSize);
  printMatrix(queue, 6, 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x30,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    1185 <main+0x55>
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x7,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x4,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x7,(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x5,(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x6,(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movl   $0x5,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movl   $0x4,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movl   $0x1,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movl   $0x2,0x4(%rax)
movl   $0x6,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
lea    -0x18(%rbp),%rcx
call   1030 <reconstructQueue@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1040 <printMatrix@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x30,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,0x18(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,0x20(%rbx)
mov    $0x8,%edi
call   1050 <malloc@plt>
mov    %rax,0x28(%rbx)
mov    (%rbx),%r8
movl   $0x7,(%r8)
mov    0x8(%rbx),%rdx
movl   $0x4,(%rdx)
mov    0x10(%rbx),%rsi
movl   $0x7,(%rsi)
mov    0x18(%rbx),%rdi
movl   $0x5,(%rdi)
mov    0x20(%rbx),%rcx
movl   $0x6,(%rcx)
movl   $0x5,(%rax)
movl   $0x0,0x4(%r8)
movl   $0x4,0x4(%rdx)
movl   $0x1,0x4(%rsi)
movl   $0x0,0x4(%rdi)
movl   $0x1,0x4(%rcx)
movl   $0x2,0x4(%rax)
movl   $0x6,0xc(%rsp)
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1030 <reconstructQueue@plt>
mov    %rax,%rdi
mov    $0x6,%esi
mov    $0x2,%edx
call   1040 <printMatrix@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = tail call i64 @malloc(i32 48)
%3 = inttoptr i64 %2 to i32**
%4 = tail call i64 @malloc(i32 8)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %3
%6 = tail call i64 @malloc(i32 8)
%7 = inttoptr i64 %6 to i32*
%8 = getelementptr inbounds i32*, i32** %3, i64 1
store i32* %7, i32** %8
%9 = tail call i64 @malloc(i32 8)
%10 = inttoptr i64 %9 to i32*
%11 = getelementptr inbounds i32*, i32** %3, i64 2
store i32* %10, i32** %11
%12 = tail call i64 @malloc(i32 8)
%13 = inttoptr i64 %12 to i32*
%14 = getelementptr inbounds i32*, i32** %3, i64 3
store i32* %13, i32** %14
%15 = tail call i64 @malloc(i32 8)
%16 = inttoptr i64 %15 to i32*
%17 = getelementptr inbounds i32*, i32** %3, i64 4
store i32* %16, i32** %17
%18 = tail call i64 @malloc(i32 8)
%19 = inttoptr i64 %18 to i32*
%20 = getelementptr inbounds i32*, i32** %3, i64 5
store i32* %19, i32** %20
%21 = load i32*, i32** %3
store i32 7, i32* %21
%22 = load i32*, i32** %8
store i32 4, i32* %22
%23 = load i32*, i32** %11
store i32 7, i32* %23
%24 = load i32*, i32** %14
store i32 5, i32* %24
%25 = load i32*, i32** %17
store i32 6, i32* %25
store i32 5, i32* %19
%26 = getelementptr inbounds i32, i32* %21, i64 1
store i32 0, i32* %26
%27 = getelementptr inbounds i32, i32* %22, i64 1
store i32 4, i32* %27
%28 = getelementptr inbounds i32, i32* %23, i64 1
store i32 1, i32* %28
%29 = getelementptr inbounds i32, i32* %24, i64 1
store i32 0, i32* %29
%30 = getelementptr inbounds i32, i32* %25, i64 1
store i32 1, i32* %30
%31 = getelementptr inbounds i32, i32* %19, i64 1
store i32 2, i32* %31
%32 = bitcast i32* %1 to i8*
store i32 6, i32* %1
%33 = call i32** @reconstructQueue(i32** %3, i32 6, i32 2, i32* %1)
%34 = call i32 @printMatrix(i32** %33, i32 6, i32 2)
ret i32 0
}