// File: /workspace/github_cpp_makefile_star2_O1/SeanChao[P]KV-Store/kvstore.cc
// Function: KVStore::renameLevel(int, int)
void KVStore::renameLevel(int level, int mode) {
    if (mode == 0) {
        int id = 0;
        if (!std::filesystem::exists(resolvePath(-1)))
            std::filesystem::create_directories(resolvePath(-1));
        while (std::filesystem::exists(resolvePath(level, id))) {
            std::filesystem::rename(resolvePath(level, id),
                                    resolvePath(-1, id));
            std::clog << "rename " << resolvePath(level, id) << "->"
                      << resolvePath(-1, id) << std::endl;
            id++;
        }
    } else if (mode == 1) {
        int tmp = 0;
        int id = 0;
        while (std::filesystem::exists(resolvePath(-1, tmp))) {
            while (std::filesystem::exists(resolvePath(level, id))) id++;
            std::filesystem::rename(resolvePath(-1, tmp++),
                                    resolvePath(level, id++));
            std::clog << "rename " << resolvePath(-1, tmp - 1) << "->"
                      << resolvePath(level, id - 1) << std::endl;
        }
    } else {
        std::clog << "error no rename with mode " << mode << std::endl;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %esi, %ebx
movq %rdi, %r14
testl %edx, %edx
je 0x6b20
movl %edx, %ebp
cmpl $0x1, %edx
jne 0x6ddc
xorl %ecx, %ecx
movq %rsp, %r15
leaq 0x30(%rsp), %r12
xorl %r13d, %r13d
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ecx, 0x2c(%rsp)
callq 0x5ea6
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x920e
movq %r12, %rdi
callq 0x3120
movq %rax, %rbp
movq %r12, %rdi
callq 0x8fba
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6916
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
testb %bpl, %bpl
je 0x6dca
movzbl %bpl, %eax
cmpl $0xff, %eax
je 0x6dca
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x5ea6
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x920e
movq %r12, %rdi
callq 0x3120
movq %rax, %rbp
movq %r12, %rdi
callq 0x8fba
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x697c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
testb %bpl, %bpl
je 0x6991
movzbl %bpl, %eax
cmpl $0xff, %eax
je 0x6991
incl %r13d
jmp 0x692e
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl 0x2c(%rsp), %ecx
callq 0x5ea6
movq %r12, %rdi
movq %rbp, %rsi
movl $0x2, %edx
callq 0x920e
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x5ea6
movq %r15, %rdi
movq %rbp, %rsi
movl $0x2, %edx
callq 0x920e
movq %r12, %rdi
movq %r15, %rsi
callq 0x3180
movq %r15, %rdi
callq 0x8fba
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6a0e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r12, %rdi
callq 0x8fba
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6a38
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movl $0x7, %edx
movq 0x8564(%rip), %rbp      # 0xefa8
movq %rbp, %rdi
leaq 0x493f(%rip), %rsi      # 0xb38d
callq 0x32b0
movq %r12, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl 0x2c(%rsp), %ecx
callq 0x5ea6
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbp, %rdi
callq 0x32b0
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0x486f(%rip), %rsi      # 0xb2fa
callq 0x32b0
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x5ea6
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x32b0
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6af6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6b12
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x2c(%rsp), %ecx
incl %ecx
incl %r13d
jmp 0x68c4
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6646
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x920e
leaq 0x30(%rsp), %rdi
callq 0x3120
movq %rax, %r15
leaq 0x30(%rsp), %rdi
callq 0x8fba
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6b77
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
cmpb $-0x1, %r15b
je 0x6b85
movzbl %r15b, %eax
testl %eax, %eax
jne 0x6bd9
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6646
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x920e
leaq 0x30(%rsp), %rdi
callq 0x3190
leaq 0x30(%rsp), %rdi
callq 0x8fba
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6bd9
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
xorl %ebp, %ebp
movq %rsp, %r15
leaq 0x30(%rsp), %r12
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x5ea6
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x920e
movq %r12, %rdi
callq 0x3120
movq %rax, %r13
movq %r12, %rdi
callq 0x8fba
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6c30
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
testb %r13b, %r13b
je 0x6dca
movzbl %r13b, %eax
cmpl $0xff, %eax
je 0x6dca
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x5ea6
movq %r12, %rdi
movq %r13, %rsi
movl $0x2, %edx
callq 0x920e
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
callq 0x5ea6
movq %r15, %rdi
movq %r13, %rsi
movl $0x2, %edx
callq 0x920e
movq %r12, %rdi
movq %r15, %rsi
callq 0x3180
movq %r15, %rdi
callq 0x8fba
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6cc2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r12, %rdi
callq 0x8fba
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6cec
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movl $0x7, %edx
movq 0x82b0(%rip), %r13      # 0xefa8
movq %r13, %rdi
leaq 0x468b(%rip), %rsi      # 0xb38d
callq 0x32b0
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x5ea6
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r13, %rdi
callq 0x32b0
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
leaq 0x45c0(%rip), %rsi      # 0xb2fa
callq 0x32b0
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
callq 0x5ea6
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x32b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %r13, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x31b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6da7
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6dc3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3280
incl %ebp
jmp 0x6be3
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x81c5(%rip), %rbx      # 0xefa8
leaq 0x45ab(%rip), %rsi      # 0xb395
movl $0x1a, %edx
movq %rbx, %rdi
callq 0x32b0
movq %rbx, %rdi
movl %ebp, %esi
callq 0x33d0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3250
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31b0
jmp 0x6f18
jmp 0x6f13
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8fba
jmp 0x6e58
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x6f2e
jmp 0x6e70
jmp 0x6e75
jmp 0x6e82
jmp 0x6e87
jmp 0x6ed8
movq %rax, %rbx
jmp 0x6ea6
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8fba
jmp 0x6e8a
movq %rax, %rbx
jmp 0x6eb0
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6ea6
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x30(%rsp), %rdi
callq 0x8fba
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6f40
movq 0x88(%rsp), %rsi
jmp 0x6f38
jmp 0x6ed8
jmp 0x6f13
jmp 0x6f18
jmp 0x6f18
jmp 0x6f13
jmp 0x6ed8
movq %rax, %rbx
jmp 0x6efd
jmp 0x6edf
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6efd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6f40
movq 0x40(%rsp), %rsi
jmp 0x6f38
movq %rax, %rbx
jmp 0x6f25
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8fba
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6f40
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x33f0