// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, -0x30(%rbp)
cmpl $0x6, 0x68(%rsi)
jl 0x1c4b
movq %rsi, %r15
movabsq $0x100000000, %r13      # imm = 0x100000000
movq 0x18(%r15), %rbx
movl $0x80, %edi
callq 0x1140
movq %rax, %r14
movq %r13, 0x68(%rax)
xorl %eax, %eax
movq %rax, 0x70(%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movups %xmm0, 0x10(%r14)
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movups %xmm0, 0x40(%r14)
movups %xmm0, 0x50(%r14)
movq %rax, 0x60(%r14)
movb $0x1, 0x78(%r14)
cmpb $0x0, 0x78(%r15)
je 0x1a68
xorl %r12d, %r12d
movq %r15, %rdi
movl $0x3, %esi
callq 0x2348
movslq 0x68(%r14), %rcx
cmpq %rcx, %r12
jge 0x19d5
movq %rcx, %rdx
movq -0x8(%r14,%rdx,8), %rsi
movq %rsi, (%r14,%rdx,8)
leaq -0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq %r12, %rsi
jg 0x19c0
cltq
movq %rax, (%r14,%r12,8)
incl %ecx
movl %ecx, 0x68(%r14)
movq %r15, %rdi
movl $0x3, %esi
callq 0x239a
movslq 0x6c(%r14), %rcx
cmpq %rcx, %r12
jge 0x1a10
movq %rcx, %rdx
movq 0x28(%r14,%rdx,8), %rsi
movq %rsi, 0x30(%r14,%rdx,8)
leaq -0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq %r12, %rsi
jg 0x19fa
movq %rax, 0x30(%r14,%r12,8)
incl %ecx
movl %ecx, 0x6c(%r14)
incq %r12
cmpq $0x3, %r12
jne 0x19a7
movq %r15, %rdi
movl $0x3, %esi
callq 0x239a
movq %rax, 0x48(%r14)
movslq 0x6c(%r15), %rax
cmpq $0x4, %rax
jl 0x1a59
movq %rax, %rcx
movq 0x28(%r15,%rcx,8), %rdx
movq %rdx, 0x30(%r15,%rcx,8)
leaq -0x1(%rcx), %rdx
movq %rdx, %rcx
cmpq $0x3, %rdx
ja 0x1a42
movq %r14, 0x48(%r15)
incl %eax
movl %eax, 0x6c(%r15)
jmp 0x1b20
movb $0x1, %r12b
xorl %r13d, %r13d
movq %r15, %rdi
movl $0x4, %esi
callq 0x2348
movslq 0x68(%r14), %rcx
cmpq %rcx, %r13
jge 0x1a9c
movq %rcx, %rdx
movq -0x8(%r14,%rdx,8), %rsi
movq %rsi, (%r14,%rdx,8)
leaq -0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq %r13, %rsi
jg 0x1a87
cltq
movq %rax, (%r14,%r13,8)
incl %ecx
movl %ecx, 0x68(%r14)
movq %r15, %rdi
movl $0x4, %esi
callq 0x239a
movslq 0x6c(%r14), %rcx
cmpq %rcx, %r13
jge 0x1ad7
movq %rcx, %rdx
movq 0x28(%r14,%rdx,8), %rsi
movq %rsi, 0x30(%r14,%rdx,8)
leaq -0x1(%rdx), %rsi
movq %rsi, %rdx
cmpq %r13, %rsi
jg 0x1ac1
movq %rax, 0x30(%r14,%r13,8)
incl %ecx
movl %ecx, 0x6c(%r14)
movl $0x1, %r13d
testb $0x1, %r12b
movl $0x0, %r12d
jne 0x1a6e
movq %r15, %rdi
movl $0x4, %esi
callq 0x239a
movq %rax, 0x40(%r14)
movq %r15, %rdi
movl $0x3, %esi
callq 0x2348
movabsq $0x100000000, %r13      # imm = 0x100000000
movb 0x78(%r15), %cl
movb %cl, 0x78(%r14)
movq 0x70(%r15), %rax
movq %rax, 0x70(%r14)
testb %cl, %cl
jne 0x1b54
movslq 0x6c(%r14), %rcx
testq %rcx, %rcx
jle 0x1b54
xorl %eax, %eax
movq 0x30(%r14,%rax,8), %rdx
movq %r14, 0x70(%rdx)
incq %rax
cmpq %rax, %rcx
jne 0x1b3f
movq 0x70(%r15), %rax
testq %rax, %rax
je 0x1bf2
movslq 0x68(%rax), %rcx
testq %rcx, %rcx
jle 0x1b76
xorl %esi, %esi
cmpq %rbx, (%rax,%rsi,8)
jg 0x1bd0
incq %rsi
cmpq %rsi, %rcx
jne 0x1b68
leal -0x1(%rcx), %edx
movl %ecx, %esi
movslq %esi, %rsi
movq %rbx, (%rax,%rsi,8)
leal 0x1(%rcx), %esi
movl %esi, 0x68(%rax)
addl $0x2, %edx
movslq 0x6c(%rax), %rsi
cmpl %edx, %esi
jle 0x1bb1
movslq %edx, %rdx
movq %rsi, %rdi
movq 0x28(%rax,%rdi,8), %r8
movq %r8, 0x30(%rax,%rdi,8)
leaq -0x1(%rdi), %r8
movq %r8, %rdi
cmpq %rdx, %r8
jg 0x1b99
jmp 0x1bb4
movslq %edx, %rdx
movq %r14, 0x30(%rax,%rdx,8)
incl %esi
movl %esi, 0x6c(%rax)
movq %rax, 0x70(%r14)
movq %rax, %r15
cmpl $0x4, %ecx
jg 0x1955
jmp 0x1c4b
leaq -0x1(%rsi), %rdx
cmpl %esi, %ecx
jle 0x1b7b
movq %rcx, %rdi
movq -0x8(%rax,%rdi,8), %r8
movq %r8, (%rax,%rdi,8)
leaq -0x1(%rdi), %r8
movq %r8, %rdi
cmpq %rsi, %r8
jg 0x1bdb
jmp 0x1b7e
movl $0x80, %edi
callq 0x1140
movq $0x0, 0x70(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x48(%rax)
movups %xmm0, 0x58(%rax)
movq %r15, 0x30(%rax)
movq %r14, 0x38(%rax)
movq %rbx, (%rax)
movabsq $0x200000001, %rcx      # imm = 0x200000001
movq %rcx, 0x68(%rax)
movb $0x0, 0x78(%rax)
movq %rax, 0x70(%r15)
movq %rax, 0x70(%r14)
movq -0x30(%rbp), %rcx
movq %rax, (%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq