// File: JameyWoo[P]csmile/analyze.cpp
// Function: insertNode(TreeNode*)
static void insertNode(TreeNode *t) {
    if (t->nodekind == "FunDecl") {
        // 新的函数, 新的作用域
        newSymtabs();
        fun_names.push_back(t->child[1]->name);
        if (t->child[0]->nodekind == "int") {
            t->type                              = "Integer";
            fun_name2ret_type[t->child[1]->name] = "Integer";
        } else if (t->child[0]->nodekind == "void") {
            t->type                              = "Void";
            fun_name2ret_type[t->child[1]->name] = "Void";
        }
    }
    // 调用类型. 需要查符号表来赋值
    if (t->nodekind == "Call") {
        // t->nodekind =
        t->type = fun_name2ret_type[t->child[0]->name];
    }
    if (t->nodekind == "LocVarDecl") {  // 局部变量声明
        // 声明地时候只在符号表中添加, 检测到Id地时候才添加行号
        if (st_lookup(t->child[1]->name) == -1) {  // 符号表里没有
            st_insert(t->child[1]->name, -1, location++, 2);
        } else {
            // 符号表里有
            error("line " + to_string(t->child[1]->line) + " : 局部变量声明错误...");
            isError++;
        }
    } else if (t->nodekind == "ParamId") {
        // 作为参数地Id
        if (st_lookup(t->name) == -1) {  // 符号表里没有
            st_insert(t->name, t->line, location++, 1);
        } else {
            // 符号表里有
            error("line " + to_string(t->line) + " : 参数变量声明错误...");
            isError++;
        }
    } else if (t->nodekind == "Id") {
        if (st_lookup(t->name) == -1) {  // 符号表里没有
            st_insert(t->name, t->line, location++, 3);
        } else {
            // 符号表里有
            st_insert(t->name, t->line, -1, 3);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x220, %rsp            # imm = 0x220
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x13247(%rip), %rsi     # 0x21235
callq 0x5e70
testb $0x1, %al
jne 0xdffc
jmp 0xe0d8
callq 0x108b0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc0, %rsi
leaq 0x209d1(%rip), %rdi     # 0x2e9e8
callq 0x5db0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
leaq 0x130ca(%rip), %rsi     # 0x210f8
callq 0x5e70
testb $0x1, %al
jne 0xe039
jmp 0xe079
movq -0x8(%rbp), %rdi
addq $0x78, %rdi
leaq 0x133e1(%rip), %rsi     # 0x21429
callq 0x33a0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc0, %rsi
leaq 0x2099d(%rip), %rdi     # 0x2ea00
callq 0xf2e0
movq %rax, %rdi
leaq 0x133b7(%rip), %rsi     # 0x21429
callq 0x33a0
jmp 0xe0d6
movq -0x8(%rbp), %rax
movq (%rax), %rdi
addq $0x30, %rdi
leaq 0x13071(%rip), %rsi     # 0x210fc
callq 0x5e70
testb $0x1, %al
jne 0xe096
jmp 0xe0d4
movq -0x8(%rbp), %rdi
addq $0x78, %rdi
leaq 0x1338c(%rip), %rsi     # 0x21431
callq 0x33a0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc0, %rsi
leaq 0x20940(%rip), %rdi     # 0x2ea00
callq 0xf2e0
movq %rax, %rdi
leaq 0x13362(%rip), %rsi     # 0x21431
callq 0x33a0
jmp 0xe0d6
jmp 0xe0d8
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x130f3(%rip), %rsi     # 0x211da
callq 0x5e70
testb $0x1, %al
jne 0xe0f2
jmp 0xe11c
movq -0x8(%rbp), %rax
movq (%rax), %rsi
addq $0xc0, %rsi
leaq 0x208f9(%rip), %rdi     # 0x2ea00
callq 0xf2e0
movq %rax, %rsi
movq -0x8(%rbp), %rdi
addq $0x78, %rdi
callq 0x3050
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x1308b(%rip), %rsi     # 0x211b6
callq 0x5e70
testb $0x1, %al
jne 0xe139
jmp 0xe2f0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc0, %rsi
leaq -0x28(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x3120
movq -0x1c8(%rbp), %rdi
callq 0x108f0
movl %eax, -0x1bc(%rbp)
jmp 0xe16c
leaq -0x28(%rbp), %rdi
callq 0x34e8
movl -0x1bc(%rbp), %eax
cmpl $-0x1, %eax
jne 0xe20d
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0xc0, %rsi
leaq -0x58(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x3120
movq -0x1d0(%rbp), %rdi
movl 0x20880(%rip), %edx     # 0x2ea30
movl %edx, %eax
incl %eax
movl %eax, 0x20876(%rip)     # 0x2ea30
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x2, %ecx
callq 0x10940
jmp 0xe1cb
leaq -0x58(%rbp), %rdi
callq 0x34e8
jmp 0xe2eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x34e8
jmp 0xe646
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x34e8
jmp 0xe646
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x50(%rax), %esi
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0xf460
movq -0x1d8(%rbp), %rdx
leaq 0x131fd(%rip), %rsi     # 0x21436
leaq -0x98(%rbp), %rdi
callq 0xf410
jmp 0xe247
leaq 0x131ee(%rip), %rdx     # 0x2143c
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0xf3c0
jmp 0xe260
leaq -0x78(%rbp), %rdi
callq 0x11010
jmp 0xe26b
leaq -0x78(%rbp), %rdi
callq 0x34e8
leaq -0x98(%rbp), %rdi
callq 0x34e8
leaq -0xb8(%rbp), %rdi
callq 0x34e8
movl 0x2074e(%rip), %eax     # 0x2e9e0
addl $0x1, %eax
movl %eax, 0x20745(%rip)     # 0x2e9e0
jmp 0xe2eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xe2da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xe2ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x34e8
leaq -0x98(%rbp), %rdi
callq 0x34e8
leaq -0xb8(%rbp), %rdi
callq 0x34e8
jmp 0xe646
jmp 0xe63d
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x12ea8(%rip), %rsi     # 0x211a7
callq 0x5e70
testb $0x1, %al
jne 0xe30d
jmp 0xe4d8
movq -0x8(%rbp), %rsi
addq $0xc0, %rsi
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x3120
movq -0x1e8(%rbp), %rdi
callq 0x108f0
movl %eax, -0x1dc(%rbp)
jmp 0xe33f
leaq -0xd8(%rbp), %rdi
callq 0x34e8
movl -0x1dc(%rbp), %eax
cmpl $-0x1, %eax
jne 0xe3ed
movq -0x8(%rbp), %rsi
addq $0xc0, %rsi
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x3120
movq -0x1f0(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
movl 0x206a4(%rip), %edx     # 0x2ea30
movl %edx, %eax
incl %eax
movl %eax, 0x2069a(%rip)     # 0x2ea30
movl $0x1, %ecx
callq 0x10940
jmp 0xe3a2
leaq -0xf8(%rbp), %rdi
callq 0x34e8
jmp 0xe4d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x34e8
jmp 0xe646
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x34e8
jmp 0xe646
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
leaq -0x158(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0xf460
movq -0x1f8(%rbp), %rdx
leaq 0x13021(%rip), %rsi     # 0x21436
leaq -0x138(%rbp), %rdi
callq 0xf410
jmp 0xe423
leaq 0x13031(%rip), %rdx     # 0x2145b
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xf3c0
jmp 0xe43f
leaq -0x118(%rbp), %rdi
callq 0x11010
jmp 0xe44d
leaq -0x118(%rbp), %rdi
callq 0x34e8
leaq -0x138(%rbp), %rdi
callq 0x34e8
leaq -0x158(%rbp), %rdi
callq 0x34e8
movl 0x20569(%rip), %eax     # 0x2e9e0
addl $0x1, %eax
movl %eax, 0x20560(%rip)     # 0x2e9e0
jmp 0xe4d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xe4c2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0xe4b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x34e8
leaq -0x138(%rbp), %rdi
callq 0x34e8
leaq -0x158(%rbp), %rdi
callq 0x34e8
jmp 0xe646
jmp 0xe63b
movq -0x8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x12cc5(%rip), %rsi     # 0x211ac
callq 0x5e70
testb $0x1, %al
jne 0xe4f5
jmp 0xe639
movq -0x8(%rbp), %rsi
addq $0xc0, %rsi
leaq -0x178(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x3120
movq -0x208(%rbp), %rdi
callq 0x108f0
movl %eax, -0x1fc(%rbp)
jmp 0xe527
leaq -0x178(%rbp), %rdi
callq 0x34e8
movl -0x1fc(%rbp), %eax
cmpl $-0x1, %eax
jne 0xe5d2
movq -0x8(%rbp), %rsi
addq $0xc0, %rsi
leaq -0x198(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x3120
movq -0x210(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
movl 0x204bc(%rip), %edx     # 0x2ea30
movl %edx, %eax
incl %eax
movl %eax, 0x204b2(%rip)     # 0x2ea30
movl $0x3, %ecx
callq 0x10940
jmp 0xe58a
leaq -0x198(%rbp), %rdi
callq 0x34e8
jmp 0xe637
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x34e8
jmp 0xe646
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x34e8
jmp 0xe646
movq -0x8(%rbp), %rsi
addq $0xc0, %rsi
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x3120
movq -0x218(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x50(%rax), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x3, %ecx
callq 0x10940
jmp 0xe60f
leaq -0x1b8(%rbp), %rdi
callq 0x34e8
jmp 0xe637
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x34e8
jmp 0xe646
jmp 0xe639
jmp 0xe63b
jmp 0xe63d
addq $0x220, %rsp            # imm = 0x220
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x3470
nop