// File: /workspace/github_cpp_makefile_star2_O2/akojo[P]quickfind/qfind.cpp
// Function: main
int main(int argc, char *argv[])
{
    auto flags = 0;
    int opt{};

    while ((opt = getopt(argc, argv, "adfh")) != -1) {
        switch (opt) {
        case 'a':
            flags |= DW_HIDDEN;
            break;
        case 'd':
            flags |= DW_DIRECTORIES;
            break;
        case 'f':
            flags |= DW_FILES;
            break;
        case 'h':
        case '?':
        default:
            usage();
        }
    }
    argc -= optind;
    argv += optind;

    if ((flags & (DW_DIRECTORIES | DW_FILES)) == 0) {
        flags |= DW_DIRECTORIES | DW_FILES;
    }

    vector<string> dirs = { "." };
    if (argc > 1) {
        dirs.clear();
        for (int i = 1; i < argc; ++i) {
            auto len = strlen(argv[i]);
            if (argv[i][len - 1] == '/')
                argv[i][len - 1] = '\0';
            dirs.emplace_back(argv[i]);
        }
    }

    string pattern = argc == 0 ? "" : *argv;
    vector<wstr> strings;
    for (auto& dir : dirs)
        dirwalk(dir, flags, [&](auto name) { strings.emplace_back(name); });
    auto last = match(strings.begin(), strings.end(), pattern);
    for_each(strings.begin(), last, [](auto& s) { puts(s.str.c_str()); });

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r14
movl %edi, %ebp
xorl %r15d, %r15d
leaq 0x1cb0(%rip), %rbx      # 0x412b
pushq $0x1
popq %r12
pushq $0x4
popq %r13
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2030
movl %r12d, %ecx
cmpl $0x61, %eax
je 0x24aa
cmpl $0x64, %eax
je 0x24a7
cmpl $0x66, %eax
jne 0x24af
movl %r13d, %ecx
jmp 0x24aa
pushq $0x2
popq %rcx
orl %ecx, %r15d
jmp 0x2483
cmpl $-0x1, %eax
jne 0x2678
movq 0x4b11(%rip), %rax      # 0x6fd0
movslq (%rax), %r12
movl %r15d, %eax
orl $0x6, %eax
testb $0x6, %r15b
cmovnel %r15d, %eax
movl %eax, 0xc(%rsp)
leaq 0x1c55(%rip), %rsi      # 0x4130
leaq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x271a
leaq 0x30(%rsp), %rdi
leaq 0x48(%rsp), %rsi
pushq $0x1
popq %r15
leaq 0xb(%rsp), %rcx
movq %r15, %rdx
callq 0x2756
movl %ebp, %ebx
movq %r12, 0x28(%rsp)
subl %r12d, %ebx
leaq 0x48(%rsp), %rdi
callq 0x2090
cmpl $0x2, %ebx
jl 0x256c
leaq 0x30(%rsp), %rdi
callq 0x2790
movl %ebx, %ebx
movq 0x28(%rsp), %rax
leaq (%r14,%rax,8), %r13
addq $0x8, %r13
cmpq %rbx, %r15
jae 0x256c
movq (%r13), %r12
movq %r12, %rdi
callq 0x2080
cmpb $0x2f, -0x1(%r12,%rax)
jne 0x2556
movb $0x0, -0x1(%r12,%rax)
leaq 0x30(%rsp), %rdi
movq %r13, %rsi
callq 0x2798
incq %r15
addq $0x8, %r13
jmp 0x2537
movq 0x28(%rsp), %rax
cmpl %ebp, %eax
jne 0x257e
leaq 0x1c10(%rip), %rsi      # 0x418c
jmp 0x2582
movq (%r14,%rax,8), %rsi
leaq 0x48(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x271a
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x30(%rsp), %r15
movq 0x38(%rsp), %rbp
leaq 0x88(%rsp), %r12
leaq 0x128(%rip), %rbx       # 0x26e0
leaq 0x135(%rip), %r14       # 0x26f4
leaq 0x68(%rsp), %r13
cmpq %rbp, %r15
je 0x2616
movq %r12, %rdi
movq %r15, %rsi
callq 0x21a0
andq $0x0, 0x70(%rsp)
leaq 0x10(%rsp), %rax
movq %rax, 0x68(%rsp)
movq %rbx, 0x80(%rsp)
movq %r14, 0x78(%rsp)
movq %r12, %rdi
movl 0xc(%rsp), %esi
movq %r13, %rdx
callq 0x2efc
movq %r13, %rdi
callq 0x27d2
movq %r12, %rdi
callq 0x2090
addq $0x20, %r15
jmp 0x25c4
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x3108
movq %rax, %rbx
movq 0x10(%rsp), %r14
cmpq %rbx, %r14
je 0x2646
movq 0x8(%r14), %rdi
callq 0x2200
addq $0x28, %r14
jmp 0x2632
leaq 0x10(%rsp), %rdi
callq 0x27ee
leaq 0x48(%rsp), %rdi
callq 0x2090
leaq 0x30(%rsp), %rdi
callq 0x2810
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x237c
jmp 0x269a
jmp 0x2695
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x2090
jmp 0x26d7
movq %rax, %rbx
jmp 0x26d7
movq %rax, %rbx
jmp 0x26cd
movq %rax, %rbx
jmp 0x26b9
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x27d2
leaq 0x88(%rsp), %rdi
callq 0x2090
leaq 0x10(%rsp), %rdi
callq 0x27ee
leaq 0x48(%rsp), %rdi
callq 0x2090
leaq 0x30(%rsp), %rdi
callq 0x2810
movq %rbx, %rdi
callq 0x2230
nop