#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 */
struct TreeNode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dfs(struct TreeNode *, int, int *, int /*<<< orphan*/,
                       int **, int *, int *);
void *malloc(int);
int **pathSum(struct TreeNode *root, int sum, int *returnSize,
              int **returnColumnSizes) {
  if (root == NULL) {
    *returnSize = 0;
    return NULL;
  }
  int level = 5000, cap = 1000;
  int *stack = malloc(level * sizeof(int));
  int **results = malloc(cap * sizeof(int *));
  *returnColumnSizes = malloc(cap * sizeof(int));
  dfs(root, sum, stack, 0, results, *returnColumnSizes, returnSize);
  return results;
}


x86 assembly (clang, -O0):
<pathSum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1159 <pathSum+0x39>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    11d3 <pathSum+0xb3>
movl   $0x1388,-0x2c(%rbp)
movl   $0x3e8,-0x30(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x30(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%r8
mov    -0x28(%rbp),%rax
mov    (%rax),%r9
mov    -0x20(%rbp),%rax
xor    %ecx,%ecx
mov    %rax,(%rsp)
call   1040 <dfs@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pathSum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
test   %rdi,%rdi
je     1182 <pathSum+0x62>
mov    %rcx,%r15
mov    %esi,%r14d
mov    %rdi,%rbp
mov    $0x4e20,%edi
call   1030 <malloc@plt>
mov    %rax,%r12
mov    $0x1f40,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    $0xfa0,%edi
call   1030 <malloc@plt>
mov    %rax,(%r15)
mov    %r13,(%rsp)
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    %rax,%r9
call   1040 <dfs@plt>
mov    %rbx,%rax
jmp    118c <pathSum+0x6c>
movl   $0x0,0x0(%r13)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TreeNode = type { i32 }
define i32** @pathSum(%struct.TreeNode* %0, i32 %1, i32* %2, i32** %3) {
%5 = alloca i32**
%6 = alloca %struct.TreeNode*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32**
store %struct.TreeNode* %0, %struct.TreeNode** %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store i32** %3, i32*** %9
%14 = load %struct.TreeNode*, %struct.TreeNode** %6
%15 = icmp eq %struct.TreeNode* %14, null
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = load i32*, i32** %8
store i32 0, i32* %17
store i32** null, i32*** %5
br label %47
18: ; preds = %4
store i32 5000, i32* %10
store i32 1000, i32* %11
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 4
%22 = trunc i64 %21 to i32
%23 = call i8* @malloc(i32 %22)
%24 = bitcast i8* %23 to i32*
store i32* %24, i32** %12
%25 = load i32, i32* %11
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 8
%28 = trunc i64 %27 to i32
%29 = call i8* @malloc(i32 %28)
%30 = bitcast i8* %29 to i32**
store i32** %30, i32*** %13
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 4
%34 = trunc i64 %33 to i32
%35 = call i8* @malloc(i32 %34)
%36 = bitcast i8* %35 to i32*
%37 = load i32**, i32*** %9
store i32* %36, i32** %37
%38 = load %struct.TreeNode*, %struct.TreeNode** %6
%39 = load i32, i32* %7
%40 = load i32*, i32** %12
%41 = load i32**, i32*** %13
%42 = load i32**, i32*** %9
%43 = load i32*, i32** %42
%44 = load i32*, i32** %8
%45 = call i32 @dfs(%struct.TreeNode* %38, i32 %39, i32* %40, i32 0, i32** %41, i32* %43, i32* %44)
%46 = load i32**, i32*** %13
store i32** %46, i32*** %5
br label %47
47: ; preds = %18, %16
%48 = load i32**, i32*** %5
ret i32** %48
}

LLVM IR (-O2):
%struct.TreeNode = type { i32 }
define i32** @pathSum(%struct.TreeNode* %0, i32 %1, i32* %2, i32** nocapture writeonly %3) {
%5 = icmp eq %struct.TreeNode* %0, null
br i1 %5, label %6, label %7
6: ; preds = %4
store i32 0, i32* %2
br label %16
7: ; preds = %4
%8 = tail call dereferenceable_or_null(20000) i8* @malloc(i32 20000)
%9 = bitcast i8* %8 to i32*
%10 = tail call dereferenceable_or_null(8000) i8* @malloc(i32 8000)
%11 = bitcast i8* %10 to i32**
%12 = tail call dereferenceable_or_null(4000) i8* @malloc(i32 4000)
%13 = bitcast i8* %12 to i32*
%14 = bitcast i32** %3 to i8**
store i8* %12, i8** %14
%15 = tail call i32 @dfs(%struct.TreeNode* %0, i32 %1, i32* %9, i32 0, i32** %11, i32* %13, i32* %2)
br label %16
16: ; preds = %7, %6
%17 = phi i32** [ null, %6 ], [ %11, %7 ]
ret i32** %17
}