// File: /workspace/github_cpp_makefile_star2_O3/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 0x6b92
movl %edx, %ebp
cmpl $0x1, %edx
jne 0x6e4e
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 0x5f1a
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x923c
movq %r12, %rdi
callq 0x3120
movq %rax, %rbp
movq %r12, %rdi
callq 0x8fe4
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6988
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
testb %bpl, %bpl
je 0x6e3c
movzbl %bpl, %eax
cmpl $0xff, %eax
je 0x6e3c
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x5f1a
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x923c
movq %r12, %rdi
callq 0x3120
movq %rax, %rbp
movq %r12, %rdi
callq 0x8fe4
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69ee
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
testb %bpl, %bpl
je 0x6a03
movzbl %bpl, %eax
cmpl $0xff, %eax
je 0x6a03
incl %r13d
jmp 0x69a0
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl 0x2c(%rsp), %ecx
callq 0x5f1a
movq %r12, %rdi
movq %rbp, %rsi
movl $0x2, %edx
callq 0x923c
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x5f1a
movq %r15, %rdi
movq %rbp, %rsi
movl $0x2, %edx
callq 0x923c
movq %r12, %rdi
movq %r15, %rsi
callq 0x3180
movq %r15, %rdi
callq 0x8fe4
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6a80
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r12, %rdi
callq 0x8fe4
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6aaa
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movl $0x7, %edx
movq 0x84f2(%rip), %rbp      # 0xefa8
movq %rbp, %rdi
leaq 0x48cd(%rip), %rsi      # 0xb38d
callq 0x32b0
movq %r12, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl 0x2c(%rsp), %ecx
callq 0x5f1a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %rbp, %rdi
callq 0x32b0
movq %rax, %rbp
movl $0x2, %edx
movq %rax, %rdi
leaq 0x47fd(%rip), %rsi      # 0xb2fa
callq 0x32b0
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %r13d, %ecx
callq 0x5f1a
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 0x6b68
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6b84
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3280
movl 0x2c(%rsp), %ecx
incl %ecx
incl %r13d
jmp 0x6936
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x66b8
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x923c
leaq 0x30(%rsp), %rdi
callq 0x3120
movq %rax, %r15
leaq 0x30(%rsp), %rdi
callq 0x8fe4
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6be9
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
cmpb $-0x1, %r15b
je 0x6bf7
movzbl %r15b, %eax
testl %eax, %eax
jne 0x6c4b
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x66b8
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x923c
leaq 0x30(%rsp), %rdi
callq 0x3190
leaq 0x30(%rsp), %rdi
callq 0x8fe4
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6c4b
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 0x5f1a
movq %r12, %rdi
movq %r15, %rsi
movl $0x2, %edx
callq 0x923c
movq %r12, %rdi
callq 0x3120
movq %rax, %r13
movq %r12, %rdi
callq 0x8fe4
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6ca2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
testb %r13b, %r13b
je 0x6e3c
movzbl %r13b, %eax
cmpl $0xff, %eax
je 0x6e3c
leaq 0x78(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x5f1a
movq %r12, %rdi
movq %r13, %rsi
movl $0x2, %edx
callq 0x923c
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
callq 0x5f1a
movq %r15, %rdi
movq %r13, %rsi
movl $0x2, %edx
callq 0x923c
movq %r12, %rdi
movq %r15, %rsi
callq 0x3180
movq %r15, %rdi
callq 0x8fe4
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6d34
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
movq %r12, %rdi
callq 0x8fe4
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6d5e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x3280
movl $0x7, %edx
movq 0x823e(%rip), %r13      # 0xefa8
movq %r13, %rdi
leaq 0x4619(%rip), %rsi      # 0xb38d
callq 0x32b0
movq %r12, %rdi
movq %r14, %rsi
movl %ebx, %edx
movl %ebp, %ecx
callq 0x5f1a
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq %r13, %rdi
callq 0x32b0
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
leaq 0x454e(%rip), %rsi      # 0xb2fa
callq 0x32b0
movq %r15, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
callq 0x5f1a
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 0x6e19
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6e35
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3280
incl %ebp
jmp 0x6c55
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8153(%rip), %rbx      # 0xefa8
leaq 0x4539(%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 0x6f8a
jmp 0x6f85
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8fe4
jmp 0x6eca
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x6fa0
jmp 0x6ee2
jmp 0x6ee7
jmp 0x6ef4
jmp 0x6ef9
jmp 0x6f4a
movq %rax, %rbx
jmp 0x6f18
movq %rax, %rbx
movq %rsp, %rdi
callq 0x8fe4
jmp 0x6efc
movq %rax, %rbx
jmp 0x6f22
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x6f18
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x3280
leaq 0x30(%rsp), %rdi
callq 0x8fe4
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x6fb2
movq 0x88(%rsp), %rsi
jmp 0x6faa
jmp 0x6f4a
jmp 0x6f85
jmp 0x6f8a
jmp 0x6f8a
jmp 0x6f85
jmp 0x6f4a
movq %rax, %rbx
jmp 0x6f6f
jmp 0x6f51
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6f6f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x6fb2
movq 0x40(%rsp), %rsi
jmp 0x6faa
movq %rax, %rbx
jmp 0x6f97
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x8fe4
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x6fb2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3280
movq %rbx, %rdi
callq 0x33f0