// File: SeanChao[P]KV-Store/kvstore.cc
// Function: KVStore::loadSsTable()
void KVStore::loadSsTable() {
    // checks existing ss-table
    int lv = 0;
    int count = 0;
    std::string level = resolvePath(lv);
    while (std::filesystem::exists(level)) {
        // std::string filename = "sstable-" + std::to_string(count);
        // std::clog << "see lv " << lv << std::endl;
        std::string filename = resolvePath(lv, count);
        if ((int)fileNum.size() < lv + 1) fileNum.push_back(0);
        while (std::filesystem::exists(filename)) {
            // std::clog << "see file " << filename << std::endl;
            // parse the file
            readSsTable(filename);
            fileNum[lv]++;
            filename = resolvePath(lv, ++count);
        }
        count = 0;
        level = resolvePath(++lv);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x120(%rbp)
movl $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
movl -0xc(%rbp), %edx
leaq -0x30(%rbp), %rdi
callq 0x8b40
leaq -0x58(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x2, %edx
callq 0xc5a0
jmp 0x7198
leaq -0x58(%rbp), %rdi
callq 0xc570
movb %al, -0x121(%rbp)
jmp 0x71a9
leaq -0x58(%rbp), %rdi
callq 0xc680
movb -0x121(%rbp), %al
testb $0x1, %al
jne 0x71c1
jmp 0x73c9
movq -0x120(%rbp), %rsi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq -0x88(%rbp), %rdi
callq 0x8330
jmp 0x71dc
movq -0x120(%rbp), %rdi
addq $0x60, %rdi
callq 0xcd80
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jge 0x7257
movq -0x120(%rbp), %rdi
addq $0x60, %rdi
movl $0x0, -0x8c(%rbp)
leaq -0x8c(%rbp), %rsi
callq 0xb720
jmp 0x7219
jmp 0x7257
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x73db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xc680
jmp 0x73db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x73bb
jmp 0x7259
leaq -0xb8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
movl $0x2, %edx
callq 0xc5a0
jmp 0x7273
leaq -0xb8(%rbp), %rdi
callq 0xc570
movb %al, -0x122(%rbp)
jmp 0x7287
leaq -0xb8(%rbp), %rdi
callq 0xc680
movb -0x122(%rbp), %al
testb $0x1, %al
jne 0x72a2
jmp 0x736a
leaq -0xd8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x4170
jmp 0x72b7
movq -0x120(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa2d0
jmp 0x72cc
leaq -0xd8(%rbp), %rdi
callq 0x45d8
movq -0x120(%rbp), %rdi
addq $0x60, %rdi
movslq -0xc(%rbp), %rsi
callq 0xc0e0
movq -0x120(%rbp), %rsi
movl (%rax), %ecx
incl %ecx
movl %ecx, (%rax)
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
incl %ecx
movl %ecx, -0x10(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8330
jmp 0x7312
leaq -0x88(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x43c0
leaq -0xf8(%rbp), %rdi
callq 0x45d8
jmp 0x7259
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0xc680
jmp 0x73bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x45d8
jmp 0x73bb
movq -0x120(%rbp), %rsi
movl $0x0, -0x10(%rbp)
movl -0xc(%rbp), %edx
incl %edx
movl %edx, -0xc(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x8b40
jmp 0x738e
leaq -0x30(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x43c0
leaq -0x118(%rbp), %rdi
callq 0x45d8
leaq -0x88(%rbp), %rdi
callq 0x45d8
jmp 0x7184
leaq -0x88(%rbp), %rdi
callq 0x45d8
jmp 0x73db
leaq -0x30(%rbp), %rdi
callq 0x45d8
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x45d8
movq -0x60(%rbp), %rdi
callq 0x4530
nopl (%rax)