// File: sunpihai-up[P]MulThreadsWordsCounter/WordsCounter-v3.cpp
// Function: getFiles(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void getFiles(string path)
{
    struct stat fSta;
    stat(path.c_str(), &fSta);
    if (S_ISDIR(fSta.st_mode))
    {
        DIR *pDir = opendir(path.c_str());
        struct dirent *ptr = NULL;
        // Access the files in this directory in turn
        while ((ptr = readdir(pDir)) != 0)
        {
            // Recursively enter subfolders
            // ! Must judge whether the file name starts with '.'
            if (ptr->d_type == DT_DIR && ptr->d_name[0] != '.')
            {
                getFiles(path + "/" + ptr->d_name);
                continue;
            }

            string fName = ptr->d_name;
            // Only fetch files of TXT type
            if (fName.find(".txt") != string::npos)
            {
                pathQueue.push(path + "/" + ptr->d_name);
            }
        }
        closedir(pDir);
    }
    else if (S_ISREG(fSta.st_mode) && path.find(".txt") != string::npos)
    {
        // The path is a TXT file
        pathQueue.push(path);
    }
    else
    {
        puts("Invalid path or no TXT file under the path!\n");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x168(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x3110
movq %rax, %rdi
leaq -0x98(%rbp), %rsi
callq 0x3200
movl -0x80(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x39c4
movq -0x168(%rbp), %rdi
callq 0x3110
movq %rax, %rdi
callq 0x3330
movq %rax, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0xa0(%rbp), %rdi
callq 0x3350
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0x39b6
movq -0xa8(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
jne 0x3847
movq -0xa8(%rbp), %rax
movsbl 0x13(%rax), %eax
cmpl $0x2e, %eax
je 0x3847
movq -0x168(%rbp), %rsi
leaq 0x78cc(%rip), %rdx      # 0xb072
leaq -0xe8(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x4910
movq -0x170(%rbp), %rsi
movq -0xa8(%rbp), %rdx
addq $0x13, %rdx
leaq -0xc8(%rbp), %rdi
callq 0x48c0
jmp 0x37d9
leaq -0xc8(%rbp), %rdi
callq 0x36f0
jmp 0x37e7
leaq -0xc8(%rbp), %rdi
callq 0x3458
leaq -0xe8(%rbp), %rdi
callq 0x3458
jmp 0x3753
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
jmp 0x3836
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3458
leaq -0xe8(%rbp), %rdi
callq 0x3458
jmp 0x3a1c
movq -0xa8(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x180(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x33f0
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
leaq -0x118(%rbp), %rdi
callq 0x32d0
jmp 0x3888
leaq -0x119(%rbp), %rdi
callq 0x3250
leaq -0x118(%rbp), %rdi
leaq 0x77d2(%rip), %rsi      # 0xb074
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
cmpq $-0x1, %rax
je 0x3997
movq -0x168(%rbp), %rsi
leaq 0x77af(%rip), %rdx      # 0xb072
leaq -0x160(%rbp), %rdi
callq 0x4910
jmp 0x38d1
movq -0xa8(%rbp), %rdx
addq $0x13, %rdx
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x48c0
jmp 0x38f1
leaq 0xd9e0(%rip), %rdi      # 0x112d8
leaq -0x140(%rbp), %rsi
callq 0x4990
jmp 0x3906
leaq -0x140(%rbp), %rdi
callq 0x3458
leaq -0x160(%rbp), %rdi
callq 0x3458
jmp 0x3997
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
leaq -0x119(%rbp), %rdi
callq 0x3250
jmp 0x3a1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
jmp 0x39a8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
jmp 0x3989
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xf0(%rbp)
movl %eax, -0xf4(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x3458
leaq -0x160(%rbp), %rdi
callq 0x3458
jmp 0x39a8
leaq -0x118(%rbp), %rdi
callq 0x3458
jmp 0x3753
leaq -0x118(%rbp), %rdi
callq 0x3458
jmp 0x3a1c
movq -0xa0(%rbp), %rdi
callq 0x3380
jmp 0x3a13
movl -0x80(%rbp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x3a05
movq -0x168(%rbp), %rdi
leaq 0x7693(%rip), %rsi      # 0xb074
xorl %eax, %eax
movl %eax, %edx
callq 0x3440
cmpq $-0x1, %rax
je 0x3a05
movq -0x168(%rbp), %rsi
leaq 0xd8da(%rip), %rdi      # 0x112d8
callq 0x49c0
jmp 0x3a11
leaq 0x766d(%rip), %rdi      # 0xb079
callq 0x3370
jmp 0x3a13
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0xf0(%rbp), %rdi
callq 0x33e0
nopl (%rax,%rax)