#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int **generate(int, int *, int **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: ./test n\n");
    exit(-1);
  }
  int i, j, count, *col_sizes;
  int row = atoi(argv[1]);
  int **triangle = generate(row, &count, &col_sizes);
  for (i = 0; i < row; i++) {
    for (j = 0; j < col_sizes[i]; j++) {
      printf("%d ", triangle[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     118f <main+0x3f>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x1c(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1070 <generate@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    122c <main+0xdc>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x28(%rbp),%rcx
movslq -0x14(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1210 <main+0xc0>
mov    -0x38(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11cd <main+0x7d>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ba <main+0x6a>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1203 <main+0xa3>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
lea    0xc(%rsp),%rsi
mov    %rsp,%rdx
mov    %eax,%edi
call   1080 <generate@plt>
test   %ebp,%ebp
jle    11f4 <main+0x94>
mov    %rax,%r12
mov    %ebp,%r15d
lea    0xe71(%rip),%r14
xor    %ebp,%ebp
jmp    11c3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %r15,%rbp
je     11f4 <main+0x94>
mov    (%rsp),%rax
cmpl   $0x0,(%rax,%rbp,4)
jle    11b0 <main+0x50>
xor    %ebx,%ebx
nop
mov    (%r12,%rbp,8),%rax
mov    (%rax,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
mov    (%rsp),%rax
movslq (%rax,%rbp,4),%rax
cmp    %rax,%rbx
jl     11d0 <main+0x70>
jmp    11b0 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Usage: ./test n\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = call i32** @generate(i32 %23, i32* %8, i32** %9)
store i32** %24, i32*** %11
store i32 0, i32* %6
br label %25
25: ; preds = %54, %18
%26 = load i32, i32* %6
%27 = load i32, i32* %10
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %57
29: ; preds = %25
store i32 0, i32* %7
br label %30
30: ; preds = %49, %29
%31 = load i32, i32* %7
%32 = load i32*, i32** %9
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = icmp slt i32 %31, %36
br i1 %37, label %38, label %52
38: ; preds = %30
%39 = load i32**, i32*** %11
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32*, i32** %39, i64 %41
%43 = load i32*, i32** %42
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %38
%50 = load i32, i32* %7
%51 = add nsw i32 %50, 1
store i32 %51, i32* %7
br label %30
52: ; preds = %30
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %25
57: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Usage: ./test n\0A\00"
@.str.1 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = icmp eq i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32** %4 to i8*
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = call i32** @generate(i32 %15, i32* %3, i32** %4)
%17 = icmp sgt i32 %15, 0
br i1 %17, label %18, label %44
18: ; preds = %10
%19 = zext i32 %15 to i64
br label %20
20: ; preds = %18, %40
%21 = phi i64 [ 0, %18 ], [ %42, %40 ]
%22 = load i32*, i32** %4
%23 = getelementptr inbounds i32, i32* %22, i64 %21
%24 = load i32, i32* %23
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %40
26: ; preds = %20
%27 = getelementptr inbounds i32*, i32** %16, i64 %21
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ 0, %26 ], [ %34, %28 ]
%30 = load i32*, i32** %27
%31 = getelementptr inbounds i32, i32* %30, i64 %29
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %29, 1
%35 = load i32*, i32** %4
%36 = getelementptr inbounds i32, i32* %35, i64 %21
%37 = load i32, i32* %36
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %34, %38
br i1 %39, label %28, label %40
40: ; preds = %28, %20
%41 = call i32 @putchar(i32 10)
%42 = add nuw nsw i64 %21, 1
%43 = icmp eq i64 %42, %19
br i1 %43, label %44, label %20
44: ; preds = %40, %10
ret i32 0
}