// File: /workspace/github_cpp_makefile_star2_O3/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 0x8d2c
movq %rsi, %rbx
leaq 0x30(%rdi), %r14
leaq 0xc658(%rip), %rsi      # 0x152b1
movq %rdi, %r15
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
movq %r15, 0x8(%rsp)
je 0x8d83
leaq 0xc626(%rip), %rsi      # 0x1529e
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x9104
leaq 0xc5f3(%rip), %rsi      # 0x15282
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x9291
leaq 0xc57a(%rip), %rsi      # 0x15220
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
movq %r14, 0x10(%rsp)
je 0x934f
leaq 0xc5a3(%rip), %rsi      # 0x15265
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x93d0
leaq 0xc59c(%rip), %rsi      # 0x15275
movq %r14, %rdi
callq 0x2090
movl %eax, %ebp
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12817(%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 0x941e
leaq 0xc641(%rip), %rsi      # 0x1535b
movl $0x4, %edx
movq %rax, %rdi
callq 0x2220
jmp 0x9426
leaq 0x127d5(%rip), %rbx     # 0x1b508
leaq 0xc57f(%rip), %rsi      # 0x152b9
movl $0x5, %edx
movq %rbx, %rdi
callq 0x2220
movq 0x127ba(%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 0x12777(%rip), %rdi     # 0x1b508
callq 0x2220
movq %rax, %r14
leaq 0xc51f(%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 0xc510(%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 0xc507(%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 0xc4a7(%rip), %rsi      # 0x152fa
movl $0xc, %edx
movq %rax, %rdi
callq 0x2220
movq 0x10(%r15), %rax
movq (%rax), %r15
testq %r15, %r15
je 0x8f3b
leaq 0x12691(%rip), %r12     # 0x1b508
leaq 0xc4cc(%rip), %r13      # 0x1534a
leaq 0x30(%r15), %rdi
leaq 0xc38d(%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 0x8ef4
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 0xc41c(%rip), %rsi      # 0x152f7
callq 0x2220
movq 0x8(%r15), %rax
movq 0xc0(%rax), %rsi
movq 0xc8(%rax), %rdx
jmp 0x8efc
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 0x8e7e
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x125bf(%rip), %rdi     # 0x1b508
callq 0x2220
movq %rax, %r14
leaq 0xc3f9(%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 0xc389(%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 0xc37d(%rip), %rsi      # 0x15321
movl $0x19, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
leaq 0xc374(%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 0x3c10
leaq 0xc344(%rip), %rsi      # 0x15348
movq %r14, %rdi
callq 0x2340
leaq 0x58(%rsp), %rsi
movq %r15, %rdi
callq 0x8c31
movq 0x58(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9030
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x124ca(%rip), %rdi     # 0x1b508
callq 0x2220
movq %rax, %r14
leaq 0xc302(%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 0xc2e3(%rip), %rsi      # 0x15356
movl $0x4, %edx
movq %rax, %rdi
callq 0x2220
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq %r14, %rdi
callq 0x2220
leaq 0xc2c2(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
movq 0x20(%rax), %r14
testq %r14, %r14
je 0x95e0
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 0x3c10
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8c31
movq 0xb8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x95e0
movq 0xc8(%rsp), %rsi
jmp 0x95d8
movq 0x8(%rsp), %rax
cmpq $0x0, 0x8(%rax)
je 0x922e
movq (%rax), %rbp
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x123e3(%rip), %r15     # 0x1b508
movq %r15, %rdi
callq 0x2220
movq 0x30(%rbp), %rsi
movq 0x38(%rbp), %rdx
movq %rax, %rdi
callq 0x2220
leaq 0xc22a(%rip), %rsi      # 0x1536e
movl $0x3, %edx
movq %rax, %rdi
callq 0x2220
leaq 0xc1f4(%rip), %r12      # 0x1534c
leaq 0xc198(%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 0x915f
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12301(%rip), %rdi     # 0x1b508
callq 0x2220
leaq 0xc145(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r15
testq %r15, %r15
jne 0x923a
movq (%rax), %r15
testq %r15, %r15
je 0x95e0
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 0x3c10
movq %r15, %rdi
movq %r14, %rsi
callq 0x8c31
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9283
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x21c0
movq 0x20(%r15), %r15
testq %r15, %r15
jne 0x9247
jmp 0x95e0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12269(%rip), %rdi     # 0x1b508
callq 0x2220
movq 0x8(%rsp), %r14
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
movq %rax, %rdi
callq 0x2220
leaq 0xc09b(%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 0x3c10
leaq 0xc055(%rip), %rsi      # 0x1534c
movq %r15, %rdi
callq 0x2340
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x8c31
movq 0x38(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9323
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21c0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x121d7(%rip), %rdi     # 0x1b508
callq 0x2220
leaq 0xc01b(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
jmp 0x95e0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x121ab(%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 0xbf76(%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 0x9426
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x1212a(%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 0xbef5(%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 0xbf12(%rip), %r14      # 0x1534c
movq 0x8(%rsp), %rcx
cmpq $0x0, (%rcx,%r15,8)
je 0x9505
addl $0x2, 0x122bb(%rip)     # 0x1b70c
cmpq $0x2, %r15
jne 0x94a4
movq 0x10(%rsp), %rdi
leaq 0xbdd2(%rip), %rsi      # 0x15235
callq 0x2090
movq 0x8(%rsp), %rcx
testl %eax, %eax
jne 0x94a4
cmpq $0x0, 0x10(%rcx)
je 0x94a4
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x12082(%rip), %rdi     # 0x1b508
callq 0x2220
movl $0x6, %edx
movq %rax, %rdi
leaq 0xbec6(%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 0x3c10
movq %r13, %rdi
movq %r14, %rsi
callq 0x2340
movq %r12, %rdi
movq %r13, %rsi
callq 0x8c31
movq 0x18(%rsp), %rdi
cmpq %rbp, %rdi
je 0x94ec
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x21c0
addl $-0x2, 0x12219(%rip)    # 0x1b70c
incq %r15
cmpq $0x4, %r15
movq 0x8(%rsp), %rcx
jne 0x943f
leaq 0xbd14(%rip), %rsi      # 0x15220
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x956a
leaq 0xbd51(%rip), %rsi      # 0x15275
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x956a
leaq 0xbd2e(%rip), %rsi      # 0x15265
movq %r14, %rdi
callq 0x2090
testl %eax, %eax
je 0x956a
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0x11fb7(%rip), %rdi     # 0x1b508
callq 0x2220
leaq 0xbdfb(%rip), %rsi      # 0x15358
movl $0x2, %edx
movq %rax, %rdi
callq 0x2220
movq 0x8(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0x95e0
leaq 0xbd2d(%rip), %rsi      # 0x152aa
movq %r14, %rdi
callq 0x2090
movq 0x8(%rsp), %rcx
testl %eax, %eax
je 0x95e0
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 0x3c10
movq %r14, %rdi
movq %rbx, %rsi
callq 0x8c31
movq 0x98(%rsp), %rdi
cmpq %rbp, %rdi
je 0x95e0
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 0x9638
jmp 0x9601
movq %rax, %rbx
movq 0x38(%rsp), %rdi
jmp 0x9638
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
jmp 0x9638
jmp 0x961a
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x9638
jmp 0x9626
movq %rax, %rbx
movq 0x18(%rsp), %rdi
jmp 0x9638
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %rbp, %rdi
je 0x9649
movq (%rbp), %rsi
incq %rsi
callq 0x21c0
movq %rbx, %rdi
callq 0x2310