// File: /workspace/github_cpp_makefile_star2_O2/JameyWoo[P]csmile/analyze.cpp
// Function: checkNode(TreeNode*)
static void checkNode(TreeNode *t) {
    // symtabOut << t->nodekind << endl;
    // 添加对函数类型的生成
    // 由于是后序遍历, 函数的类型是最后检查的...
    if (t->nodekind == "FunDecl") {
        // error("func...");
        if (t->child[0]->nodekind == "int")
            t->type = "Integer";
        else if (t->child[0]->nodekind == "void")
            t->type = "Void";
    } else if (t->nodekind == "Id") {
        t->type = "Integer";
    } else if (t->nodekind == "CompareOp") {
        t->type = "Boolean";
    } else if (t->nodekind == "Const") {
        t->type = "Integer";
    } else if (t->nodekind == "MDOp") {
        if (t->child[0]->type == "Integer" && t->child[1]->type == "Integer") {
            t->type = "Integer";
        } else {
            typeError++;
            error("乘除类型错误");
        }
    } else if (t->nodekind == "PMOp") {
        if (t->child[0]->type == "Integer" && t->child[1]->type == "Integer") {
            t->type = "Integer";
        } else {
            typeError++;
            error("加减类型错误");
        }
    } else if (t->nodekind == "Input") {
        t->type = "Integer";
    }

    // 语句的类型判断
    if (t->nodekind == "Selection") {
        // if 选择
        if (t->child[0]->type != "Boolean") {
            typeError++;
            error("if 类型错误");
        } else {
            // symtabOut << "match" << endl;
        }
    } else if (t->nodekind == "Iteration") {
        // while 迭代
        if (t->child[0]->type != "Boolean") {
            typeError++;
            error("while 类型错误");
        }
    } else if (t->nodekind == "Assign") {
        if (t->child[1]->type != "Integer") {
            error("t->child[1]->nodekind" + t->child[1]->nodekind);
            if (t->child[1]->nodekind != "FunDecl") {
                typeError++;
                error("line " + to_string(t->line) + ": 赋值类型错误");
            }
        } else {
            t->type = "Integer";
        }
    }
    // symtabOut << "t->type = " << t->type << endl;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
leaq 0x30(%rdi), %r14
leaq 0x7b34(%rip), %rsi      # 0xf2b1
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x77c4
movq (%rbx), %rdi
addq $0x30, %rdi
leaq 0x79dd(%rip), %rsi      # 0xf174
callq 0x368e
testb %al, %al
jne 0x77db
movq (%rbx), %rdi
addq $0x30, %rdi
leaq 0x79ca(%rip), %rsi      # 0xf178
callq 0x368e
testb %al, %al
je 0x77eb
leaq 0x78(%rbx), %rdi
leaq 0x7ceb(%rip), %rsi      # 0xf4ad
jmp 0x77e6
leaq 0x7a5d(%rip), %rsi      # 0xf228
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x78a9
leaq 0x78(%rbx), %rdi
leaq 0x7cbf(%rip), %rsi      # 0xf4a5
callq 0x2330
leaq 0x7a4b(%rip), %rsi      # 0xf23d
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x7846
movq (%rbx), %rdi
addq $0x78, %rdi
leaq 0x7cea(%rip), %rsi      # 0xf4f6
callq 0x7005
testb %al, %al
je 0x7a6e
incl 0xf0fd(%rip)            # 0x1691c
leaq 0x7cfe(%rip), %rsi      # 0xf524
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2efc
leaq 0x68(%rsp), %rdi
callq 0x85ae
leaq 0x68(%rsp), %rdi
jmp 0x789f
leaq 0x79fa(%rip), %rsi      # 0xf247
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x78d0
movq (%rbx), %rdi
addq $0x78, %rdi
leaq 0x7c8f(%rip), %rsi      # 0xf4f6
callq 0x7005
testb %al, %al
je 0x7a6e
incl 0xf0a2(%rip)            # 0x1691c
leaq 0x7cb3(%rip), %rsi      # 0xf534
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2efc
leaq 0x48(%rsp), %rdi
callq 0x85ae
leaq 0x48(%rsp), %rdi
callq 0x2358
jmp 0x7a6e
leaq 0x785d(%rip), %rsi      # 0xf10d
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x79c1
leaq 0x78(%rbx), %rdi
leaq 0x7c2b(%rip), %rsi      # 0xf4f6
jmp 0x77e6
leaq 0x79d3(%rip), %rsi      # 0xf2aa
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x7a6e
movq 0x8(%rbx), %rdi
addq $0x78, %rdi
leaq 0x7baf(%rip), %rsi      # 0xf4a5
callq 0x7005
testb %al, %al
je 0x7a5b
movq 0x8(%rbx), %rdx
addq $0x30, %rdx
leaq 0x7c35(%rip), %rsi      # 0xf547
leaq 0xe8(%rsp), %r14
movq %r14, %rdi
callq 0x8177
movq %r14, %rdi
callq 0x85ae
leaq 0xe8(%rsp), %rdi
callq 0x2358
movq 0x8(%rbx), %rdi
addq $0x30, %rdi
leaq 0x796b(%rip), %rsi      # 0xf2b1
callq 0x7005
testb %al, %al
je 0x7a6e
incl 0xefc3(%rip)            # 0x1691c
movl 0x50(%rbx), %esi
leaq 0xc8(%rsp), %rbx
movq %rbx, %rdi
callq 0x7cbf
leaq 0x7b3f(%rip), %rsi      # 0xf4b2
leaq 0x8(%rsp), %rdi
movq %rbx, %rdx
callq 0x7c9b
leaq 0x7bd6(%rip), %rdx      # 0xf55d
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x7c7c
leaq 0x28(%rsp), %rdi
callq 0x85ae
leaq 0x28(%rsp), %rdi
callq 0x2358
leaq 0x8(%rsp), %rdi
callq 0x2358
leaq 0xc8(%rsp), %rdi
jmp 0x789f
leaq 0x789d(%rip), %rsi      # 0xf265
movq %r14, %rdi
callq 0x368e
testb %al, %al
jne 0x77db
leaq 0x788c(%rip), %rsi      # 0xf26b
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x7a79
movq (%rbx), %rdi
addq $0x78, %rdi
leaq 0x7aa8(%rip), %rsi      # 0xf4a5
callq 0x368e
testb %al, %al
je 0x7a22
movq 0x8(%rbx), %rdi
addq $0x78, %rdi
leaq 0x7a90(%rip), %rsi      # 0xf4a5
callq 0x368e
testb %al, %al
jne 0x77db
incl 0xeef4(%rip)            # 0x1691c
leaq 0x7acf(%rip), %rsi      # 0xf4fe
leaq 0xa8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2efc
leaq 0xa8(%rsp), %rdi
callq 0x85ae
leaq 0xa8(%rsp), %rdi
jmp 0x7af3
addq $0x78, %rbx
leaq 0x7a3f(%rip), %rsi      # 0xf4a5
movq %rbx, %rdi
callq 0x2330
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
retq
leaq 0x77f0(%rip), %rsi      # 0xf270
movq %r14, %rdi
callq 0x368e
testb %al, %al
je 0x7afd
movq (%rbx), %rdi
addq $0x78, %rdi
leaq 0x7a0b(%rip), %rsi      # 0xf4a5
callq 0x368e
testb %al, %al
je 0x7abf
movq 0x8(%rbx), %rdi
addq $0x78, %rdi
leaq 0x79f3(%rip), %rsi      # 0xf4a5
callq 0x368e
testb %al, %al
jne 0x77db
incl 0xee57(%rip)            # 0x1691c
leaq 0x7a45(%rip), %rsi      # 0xf511
leaq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2efc
leaq 0x88(%rsp), %rdi
callq 0x85ae
leaq 0x88(%rsp), %rdi
callq 0x2358
jmp 0x77eb
leaq 0x7771(%rip), %rsi      # 0xf275
movq %r14, %rdi
callq 0x368e
testb %al, %al
jne 0x77db
jmp 0x77eb
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x7b83
jmp 0x7b8a
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x7b83
jmp 0x7b8a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2358
jmp 0x7b49
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2358
jmp 0x7b58
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0x7b83
movq %rax, %rbx
leaq 0xe8(%rsp), %rdi
jmp 0x7b83
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x7b83
jmp 0x7b8a
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2358
jmp 0x7b8d
movq %rax, %rbx
movq %rbx, %rdi
callq 0x2300
nop