// File: CoderUper[P]BTree/BTree.cpp
// Function: BTree::SolveOverflow(Node*)
void BTree::SolveOverflow(Node* node)
{
    //判断是否需要上溢操作
    if(node->key_num<2*M) return;
    //存储要分裂的关键之
    keyType e=node->key[M];
    //生成新节点，并赋值
    Node* new_node=create_node();
    //判断用B+树还是B树分裂法
    if(node->is_leaf)
    {
        for(int i=0;i<M;i++)
        {
            new_node->key_insert(i,node->key_remove(M));
            new_node->child_insert(i,node->child_remove(M));
        }
        new_node->child[M]=node->child_remove(M);
        node->child_insert(M,new_node);
    }
    else
    {
        for(int i=0;i<M-1;i++)
        {
            new_node->key_insert(i,node->key_remove(M+1));
            new_node->child_insert(i,node->child_remove(M+1));
        }
        new_node->child[M-1]=node->child_remove(M+1);
        node->key_remove(M);
    }
    new_node->is_leaf=node->is_leaf;
    new_node->parent=node->parent;
    if(!new_node->is_leaf)
        for(int i=0;i<new_node->child_num;i++)
            new_node->child[i]->parent=new_node;
    //分裂的点是根节点
    if(node->parent==NULL)
    {
        //初始化新根节点
        Node* new_root=create_node();
        new_root->child[0]=node;
        new_root->child[1]=new_node;
        new_root->key[0]=e;
        new_root->key_num=1;
        new_root->child_num=2;
        new_root->is_leaf=false;
        node->parent=new_root;
        new_node->parent=new_root;
        root=new_root;

    }
    //分裂点不是根节点
    else
    {
        Node* p=node->parent;
        int pos=p->search(e);
        p->key_insert(pos+1,e);
        p->child_insert(pos+2,new_node);
        new_node->parent=p;
        SolveOverflow(p);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x6, 0x68(%rax)
jge 0x24ba
jmp 0x275c
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x18(%rbp)
callq 0x21c0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
testb $0x1, 0x78(%rax)
je 0x257f
movl $0x0, -0x24(%rbp)
cmpl $0x3, -0x24(%rbp)
jge 0x254f
movq -0x20(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x31a0
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %esi
movslq %eax, %rdx
callq 0x30c0
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x3250
movq -0x60(%rbp), %rdi
movl -0x54(%rbp), %esi
movq %rax, %rdx
callq 0x3130
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x24e8
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x3250
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x3, %esi
callq 0x3130
jmp 0x2620
movl $0x0, -0x28(%rbp)
cmpl $0x2, -0x28(%rbp)
jge 0x25f9
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x31a0
movq -0x90(%rbp), %rdi
movl -0x84(%rbp), %esi
movslq %eax, %rdx
callq 0x30c0
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3250
movq -0x80(%rbp), %rdi
movl -0x74(%rbp), %esi
movq %rax, %rdx
callq 0x3130
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2586
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x3250
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x31a0
movq -0x10(%rbp), %rax
movb 0x78(%rax), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x78(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x20(%rbp), %rax
testb $0x1, 0x78(%rax)
jne 0x2680
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x6c(%rcx), %eax
jge 0x267e
movq -0x20(%rbp), %rcx
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rdx
movq 0x30(%rax,%rdx,8), %rax
movq %rcx, 0x70(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2652
jmp 0x2680
movq -0x10(%rbp), %rax
cmpq $0x0, 0x70(%rax)
jne 0x2701
movq -0x50(%rbp), %rdi
callq 0x21c0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq -0x10(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %rdx, 0x30(%rcx)
movq -0x20(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %rdx, 0x38(%rcx)
movq -0x18(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq %rdx, (%rcx)
movq -0x38(%rbp), %rcx
movl $0x1, 0x68(%rcx)
movq -0x38(%rbp), %rcx
movl $0x2, 0x6c(%rcx)
movq -0x38(%rbp), %rcx
movb $0x0, 0x78(%rcx)
movq -0x38(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq %rdx, 0x70(%rcx)
movq -0x38(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq %rdx, 0x70(%rcx)
movq -0x38(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x275c
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3050
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %rdi
movl -0x44(%rbp), %esi
addl $0x1, %esi
movq -0x18(%rbp), %rdx
callq 0x30c0
movq -0x40(%rbp), %rdi
movl -0x44(%rbp), %esi
addl $0x2, %esi
movq -0x20(%rbp), %rdx
callq 0x3130
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x40(%rbp), %rsi
callq 0x2490
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)