// File: jaycelq[P]BPlusTree/BPlusTree.cpp
// Function: BPlusTree::getrange[abi:cxx11](int, int)
map<int, string> BPlusTree::getrange(int key1, int key2)
{
    Node *n = root;
    int i = 0;
    map<int, string> res;
    if(root == NULL) return res;
    while(n->isLeaf == false) {
        innerNode *inner = (innerNode*) n;
        int slot = inner->getLower(key1);
        n = inner->child[slot];
    }

    leafNode *leaf = (leafNode *)n;

    int slot = leaf->getLower(key1)-1;
	
    if(leaf->key[slot] != key1) slot++;

    i = slot;
    while(true) {
        for(; i < leaf->keyNum && leaf->key[i] >= key1 && leaf->key[i] <= key2; i++) {
            res[leaf->key[i]] = leaf->value[i];
        }
        if(i >= leaf->keyNum) {
            i = 0;
            leaf = leaf -> right;
        } 
        else break;
    }
    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x78(%rbp)
movq %rdi, %rax
movq %rax, -0x70(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
callq 0x3580
movq -0x68(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x323d
movb $0x1, -0x25(%rbp)
movl $0x1, -0x2c(%rbp)
jmp 0x33c6
jmp 0x323f
movq -0x20(%rbp), %rax
movb 0x8(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x329f
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %esi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, -0x7c(%rbp)
jmp 0x326c
movl -0x7c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x38(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
jmp 0x323f
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
callq 0x3680
jmp 0x33e2
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, -0x80(%rbp)
jmp 0x32bb
movl -0x80(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x58(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movl 0x70(%rax,%rcx,4), %eax
cmpl -0x14(%rbp), %eax
je 0x32de
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x32e6
jmp 0x32e8
movl -0x24(%rbp), %ecx
movq -0x58(%rbp), %rdx
xorl %eax, %eax
cmpl 0xc(%rdx), %ecx
movb %al, -0x81(%rbp)
jge 0x332d
movq -0x58(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl 0x70(%rax,%rcx,4), %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x81(%rbp)
jl 0x332d
movq -0x58(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl 0x70(%rax,%rcx,4), %eax
cmpl -0x18(%rbp), %eax
setle %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x3339
jmp 0x3390
movq -0x78(%rbp), %rdi
movq -0x58(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rcx, %rdx
shlq $0x5, %rdx
leaq 0x10(%rax,%rdx), %rdx
movq %rdx, -0x98(%rbp)
leaq 0x70(%rax,%rcx,4), %rsi
callq 0x35a0
movq %rax, -0x90(%rbp)
jmp 0x336b
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdi
callq 0x2030
jmp 0x3380
jmp 0x3382
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x32e8
movl -0x24(%rbp), %eax
movq -0x58(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jl 0x33b4
movl $0x0, -0x24(%rbp)
movq -0x58(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0x33b6
jmp 0x33bb
jmp 0x32e4
movb $0x1, -0x25(%rbp)
movl $0x1, -0x2c(%rbp)
testb $0x1, -0x25(%rbp)
jne 0x33d5
movq -0x78(%rbp), %rdi
callq 0x3680
movq -0x70(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x2270
nopl (%rax,%rax)