// File: /workspace/github_cpp_makefile_star2_O3/jaycelq[P]BPlusTree/BPlusTree.cpp
// Function: BPlusTree::insertNode(BPlusTree::Node*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, BPlusTree::Node*, std::stack<BPlusTree::Node*, std::deque<BPlusTree::Node*, std::allocator<BPlusTree::Node*>>>*)
void BPlusTree::insertNode(Node* node, int key, string v, Node *p, stack<Node*>* parent)
{
    Node* newNode;
    int newKey;
    if(node->keyNum < maxKeyNum) {
        if(node->isLeaf) ((leafNode*)node)->insert(key, v);
        else ((innerNode *)node)->insert(key, p);
    }
    else {
        if(node->isLeaf) {
            newNode = new leafNode();
            newKey = ((leafNode*)node)->split((leafNode *)newNode);

            if(key < newKey) {
                ((leafNode*)node)->insert(key, v);
            }
            else
                ((leafNode*)newNode)->insert(key, v);
        }
        else {
            newNode = new innerNode();
            newKey = ((innerNode*)node)->split(newNode, key);
            if(newKey == key) {
                ((innerNode *)newNode)->child[0] = p;
            }
            else if(newKey > key) {
                ((innerNode*)node)->insert(key, p);
            }
            else {
                ((innerNode*)newNode)->insert(key, p);
            }
        }

        if(node == root) {
            innerNode* newRoot = new innerNode();
            newRoot->keyNum = 1;
            newRoot->key[0] = newKey;
            newRoot->child[0] = node;
            newRoot->child[1] = newNode;
            root = newRoot;
        }
        else {
            Node* p = parent->top();
            parent->pop();
            insertNode(p, newKey, v, newNode, parent);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r8, %rbx
movl %edx, %ebp
movq %rsi, %r15
cmpl $0x2, 0xc(%rsi)
movb 0x8(%rsi), %al
jg 0x25f6
testb %al, %al
je 0x26c2
leaq 0x88(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rcx), %rsi
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d7e
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x242c
movq 0x78(%rsp), %rdi
cmpq %r12, %rdi
je 0x28ab
movq 0x88(%rsp), %rsi
jmp 0x2874
movq %r9, %r14
movq %rcx, 0x10(%rsp)
testb %al, %al
movq %rdi, 0x8(%rsp)
je 0x26e0
movl $0x90, %edi
callq 0x2110
movq %rax, %r13
movl $0x0, 0xc(%rax)
leaq 0x4762(%rip), %rax      # 0x6d88
movq %rax, (%r13)
movl $0x20, %eax
leaq (%rax,%r13), %rcx
movq %rcx, -0x10(%r13,%rax)
movq $0x0, -0x8(%r13,%rax)
movb $0x0, (%r13,%rax)
addq $0x20, %rax
cmpq $0x80, %rax
jne 0x262f
movb $0x1, 0x8(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%r13)
movq %r15, %rdi
movq %r13, %rsi
callq 0x24aa
movl %eax, %ebx
cmpl %ebp, %eax
jle 0x2742
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x2d7e
movq %r15, %rdi
movl %ebp, %esi
leaq 0x38(%rsp), %rdx
callq 0x242c
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x278b
movq 0x48(%rsp), %rsi
jmp 0x2783
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2342
movq %r14, %r12
movl $0x40, %edi
callq 0x2110
movq %rax, %r13
movl $0x0, 0xc(%rax)
leaq 0x465a(%rip), %rax      # 0x6d58
movq %rax, (%r13)
movb $0x0, 0x8(%r13)
movl 0x34(%r15), %eax
movl 0x38(%r15), %r14d
cmpl %ebp, %eax
setl %cl
cmpl %ebp, %r14d
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x2794
movl %r14d, 0x30(%r13)
movq 0x28(%r15), %rax
movq %rax, 0x18(%r13)
movl $0x1, 0xc(%r13)
movl $0x2, 0xc(%r15)
jmp 0x27da
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x2d7e
movq %r13, %rdi
movl %ebp, %esi
leaq 0x18(%rsp), %rdx
callq 0x242c
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x278b
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2120
movl %ebx, %ebp
movq 0x8(%rsp), %rbx
jmp 0x27ff
cmpl %ebp, %r14d
jge 0x27a7
movl $0x2, %edx
xorl %ecx, %ecx
movl $0x28, %esi
jmp 0x27c5
movl %r14d, 0x30(%r13)
movq 0x28(%r15), %rcx
movq %rcx, 0x18(%r13)
movl $0x1, %ecx
movl $0x20, %esi
movl $0x1, %edx
movl %eax, %r14d
movq (%r15,%rsi), %rax
movq %rax, 0x10(%r13)
movl %ecx, 0xc(%r13)
movl %edx, 0xc(%r15)
cmpl %ebp, %r14d
jne 0x27e0
movq %rbx, 0x10(%r13)
jmp 0x27f7
jle 0x27e7
movq %r15, %rdi
jmp 0x27ea
movq %r13, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x2342
movl %r14d, %ebp
movq 0x8(%rsp), %rbx
movq %r12, %r14
cmpq %r15, (%rbx)
je 0x287e
movq 0x30(%r14), %rax
cmpq 0x38(%r14), %rax
jne 0x281b
movq 0x48(%r14), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movq -0x8(%rax), %rbx
movq %r14, %rdi
callq 0x2e14
leaq 0x68(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x2d7e
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
movq %r15, %rcx
movq %r13, %r8
movq %r14, %r9
callq 0x2580
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x28ab
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2120
jmp 0x28ab
movl $0x40, %edi
callq 0x2110
leaq 0x44c9(%rip), %rcx      # 0x6d58
movq %rcx, (%rax)
movb $0x0, 0x8(%rax)
movl $0x1, 0xc(%rax)
movl %ebp, 0x30(%rax)
movq %r15, 0x10(%rax)
movq %r13, 0x18(%rax)
movq %rax, (%rbx)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x18(%rsp), %rdi
jmp 0x28e3
movq %rax, %rbx
movq 0x38(%rsp), %rdi
jmp 0x28e3
movq %rax, %rbx
movq 0x78(%rsp), %rdi
jmp 0x28e3
movq %rax, %rbx
movq 0x58(%rsp), %rdi
cmpq %r12, %rdi
je 0x28f4
movq (%r12), %rsi
incq %rsi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0