// File: tsoding[P]cxx-invert-file-tree/inverter.cpp
// Function: free_file_name(std::filesystem::__cxx11::path const&)
fs::path free_file_name(const fs::path &root)
{
    std::string prefix = "_";
    int counter = 0;

    while (fs::exists(root / (prefix + std::to_string(counter)))) {
        counter++;
    }

    return root / (prefix + std::to_string(counter));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x158(%rbp)
movq %rdi, %rax
movq %rax, -0x150(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x33c0
movq -0x148(%rbp), %rdx
leaq 0x4a32(%rip), %rsi      # 0x8024
leaq -0x30(%rbp), %rdi
callq 0x3d30
jmp 0x35fd
leaq -0x31(%rbp), %rdi
callq 0x32b0
movl $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x160(%rbp)
movl -0x48(%rbp), %esi
leaq -0xd8(%rbp), %rdi
callq 0x3ee0
jmp 0x3629
leaq -0xb8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x3e90
jmp 0x3642
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
movl $0x2, %edx
callq 0x4000
jmp 0x365c
movq -0x160(%rbp), %rsi
leaq -0x70(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0x3e10
jmp 0x3675
leaq -0x70(%rbp), %rdi
callq 0x3de0
movb %al, -0x161(%rbp)
jmp 0x3686
leaq -0x70(%rbp), %rdi
callq 0x4090
leaq -0x98(%rbp), %rdi
callq 0x4090
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xd8(%rbp), %rdi
callq 0x3180
movb -0x161(%rbp), %al
testb $0x1, %al
jne 0x36c2
jmp 0x3763
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x360d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x32b0
jmp 0x3860
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3857
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3752
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x3746
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x373a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x4090
leaq -0x98(%rbp), %rdi
callq 0x4090
leaq -0xb8(%rbp), %rdi
callq 0x3180
leaq -0xd8(%rbp), %rdi
callq 0x3180
jmp 0x3857
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
movl -0x48(%rbp), %esi
leaq -0x140(%rbp), %rdi
callq 0x3ee0
jmp 0x377f
leaq -0x120(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x140(%rbp), %rdx
callq 0x3e90
jmp 0x3798
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
movl $0x2, %edx
callq 0x4000
jmp 0x37b2
movq -0x170(%rbp), %rsi
movq -0x158(%rbp), %rdi
leaq -0x100(%rbp), %rdx
callq 0x3e10
jmp 0x37ce
leaq -0x100(%rbp), %rdi
callq 0x4090
leaq -0x120(%rbp), %rdi
callq 0x3180
leaq -0x140(%rbp), %rdi
callq 0x3180
leaq -0x30(%rbp), %rdi
callq 0x3180
movq -0x150(%rbp), %rax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x384b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x383f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x4090
leaq -0x120(%rbp), %rdi
callq 0x3180
leaq -0x140(%rbp), %rdi
callq 0x3180
leaq -0x30(%rbp), %rdi
callq 0x3180
movq -0x40(%rbp), %rdi
callq 0x33b0
nopl (%rax)