// File: /workspace/github_cpp_makefile_star2_O2/xx01cyx[P]LSM-Tree/kvstore.cc
// Function: KVStore::compact0()
void KVStore::compact0() {

    vector<SSTPtr> SSTs = *ssTables[0];
    if (SSTs.size() != 3) {
        cerr << "Number of SSTs in L0 is not 3. L0-compaction error." << endl;
        exit(-1);
    }

    if (!ssTables.count(1))
        ssTables[1] = make_shared<vector<SSTPtr>>();

    // Get the overall interval of SSTs in L0.
    LsmKey minKey, maxKey;
    getCompact0Range(minKey, maxKey);

    // Get all the SSTs in L0 and L1 that need merge.
    int64_t minOverlapIndex = -1;
    int64_t maxOverlapIndex = -1;
    vector<SSTPtr> overlapSSTs = getOverlapSSTs(minKey, maxKey, 1,
                                                minOverlapIndex, maxOverlapIndex);

    // Get all k-v pairs from the disk.
    SSTs.insert(SSTs.end(), overlapSSTs.begin(), overlapSSTs.end());
    KVPair data = getCompactionData(SSTs);

    // Remove the overlapping SST files in the disk.
    reconstructLowerLevelDisk( minOverlapIndex, maxOverlapIndex, 1);

    // Sort the keys and write the data into the disk.
    TimeStamp maxTimeStamp = getMaxTimeStamp(SSTs);
    vector<SSTPtr> mergedSSTs = merge0AndWriteToDisk(SSTs, maxTimeStamp, data);

    // Reconstruct L1 in memory.
    reconstructLowerLevelMemory(minOverlapIndex, maxOverlapIndex, mergedSSTs, 1);

    // Clear L0 in memory and delete corresponding files in the disk.
    reconstructL0();

}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0xb0, %rsp
movq %rdi, %rbx
leaq 0x20(%rdi), %r14
leaq 0x60(%rsp), %rsi
andq $0x0, (%rsi)
movq %r14, %rdi
callq 0xad0a
movq (%rax), %rsi
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xa5bc
movq 0x8(%r15), %rax
subq (%r15), %rax
cmpq $0x30, %rax
jne 0x840d
leaq 0x60(%rsp), %rsi
movq $0x1, (%rsi)
movq %r14, %rdi
callq 0xbfd4
testq %rax, %rax
jne 0x8307
leaq 0x60(%rsp), %rdi
callq 0xa44a
leaq 0x28(%rsp), %rsi
movq $0x1, (%rsi)
movq %r14, %rdi
callq 0xad0a
leaq 0x60(%rsp), %rsi
movq %rax, %rdi
callq 0xb188
leaq 0x68(%rsp), %rdi
callq 0x6932
leaq 0x58(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq %rbx, %rdi
callq 0x866e
leaq 0x48(%rsp), %r9
orq $-0x1, (%r9)
leaq 0x40(%rsp), %rax
orq $-0x1, (%rax)
movq 0x58(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq %rax, (%rsp)
leaq 0x28(%rsp), %rdi
pushq $0x1
popq %r8
movq %rbx, %rsi
callq 0x8754
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rcx
callq 0xa610
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x88a6
movq 0x48(%rsp), %r14
movq 0x40(%rsp), %r15
pushq $0x1
popq %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x89a2
leaq 0x10(%rsp), %rdi
callq 0x81d8
leaq 0x98(%rsp), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x60(%rsp), %r8
movq %rbx, %rsi
movq %rax, %rcx
callq 0x8a20
leaq 0x98(%rsp), %rcx
pushq $0x1
popq %r8
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x8df0
movq %rbx, %rdi
callq 0x8fb4
leaq 0x98(%rsp), %rdi
callq 0xa552
leaq 0x60(%rsp), %rdi
callq 0xaa82
leaq 0x28(%rsp), %rdi
callq 0xa552
leaq 0x10(%rsp), %rdi
callq 0xa552
addq $0xb0, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0xcbdc(%rip), %rdi      # 0x14ff0
leaq 0x5fe5(%rip), %rsi      # 0xe400
callq 0x3230
movq %rax, %rdi
callq 0x3120
pushq $-0x1
popq %rdi
callq 0x3280
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x6932
jmp 0x8480
jmp 0x8457
jmp 0x8457
jmp 0x8447
jmp 0x8447
movq %rax, %rbx
jmp 0x846c
jmp 0x844e
movq %rax, %rbx
jmp 0x8476
jmp 0x8457
jmp 0x8457
movq %rax, %rbx
jmp 0x8480
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0xa552
leaq 0x60(%rsp), %rdi
callq 0xaa82
leaq 0x28(%rsp), %rdi
callq 0xa552
leaq 0x10(%rsp), %rdi
callq 0xa552
movq %rbx, %rdi
callq 0x3440