// File: /workspace/github_cpp_makefile_star2_O1/jaycelq[P]BPlusTree/BPlusTree.cpp
// Function: BPlusTree::put(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void BPlusTree::put(int key, string value)
{
    stack<Node *> parent;
    Node *n = root;
    if(root == NULL) {
        root = new leafNode();
        insertNode(root , key, value, NULL , &parent);
        return;
    }

    while(n->isLeaf == false) {
        innerNode *inner = (innerNode*) n;
        int slot = inner->getLower(key);
        parent.push(n);
        n = inner->child[slot];
    }

    leafNode *leaf = (leafNode *)n;

    int slot = leaf->getLower(key);
    if(slot > 0) slot -= 1; 
    if(leaf->key[slot] == key) leaf->value[slot] = value;
    else insertNode(leaf , key, value, NULL , &parent);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, %r15
movl %esi, %ebx
movq %rdi, %r13
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x2e0e
movq (%r13), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x298c
movq %r13, 0x8(%rsp)
movq (%rsp), %r12
cmpb $0x0, 0x8(%r12)
jne 0x294d
leaq 0x50(%rsp), %r13
movq %rsp, %rbp
movq (%r12), %rax
movq %r12, %rdi
movl %ebx, %esi
callq *(%rax)
movl %eax, %r14d
movq 0x80(%rsp), %rax
movq 0x90(%rsp), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0x292e
movq (%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x80(%rsp)
jmp 0x2939
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2f84
movslq %r14d, %rax
movq 0x10(%r12,%rax,8), %r12
movq %r12, (%rsp)
cmpb $0x0, 0x8(%r12)
je 0x28f5
movq (%r12), %rax
movq %r12, %rdi
movl %ebx, %esi
callq *(%rax)
movq 0x8(%rsp), %r13
xorl %ecx, %ecx
testl %eax, %eax
setg %cl
subl %ecx, %eax
cltq
cmpl %ebx, 0x70(%r12,%rax,4)
jne 0x2a27
shlq $0x5, %rax
leaq (%r12,%rax), %rdi
addq $0x10, %rdi
movq %r15, %rsi
callq 0x2090
jmp 0x2a73
movl $0x90, %edi
callq 0x2110
movq %rax, %r12
movl $0x0, 0xc(%rax)
leaq 0x43c9(%rip), %rax      # 0x6d70
movq %rax, (%r12)
movl $0x20, %eax
leaq (%r12,%rax), %rcx
movq %rcx, -0x10(%r12,%rax)
movq $0x0, -0x8(%r12,%rax)
movb $0x0, (%r12,%rax)
addq $0x20, %rax
cmpq $0x80, %rax
jne 0x29b0
movb $0x1, 0x8(%r12)
xorps %xmm0, %xmm0
movups %xmm0, 0x80(%r12)
movq %r12, (%r13)
leaq 0x40(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %rdi
callq 0x2d32
leaq 0x30(%rsp), %rcx
leaq 0x50(%rsp), %r9
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %edx
xorl %r8d, %r8d
callq 0x2584
movq 0x30(%rsp), %rdi
jmp 0x2a63
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x2d32
leaq 0x10(%rsp), %rcx
leaq 0x50(%rsp), %r9
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %edx
xorl %r8d, %r8d
callq 0x2584
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2a73
movq (%r14), %rsi
incq %rsi
callq 0x2120
leaq 0x50(%rsp), %rdi
callq 0x2c6a
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ac6
movq 0x20(%rsp), %rsi
jmp 0x2ab5
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ac6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2120
jmp 0x2ac6
jmp 0x2ac3
jmp 0x2ac3
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2c6a
movq %rbx, %rdi
callq 0x21a0