// File: 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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rcx, -0xc0(%rbp)
movq %rdx, -0xb8(%rbp)
movq %rdi, -0xb0(%rbp)
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rax
movq %rax, -0x50(%rbp)
movq $0x1, -0x48(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x122c0
movq -0xa0(%rbp), %rcx
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x122e0
jmp 0x1269f
leaq -0x59(%rbp), %rdi
callq 0x12360
movq -0xb0(%rbp), %rdi
movb $0x0, -0x6d(%rbp)
callq 0xc640
leaq -0x40(%rbp), %rdi
callq 0x12380
xorb $-0x1, %al
testb $0x1, %al
jne 0x126cc
jmp 0x1292b
leaq -0x40(%rbp), %rdi
callq 0x123c0
movq (%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x12400
cmpq $0x0, -0x28(%rbp)
jne 0x12708
jmp 0x126b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x12360
jmp 0x1295a
movq -0x28(%rbp), %rax
testb $0x1, 0x8(%rax)
jne 0x12871
movq -0xc0(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
cltq
shlq $0x5, %rax
addq %rax, %rsi
callq 0x12970
testb $0x1, %al
jne 0x12743
jmp 0x1278e
movq -0x28(%rbp), %rcx
movq 0x18(%rcx), %rax
movslq 0x4(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x12590
jmp 0x12766
jmp 0x1278e
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
callq 0xaa50
leaq -0x40(%rbp), %rdi
callq 0x125c0
jmp 0x1295a
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x7c(%rbp)
jle 0x1282c
movq -0xb8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x7c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x129b0
testb $0x1, %al
jne 0x127f1
movq -0xc0(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
movl -0x7c(%rbp), %eax
subl $0x1, %eax
cltq
shlq $0x5, %rax
addq %rax, %rsi
callq 0x12970
testb $0x1, %al
jne 0x127f1
jmp 0x1281c
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x7c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x88(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x12590
jmp 0x1281a
jmp 0x1281c
jmp 0x1281e
movl -0x7c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x1279b
movq -0xb8(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x129b0
testb $0x1, %al
jne 0x12846
jmp 0x1286c
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x12590
jmp 0x1286a
jmp 0x1286c
jmp 0x12926
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jge 0x12924
movq -0xb8(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x94(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x12970
testb $0x1, %al
jne 0x128b6
jmp 0x1290e
movq -0xc0(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x94(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x129b0
testb $0x1, %al
jne 0x128de
jmp 0x1290e
movq -0xb0(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movslq -0x94(%rbp), %rcx
movl 0x8(%rax,%rcx,8), %eax
movl %eax, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x10a10
jmp 0x1290c
jmp 0x1290e
jmp 0x12910
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x1287b
jmp 0x12926
jmp 0x126b8
movb $0x1, -0x6d(%rbp)
testb $0x1, -0x6d(%rbp)
jne 0x12941
movq -0xb0(%rbp), %rdi
callq 0xaa50
leaq -0x40(%rbp), %rdi
callq 0x125c0
movq -0xa8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x3410
nopw %cs:(%rax,%rax)
nopl (%rax)