// File: /workspace/github_cpp_makefile_star2_O1/JameyWoo[P]csmile/parse.cpp
// Function: preOrder(TreeNode*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void preOrder(TreeNode* t, string indent) {
    // if (t != NULL)
    //     out << "t->nodekind = " << t->nodekind << endl;
    if (t == NULL) {
        out << "NULL!" << endl;
        return;
    }
    if (t->nodekind == "FunDecl") {
        out << indent << "FunctionDeclaration {\n"
            << indent << "  type: FunctionDeclaration\n"
            << indent << "  id: " << t->child[1]->name << endl
            << indent << "  params: [\n";
        TreeNode* param = t->child[2]->child[0];
        while (param != NULL) {
            if (param->nodekind == "void") {
                out << indent << "    " << param->nodekind << endl;
            } else {
                out << indent << "    " << param->child[0]->nodekind << ": " << param->child[1]->name << endl;
            }
            param = param->sibling;
        }
        out << indent << "  ]\n"
            << indent << "  body: BlockStatement {\n"
            << indent << "    type: BlockStatement\n"
            << indent << "    body: [\n";
        preOrder(t->child[3], indent + "      ");
        out << indent << "    ]\n"
            << indent << "  }\n"
            << indent << "}\n";
        if (t->sibling != NULL) preOrder(t->sibling, indent);
        return;
    }
    if (t->nodekind == "Compound") {
        if (t->child[1] != NULL) {
            TreeNode* loc = t->child[0];
            out << indent << loc->nodekind << ":{\n";
            while (loc != NULL) {
                out << indent << "  " << loc->child[0]->nodekind << ": " << loc->child[1]->name << endl;
                loc = loc->sibling;
            }
            out << indent << "}\n";
        }
        TreeNode* stmt = NULL;
        if (t->child[1] == NULL) {
            stmt = t->child[0];
        } else
            stmt = t->child[1];
        while (stmt != NULL) {
            preOrder(stmt, indent);
            stmt = stmt->sibling;
        }
        return;
    }
    if (t->nodekind == "ReturnStmt") {
        out << indent << t->nodekind << ": {\n";
        preOrder(t->child[0], indent + "  ");
        out << indent << "}\n";
        return;
    }
    if (t->nodekind == "Id") {
        out << indent << t->nodekind << ": " << t->name << endl;
    } else if (t->nodekind == "Const") {
        out << indent << t->nodekind << ": " << t->val << endl;
    } else if (t->nodekind != "Input") {
        out << indent << t->nodekind << ": {\n";
    } else {  // ReturnStmt 会出现在这里输出
        out << indent << t->nodekind << endl;
    }

    for (int i = 0; i < MAX_CHILDREN; ++i) {
        // out << "i = " << i << endl;
        if (t->child[i] == NULL) break;
        blank += 2;
        if (i == 2 && t->nodekind == "Selection") {
            if (t->child[2] != NULL) {
                out << indent << "Else:\n";
            }
        }
        preOrder(t->child[i], indent + "  ");
        blank -= 2;
    }
    if (t->nodekind != "Id" && t->nodekind != "Input" && t->nodekind != "Const") {
        out << indent << "}\n";
    }
    // Assign 的sibling会重复
    // out << "t->nodekind = " << t->nodekind << endl;
    if (t->sibling != NULL) {
        if (t->nodekind != "Assign") {
            preOrder(t->sibling, indent);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
testq %rdi, %rdi
je 0x8dab
movq %rsi, %rbx
leaq 0x30(%rdi), %r14
leaq 0xc5d9(%rip), %rsi      # 0x152b1
movq %rdi, %r15
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
movq %r15, 0x8(%rsp)
je 0x8e02
leaq 0xc5a7(%rip), %rsi      # 0x1529e
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x9183
leaq 0xc574(%rip), %rsi      # 0x15282
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x931d
leaq 0xc4fb(%rip), %rsi      # 0x15220
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
movq %r14, 0x10(%rsp)
je 0x93db
leaq 0xc524(%rip), %rsi      # 0x15265
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x945c
leaq 0xc51d(%rip), %rsi      # 0x15275
movq %r14, %rdi
callq 0x2090
movl %eax, %ebp
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12798(%rip), %rdi     # 0x1b508
callq 0x2220
movq 0x8(%rsp), %rcx
movq 0x30(%rcx), %rsi
movq 0x38(%rcx), %rdx
movq %rax, %rdi
callq 0x2220
testl %ebp, %ebp
je 0x94aa
leaq 0xc5c2(%rip), %rsi      # 0x1535b
movl $0x4, %edx
movq %rax, %rdi
callq 0x2220
jmp 0x94b2
leaq 0x12756(%rip), %rbx     # 0x1b508
leaq 0xc500(%rip), %rsi      # 0x152b9
movl $0x5, %edx
movq %rbx, %rdi
callq 0x2220
movq 0x1273b(%rip), %rax     # 0x1b508
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2120
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x126f8(%rip), %rdi     # 0x1b508
callq 0x2220
movq %rax, %r14
leaq 0xc4a0(%rip), %rsi      # 0x152bf
movl $0x16, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xc491(%rip), %rsi      # 0x152d6
movl $0x1c, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xc488(%rip), %rsi      # 0x152f3
movl $0x6, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%r15), %rax
movq 0xc0(%rax), %rsi
movq 0xc8(%rax), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %rax, %rdi
callq 0x2220
leaq 0xc428(%rip), %rsi      # 0x152fa
movl $0xc, %edx
movq %rax, %rdi
callq 0x2220
movq 0x10(%r15), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x8fba
leaq 0x12612(%rip), %r12     # 0x1b508
leaq 0xc44d(%rip), %r13      # 0x1534a
leaq 0x30(%r15), %rdi
leaq 0xc30e(%rip), %rsi      # 0x15216
callq 0x2090
movl %eax, %ebp
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r12, %rdi
callq 0x2220
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2220
testl %ebp, %ebp
je 0x8f73
movq (%r15), %rax
movq 0x30(%rax), %rsi
movq 0x38(%rax), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
leaq 0xc39d(%rip), %rsi      # 0x152f7
callq 0x2220
movq 0x8(%r15), %rax
movq 0xc0(%rax), %rsi
movq 0xc8(%rax), %rdx
jmp 0x8f7b
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x20(%r15), %r15
testq %r15, %r15
jne 0x8efd
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12540(%rip), %rdi     # 0x1b508
callq 0x2220
movq %rax, %r14
leaq 0xc37a(%rip), %rsi      # 0x15351
movl $0x4, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xc30a(%rip), %rsi      # 0x15307
movl $0x19, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xc2fe(%rip), %rsi      # 0x15321
movl $0x19, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
leaq 0xc2f5(%rip), %rsi      # 0x1533b
movl $0xc, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
movq 0x18(%rax), %r15
leaq 0x68(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r14
movq %r14, %rdi
callq 0x3c5c
leaq 0xc2c5(%rip), %rsi      # 0x15348
movq %r14, %rdi
callq 0x2340
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x8cb0
movq 0x58(%rsp), %rdi
cmpq %rbp, %rdi
je 0x90af
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x1244b(%rip), %rdi     # 0x1b508
callq 0x2220
movq %rax, %r14
leaq 0xc283(%rip), %rsi      # 0x1534f
movl $0x6, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xc264(%rip), %rsi      # 0x15356
movl $0x4, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
leaq 0xc243(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r14
testq %r14, %r14
je 0x966c
leaq 0xc8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
callq 0x3c5c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8cb0
movq 0xb8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x966c
movq 0xc8(%rsp), %rsi
jmp 0x9664
movq 0x8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x92b1
movq (%rax), %rbp
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12364(%rip), %rdi     # 0x1b508
callq 0x2220
movq 0x30(%rbp), %rsi
movq 0x38(%rbp), %rdx
movq %rax, %rdi
callq 0x2220
leaq 0xc1ae(%rip), %rsi      # 0x1536e
movl $0x3, %edx
movq %rax, %rdi
callq 0x2220
testq %rbp, %rbp
je 0x9285
leaq 0x1232b(%rip), %r15     # 0x1b508
leaq 0xc168(%rip), %r12      # 0x1534c
leaq 0xc10c(%rip), %r13      # 0x152f7
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r15, %rdi
callq 0x2220
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2220
movq (%rbp), %rax
movq 0x30(%rax), %rsi
movq 0x38(%rax), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
movl $0x2, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x2220
movq 0x8(%rbp), %rax
movq 0xc0(%rax), %rsi
movq 0xc8(%rax), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq 0x20(%rbp), %rbp
testq %rbp, %rbp
jne 0x91eb
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12275(%rip), %rdi     # 0x1b508
callq 0x2220
leaq 0xc0b9(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r15
testq %r15, %r15
jne 0x92bd
movq (%rax), %r15
testq %r15, %r15
je 0x966c
leaq 0x88(%rsp), %rbp
leaq 0x78(%rsp), %r14
movq %rbp, 0x78(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x3c5c
movq %r15, %rdi
movq %r14, %rsi
callq 0x8cb0
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x930f
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x20(%r15), %r15
testq %r15, %r15
jne 0x92d3
jmp 0x966c
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x121dd(%rip), %rdi     # 0x1b508
callq 0x2220
movq 0x8(%rsp), %r14
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
movq %rax, %rdi
callq 0x2220
leaq 0xc00f(%rip), %rsi      # 0x1535b
movl $0x4, %edx
movq %rax, %rdi
callq 0x2220
movq (%r14), %r14
leaq 0x48(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x3c5c
leaq 0xbfc9(%rip), %rsi      # 0x1534c
movq %r15, %rdi
callq 0x2340
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x8cb0
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x93af
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x1214b(%rip), %rdi     # 0x1b508
callq 0x2220
leaq 0xbf8f(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
jmp 0x966c
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x1211f(%rip), %rdi     # 0x1b508
callq 0x2220
movq 0x8(%rsp), %r15
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %rax, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xbeea(%rip), %rsi      # 0x152f7
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0xc0(%r15), %rsi
movq 0xc8(%r15), %rdx
movq %r14, %rdi
callq 0x2220
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
jmp 0x94b2
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x1209e(%rip), %rdi     # 0x1b508
callq 0x2220
movq 0x8(%rsp), %r15
movq 0x30(%r15), %rsi
movq 0x38(%r15), %rdx
movq %rax, %rdi
callq 0x2220
movq %rax, %r14
leaq 0xbe69(%rip), %rsi      # 0x152f7
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movl 0xb8(%r15), %esi
movq %r14, %rdi
callq 0x2300
movq %rax, %rdi
callq 0x20e0
leaq 0x28(%rsp), %rbp
xorl %r15d, %r15d
leaq 0x18(%rsp), %r13
leaq 0xbe86(%rip), %r14      # 0x1534c
movq 0x8(%rsp), %rcx
cmpq $0x0, (%rcx,%r15,8)
je 0x9591
addl $0x2, 0x1222f(%rip)     # 0x1b70c
cmpq $0x2, %r15
jne 0x9530
movq 0x10(%rsp), %rdi
leaq 0xbd46(%rip), %rsi      # 0x15235
callq 0x2090
movq 0x8(%rsp), %rcx
testl %eax, %eax
jne 0x9530
cmpq $0x0, 0x10(%rcx)
je 0x9530
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x11ff6(%rip), %rdi     # 0x1b508
callq 0x2220
movl $0x6, %edx
movq %rax, %rdi
leaq 0xbe3a(%rip), %rsi      # 0x15360
callq 0x2220
movq 0x8(%rsp), %rcx
movq (%rcx,%r15,8), %r12
movq %rbp, 0x18(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3c5c
movq %r13, %rdi
movq %r14, %rsi
callq 0x2340
movq %r12, %rdi
movq %r13, %rsi
callq 0x8cb0
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9578
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21c0
addl $-0x2, 0x1218d(%rip)    # 0x1b70c
incq %r15
cmpq $0x4, %r15
movq 0x8(%rsp), %rcx
jne 0x94cb
leaq 0xbc88(%rip), %rsi      # 0x15220
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x95f6
leaq 0xbcc5(%rip), %rsi      # 0x15275
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x95f6
leaq 0xbca2(%rip), %rsi      # 0x15265
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x95f6
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x11f2b(%rip), %rdi     # 0x1b508
callq 0x2220
leaq 0xbd6f(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0x966c
leaq 0xbca1(%rip), %rsi      # 0x152aa
movq %r14, %rdi
callq 0x2090
movq 0x8(%rsp), %rcx
testl %eax, %eax
je 0x966c
movq 0x20(%rcx), %r14
leaq 0xa8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
callq 0x3c5c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8cb0
movq 0x98(%rsp), %rdi
cmpq %rbp, %rdi
je 0x966c
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x21c0
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x98(%rsp), %rdi
jmp 0x96c4
jmp 0x968d
movq %rax, %rbx
movq 0x38(%rsp), %rdi
jmp 0x96c4
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
jmp 0x96c4
jmp 0x96a6
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x96c4
jmp 0x96b2
movq %rax, %rbx
movq 0x18(%rsp), %rdi
jmp 0x96c4
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x96d5
movq (%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2310