// File: SeanChao[P]KV-Store/kvstore.cc
// Function: KVStore::get[abi:cxx11](unsigned long)
std::string KVStore::get(uint64_t key) {
    std::clog << "? " << key << std::endl;
    // looks for key in memTable
    std::string *strPointer = memTable->get(key);
    if (strPointer) {
        std::clog << "\t[m]->" << std::string(*strPointer, 0, 40) << std::endl;
        return *strPointer;
    }
    // looks for key in SsTables using indexTable
    uint64_t offset = 0;
    int count = findIndexedKey(key, &offset);
    bool found = count != -1;
    // calculate coresponding ssTable level and id
    // int back = count;
    int level = 0;
    while (count - fileNum[level] >= 0) {
        count -= fileNum[level];
        level++;
    }
    int fileId = count;
    if (found) {
        // reads value on disk according to offest
        std::clog << "\t@" << level << "-" << fileId << std::endl;
        return readPair(resolvePath(level, fileId), offset);
    }
    return "";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0xa8(%rbp)
movq %rdi, %rax
movq %rax, -0xa0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
movq 0x172b6(%rip), %rdi     # 0x1efa0
leaq 0xe638(%rip), %rsi      # 0x16329
callq 0x42f0
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x4090
movq %rax, %rdi
movq 0x172a4(%rip), %rsi     # 0x1efb0
callq 0x4320
movq -0x98(%rbp), %rdi
addq $0x38, %rdi
callq 0xb830
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0xbff0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x7ddc
movq 0x1725d(%rip), %rdi     # 0x1efa0
leaq 0xe5e2(%rip), %rsi      # 0x1632c
callq 0x42f0
movq %rax, -0xc0(%rbp)
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
movl $0x28, %ecx
callq 0x4450
movq -0xc0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x42c0
movq %rax, -0xb0(%rbp)
jmp 0x7d8f
movq -0xb0(%rbp), %rdi
movq 0x17213(%rip), %rsi     # 0x1efb0
callq 0x4320
jmp 0x7da4
leaq -0x40(%rbp), %rdi
callq 0x45d8
movq -0xa8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4170
jmp 0x7f7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x45d8
jmp 0x7f8a
movq -0x98(%rbp), %rdi
movq $0x0, -0x58(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x7fa0
movl %eax, -0x5c(%rbp)
cmpl $-0x1, -0x5c(%rbp)
setne %al
andb $0x1, %al
movb %al, -0x5d(%rbp)
movl $0x0, -0x64(%rbp)
movq -0x98(%rbp), %rdi
movl -0x5c(%rbp), %eax
movl %eax, -0xc4(%rbp)
addq $0x60, %rdi
movslq -0x64(%rbp), %rsi
callq 0xc0e0
movq %rax, %rcx
movl -0xc4(%rbp), %eax
subl (%rcx), %eax
cmpl $0x0, %eax
jl 0x7e64
movq -0x98(%rbp), %rdi
addq $0x60, %rdi
movslq -0x64(%rbp), %rsi
callq 0xc0e0
movl (%rax), %ecx
movl -0x5c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x5c(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x7e0e
movl -0x5c(%rbp), %eax
movl %eax, -0x68(%rbp)
testb $0x1, -0x5d(%rbp)
je 0x7f23
movq 0x17125(%rip), %rdi     # 0x1efa0
leaq 0xe4b1(%rip), %rsi      # 0x16333
callq 0x42f0
movq %rax, %rdi
movl -0x64(%rbp), %esi
callq 0x4510
movq %rax, %rdi
leaq 0xe4d9(%rip), %rsi      # 0x16375
callq 0x42f0
movq %rax, %rdi
movl -0x68(%rbp), %esi
callq 0x4510
movq %rax, %rdi
movq 0x170fa(%rip), %rsi     # 0x1efb0
callq 0x4320
movq -0x98(%rbp), %rsi
movl -0x64(%rbp), %edx
movl -0x68(%rbp), %ecx
leaq -0x88(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x8330
movq -0xa8(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xd0(%rbp), %rdx
movq -0x58(%rbp), %rcx
callq 0x8130
jmp 0x7efb
leaq -0x88(%rbp), %rdi
callq 0x45d8
jmp 0x7f7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x45d8
jmp 0x7f8a
leaq -0x89(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x4540
movq -0xa8(%rbp), %rdi
movq -0xd8(%rbp), %rdx
leaq 0xe3dd(%rip), %rsi      # 0x16328
callq 0x5020
jmp 0x7f52
leaq -0x89(%rbp), %rdi
callq 0x4340
jmp 0x7f7a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x89(%rbp), %rdi
callq 0x4340
jmp 0x7f8a
movq -0xa0(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x4530
nopw %cs:(%rax,%rax)