// File: /workspace/github_cpp_makefile_star2_O2/acliusBackHome[P]kamaya/dist/ParseNode.cpp
// Function: ParseNode::action_variable_declaration_code_generate(IR&, ParseExpression const&, ParseType const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long const&) const
size_t ParseNode::action_variable_declaration_code_generate(
        IR &ir, const ParseExpression &init_expr, const ParseType &this_type,
        const string &symbol, const size_t &scope_id) const {
    if (generating_code) {
        size_t addr;
        if (scope_id != 0) {
            addr = ir.allocEmit(scope_id, symbol, this_type.get_size(), node_id);
            ir.varDecEmit(addr, init_expr, node_id, scope_id);
        } else {
            if (init_expr.get_expr_type() == E_UNDEFINED) {
                addr = ir.dataUndefinedEmit(symbol, this_type.get_size(), node_id);
            } else {
                if (init_expr.is_const()) {
                    addr = ir.dataEmit(symbol, this_type.get_size(), IR::getConstValueStr(init_expr), node_id);
                } else {
                    // TODO: 支持静态区非常量初始化表达式
                    string info = "ParseNode::action_variable_declaration_code_generate";
                    info += " node_id=" + to_string(node_id);
                    throw ParseException(EX_NOT_IMPLEMENTED, info);
                }
            }
        }
        if (symbol == "input") {
            ir.readEmit(addr, node_id);
        }
        // init_expr.set_address(addr); 没有任何作用
        return addr;
    }
    return (size_t) -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq 0x39784(%rip), %rax     # 0x532fc
cmpb $0x1, (%rax)
jne 0x19be4
movq %r9, %rbx
movq %r8, %r15
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, -0x30(%rbp)
cmpq $0x0, (%r9)
je 0x19bed
movq %r13, %rdi
callq 0x21bec
leaq -0x58(%rbp), %rcx
movq %rax, (%rcx)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r15, -0x38(%rbp)
movq %r14, %r15
movq -0x30(%rbp), %r14
movq %r14, %r8
callq 0x33d08
movq %rax, %r13
movq (%r14), %rcx
movq %r15, %r14
movq -0x38(%rbp), %r15
movq (%rbx), %r8
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x33f38
jmp 0x19c69
pushq $-0x1
popq %r13
jmp 0x19c8e
movq %r12, %rdi
callq 0x26408
testl %eax, %eax
je 0x19c49
movq %r12, %rdi
callq 0x24972
testb %al, %al
je 0x19ca0
movq %r13, %rdi
callq 0x21bec
movq %rax, %rbx
leaq -0x58(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x32b54
movq -0x30(%rbp), %rax
movq (%rax), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r13, %rcx
callq 0x32c88
movq %rax, %r13
leaq -0x58(%rbp), %rdi
callq 0x4598
jmp 0x19c69
movq %r13, %rdi
callq 0x21bec
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x32db2
movq %rax, %r13
leaq 0x20fc9(%rip), %rsi     # 0x3ac39
movq %r15, %rdi
callq 0x1ddf5
testb %al, %al
je 0x19c8e
movq -0x30(%rbp), %rax
movq (%rax), %rdx
movq %r14, %rdi
movq %r13, %rsi
callq 0x1de06
movq %r13, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20f5d(%rip), %rsi     # 0x3ac04
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4130
movq -0x30(%rbp), %rax
movq (%rax), %rsi
leaq -0x98(%rbp), %rdi
callq 0xc865
leaq 0x20a22(%rip), %rsi     # 0x3a6f0
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xc837
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x4580
leaq -0x78(%rbp), %rdi
callq 0x4598
leaq -0x98(%rbp), %rdi
callq 0x4598
pushq $0x28
popq %rdi
callq 0x4180
movq %rax, %r14
pushq $0x13
popq %rsi
leaq -0x58(%rbp), %rdx
movq %rax, %rdi
callq 0x2b53c
leaq 0x3904f(%rip), %rsi     # 0x52d70
leaq -0xd480(%rip), %rdx     # 0xc8a8
movq %r14, %rdi
callq 0x44e0
jmp 0x19d65
movq %rax, %rbx
movq %r14, %rdi
callq 0x4220
jmp 0x19d68
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x4598
jmp 0x19d50
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x4598
jmp 0x19d68
jmp 0x19d65
movq %rax, %rbx
jmp 0x19d71
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x4598
movq %rbx, %rdi
callq 0x4500
nop