// File: SeanChao[P]KV-Store/kvstore.cc
// Function: KVStore::del(unsigned long)
bool KVStore::del(uint64_t key) {
    std::clog << "- " << key << std::endl;
    std::string val = get(key);
    bool exists = false;
    std::shared_ptr<std::string> strVal(new std::string);

    uint64_t offset = 0;
    // exists in some ssTable
    if (findIndexedKey(key, &offset) != -1) {
        if (val != "") {
            put(key, "");
            exists = true;
        }else {
            exists = false;
        }
        // std::clog << "\tindexed" << std::endl;
    } else if (memTable->remove(key, strVal)) {
        this->memTableSize -= getDataSize((*strVal).length());
        exists = true;
        std::clog << "\tin mem" << std::endl;
    }
    if (!exists) std::clog << "x" << std::endl;
    return exists;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0x16a8b(%rip), %rdi     # 0x1efa0
leaq 0xde1a(%rip), %rsi      # 0x16336
callq 0x42f0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x4090
movq %rax, %rdi
movq 0x16a79(%rip), %rsi     # 0x1efb0
callq 0x4320
movq -0xa8(%rbp), %rsi
movq -0x10(%rbp), %rdx
movq (%rsi), %rax
movq 0x8(%rax), %rax
leaq -0x30(%rbp), %rdi
callq *%rax
movb $0x0, -0x31(%rbp)
movl $0x20, %edi
callq 0x4300
movq %rax, -0xa0(%rbp)
jmp 0x856b
movq -0xa0(%rbp), %rdi
callq 0x4460
movq -0xa0(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xc100
jmp 0x8589
movq -0xa8(%rbp), %rdi
movq $0x0, -0x60(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdx
callq 0x7fa0
movl %eax, -0xac(%rbp)
jmp 0x85ad
movl -0xac(%rbp), %eax
cmpl $-0x1, %eax
je 0x86b0
leaq 0xdd65(%rip), %rsi      # 0x16328
leaq -0x30(%rbp), %rdi
callq 0xc130
movb %al, -0xad(%rbp)
jmp 0x85d4
movb -0xad(%rbp), %al
testb $0x1, %al
jne 0x85e3
jmp 0x86a7
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x4540
movq -0xb8(%rbp), %rdx
leaq 0xdd19(%rip), %rsi      # 0x16328
leaq -0x80(%rbp), %rdi
callq 0x5020
jmp 0x861a
movq -0xc0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
leaq -0x80(%rbp), %rdx
callq *%rax
jmp 0x8636
leaq -0x80(%rbp), %rdi
callq 0x45d8
leaq -0x81(%rbp), %rdi
callq 0x4340
movb $0x1, -0x31(%rbp)
jmp 0x86ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8829
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8820
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x8696
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x45d8
leaq -0x81(%rbp), %rdi
callq 0x4340
jmp 0x8820
movb $0x0, -0x31(%rbp)
jmp 0x87bb
movq -0xa8(%rbp), %rdi
addq $0x38, %rdi
callq 0xb830
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x98(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
leaq -0x48(%rbp), %rsi
callq 0xc4f0
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq -0xd0(%rbp), %rdx
callq 0xc160
movb %al, -0xc1(%rbp)
jmp 0x870b
leaq -0x98(%rbp), %rdi
callq 0xc520
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x8726
jmp 0x87b9
leaq -0x48(%rbp), %rdi
callq 0xc540
movq %rax, %rdi
callq 0x4490
movq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0xbfd0
movq %rax, -0xe8(%rbp)
jmp 0x874f
movq -0xa8(%rbp), %rax
movq -0xe8(%rbp), %rdx
movq 0x30(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x30(%rax)
movb $0x1, -0x31(%rbp)
movq 0x1682d(%rip), %rdi     # 0x1efa0
leaq 0xdbbf(%rip), %rsi      # 0x16339
callq 0x42f0
movq %rax, -0xf0(%rbp)
jmp 0x8788
movq -0xf0(%rbp), %rdi
movq 0x1681a(%rip), %rsi     # 0x1efb0
callq 0x4320
jmp 0x879d
jmp 0x87b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x98(%rbp), %rdi
callq 0xc520
jmp 0x8820
jmp 0x87bb
testb $0x1, -0x31(%rbp)
jne 0x87f4
movq 0x167d8(%rip), %rdi     # 0x1efa0
leaq 0xdb72(%rip), %rsi      # 0x16341
callq 0x42f0
movq %rax, -0xf8(%rbp)
jmp 0x87dd
movq -0xf8(%rbp), %rdi
movq 0x167c5(%rip), %rsi     # 0x1efb0
callq 0x4320
jmp 0x87f2
jmp 0x87f4
movb -0x31(%rbp), %al
movb %al, -0xf9(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xc520
leaq -0x30(%rbp), %rdi
callq 0x45d8
movb -0xf9(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0xc520
leaq -0x30(%rbp), %rdi
callq 0x45d8
movq -0x50(%rbp), %rdi
callq 0x4530
nopl (%rax,%rax)