#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 pasc_position(int, int);
int *get_row_recursive(int rowIndex, int *returnSize) {
  int pasc_size = rowIndex + 1;
  int *row = (int *)malloc(pasc_size * sizeof(int));
  for (int c = 0; c < pasc_size; c++)
    row[c] = pasc_position(rowIndex, c);
  *returnSize = pasc_size;
  return row;
}


x86 assembly (clang, -O0):
<get_row_recursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1184 <get_row_recursive+0x64>
mov    -0x4(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1040 <pasc_position@plt>
mov    %eax,%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1152 <get_row_recursive+0x32>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_row_recursive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
lea    0x1(%r15),%r13d
lea    0x4(,%r15,4),%edi
call   1030 <malloc@plt>
mov    %rax,%r12
test   %r15d,%r15d
js     1167 <get_row_recursive+0x47>
mov    %r13d,%ebp
xor    %ebx,%ebx
nop
mov    %r15d,%edi
mov    %ebx,%esi
call   1040 <pasc_position@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <get_row_recursive+0x30>
mov    %r13d,(%r14)
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32* @get_row_recursive(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %6
store i32 0, i32* %7
br label %16
16: ; preds = %28, %2
%17 = load i32, i32* %7
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %31
20: ; preds = %16
%21 = load i32, i32* %3
%22 = load i32, i32* %7
%23 = call i32 @pasc_position(i32 %21, i32 %22)
%24 = load i32*, i32** %6
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
store i32 %23, i32* %27
br label %28
28: ; preds = %20
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %16
31: ; preds = %16
%32 = load i32, i32* %5
%33 = load i32*, i32** %4
store i32 %32, i32* %33
%34 = load i32*, i32** %6
ret i32* %34
}

LLVM IR (-O2):
define i32* @get_row_recursive(i32 %0, i32* nocapture writeonly %1) {
%3 = add i32 %0, 1
%4 = shl i32 %3, 2
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to i32*
%7 = icmp slt i32 %0, 0
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = zext i32 %3 to i64
br label %11
10: ; preds = %11, %2
store i32 %3, i32* %1
ret i32* %6
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %16, %11 ]
%13 = trunc i64 %12 to i32
%14 = tail call i32 @pasc_position(i32 %0, i32 %13)
%15 = getelementptr inbounds i32, i32* %6, i64 %12
store i32 %14, i32* %15
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %9
br i1 %17, label %10, label %11
}