#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 *, int, ...);
int **reconstructMatrix(int, int, int *, int, int *, int **);
int main() {
  int upper = 2, lower = 1;
  int col[3] = {1, 1, 1};
  int *colsum = col;
  int colsumSize = 3;
  int returnSize, *returnColumnSizes;
  int **ret = reconstructMatrix(upper, lower, colsum, colsumSize, &returnSize,
                                &returnColumnSizes);
  printf("%d\n", *returnColumnSizes);
  for (int i = 0; i < *returnColumnSizes; i++)
    printf("%d %d\n", ret[0][i], ret[1][i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeba(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1040 <reconstructMatrix@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x30(%rbp),%rcx
cmp    (%rcx),%eax
jge    11e1 <main+0xc1>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1199 <main+0x79>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0xed9(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xec6(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rdx
lea    0x1c(%rsp),%r8
lea    0x8(%rsp),%r9
mov    $0x2,%edi
mov    $0x1,%esi
mov    $0x3,%ecx
call   1040 <reconstructMatrix@plt>
mov    %rax,%r15
mov    0x8(%rsp),%rax
mov    (%rax),%esi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rax
cmpl   $0x0,(%rax)
jle    11b8 <main+0x98>
lea    0xe81(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15),%rax
mov    0x8(%r15),%rcx
mov    (%rax,%rbx,4),%esi
mov    (%rcx,%rbx,4),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
mov    0x8(%rsp),%rax
movslq (%rax),%rax
cmp    %rax,%rbx
jl     1190 <main+0x70>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.col = [3 x i32] [i32 1, i32 1, i32 1]
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast [3 x i32]* %1 to i8*
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32** %3 to i8*
%8 = call i32** @reconstructMatrix(i32 2, i32 1, i32* %5, i32 3, i32* %2, i32** %3)
%9 = load i32*, i32** %3
%10 = load i32, i32* %9
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = getelementptr inbounds i32*, i32** %8, i64 1
br label %18
17: ; preds = %18, %0
ret i32 0
18: ; preds = %15, %18
%19 = phi i64 [ 0, %15 ], [ %27, %18 ]
%20 = load i32*, i32** %8
%21 = getelementptr inbounds i32, i32* %20, i64 %19
%22 = load i32, i32* %21
%23 = load i32*, i32** %16
%24 = getelementptr inbounds i32, i32* %23, i64 %19
%25 = load i32, i32* %24
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %25)
%27 = add nuw nsw i64 %19, 1
%28 = load i32*, i32** %3
%29 = load i32, i32* %28
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %27, %30
br i1 %31, label %18, label %17
}