// File: /workspace/github_cpp_makefile_star2_O1/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 0x25f9
testb %al, %al
je 0x26ca
leaq 0x88(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rcx), %rsi
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d32
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x242c
movq 0x78(%rsp), %rdi
cmpq %r14, %rdi
je 0x2840
movq 0x88(%rsp), %rsi
jmp 0x2805
movq %rdi, %r14
movq %rcx, 0x10(%rsp)
movq %r9, %r12
testb %al, %al
je 0x26e8
movl $0x90, %edi
callq 0x2110
movq %rax, %r13
movl $0x0, 0xc(%rax)
leaq 0x4749(%rip), %rax      # 0x6d70
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 0x2630
movq %r14, 0x8(%rsp)
movb $0x1, 0x8(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%r13)
movq %r15, %rdi
movq %r13, %rsi
callq 0x24aa
movl %eax, 0x4(%rsp)
cmpl %ebp, %eax
jle 0x2727
leaq 0x68(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d32
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x242c
movq 0x58(%rsp), %rdi
cmpq %r14, %rdi
je 0x2770
movq 0x68(%rsp), %rsi
jmp 0x2768
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
movl $0x40, %edi
callq 0x2110
movq %rax, %r13
movl $0x0, 0xc(%rax)
leaq 0x463d(%rip), %rax      # 0x6d40
movq %rax, (%r13)
movb $0x0, 0x8(%r13)
movq %r15, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x2380
movl %eax, 0x4(%rsp)
cmpl %ebp, %eax
jne 0x2777
movq %rbx, 0x10(%r13)
jmp 0x278b
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x2d32
movq %r13, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x242c
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2770
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2120
movq 0x8(%rsp), %r14
jmp 0x278b
jle 0x277e
movq %r15, %rdi
jmp 0x2781
movq %r13, %rdi
movl %ebp, %esi
movq %rbx, %rdx
callq 0x2342
cmpq %r15, (%r14)
je 0x280f
movq %r14, %rbp
movq 0x30(%r12), %rax
cmpq 0x38(%r12), %rax
jne 0x27ad
movq 0x48(%r12), %rcx
movl $0x200, %eax            # imm = 0x200
addq -0x8(%rcx), %rax
movq -0x8(%rax), %rbx
movq %r12, %rdi
callq 0x2dc2
leaq 0x28(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x10(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x2d32
movq %rbp, %rdi
movq %rbx, %rsi
movl 0x4(%rsp), %edx
movq %r15, %rcx
movq %r13, %r8
movq %r12, %r9
callq 0x2584
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x2840
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x2120
jmp 0x2840
movl $0x40, %edi
callq 0x2110
leaq 0x4520(%rip), %rcx      # 0x6d40
movq %rcx, (%rax)
movb $0x0, 0x8(%rax)
movl $0x1, 0xc(%rax)
movl 0x4(%rsp), %ecx
movl %ecx, 0x30(%rax)
movq %r15, 0x10(%rax)
movq %r13, 0x18(%rax)
movq %rax, (%r14)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
jmp 0x2878
movq %rax, %rbx
movq 0x58(%rsp), %rdi
jmp 0x2878
movq %rax, %rbx
movq 0x78(%rsp), %rdi
jmp 0x2878
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r14, %rdi
je 0x2888
movq (%r14), %rsi
incq %rsi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0