// File: acliusBackHome[P]kamaya/dist/ParseTree.cpp
// Function: ParseTree::set_parent(unsigned long, unsigned long)
void ParseTree::set_parent(size_t node_id, size_t parent) {
    if (node_id >= node_msg.size() || parent >= node_msg.size()) {
        printf("set_parent:无效的节点id(%zu, %zu)\n", node_id, parent);
        return;
    }
    if (node_parent[node_id] == (size_t) (-1)) {
        node_parent[node_id] = parent;
        if (!nodes[parent].has_key(K_BEGIN_CODE) && nodes[node_id].has_key(K_BEGIN_CODE)) {
            // 如果父节点没有K_BEGIN_CODE键值且孩子
            // 拥有键值K_BEGIN_CODE, 那么其K_BEGIN_CODE将
            // 传到其父节点也就是该节点上
            nodes[parent].set_begin_code(nodes[node_id].get_begin_code());
        }
        node_children[parent].push_back(node_id);
    } else {
        printf("该节点%zu已经有了父节点%zu, 不能再设父节点为%zu\n", node_id, node_parent[node_id], parent);
    }
    if (last_nodes.find(node_id) != last_nodes.end()) {
        last_nodes.erase(node_id);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
addq $0x18, %rdi
callq 0x171f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x31eba
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
addq $0x18, %rdi
callq 0x171f0
movq %rax, %rcx
movq -0x40(%rbp), %rax
cmpq %rcx, %rax
jb 0x31ed5
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq 0x5d774(%rip), %rdi     # 0x8f63d
movb $0x0, %al
callq 0x4080
jmp 0x3201b
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
movq -0x10(%rbp), %rsi
callq 0x34060
cmpq $-0x1, (%rax)
jne 0x31f9f
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
addq $0x30, %rdi
movq -0x10(%rbp), %rsi
callq 0x34060
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rdi
movq %rcx, (%rax)
movq -0x18(%rbp), %rsi
callq 0x34080
movq %rax, %rdi
movl $0x400000, %esi         # imm = 0x400000
callq 0x3e240
testb $0x1, %al
jne 0x31f80
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x34080
movq %rax, %rdi
movl $0x400000, %esi         # imm = 0x400000
callq 0x3e240
testb $0x1, %al
jne 0x31f4e
jmp 0x31f80
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x34080
movq -0x38(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rsi
callq 0x34080
movq %rax, %rdi
callq 0x3e1d0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0x3e960
movq -0x38(%rbp), %rdi
addq $0x60, %rdi
movq -0x18(%rbp), %rsi
callq 0x340a0
movq %rax, %rdi
leaq -0x10(%rbp), %rsi
callq 0x340c0
jmp 0x31fd1
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
addq $0x30, %rdi
movq -0x10(%rbp), %rsi
callq 0x34060
movq -0x58(%rbp), %rsi
movq (%rax), %rdx
movq -0x18(%rbp), %rcx
leaq 0x5d69b(%rip), %rdi     # 0x8f665
movb $0x0, %al
callq 0x4080
movq -0x38(%rbp), %rdi
addq $0x78, %rdi
leaq -0x10(%rbp), %rsi
callq 0x34160
movq -0x38(%rbp), %rdi
movq %rax, -0x20(%rbp)
addq $0x78, %rdi
callq 0x341a0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x34130
testb $0x1, %al
jne 0x3200a
jmp 0x3201b
movq -0x38(%rbp), %rdi
addq $0x78, %rdi
leaq -0x10(%rbp), %rsi
callq 0x341d0
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)