// File: /workspace/github_cpp_makefile_star2_O3/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 0x2e60
movq (%r13), %r12
movq %r12, (%rsp)
testq %r12, %r12
je 0x29f4
movq %r13, 0x8(%rsp)
cmpb $0x0, 0x8(%r12)
jne 0x29b5
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 0x2996
movq (%rsp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x80(%rsp)
jmp 0x29a1
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2fd6
movslq %r14d, %rax
movq 0x10(%r12,%rax,8), %r12
movq %r12, (%rsp)
cmpb $0x0, 0x8(%r12)
je 0x295d
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 0x2a8f
shlq $0x5, %rax
leaq (%r12,%rax), %rdi
addq $0x10, %rdi
movq %r15, %rsi
callq 0x2090
jmp 0x2adb
movl $0x90, %edi
callq 0x2110
movq %rax, %r12
movl $0x0, 0xc(%rax)
leaq 0x4379(%rip), %rax      # 0x6d88
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 0x2a18
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 0x2d7e
leaq 0x30(%rsp), %rcx
leaq 0x50(%rsp), %r9
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %edx
xorl %r8d, %r8d
callq 0x2580
movq 0x30(%rsp), %rdi
jmp 0x2acb
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rdi
callq 0x2d7e
leaq 0x10(%rsp), %rcx
leaq 0x50(%rsp), %r9
movq %r13, %rdi
movq %r12, %rsi
movl %ebx, %edx
xorl %r8d, %r8d
callq 0x2580
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x2adb
movq (%r14), %rsi
incq %rsi
callq 0x2120
leaq 0x50(%rsp), %rdi
callq 0x2cae
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 0x2b2e
movq 0x20(%rsp), %rsi
jmp 0x2b1d
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r14, %rdi
je 0x2b2e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x2120
jmp 0x2b2e
jmp 0x2b2b
jmp 0x2b2b
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2cae
movq %rbx, %rdi
callq 0x21a0