#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ traverse(struct TreeNode *, struct TreeNode **, int, char **,
                            int *);
char **binaryTreePaths(struct TreeNode *root, int *returnSize) {
  if (root == NULL)
    return NULL;
  int top = -1;
  struct TreeNode **stack =
      (struct TreeNode **)malloc(sizeof(struct TreeNode *) * 1000);
  stack[++top] = root;
  char **ss = (char **)malloc(sizeof(char *) * 1000);
  traverse(root, stack, top, ss, returnSize);
  return ss;
}


x86 assembly (clang, -O0):
<binaryTreePaths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1148 <binaryTreePaths+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11a3 <binaryTreePaths+0x83>
movl   $0xffffffff,-0x1c(%rbp)
mov    $0x1f40,%edi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x1f40,%edi
call   1040 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%r8
call   1030 <traverse@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binaryTreePaths>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1165 <binaryTreePaths+0x45>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1f40,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rbx,(%rax)
mov    $0x1f40,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %edx,%edx
mov    %rax,%rcx
mov    %r14,%r8
call   1030 <traverse@plt>
jmp    1168 <binaryTreePaths+0x48>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TreeNode = type { i32 }
define i8** @binaryTreePaths(%struct.TreeNode* %0, i32* %1) {
%3 = alloca i8**
%4 = alloca %struct.TreeNode*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.TreeNode**
%8 = alloca i8**
store %struct.TreeNode* %0, %struct.TreeNode** %4
store i32* %1, i32** %5
%9 = load %struct.TreeNode*, %struct.TreeNode** %4
%10 = icmp eq %struct.TreeNode* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i8** null, i8*** %3
br label %30
12: ; preds = %2
store i32 -1, i32* %6
%13 = call i64 @malloc(i32 8000)
%14 = inttoptr i64 %13 to %struct.TreeNode**
store %struct.TreeNode** %14, %struct.TreeNode*** %7
%15 = load %struct.TreeNode*, %struct.TreeNode** %4
%16 = load %struct.TreeNode**, %struct.TreeNode*** %7
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds %struct.TreeNode*, %struct.TreeNode** %16, i64 %19
store %struct.TreeNode* %15, %struct.TreeNode** %20
%21 = call i64 @malloc(i32 8000)
%22 = inttoptr i64 %21 to i8**
store i8** %22, i8*** %8
%23 = load %struct.TreeNode*, %struct.TreeNode** %4
%24 = load %struct.TreeNode**, %struct.TreeNode*** %7
%25 = load i32, i32* %6
%26 = load i8**, i8*** %8
%27 = load i32*, i32** %5
%28 = call i32 @traverse(%struct.TreeNode* %23, %struct.TreeNode** %24, i32 %25, i8** %26, i32* %27)
%29 = load i8**, i8*** %8
store i8** %29, i8*** %3
br label %30
30: ; preds = %12, %11
%31 = load i8**, i8*** %3
ret i8** %31
}

LLVM IR (-O2):
%struct.TreeNode = type { i32 }
define i8** @binaryTreePaths(%struct.TreeNode* %0, i32* %1) {
%3 = icmp eq %struct.TreeNode* %0, null
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = tail call i64 @malloc(i32 8000)
%6 = inttoptr i64 %5 to %struct.TreeNode**
store %struct.TreeNode* %0, %struct.TreeNode** %6
%7 = tail call i64 @malloc(i32 8000)
%8 = inttoptr i64 %7 to i8**
%9 = tail call i32 @traverse(%struct.TreeNode* %0, %struct.TreeNode** %6, i32 0, i8** %8, i32* %1)
br label %10
10: ; preds = %2, %4
%11 = phi i8** [ %8, %4 ], [ null, %2 ]
ret i8** %11
}