// File: waltersharpWEI[P]CommentEliminator/main.cpp
// Function: initializeSourceFileDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int initializeSourceFileDir(string Dir) {
    if (DIR* Dp = opendir(Dir.c_str())) {
        //if can not open the Directory, display the error
        if (Dp == NULL) {
            cout << strerror(errno);
        }
        //read every item in the directory
        while (struct dirent * Ep = readdir(Dp)) {
            //if it's a regular file
            if (Ep->d_type == DT_REG) {
                // and it's a source file
                if (isSource(Ep->d_name)) {
                    //construct the full path of the source file
                    string FilePath = Dir + "/" + Ep->d_name;
                    cout << "Adding source file " << FilePath << endl;
                    int TempFileSize = 0;
                    struct stat StatBuffer;
                    if (stat(FilePath.c_str(),&StatBuffer) < 0) {
                        //just use 0
                    } else {
                        TempFileSize = StatBuffer.st_size;
                    }

                    FileList.push_back(FileRecord(FilePath,TempFileSize));
                    cout << "Source file added" << endl;
                }
            //if it's a directory
            } else if (Ep->d_type == DT_DIR) {
                //if it's not a (current directory or father directory)
                if (strncmp(Ep->d_name,".",100000) != 0 && strncmp(Ep->d_name,"..",100000) != 0){
                    cout << "Entering Directory " << Dir << endl;
                    //recursive call to the child directory
                    initializeSourceFileDir(Dir + "/" + Ep->d_name);
                    cout << "Leaving Directory " << endl;
                }
            }
        }
        //close the directory handle
        closedir(Dp);
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x1b8(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x20d0
movq %rax, %rdi
callq 0x2350
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x306e
cmpq $0x0, -0x10(%rbp)
jne 0x2c84
callq 0x2040
movl (%rax), %edi
callq 0x20a0
movq %rax, %rsi
movq 0xb349(%rip), %rdi      # 0xdfc8
callq 0x2200
jmp 0x2c86
movq -0x10(%rbp), %rdi
callq 0x2360
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x3065
movq -0x18(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x8, %eax
jne 0x2f1a
movq -0x18(%rbp), %rax
addq $0x13, %rax
movq %rax, -0x1c8(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x23d0
movq -0x1c8(%rbp), %rsi
movq -0x1c0(%rbp), %rdx
leaq -0x38(%rbp), %rdi
callq 0x3f80
jmp 0x2ce7
leaq -0x38(%rbp), %rdi
callq 0x2910
movb %al, -0x1c9(%rbp)
jmp 0x2cf8
leaq -0x38(%rbp), %rdi
callq 0x2130
leaq -0x39(%rbp), %rdi
callq 0x2260
movb -0x1c9(%rbp), %al
testb $0x1, %al
jne 0x2d19
jmp 0x2f15
movq -0x1b8(%rbp), %rsi
leaq 0x6328(%rip), %rdx      # 0x904f
leaq -0x90(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x40b0
movq -0x1d8(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x13, %rdx
leaq -0x70(%rbp), %rdi
callq 0x4060
jmp 0x2d54
leaq -0x90(%rbp), %rdi
callq 0x2130
movq 0xb261(%rip), %rdi      # 0xdfc8
leaq 0x62e3(%rip), %rsi      # 0x9051
callq 0x2200
movq %rax, -0x1e0(%rbp)
jmp 0x2d7c
movq -0x1e0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x21b0
movq %rax, -0x1e8(%rbp)
jmp 0x2d95
movq -0x1e8(%rbp), %rdi
movq 0xb20d(%rip), %rsi      # 0xdfb0
callq 0x2240
jmp 0x2daa
movl $0x0, -0x94(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
leaq -0x128(%rbp), %rsi
callq 0x21d0
cmpl $0x0, %eax
jge 0x2e32
jmp 0x2e3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2df6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2130
leaq -0x39(%rbp), %rdi
callq 0x2260
jmp 0x3079
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x2130
jmp 0x3079
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2f07
movq -0xf8(%rbp), %rax
movl %eax, -0x94(%rbp)
leaq -0x170(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x20e0
jmp 0x2e51
movl -0x94(%rbp), %edx
leaq -0x150(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x4160
jmp 0x2e6c
leaq 0xb3cd(%rip), %rdi      # 0xe240
leaq -0x150(%rbp), %rsi
callq 0x4130
jmp 0x2e81
leaq -0x150(%rbp), %rdi
callq 0x41d0
leaq -0x170(%rbp), %rdi
callq 0x2130
movq 0xb128(%rip), %rdi      # 0xdfc8
leaq 0x61be(%rip), %rsi      # 0x9065
callq 0x2200
movq %rax, -0x1f0(%rbp)
jmp 0x2eb5
movq -0x1f0(%rbp), %rdi
movq 0xb0ed(%rip), %rsi      # 0xdfb0
callq 0x2240
jmp 0x2eca
leaq -0x70(%rbp), %rdi
callq 0x2130
jmp 0x2f15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x2efb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x41d0
leaq -0x170(%rbp), %rdi
callq 0x2130
leaq -0x70(%rbp), %rdi
callq 0x2130
jmp 0x3079
jmp 0x3060
movq -0x18(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
jne 0x305e
movq -0x18(%rbp), %rdi
addq $0x13, %rdi
leaq 0x613e(%rip), %rsi      # 0x9078
movl $0x186a0, %edx          # imm = 0x186A0
callq 0x2100
cmpl $0x0, %eax
je 0x305c
movq -0x18(%rbp), %rdi
addq $0x13, %rdi
leaq 0x611b(%rip), %rsi      # 0x9077
movl $0x186a0, %edx          # imm = 0x186A0
callq 0x2100
cmpl $0x0, %eax
je 0x305c
movq 0xb052(%rip), %rdi      # 0xdfc8
leaq 0x60fd(%rip), %rsi      # 0x907a
callq 0x2200
movq -0x1b8(%rbp), %rsi
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
movq 0xb015(%rip), %rsi      # 0xdfb0
callq 0x2240
movq -0x1b8(%rbp), %rsi
leaq 0x60a1(%rip), %rdx      # 0x904f
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x40b0
movq -0x1f8(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x13, %rdx
leaq -0x190(%rbp), %rdi
callq 0x4060
jmp 0x2fde
leaq -0x190(%rbp), %rdi
callq 0x2c30
jmp 0x2fec
leaq -0x190(%rbp), %rdi
callq 0x2130
leaq -0x1b0(%rbp), %rdi
callq 0x2130
movq 0xafbd(%rip), %rdi      # 0xdfc8
leaq 0x607c(%rip), %rsi      # 0x908e
callq 0x2200
movq %rax, %rdi
movq 0xaf8f(%rip), %rsi      # 0xdfb0
callq 0x2240
jmp 0x305c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x304e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x190(%rbp), %rdi
callq 0x2130
leaq -0x1b0(%rbp), %rdi
callq 0x2130
jmp 0x3079
jmp 0x305e
jmp 0x3060
jmp 0x2c86
movq -0x10(%rbp), %rdi
callq 0x2390
xorl %eax, %eax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x23c0
nopw %cs:(%rax,%rax)