// File: SeanChao[P]KV-Store/kvstore.cc
// Function: KVStore::compaction(int)
void KVStore::compaction(int level) {
    std::clog << "run compaction on level " << level << std::endl;
    // range statistics
    int nextLv = level + 1;
    int nextLvPos = -1;        // index of insertion point of indexTable in next
                               // level, -1 indicates no assignment yet
    std::vector<Location> id;  // location of tables to be merged
    uint64_t min = UINT64_MAX;
    uint64_t max = 0;
    if (level == 0) {
        uint64_t t0Min = indexTableList[0].front().key;
        uint64_t t1Min = indexTableList[1].front().key;
        uint64_t t0Max = indexTableList[0].back().key;
        uint64_t t1Max = indexTableList[1].back().key;
        uint64_t t2Min = indexTableList[2].front().key;
        uint64_t t2Max = indexTableList[2].back().key;
        min = std::min({t0Min, t1Min, t2Min});
        max = std::max({t0Max, t1Max, t2Max});
        // std::clog << "[lv0]compaction range " << min << " " << max <<
        // std::endl;
        id.push_back(Location(0, 2));
        id.push_back(Location(0, 1));
        id.push_back(Location(0, 0));
    } else {
        // selects exceeding files and merges them into next level
        int more = fileNum[level] - levelSizeLim(level);
        // counts the range of keys in the last file of current level
        for (int i = 0; i < more; i++) {
            int tabId = getIndex(level, levelSizeLim(level) + i);
            uint64_t tMin = indexTableList[tabId].front().key;
            uint64_t tMax = indexTableList[tabId].back().key;
            if (tMin < min) min = tMin;
            max = tMax > max ? tMax : max;
            id.push_back(Location(level, levelSizeLim(level) + i));
        }
    }
    // looks for key range overlapped files
    int delFiles = 0;
    for (int i = 0; fileNum.size() > (size_t)nextLv && i < fileNum[nextLv];
         i++) {
        int tabId = getIndex(nextLv, i);
        uint64_t tMin = indexTableList[tabId].front().key;
        uint64_t tMax = indexTableList[tabId].back().key;
        if (!(tMax < min || max < tMin)) {
            id.push_back(Location(nextLv, i));
            delFiles++;
            // if (nextLvPos == -1) nextLvPos = i;
        }
        if (tMax < min) nextLvPos = i + 1;
    }
    // merge
    std::vector<Pair> all;
    for (size_t i = 0; i < id.size(); i++) {
        // reads ssTable and build pair vector
        std::vector<Pair> t = readSsTable(id[i].level, id[i].id);
        all = merge(all, t);
    }
    // std::clog << "Merged all data: " << std::endl;
    // for (auto &i : all)
    // std::clog << "\t" << i.key << ":\t" << std::string(i.val, 0, 50)
    // << std::endl;
    // update state: removes indexTable from memory, updates fileNum
    for (int i = (int)id.size() - 1; i >= 0; i--) {
        indexTableList.erase(indexTableList.begin() + getIndex(id[i]));
        fileNum[id[i].level]--;
        if (!std::filesystem::remove(resolvePath(id[i])))
            std::clog << "error deleting " << resolvePath(id[i]) << std::endl;
    }
    // slice merged data and write to disk
    // program state is updated in call to writeSsTable
    uint64_t size = 0;
    std::vector<Pair> tmp;
    if (nextLvPos == -1) nextLvPos = 0;
    // renames all file in nextLv to avoid rename hazard
    renameLevel(nextLv, 0);
    for (auto &i : all) {
        size += i.val.length() + DATA_CONST_SIZE;
        tmp.push_back(i);
        if (size >= MEM_TABLE_SIZE_MAX || i.key == all.back().key) {
            writeSsTable(tmp, Location(nextLv, nextLvPos++), true);
            size = 0;
            tmp.clear();
        }
    }
    renameLevel(nextLv, 1);
    // call compaction on next level if necessary
    if (fileNum[nextLv] > levelSizeLim(nextLv)) compaction(nextLv);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x380, %rsp            # imm = 0x380
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
movq 0x1595c(%rip), %rdi     # 0x1efa0
leaq 0xcd4f(%rip), %rsi      # 0x1639a
callq 0x42f0
movq %rax, %rdi
movl -0xc(%rbp), %esi
callq 0x4510
movq %rax, %rdi
movq 0x1594b(%rip), %rsi     # 0x1efb0
callq 0x4320
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl $0xffffffff, -0x14(%rbp) # imm = 0xFFFFFFFF
leaq -0x30(%rbp), %rdi
callq 0xd5c0
movq $-0x1, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x98c6
movq -0x2b0(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x2c8(%rbp)
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x2d8(%rbp)
callq 0xd5e0
movq %rax, %rdi
callq 0xd600
movq -0x2c8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x1, %esi
movq %rsi, -0x2d0(%rbp)
callq 0xd5e0
movq %rax, %rdi
callq 0xd600
movq -0x2d8(%rbp), %rsi
movq -0x2c8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x50(%rbp)
callq 0xd5e0
movq %rax, %rdi
callq 0xd630
movq -0x2d0(%rbp), %rsi
movq -0x2c8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0xd5e0
movq %rax, %rdi
callq 0xd630
movq -0x2c8(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movl $0x2, %esi
movq %rsi, -0x2c0(%rbp)
callq 0xd5e0
movq %rax, %rdi
callq 0xd600
movq -0x2c8(%rbp), %rdi
movq -0x2c0(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0xd5e0
movq %rax, %rdi
callq 0xd630
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x80(%rbp)
movq $0x3, -0x78(%rbp)
movq -0x80(%rbp), %rdi
movq -0x78(%rbp), %rsi
callq 0xd670
movq %rax, -0x2b8(%rbp)
jmp 0x97cc
movq -0x2b8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xd0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq $0x3, -0xb0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0xd6b0
movq %rax, -0x2e0(%rbp)
jmp 0x982d
movq -0x2e0(%rbp), %rax
movq %rax, -0x40(%rbp)
leaq -0xd8(%rbp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xd720
jmp 0x984d
leaq -0x30(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xd6f0
jmp 0x985f
leaq -0xe0(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0xd720
jmp 0x9874
leaq -0x30(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0xd6f0
jmp 0x9886
leaq -0xe8(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0xd720
jmp 0x9898
leaq -0x30(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0xd6f0
jmp 0x98aa
jmp 0x9a80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa2b1
movq -0x2b0(%rbp), %rdi
addq $0x60, %rdi
movslq -0xc(%rbp), %rsi
callq 0xc0e0
movq -0x2b0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x2e8(%rbp)
movl -0xc(%rbp), %esi
callq 0xd740
movl %eax, -0x2e4(%rbp)
jmp 0x98f9
movl -0x2e4(%rbp), %ecx
movl -0x2e8(%rbp), %eax
subl %ecx, %eax
movl %eax, -0xec(%rbp)
movl $0x0, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
cmpl -0xec(%rbp), %eax
jge 0x9a7e
movq -0x2b0(%rbp), %rdi
movl -0xc(%rbp), %esi
movl %esi, -0x2f0(%rbp)
callq 0xd740
movl %eax, -0x2ec(%rbp)
jmp 0x9946
movl -0x2f0(%rbp), %esi
movq -0x2b0(%rbp), %rdi
movl -0x2ec(%rbp), %edx
movl -0xf0(%rbp), %eax
addl %eax, %edx
callq 0xafe0
movl %eax, -0x2f4(%rbp)
jmp 0x996e
movq -0x2b0(%rbp), %rdi
movl -0x2f4(%rbp), %eax
movl %eax, -0xf4(%rbp)
addq $0x40, %rdi
movslq -0xf4(%rbp), %rsi
callq 0xd5e0
movq %rax, %rdi
callq 0xd600
movq -0x2b0(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x100(%rbp)
addq $0x40, %rdi
movslq -0xf4(%rbp), %rsi
callq 0xd5e0
movq %rax, %rdi
callq 0xd630
movq (%rax), %rax
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x99e4
movq -0x100(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x40(%rbp), %rax
jbe 0x9a01
movq -0x108(%rbp), %rax
movq %rax, -0x300(%rbp)
jmp 0x9a0c
movq -0x40(%rbp), %rax
movq %rax, -0x300(%rbp)
movq -0x2b0(%rbp), %rdi
movq -0x300(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0xc(%rbp), %esi
movl %esi, -0x308(%rbp)
callq 0xd740
movl %eax, -0x304(%rbp)
jmp 0x9a34
movl -0x308(%rbp), %esi
movl -0x304(%rbp), %edx
movl -0xf0(%rbp), %eax
addl %eax, %edx
leaq -0x110(%rbp), %rdi
callq 0xd720
jmp 0x9a56
leaq -0x30(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xd6f0
jmp 0x9a68
jmp 0x9a6a
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x9917
jmp 0x9a80
movl $0x0, -0x114(%rbp)
movl $0x0, -0x118(%rbp)
movq -0x2b0(%rbp), %rdi
addq $0x60, %rdi
callq 0xcd80
movq %rax, %rcx
movslq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x309(%rbp)
jbe 0x9aec
movq -0x2b0(%rbp), %rdi
movl -0x118(%rbp), %eax
movl %eax, -0x310(%rbp)
addq $0x60, %rdi
movslq -0x10(%rbp), %rsi
callq 0xc0e0
movq %rax, %rcx
movl -0x310(%rbp), %eax
cmpl (%rcx), %eax
setl %al
movb %al, -0x309(%rbp)
movb -0x309(%rbp), %al
testb $0x1, %al
jne 0x9afb
jmp 0x9bf7
movq -0x2b0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x118(%rbp), %edx
callq 0xafe0
movl %eax, -0x314(%rbp)
jmp 0x9b18
movq -0x2b0(%rbp), %rdi
movl -0x314(%rbp), %eax
movl %eax, -0x11c(%rbp)
addq $0x40, %rdi
movslq -0x11c(%rbp), %rsi
callq 0xd5e0
movq %rax, %rdi
callq 0xd600
movq -0x2b0(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x128(%rbp)
addq $0x40, %rdi
movslq -0x11c(%rbp), %rsi
callq 0xd5e0
movq %rax, %rdi
callq 0xd630
movq (%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x9bc8
movq -0x40(%rbp), %rax
cmpq -0x128(%rbp), %rax
jb 0x9bc8
movl -0x10(%rbp), %esi
movl -0x118(%rbp), %edx
leaq -0x138(%rbp), %rdi
callq 0xd720
jmp 0x9ba7
leaq -0x30(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0xd6f0
jmp 0x9bb9
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
movq -0x130(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x9be1
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x9be3
movl -0x118(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x118(%rbp)
jmp 0x9a94
leaq -0x150(%rbp), %rdi
callq 0xce50
movq $0x0, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x320(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xd760
movq %rax, %rcx
movq -0x320(%rbp), %rax
cmpq %rcx, %rax
jae 0x9da9
movq -0x158(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0xd780
movq -0x330(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x324(%rbp)
movq -0x158(%rbp), %rsi
callq 0xd780
movq -0x2b0(%rbp), %rsi
movl -0x324(%rbp), %edx
movl 0x4(%rax), %ecx
leaq -0x170(%rbp), %rdi
callq 0xa510
jmp 0x9c88
leaq -0x1a0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xd7a0
jmp 0x9c9d
leaq -0x1b8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0xd7a0
jmp 0x9cb2
movq -0x2b0(%rbp), %rsi
leaq -0x188(%rbp), %rdi
leaq -0x1a0(%rbp), %rdx
leaq -0x1b8(%rbp), %rcx
callq 0xb090
jmp 0x9cd5
leaq -0x150(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0xd890
leaq -0x188(%rbp), %rdi
callq 0xcf30
leaq -0x1b8(%rbp), %rdi
callq 0xcf30
leaq -0x1a0(%rbp), %rdi
callq 0xcf30
leaq -0x170(%rbp), %rdi
callq 0xcf30
movq -0x158(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x158(%rbp)
jmp 0x9c0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa2a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x9d98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x9d8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0xcf30
leaq -0x1a0(%rbp), %rdi
callq 0xcf30
leaq -0x170(%rbp), %rdi
callq 0xcf30
jmp 0xa2a5
leaq -0x30(%rbp), %rdi
callq 0xd760
subl $0x1, %eax
movl %eax, -0x1bc(%rbp)
cmpl $0x0, -0x1bc(%rbp)
jl 0xa031
movq -0x2b0(%rbp), %rdi
addq $0x40, %rdi
movq %rdi, -0x340(%rbp)
callq 0xccb0
movq %rax, -0x1d8(%rbp)
movslq -0x1bc(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xd780
movq -0x2b0(%rbp), %rdi
movq %rax, %rsi
callq 0xafb0
movl %eax, -0x334(%rbp)
jmp 0x9e0d
movl -0x334(%rbp), %eax
movslq %eax, %rsi
leaq -0x1d8(%rbp), %rdi
callq 0xd580
movq %rax, -0x1d0(%rbp)
leaq -0x1c8(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0xcce0
movq -0x340(%rbp), %rdi
movq -0x1c8(%rbp), %rsi
callq 0xd8c0
movq %rax, -0x348(%rbp)
jmp 0x9e58
movq -0x2b0(%rbp), %rax
movq -0x348(%rbp), %rcx
movq %rcx, -0x1e0(%rbp)
addq $0x60, %rax
movq %rax, -0x358(%rbp)
movslq -0x1bc(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0xd780
movq -0x358(%rbp), %rdi
movslq (%rax), %rsi
callq 0xc0e0
movq -0x350(%rbp), %rdi
movl (%rax), %ecx
decl %ecx
movl %ecx, (%rax)
movslq -0x1bc(%rbp), %rsi
callq 0xd780
movq -0x2b0(%rbp), %rsi
movq %rax, %rdx
leaq -0x228(%rbp), %rdi
callq 0xa960
jmp 0x9ecf
leaq -0x208(%rbp), %rdi
leaq -0x228(%rbp), %rsi
movl $0x2, %edx
callq 0xd1a0
jmp 0x9ee9
leaq -0x208(%rbp), %rdi
callq 0x4290
movb %al, -0x359(%rbp)
jmp 0x9efd
movb -0x359(%rbp), %al
xorb $-0x1, %al
movb %al, -0x35a(%rbp)
leaq -0x208(%rbp), %rdi
callq 0xc680
leaq -0x228(%rbp), %rdi
callq 0x45d8
movb -0x35a(%rbp), %al
testb $0x1, %al
jne 0x9f32
jmp 0xa01b
movq 0x15067(%rip), %rdi     # 0x1efa0
leaq 0xc473(%rip), %rsi      # 0x163b3
callq 0x42f0
movq %rax, -0x368(%rbp)
jmp 0x9f4e
movslq -0x1bc(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xd780
movq -0x2b0(%rbp), %rsi
movq %rax, %rdx
leaq -0x248(%rbp), %rdi
callq 0xa960
jmp 0x9f76
movq -0x368(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x42c0
movq %rax, -0x370(%rbp)
jmp 0x9f92
movq -0x370(%rbp), %rdi
movq 0x15010(%rip), %rsi     # 0x1efb0
callq 0x4320
jmp 0x9fa7
leaq -0x248(%rbp), %rdi
callq 0x45d8
jmp 0xa01b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0x9fe7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x208(%rbp), %rdi
callq 0xc680
leaq -0x228(%rbp), %rdi
callq 0x45d8
jmp 0xa2a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x248(%rbp), %rdi
callq 0x45d8
jmp 0xa2a5
jmp 0xa01d
movl -0x1bc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1bc(%rbp)
jmp 0x9dbb
movq $0x0, -0x250(%rbp)
leaq -0x268(%rbp), %rdi
callq 0xce50
cmpl $-0x1, -0x14(%rbp)
jne 0xa055
movl $0x0, -0x14(%rbp)
movq -0x2b0(%rbp), %rdi
movl -0x10(%rbp), %esi
xorl %edx, %edx
callq 0x8cf0
jmp 0xa068
leaq -0x150(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rdi
callq 0xd4a0
movq %rax, -0x278(%rbp)
movq -0x270(%rbp), %rdi
callq 0xd4d0
movq %rax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xd500
testb $0x1, %al
jne 0xa0b8
jmp 0xa203
leaq -0x278(%rbp), %rdi
callq 0xd540
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rdi
addq $0x10, %rdi
callq 0x4490
movq -0x250(%rbp), %rcx
leaq 0x28(%rax,%rcx), %rax
movq %rax, -0x250(%rbp)
movq -0x288(%rbp), %rsi
leaq -0x268(%rbp), %rdi
callq 0xd930
jmp 0xa103
cmpq $0x200000, -0x250(%rbp) # imm = 0x200000
jae 0xa140
movq -0x288(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x378(%rbp)
leaq -0x150(%rbp), %rdi
callq 0xd9a0
movq %rax, %rcx
movq -0x378(%rbp), %rax
cmpq (%rcx), %rax
jne 0xa1f0
leaq -0x2a0(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0xd7a0
jmp 0xa155
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl %edx, %eax
incl %eax
movl %eax, -0x14(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0xd720
jmp 0xa170
movq -0x2b0(%rbp), %rdi
movq -0x2a8(%rbp), %rdx
leaq -0x2a0(%rbp), %rsi
movl $0x1, %ecx
callq 0xa9a0
jmp 0xa191
leaq -0x2a0(%rbp), %rdi
callq 0xcf30
movq $0x0, -0x250(%rbp)
leaq -0x268(%rbp), %rdi
callq 0xd9e0
jmp 0xa1f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0xcf30
jmp 0xa299
jmp 0xa1f2
leaq -0x278(%rbp), %rdi
callq 0xd560
jmp 0xa09c
movq -0x2b0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl $0x1, %edx
callq 0x8cf0
jmp 0xa219
movq -0x2b0(%rbp), %rdi
addq $0x60, %rdi
movslq -0x10(%rbp), %rsi
callq 0xc0e0
movq -0x2b0(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x380(%rbp)
movl -0x10(%rbp), %esi
callq 0xd740
movl %eax, -0x37c(%rbp)
jmp 0xa24c
movl -0x380(%rbp), %eax
movl -0x37c(%rbp), %ecx
cmpl %ecx, %eax
jle 0xa26f
movq -0x2b0(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x9620
jmp 0xa26d
jmp 0xa26f
leaq -0x268(%rbp), %rdi
callq 0xcf30
leaq -0x150(%rbp), %rdi
callq 0xcf30
leaq -0x30(%rbp), %rdi
callq 0xda00
addq $0x380, %rsp            # imm = 0x380
popq %rbp
retq
leaq -0x268(%rbp), %rdi
callq 0xcf30
leaq -0x150(%rbp), %rdi
callq 0xcf30
leaq -0x30(%rbp), %rdi
callq 0xda00
movq -0xa0(%rbp), %rdi
callq 0x4530
nopw %cs:(%rax,%rax)