// File: xx01cyx[P]LSM-Tree/kvstore.cc
// Function: KVStore::getOverlapSSTs(unsigned long, unsigned long, unsigned long, long&, long&)
vector<SSTPtr> KVStore::getOverlapSSTs(LsmKey minKey, LsmKey maxKey, size_t level,
                                       int64_t& minOverlapIndex, int64_t& maxOverlapIndex) {

    vector<SSTPtr> overlapSSTs;

    if (ssTables[level]->empty())
        return overlapSSTs;

    vector<SSTPtr> levelSSTs = *ssTables[level];
    uint32_t length = levelSSTs.size();

    uint32_t leftIndex = sstBinarySearch(levelSSTs, minKey, 0, length - 1);

    if (levelSSTs[leftIndex]->getMaxKey() < minKey)
        if ((leftIndex == length - 1)
            || (leftIndex < length - 1 && levelSSTs[leftIndex+1]->getMinKey() > maxKey))
            return overlapSSTs;

    minOverlapIndex = leftIndex;
    maxOverlapIndex = 1 + sstBinarySearch(levelSSTs, maxKey, 0, length - 1);

    for (uint32_t i = minOverlapIndex; i < maxOverlapIndex; ++i)
        overlapSSTs.push_back(levelSSTs[i]);

    return overlapSSTs;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x90(%rbp)
movq %rdi, %rax
movq %rax, -0x88(%rbp)
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movb $0x0, -0x31(%rbp)
callq 0x15ef0
movq -0x80(%rbp), %rdi
addq $0x20, %rdi
leaq -0x28(%rbp), %rsi
callq 0x16370
movq %rax, -0x78(%rbp)
jmp 0x12460
movq -0x78(%rbp), %rdi
callq 0x166e0
movq %rax, %rdi
callq 0x160e0
testb $0x1, %al
jne 0x12477
jmp 0x12498
movb $0x1, -0x31(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x12649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1266b
movq -0x80(%rbp), %rdi
addq $0x20, %rdi
leaq -0x28(%rbp), %rsi
callq 0x16370
movq %rax, -0x98(%rbp)
jmp 0x124b2
movq -0x98(%rbp), %rdi
callq 0x16540
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x16570
jmp 0x124cc
leaq -0x60(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x16120
movq -0xa8(%rbp), %rdi
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rsi
movl -0x64(%rbp), %ecx
decl %ecx
xorl %edx, %edx
callq 0x120b0
movl %eax, -0x9c(%rbp)
jmp 0x124fe
movl -0x9c(%rbp), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x16170
movq %rax, %rdi
callq 0xd330
movq %rax, %rdi
callq 0x9900
movq %rax, -0xb0(%rbp)
jmp 0x1252e
movq -0xb0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x125b7
movl -0x68(%rbp), %eax
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x1258b
movl -0x68(%rbp), %eax
movl -0x64(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x125b5
movl -0x68(%rbp), %eax
incl %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x16170
movq %rax, %rdi
callq 0xd330
movq %rax, %rdi
callq 0x98e0
movq %rax, -0xb8(%rbp)
jmp 0x1257e
movq -0xb8(%rbp), %rax
cmpq -0x20(%rbp), %rax
jbe 0x125b5
movb $0x1, -0x31(%rbp)
movl $0x1, -0x48(%rbp)
jmp 0x12640
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x163c0
jmp 0x1266b
jmp 0x125b7
movl -0x68(%rbp), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rsi
movl -0x64(%rbp), %ecx
decl %ecx
leaq -0x60(%rbp), %rdi
xorl %edx, %edx
callq 0x120b0
movl %eax, -0xbc(%rbp)
jmp 0x125df
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movq 0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq 0x10(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x12635
movl -0x6c(%rbp), %eax
movl %eax, %esi
leaq -0x60(%rbp), %rdi
callq 0x16170
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x16050
jmp 0x12628
jmp 0x1262a
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x125fd
movb $0x1, -0x31(%rbp)
movl $0x1, -0x48(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x163c0
testb $0x1, -0x31(%rbp)
jne 0x1265b
movq -0x90(%rbp), %rdi
callq 0x163c0
movq -0x88(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x163c0
movq -0x40(%rbp), %rdi
callq 0x4560