// File: /workspace/github_cpp_makefile_star2_O3/xx01cyx[P]LSM-Tree/kvstore.cc
// Function: KVStore::readAllSSTsFromDisk()
void KVStore::readAllSSTsFromDisk() {
    size_t level = 0;
    string levelDir = "./data/level-" + to_string(level) + "/";
    vector<string> filenames;
    bool emptyL0;

    while (utils::dirExists(levelDir)) {
        utils::scanDir(levelDir, filenames);
        vector<SSTPtr> levelSSTs;
        for (const auto& filename : filenames) {
            string sstName = levelDir + filename;
            SSTPtr sst = readSSTFromDisk(sstName, level);
            levelSSTs.push_back(sst);
        }

        if (level == 0) {
            if (levelSSTs.empty())
                emptyL0 = true;
            else if (levelSSTs.size() == 1)
                timeStamp = levelSSTs.front()->getTimeStamp() + 1;
            else {
                SSTTimeStampPriorComparator timeStampLessThan;
                SSTPtr firstSST = levelSSTs[0];
                SSTPtr secondSST = levelSSTs[1];
                timeStamp = timeStampLessThan(firstSST, secondSST) ?
                            secondSST->getTimeStamp() + 1 : firstSST->getTimeStamp() + 1;
            }
        } else {
            if (level == 1 && emptyL0)
                timeStamp = getMaxTimeStamp(levelSSTs) + 1;
            SSTKeyPriorComparator sstComparator;
            sort(levelSSTs.begin(), levelSSTs.end(), sstComparator);
        }
        ssTables[level] = make_shared<vector<SSTPtr>>(levelSSTs);

        ++level;
        levelDir = "./data/level-" + to_string(level) + "/";
        filenames.clear();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x28(%rsp)
movq $0x0, 0x20(%rsp)
leaq 0x10(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq %rsp, %r14
movl $0x1, %esi
movq %r14, %rdi
xorl %edx, %edx
callq 0x32c0
movq (%r14), %rax
movb $0x30, (%rax)
leaq 0x795c(%rip), %rcx      # 0x101ad
movl $0xd, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x32a0
leaq 0xe0(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8893
movq %rdx, 0xd0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xe0(%rsp)
jmp 0x8899
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
leaq 0xd0(%rsp), %r15
movq %rdx, 0x8(%r15)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x79f2(%rip), %rsi      # 0x102b1
movq %r15, %rdi
callq 0x3490
leaq 0x40(%rsp), %rsi
movq %rsi, -0x10(%rsi)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x88ee
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x88f4
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x8931
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3280
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x8947
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
xorps %xmm0, %xmm0
leaq 0x70(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0xc0(%rsp), %r12
movq 0x28(%rsp), %rax
addq $0x20, %rax
movq %rax, 0x160(%rsp)
leaq 0x50(%rsp), %r13
leaq 0x178(%rsp), %rax
movq %rax, 0x168(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0x168(%rsp), %rdi
callq 0x55b2
movq 0x168(%rsp), %rdi
movq %r15, %rsi
callq 0x3220
testl %eax, %eax
sete %bl
movl 0xe8(%rsp), %ebp
movq 0x168(%rsp), %rdi
leaq 0x178(%rsp), %rax
cmpq %rax, %rdi
je 0x89e3
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x3280
shrl $0xe, %ebp
andl $0x1, %ebp
andb %bpl, %bl
je 0x8f43
movq %r12, 0xb0(%rsp)
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
addq %rsi, %rdx
leaq 0xb0(%rsp), %rdi
callq 0x55b2
movq 0xb0(%rsp), %rdi
callq 0x3390
movq %rax, %rbx
movq %rax, %rdi
callq 0x33a0
leaq 0x10(%rsp), %rbp
testq %rax, %rax
je 0x8a9e
addq $0x13, %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0x3230
cmpb $0x2e, 0xd0(%rsp)
je 0x8a94
movq %rbp, (%rsp)
movq %r15, %rdi
callq 0x3110
leaq (%rsp,%rax), %rdx
addq $0xd0, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x5648
leaq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0xd25a
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8a94
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x33a0
jmp 0x8a31
movq %rbx, %rdi
callq 0x33d0
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x8ac3
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3280
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r12
cmpq %r12, %rbx
je 0x8b48
movq %r15, %rdi
leaq 0x30(%rsp), %rsi
movq %rbx, %rdx
callq 0xcd6c
movq 0x20(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x9c26
movq %r13, %rdi
movq %r14, %rsi
callq 0xcdc6
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8b1d
callq 0x7c76
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x8b42
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3280
addq $0x20, %rbx
jmp 0x8ade
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x8b87
cmpq $0x1, %rax
jne 0x8bcc
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %rbp
cmpq %rbp, %r12
je 0x8bb9
xorl %ebx, %ebx
movq (%r12), %rdi
callq 0x6860
cmpq %rbx, %rax
cmovaq %rax, %rbx
addq $0x10, %r12
cmpq %rbp, %r12
jne 0x8b69
incq %rbx
jmp 0x8bbe
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
cmpq %rcx, %rax
je 0x8c08
subq %rax, %rcx
cmpq $0x10, %rcx
jne 0x8e88
movq (%rax), %rdi
callq 0x6860
incq %rax
movq 0x28(%rsp), %rcx
movq %rax, 0x58(%rcx)
jmp 0x8c08
movl $0x1, %ebx
movq 0x28(%rsp), %rax
movq %rbx, 0x58(%rax)
leaq 0x10(%rsp), %rbp
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r12
cmpq %r12, %rbx
je 0x8c08
movq %r12, %rax
subq %rbx, %rax
sarq $0x4, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0xdb07
movq %rbx, %rdi
movq %r12, %rsi
callq 0xdbba
movq $0x0, 0xd0(%rsp)
leaq 0xd8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0xe356
movq 0x160(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xe280
movaps 0xd0(%rsp), %xmm0
xorps %xmm1, %xmm1
movaps %xmm1, 0xd0(%rsp)
movq 0x8(%rax), %rdi
movups %xmm0, (%rax)
testq %rdi, %rdi
je 0x8c60
callq 0x7c76
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8c72
callq 0x7c76
movq 0x20(%rsp), %rbx
incq %rbx
movq %rbx, 0x20(%rsp)
movl $0x1, %esi
cmpq $0xa, %rbx
jb 0x8cd9
movl $0x4, %esi
movq %rbx, %rcx
movabsq $0x346dc5d63886594b, %rdi # imm = 0x346DC5D63886594B
cmpq $0x63, %rcx
jbe 0x8cd2
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x8cd7
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x8cd9
movq %rcx, %rax
mulq %rdi
shrq $0xb, %rdx
addl $0x4, %esi
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x8c9c
addl $-0x3, %esi
jmp 0x8cd9
addl $-0x2, %esi
jmp 0x8cd9
decl %esi
movl %esi, %esi
leaq 0xa0(%rsp), %rax
movq %rax, 0x90(%rsp)
leaq 0x90(%rsp), %r12
movq %r12, %rdi
xorl %edx, %edx
callq 0x32c0
movq 0x90(%rsp), %rdi
movl 0x98(%rsp), %esi
movq %rbx, %rdx
callq 0x6978
movl $0xd, %r8d
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x7485(%rip), %rcx      # 0x101ad
callq 0x32a0
movq %rbp, (%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq 0xe0(%rsp), %rbx
je 0x8d56
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
jmp 0x8d5d
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rdi
leaq 0x7532(%rip), %rsi      # 0x102b1
callq 0x3490
movq %rbx, 0xd0(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x8db0
movq %rdx, 0xd0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xe0(%rsp)
jmp 0x8db6
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0xd8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x32e0
movq 0xd0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x8dfb
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3280
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x8e11
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x8e36
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r12
cmpq %rbx, %r12
je 0x8e73
leaq 0x10(%rbx), %rbp
movq -0x10(%rbp), %rdi
cmpq %rdi, %rbp
je 0x8e5e
movq (%rbp), %rsi
incq %rsi
callq 0x3280
leaq 0x20(%rbp), %rax
addq $0x10, %rbp
cmpq %r12, %rbp
movq %rax, %rbp
jne 0x8e49
movq %rbx, 0x78(%rsp)
movq %r13, %rdi
callq 0xce64
leaq 0xc0(%rsp), %r12
jmp 0x8978
movq (%rax), %rcx
movq %rcx, 0xd0(%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0xd8(%rsp)
testq %rcx, %rcx
je 0x8ebe
movq 0xd11d(%rip), %rdx      # 0x15fc8
cmpb $0x0, (%rdx)
je 0x8eb5
incl 0x8(%rcx)
jmp 0x8ebe
lock
incl 0x8(%rcx)
movq 0x50(%rsp), %rax
movq 0x10(%rax), %rcx
movq %rcx, (%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x8ee9
movq 0xd0ed(%rip), %rcx      # 0x15fc8
cmpb $0x0, (%rcx)
je 0x8ee5
incl 0x8(%rax)
jmp 0x8ee9
lock
incl 0x8(%rax)
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xce0c
testb %al, %al
movq %r15, %rax
cmovneq %r14, %rax
movq (%rax), %rdi
callq 0x6860
incq %rax
movq 0x28(%rsp), %rcx
movq %rax, 0x58(%rcx)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x8f28
callq 0x7c76
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8c08
callq 0x7c76
jmp 0x8c08
leaq 0x70(%rsp), %rdi
callq 0xceb2
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x8f69
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3280
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x8fa8
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x8fa8
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x90f8
movq 0x10(%rsp), %rsi
jmp 0x90f0
jmp 0x9079
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x9026
callq 0x7c76
jmp 0x9026
jmp 0x9079
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x9000
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x9000
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x90a6
movq 0xa0(%rsp), %rsi
jmp 0x909e
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x90a6
callq 0x7c76
jmp 0x90a6
jmp 0x9079
jmp 0x9079
jmp 0x90b2
movq %rax, %rbx
jmp 0x90d2
jmp 0x9079
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %rbp, %rdi
je 0x90b5
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
jmp 0x90b5
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x9081
callq 0x7c76
jmp 0x9081
movq %rax, %rbx
jmp 0x90a6
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
leaq 0xe0(%rsp), %rax
cmpq %rax, %rdi
je 0x90a6
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x50(%rsp), %rdi
callq 0xce64
jmp 0x90d2
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r12, %rdi
je 0x90d2
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x70(%rsp), %rdi
callq 0xceb2
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x90f8
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x3460