// File: JameyWoo[P]csmile/parse.cpp
// Function: declaration()
TreeNode* declaration() {
    /**
     * 对声明(函数/变量)的递归下降分析
     */
    TreeNode* t;
    TreeNode* p;
    // cout << ptoken.type << ": " << ptoken.value << endl;
    if (ptoken.type == "int") {
        p = new TreeNode("int");
        match("int");
    } else {
        p = new TreeNode("void");
        match("void");
    }
    if (p != NULL && ptoken.type == "Id") {  // 变量/函数名
        TreeNode* q = new TreeNode("Id");
        q->name     = ptoken.value;
        q->line     = ptoken.line;
        match("Id");
        // TODO: 需要增加数组
        if (ptoken.type == "Semicolon") {  // 检测到分号, 变量声明
            t            = new TreeNode("VarDecl");
            t->child[0]  = p;
            t->child[1]  = q;
            t->child_cnt = 2;  // 记录子节点的个数
            match("Semicolon");
        } else if (ptoken.type == "Assign") {  // 初始化变量并赋值
            match("Assign");
            Token tmp = match("Num");
            match("Semicolon");
            int val      = stoi(tmp.value);
            t            = new TreeNode("VarAssign");
            t->child[0]  = p;
            t->child[1]  = q;
            t->child_cnt = 2;
            q->val       = val;
        } else if (ptoken.type == "LeftBracket") {  // 左括号, 说明是函数
            match("LeftBracket");
            t           = new TreeNode("FunDecl");
            t->child[0] = p;
            t->child[1] = q;
            t->child[2] = params();  // ! 解析函数的参数
            match("RightBracket");
            t->child[3]  = compound_stmt();
            t->child_cnt = 4;
        } else {
            error();
        }
    }
    return t;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5c0, %rsp            # imm = 0x5C0
leaq 0x22466(%rip), %rdi     # 0x2e588
leaq 0x14fcf(%rip), %rsi     # 0x210f8
callq 0x5e70
testb $0x1, %al
jne 0xc137
jmp 0xc296
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x518(%rbp)
movb $0x1, -0x45(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x510(%rbp)
callq 0x3480
movq -0x510(%rbp), %rdx
leaq 0x14f8e(%rip), %rsi     # 0x210f8
leaq -0x30(%rbp), %rdi
callq 0x4ef0
jmp 0xc175
movq -0x518(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xdb50
jmp 0xc187
movq -0x518(%rbp), %rax
movb $0x0, -0x45(%rbp)
movq %rax, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x34e8
leaq -0x31(%rbp), %rdi
callq 0x32d0
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x520(%rbp)
callq 0x3480
movq -0x520(%rbp), %rdx
leaq 0x14f2f(%rip), %rsi     # 0x210f8
leaq -0xb0(%rbp), %rdi
callq 0x4ef0
jmp 0xc1d7
leaq -0x90(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x80b0
jmp 0xc1ec
leaq -0x90(%rbp), %rdi
callq 0x4ec0
leaq -0xb0(%rbp), %rdi
callq 0x34e8
leaq -0xb1(%rbp), %rdi
callq 0x32d0
jmp 0xc413
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc238
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x34e8
leaq -0x31(%rbp), %rdi
callq 0x32d0
testb $0x1, -0x45(%rbp)
jne 0xc249
jmp 0xc25a
movq -0x518(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc285
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x34e8
leaq -0xb1(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x530(%rbp)
movb $0x1, -0xda(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x3480
movq -0x528(%rbp), %rdx
leaq 0x14e2d(%rip), %rsi     # 0x210fc
leaq -0xd8(%rbp), %rdi
callq 0x4ef0
jmp 0xc2dd
movq -0x530(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xdb50
jmp 0xc2f2
movq -0x530(%rbp), %rax
movb $0x0, -0xda(%rbp)
movq %rax, -0x10(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x34e8
leaq -0xd9(%rbp), %rdi
callq 0x32d0
leaq -0x149(%rbp), %rdi
movq %rdi, -0x538(%rbp)
callq 0x3480
movq -0x538(%rbp), %rdx
leaq 0x14dbf(%rip), %rsi     # 0x210fc
leaq -0x148(%rbp), %rdi
callq 0x4ef0
jmp 0xc34b
leaq -0x128(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x80b0
jmp 0xc360
leaq -0x128(%rbp), %rdi
callq 0x4ec0
leaq -0x148(%rbp), %rdi
callq 0x34e8
leaq -0x149(%rbp), %rdi
callq 0x32d0
jmp 0xc413
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc3af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x34e8
leaq -0xd9(%rbp), %rdi
callq 0x32d0
testb $0x1, -0xda(%rbp)
jne 0xc3c6
jmp 0xc3d7
movq -0x530(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc402
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x34e8
leaq -0x149(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
cmpq $0x0, -0x10(%rbp)
je 0xcd72
leaq 0x22163(%rip), %rdi     # 0x2e588
leaq 0x14d80(%rip), %rsi     # 0x211ac
callq 0x5e70
testb $0x1, %al
jne 0xc43a
jmp 0xcd72
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x548(%rbp)
movb $0x1, -0x17a(%rbp)
leaq -0x179(%rbp), %rdi
movq %rdi, -0x540(%rbp)
callq 0x3480
movq -0x540(%rbp), %rdx
leaq 0x14d39(%rip), %rsi     # 0x211ac
leaq -0x178(%rbp), %rdi
callq 0x4ef0
jmp 0xc481
movq -0x548(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0xdb50
jmp 0xc496
movb $0x0, -0x17a(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x34e8
leaq -0x179(%rbp), %rdi
callq 0x32d0
movq -0x548(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rdi
addq $0xc0, %rdi
leaq 0x220d0(%rip), %rsi     # 0x2e5a8
callq 0x3050
movl 0x220e5(%rip), %ecx     # 0x2e5c8
movq -0x158(%rbp), %rax
movl %ecx, 0x50(%rax)
leaq -0x1e9(%rbp), %rdi
movq %rdi, -0x550(%rbp)
callq 0x3480
movq -0x550(%rbp), %rdx
leaq 0x14c9e(%rip), %rsi     # 0x211ac
leaq -0x1e8(%rbp), %rdi
callq 0x4ef0
jmp 0xc51c
leaq -0x1c8(%rbp), %rdi
leaq -0x1e8(%rbp), %rsi
callq 0x80b0
jmp 0xc531
leaq -0x1c8(%rbp), %rdi
callq 0x4ec0
leaq -0x1e8(%rbp), %rdi
callq 0x34e8
leaq -0x1e9(%rbp), %rdi
callq 0x32d0
leaq 0x2202c(%rip), %rdi     # 0x2e588
leaq 0x14b66(%rip), %rsi     # 0x210c9
callq 0x5e70
testb $0x1, %al
jne 0xc571
jmp 0xc79d
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x560(%rbp)
movb $0x1, -0x212(%rbp)
leaq -0x211(%rbp), %rdi
movq %rdi, -0x558(%rbp)
callq 0x3480
movq -0x558(%rbp), %rdx
leaq 0x14c0f(%rip), %rsi     # 0x211b9
leaq -0x210(%rbp), %rdi
callq 0x4ef0
jmp 0xc5b8
movq -0x560(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0xdb50
jmp 0xc5cd
movq -0x560(%rbp), %rax
movb $0x0, -0x212(%rbp)
movq %rax, -0x8(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x34e8
leaq -0x211(%rbp), %rdi
callq 0x32d0
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x158(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl $0x2, 0x28(%rax)
leaq -0x281(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0x3480
movq -0x568(%rbp), %rdx
leaq 0x14a8c(%rip), %rsi     # 0x210c9
leaq -0x280(%rbp), %rdi
callq 0x4ef0
jmp 0xc64b
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x80b0
jmp 0xc660
leaq -0x260(%rbp), %rdi
callq 0x4ec0
leaq -0x280(%rbp), %rdi
callq 0x34e8
leaq -0x281(%rbp), %rdi
callq 0x32d0
jmp 0xcd70
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc6af
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x34e8
leaq -0x179(%rbp), %rdi
callq 0x32d0
testb $0x1, -0x17a(%rbp)
jne 0xc6c6
jmp 0xc6d7
movq -0x548(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc702
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x34e8
leaq -0x1e9(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc739
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x34e8
leaq -0x211(%rbp), %rdi
callq 0x32d0
testb $0x1, -0x212(%rbp)
jne 0xc750
jmp 0xc761
movq -0x560(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc78c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x34e8
leaq -0x281(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
leaq 0x21de4(%rip), %rdi     # 0x2e588
leaq 0x14a83(%rip), %rsi     # 0x2122e
callq 0x5e70
testb $0x1, %al
jne 0xc7b9
jmp 0xcaf0
leaq -0x2f1(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x3480
movq -0x570(%rbp), %rdx
leaq 0x14a54(%rip), %rsi     # 0x2122e
leaq -0x2f0(%rbp), %rdi
callq 0x4ef0
jmp 0xc7e8
leaq -0x2d0(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x80b0
jmp 0xc7fd
leaq -0x2d0(%rbp), %rdi
callq 0x4ec0
leaq -0x2f0(%rbp), %rdi
callq 0x34e8
leaq -0x2f1(%rbp), %rdi
callq 0x32d0
leaq -0x361(%rbp), %rdi
movq %rdi, -0x578(%rbp)
callq 0x3480
movq -0x578(%rbp), %rdx
leaq 0x1484b(%rip), %rsi     # 0x2108d
leaq -0x360(%rbp), %rdi
callq 0x4ef0
jmp 0xc850
leaq -0x340(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x80b0
jmp 0xc865
leaq -0x360(%rbp), %rdi
callq 0x34e8
leaq -0x361(%rbp), %rdi
callq 0x32d0
leaq -0x3d1(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0x3480
movq -0x580(%rbp), %rdx
leaq 0x1482b(%rip), %rsi     # 0x210c9
leaq -0x3d0(%rbp), %rdi
callq 0x4ef0
jmp 0xc8ac
leaq -0x3b0(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x80b0
jmp 0xc8c1
leaq -0x3b0(%rbp), %rdi
callq 0x4ec0
leaq -0x3d0(%rbp), %rdi
callq 0x34e8
leaq -0x3d1(%rbp), %rdi
callq 0x32d0
leaq -0x320(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0xdbf0
movl %eax, -0x584(%rbp)
jmp 0xc902
movl -0x584(%rbp), %eax
movl %eax, -0x3d8(%rbp)
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x590(%rbp)
jmp 0xc921
movb $0x1, -0x3fa(%rbp)
leaq -0x3f9(%rbp), %rdi
movq %rdi, -0x598(%rbp)
callq 0x3480
movq -0x598(%rbp), %rdx
leaq 0x148e2(%rip), %rsi     # 0x2122b
leaq -0x3f8(%rbp), %rdi
callq 0x4ef0
jmp 0xc957
movq -0x590(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0xdb50
jmp 0xc96c
movq -0x590(%rbp), %rax
movb $0x0, -0x3fa(%rbp)
movq %rax, -0x8(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x34e8
leaq -0x3f9(%rbp), %rdi
callq 0x32d0
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x158(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movl $0x2, 0x28(%rax)
movl -0x3d8(%rbp), %ecx
movq -0x158(%rbp), %rax
movl %ecx, 0xb8(%rax)
leaq -0x340(%rbp), %rdi
callq 0x4ec0
jmp 0xcd6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xca05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x34e8
leaq -0x2f1(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xca3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x34e8
leaq -0x361(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xca73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x34e8
leaq -0x3d1(%rbp), %rdi
callq 0x32d0
jmp 0xcadf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcadf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcab5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x3f8(%rbp), %rdi
callq 0x34e8
leaq -0x3f9(%rbp), %rdi
callq 0x32d0
testb $0x1, -0x3fa(%rbp)
jne 0xcacc
jmp 0xcadd
movq -0x590(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xcadf
leaq -0x340(%rbp), %rdi
callq 0x4ec0
jmp 0xcd7f
leaq 0x21a91(%rip), %rdi     # 0x2e588
leaq 0x145b2(%rip), %rsi     # 0x210b0
callq 0x5e70
testb $0x1, %al
jne 0xcb0c
jmp 0xcd67
leaq -0x469(%rbp), %rdi
movq %rdi, -0x5a0(%rbp)
callq 0x3480
movq -0x5a0(%rbp), %rdx
leaq 0x14583(%rip), %rsi     # 0x210b0
leaq -0x468(%rbp), %rdi
callq 0x4ef0
jmp 0xcb3b
leaq -0x448(%rbp), %rdi
leaq -0x468(%rbp), %rsi
callq 0x80b0
jmp 0xcb50
leaq -0x448(%rbp), %rdi
callq 0x4ec0
leaq -0x468(%rbp), %rdi
callq 0x34e8
leaq -0x469(%rbp), %rdi
callq 0x32d0
movl $0xe0, %edi
callq 0x3280
movq %rax, -0x5b0(%rbp)
movb $0x1, -0x492(%rbp)
leaq -0x491(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
callq 0x3480
movq -0x5a8(%rbp), %rdx
leaq 0x14688(%rip), %rsi     # 0x21235
leaq -0x490(%rbp), %rdi
callq 0x4ef0
jmp 0xcbbb
movq -0x5b0(%rbp), %rdi
leaq -0x490(%rbp), %rsi
callq 0xdb50
jmp 0xcbd0
movq -0x5b0(%rbp), %rax
movb $0x0, -0x492(%rbp)
movq %rax, -0x8(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x34e8
leaq -0x491(%rbp), %rdi
callq 0x32d0
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq -0x158(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
callq 0x8910
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
leaq -0x501(%rbp), %rdi
movq %rdi, -0x5b8(%rbp)
callq 0x3480
movq -0x5b8(%rbp), %rdx
leaq 0x14477(%rip), %rsi     # 0x210bc
leaq -0x500(%rbp), %rdi
callq 0x4ef0
jmp 0xcc53
leaq -0x4e0(%rbp), %rdi
leaq -0x500(%rbp), %rsi
callq 0x80b0
jmp 0xcc68
leaq -0x4e0(%rbp), %rdi
callq 0x4ec0
leaq -0x500(%rbp), %rdi
callq 0x34e8
leaq -0x501(%rbp), %rdi
callq 0x32d0
callq 0xbea0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl $0x4, 0x28(%rax)
jmp 0xcd6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xccd2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x468(%rbp), %rdi
callq 0x34e8
leaq -0x469(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcd09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x490(%rbp), %rdi
callq 0x34e8
leaq -0x491(%rbp), %rdi
callq 0x32d0
testb $0x1, -0x492(%rbp)
jne 0xcd20
jmp 0xcd31
movq -0x5b0(%rbp), %rdi
movl $0xe0, %esi
callq 0x3290
jmp 0xcd7f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcd59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x500(%rbp), %rdi
callq 0x34e8
leaq -0x501(%rbp), %rdi
callq 0x32d0
jmp 0xcd7f
callq 0x8040
jmp 0xcd6e
jmp 0xcd70
jmp 0xcd72
movq -0x8(%rbp), %rax
addq $0x5c0, %rsp            # imm = 0x5C0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3470
nopl (%rax,%rax)