// File: /workspace/github_cpp_makefile_star2_O1/acliusBackHome[P]kamaya/dist/ParseDeclaration.cpp
// Function: ParseScope::declaration(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, ParseFunction const&)
void ParseScope::declaration(const string &symbol, const ParseFunction &function) {
    if (symbol.empty()) {
        printf("ParseDeclaration(const string &symbol, const ParseFunction &function): 警告: 试图声明空符号\n");
        return;
    }
    if (parent_scope) {
        // TODO: 加入结构体后需要判断当前语句块是否是结构体声明里的
        printf("ParseDeclaration(const string &symbol, const ParseFunction &function): 警告: 试图在非静态区声明函数%s\n",
               function.get_info().c_str());
        return;
    }
    auto it = symbol2dec_ptr.find(symbol);
    if (it != symbol2dec_ptr.end()) {
        if (it->second.first != D_FUNCTION) {
            printf("ParseDeclaration(const string &symbol, const ParseFunction &function): 警告: "
                   "符号%s已被声明但不是函数声明, 试图重声明为函数%s\n", symbol.c_str(),
                   function.get_info().c_str());
            return;
        }
        vector<size_t> &dec_ptr = it->second.second;
        if (dec_ptr.empty()) {
            printf("ParseDeclaration(const string &symbol, const ParseFunction &function): 警告: 发现异常:"
                   "符号%s被声明为函数, 但是找不到其记录, 请检查实现和调用\n", symbol.c_str());
            return;
        }
        const ParseType &ret_type = ((ParseFunction *) dec_ptr[0])->get_ret_type(),
                &this_ret_type = function.get_ret_type();
        if (ret_type < this_ret_type || this_ret_type < ret_type) {
            string info = "ParseDeclaration(const string &symbol, const ParseFunction &function)";
            info += " symbol=" + symbol;
            info += " previous_ret_type" + ret_type.get_info();
            info += " this_ret_type" + this_ret_type.get_info();
            throw ParseException(EX_INVALID_FUNC_OVERRIDE, info);
        }
        const auto &this_args = function.get_args();
        for (const auto &func_ptr : dec_ptr) {
            const auto &args = ((ParseFunction *) func_ptr)->get_args();
            if (this_args.size() == args.size()) {
                bool is_the_same = true;
                for (size_t i = 0; is_the_same && i < this_args.size(); ++i) {
                    if (this_args[i] < args[i] || args[i] < this_args[i]) {
                        is_the_same = false;
                    }
                }
                if (is_the_same) {
                    printf("ParseDeclaration(const string &symbol, const ParseFunction &function): 警告:"
                           "试图处重复定义函数%s: %s, 跳过此操作\n", symbol.c_str(), function.get_info().c_str());
                    return;
                }
            }
        }
        dec_ptr.emplace_back((size_t) new ParseFunction(function));
        return;
    }
    vector<size_t> func_ptr;
    func_ptr.emplace_back((size_t) new ParseFunction(function));
    symbol2dec_ptr[symbol] = pair<DeclarationType, vector<size_t> >(D_FUNCTION, func_ptr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
cmpq $0x0, 0x8(%rsi)
je 0x30608
movq %rdx, %r14
movq %rdi, %r13
cmpq $0x0, (%rdi)
je 0x30625
leaq -0x80(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2f27a
movq (%rbx), %rsi
leaq 0x17480(%rip), %rdi     # 0x47a5e
xorl %eax, %eax
callq 0x4070
movq (%rbx), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x305f6
callq 0x42b0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17a0c(%rip), %rdi     # 0x4801b
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4480
movq %rsi, %rbx
leaq 0x10(%r13), %r12
movq %r12, %rdi
callq 0x32002
addq $0x18, %r13
cmpq %r13, %rax
je 0x307b4
movq %rax, %r15
cmpl $0x1, 0x40(%rax)
jne 0x30805
movq 0x48(%r15), %rax
cmpq 0x50(%r15), %rax
je 0x308d2
movq (%rax), %rsi
leaq -0x80(%rbp), %rdi
callq 0x27510
leaq -0xe0(%rbp), %rdi
movq %r14, %rsi
callq 0x27510
leaq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x289bc
testb %al, %al
jne 0x30963
leaq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x289bc
testb %al, %al
jne 0x30963
movq %rbx, -0xf0(%rbp)
movq 0x48(%r15), %rax
movq %r15, -0xe8(%rbp)
movq 0x50(%r15), %rcx
movq %rcx, -0xf8(%rbp)
cmpq %rcx, %rax
je 0x30770
movq %rax, -0x100(%rbp)
movq (%rax), %r13
movq 0x60(%r14), %rax
subq 0x58(%r14), %rax
movq 0x60(%r13), %rcx
subq 0x58(%r13), %rcx
cmpq %rcx, %rax
jne 0x30758
movb $0x1, %r12b
movq $-0x1, %r15
xorl %ebx, %ebx
movq 0x58(%r14), %rdi
movq 0x60(%r14), %rax
subq %rdi, %rax
sarq $0x3, %rax
movabsq $0x4ec4ec4ec4ec4ec5, %rcx # imm = 0x4EC4EC4EC4EC4EC5
imulq %rcx, %rax
incq %r15
cmpq %rax, %r15
jae 0x308f4
addq %rbx, %rdi
movq 0x58(%r13), %rsi
addq %rbx, %rsi
callq 0x2f042
testb %al, %al
jne 0x3074b
movq 0x58(%r13), %rdi
addq %rbx, %rdi
movq 0x58(%r14), %rsi
addq %rbx, %rsi
callq 0x2f042
testb %al, %al
je 0x3074e
xorl %r12d, %r12d
addq $0x68, %rbx
testb $0x1, %r12b
jne 0x306f8
movq -0x100(%rbp), %rax
addq $0x8, %rax
cmpq -0xf8(%rbp), %rax
jne 0x306cd
movl $0x78, %edi
callq 0x42e0
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x25b74
movq -0xe8(%rbp), %rdi
movq %r12, -0xa0(%rbp)
movq 0x50(%rdi), %rsi
cmpq 0x58(%rdi), %rsi
je 0x30939
movq %r12, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x50(%rdi)
jmp 0x30949
xorps %xmm0, %xmm0
movaps %xmm0, -0xe0(%rbp)
movq $0x0, -0xd0(%rbp)
movl $0x78, %edi
callq 0x42e0
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x25b74
movq %r15, -0x80(%rbp)
movq -0xd8(%rbp), %rsi
cmpq -0xd0(%rbp), %rsi
je 0x30833
movq %r15, (%rsi)
addq $0x8, %rsi
movq %rsi, -0xd8(%rbp)
jmp 0x30843
movq (%rbx), %rbx
leaq -0x80(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2f27a
movq (%r15), %rdx
leaq 0x172b1(%rip), %rdi     # 0x47ad2
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4070
movq (%r15), %rdi
jmp 0x305e8
leaq -0xe0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x19282
leaq -0x78(%rbp), %r14
movl $0x1, -0x8(%r14)
leaq -0xe0(%rbp), %rsi
movq %r14, %rdi
callq 0x26102
movq %r12, %rdi
movq %rbx, %rsi
callq 0x3196c
movl -0x80(%rbp), %ecx
movl %ecx, (%rax)
movq 0x8(%rax), %rdi
movups 0x10(%rax), %xmm0
movq -0x78(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq %rdi, -0x78(%rbp)
movups %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movq $0x0, 0x10(%r14)
testq %rdi, %rdi
je 0x308af
callq 0x42b0
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
je 0x308bd
callq 0x42b0
movq -0xe0(%rbp), %rdi
testq %rdi, %rdi
jne 0x305f1
jmp 0x305f6
movq (%rbx), %rsi
leaq 0x1728c(%rip), %rdi     # 0x47b68
xorl %eax, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4070
movq -0xf0(%rbp), %rax
movq (%rax), %rbx
leaq -0xa0(%rbp), %rdi
movq %r14, %rsi
callq 0x2f27a
leaq -0x90(%rbp), %r14
movq -0x10(%r14), %rdx
leaq 0x1735d(%rip), %rdi     # 0x47c7c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4070
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x30949
callq 0x42b0
jmp 0x30949
addq $0x48, %rdi
leaq -0xa0(%rbp), %rdx
callq 0x19282
leaq -0xe0(%rbp), %rdi
callq 0x28344
leaq -0x80(%rbp), %rdi
callq 0x28344
jmp 0x305f6
leaq -0x90(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x1729f(%rip), %rsi     # 0x47c14
leaq 0x172dd(%rip), %rdx     # 0x47c59
leaq -0xa0(%rbp), %rdi
callq 0xf65c
leaq 0x173ec(%rip), %rsi     # 0x47d7b
leaq -0x48(%rbp), %rdi
movq %rbx, %rdx
callq 0xe775
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x4110
leaq -0x38(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x309c1
callq 0x42b0
leaq -0x120(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x27a86
leaq 0x17282(%rip), %rsi     # 0x47c5a
leaq -0x48(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0xe2af
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x4110
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x30a0a
callq 0x42b0
leaq -0x110(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x30a20
callq 0x42b0
leaq -0x120(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x27a86
leaq 0x17233(%rip), %rsi     # 0x47c6d
leaq -0x48(%rbp), %rdi
leaq -0x120(%rbp), %rdx
callq 0xe2af
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
callq 0x4110
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x30a6c
callq 0x42b0
movq -0x120(%rbp), %rdi
cmpq %r12, %rdi
je 0x30a7d
callq 0x42b0
movl $0x28, %edi
callq 0x4190
movq %rax, %r14
leaq -0xa0(%rbp), %rdx
movq %rax, %rdi
movl $0x16, %esi
callq 0x33d12
leaq 0x2b2cb(%rip), %rsi     # 0x5bd70
leaq -0x226f2(%rip), %rdx    # 0xe3ba
movq %r14, %rdi
callq 0x4540
jmp 0x30b29
movq %rax, %rbx
movq %r14, %rdi
callq 0x4250
jmp 0x30b2c
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x30ad9
callq 0x42b0
jmp 0x30ad9
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r12, %rdi
jne 0x30b1a
jmp 0x30b2c
jmp 0x30b29
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x30aff
callq 0x42b0
jmp 0x30aff
movq %rax, %rbx
leaq -0x110(%rbp), %rax
jmp 0x30b11
jmp 0x30b29
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x30b2c
callq 0x42b0
jmp 0x30b2c
movq %rax, %rbx
movq %r12, %rdi
jmp 0x30b38
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r15, %rdi
je 0x30b82
callq 0x42b0
jmp 0x30b82
jmp 0x30b7f
jmp 0x30b7f
jmp 0x30b7f
movq %rax, %rbx
jmp 0x30b8e
movq %rax, %rbx
movq -0x78(%rbp), %rdi
testq %rdi, %rdi
jne 0x30b60
jmp 0x30b6c
jmp 0x30b69
movq %rax, %rbx
movq %r15, %rdi
callq 0x42b0
jmp 0x30b6c
jmp 0x30b7f
movq %rax, %rbx
movq -0xe0(%rbp), %rdi
testq %rdi, %rdi
je 0x30b97
callq 0x42b0
jmp 0x30b97
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
callq 0x28344
leaq -0x80(%rbp), %rdi
callq 0x28344
movq %rbx, %rdi
callq 0x4560
nop