// File: /workspace/github_cpp_makefile_star2_O1/ChaohuiYu[P]BPlusTree/BPlusTree.cpp
// Function: BPlusTree<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>::rangeQueryValue(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
vector<int> BPT<T>::rangeQueryValue(T key1, T key2) {
    BPT_NODE* node;
    vector<BPT_NODE*> nodeStack {_root};
    vector<int> queryValues;

    while(!nodeStack.empty()) {
        node = nodeStack.back();
        nodeStack.pop_back();

        if (node == NULL) {
            continue;
        }

        if (!node->_isLeaf) {
            if (key2 >= node->_keys[node->_keyCount - 1]) {
                nodeStack.push_back((BPT_NODE*)node->_pointers[node->_keyCount]);
            }
            for (int i = node->_keyCount - 1; i > 0; i--) {
                if (key1 <= node->_keys[i] || key2 >= node->_keys[i-1]) {
                    nodeStack.push_back((BPT_NODE*)node->_pointers[i]);
                }
            }
            if (key1 <= node->_keys[0]) {
                nodeStack.push_back((BPT_NODE*)node->_pointers[0]);
            }
        }
        else {
            FOR(i, 0, node->_keyCount) {
                if (node->_keys[i] >= key1 && node->_keys[i] <= key2) {
                    queryValues.push_back((int)(long long)node->_pointers[i+1]);
                }
            }
        }
    }
    return queryValues;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rdi, %rbx
movq (%rsi), %rax
movq %rsp, %rsi
movq %rax, (%rsi)
leaq 0x10(%rsp), %r12
leaq 0xf(%rsp), %rcx
movl $0x1, %edx
movq %r12, %rdi
callq 0x9b8c
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
movq (%r12), %rdi
movq 0x8(%r12), %rax
cmpq %rax, %rdi
je 0x9f02
movq -0x8(%rax), %rbp
addq $-0x8, %rax
movq %rax, 0x18(%rsp)
testq %rbp, %rbp
je 0x9ef3
cmpb $0x1, 0x8(%rbp)
jne 0x9e25
cmpl $0x0, 0x4(%rbp)
jle 0x9ef3
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x10(%rbp), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x2050
testl %eax, %eax
js 0x9e10
movq 0x10(%rbp), %rdi
addq %r13, %rdi
movq %r14, %rsi
callq 0x2050
testl %eax, %eax
jg 0x9e10
movq 0x18(%rbp), %rax
movl 0x8(%rax,%r12,8), %eax
movl %eax, (%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x9e05
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x9e10
movq %rbx, %rdi
movq %rsp, %rdx
callq 0xa95a
incq %r12
movslq 0x4(%rbp), %rax
addq $0x20, %r13
cmpq %rax, %r12
jl 0x9dbd
jmp 0x9ef3
movq 0x10(%rbp), %rax
movslq 0x4(%rbp), %rcx
shlq $0x5, %rcx
leaq (%rax,%rcx), %rsi
addq $-0x20, %rsi
movq %r14, %rdi
callq 0x2050
testl %eax, %eax
js 0x9e62
movq 0x18(%rbp), %rax
movslq 0x4(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, (%rsp)
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0xaadc
movslq 0x4(%rbp), %r12
cmpq $0x2, %r12
jl 0x9ecb
leaq 0x1(%r12), %r13
shlq $0x5, %r12
addq $-0x40, %r12
movq 0x10(%rbp), %rax
leaq (%rax,%r12), %rsi
addq $0x20, %rsi
movq %r15, %rdi
callq 0x2050
testl %eax, %eax
jle 0x9ea4
movq 0x10(%rbp), %rsi
addq %r12, %rsi
movq %r14, %rdi
callq 0x2050
testl %eax, %eax
js 0x9ebe
movq 0x18(%rbp), %rax
movq -0x10(%rax,%r13,8), %rax
movq %rax, (%rsp)
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0xaadc
decq %r13
addq $-0x20, %r12
cmpq $0x2, %r13
jg 0x9e79
movq 0x10(%rbp), %rsi
movq %r15, %rdi
callq 0x2050
testl %eax, %eax
jg 0x9ef3
movq 0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, (%rsp)
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0xaadc
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rax
jmp 0x9d88
testq %rdi, %rdi
je 0x9f14
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x9f32
jmp 0x9f32
jmp 0x9f6c
jmp 0x9f6c
jmp 0x9f32
jmp 0x9f6c
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x9f49
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x21e0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x9f60
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21e0
movq %r14, %rdi
callq 0x22e0
jmp 0x9f6c
jmp 0x9f6c
movq %rax, %rdi
callq 0x42a3