// File: /workspace/github_cpp_makefile_star2_O1/nachogoro[P]wordcrack-herminia/src/main.cpp
// Function: main
int main(int argc, char** argv)
{
    std::string programName(argv[0]);
    if (argc != 9) {
        printUsage(programName);
        return 0;
    }

    std::string dictFileName;
    std::string boardFileName;
    std::string outFileWords;
    std::string outFileCoords;

    // Get the configuration parameters
    for (int i = 1; i <= 7; i+=2)
    {
        std::string config(argv[i]);
        if (config == "--dict") {
            dictFileName = argv[i+1];
        } else if (config == "--board") {
            boardFileName = argv[i+1];
        } else if (config == "--outwords") {
            outFileWords = argv[i+1];
        } else if (config == "--outcoords") {
            outFileCoords = argv[i+1];
        } else {
            printUsage(programName);
            return 0;
        }
    }

    // Validate the configuration parameters
    validateConfig(dictFileName, boardFileName, outFileWords, outFileCoords);

    std::chrono::high_resolution_clock::time_point dictStart =
        std::chrono::high_resolution_clock::now();

    Dictionary dict(dictFileName);

    std::chrono::high_resolution_clock::time_point dictEnd =
        std::chrono::high_resolution_clock::now();
    auto dictDuration = std::chrono::duration_cast<std::chrono::seconds>(dictEnd - dictStart).count();

    std::cout << "Dictionary loaded in " << dictDuration << " seconds" << std::endl;

    Board board(boardFileName);
    std::map<Word, int> foundWords;

    std::chrono::high_resolution_clock::time_point start =
        std::chrono::high_resolution_clock::now();

    findAllWords(board,dict,foundWords);

    std::chrono::high_resolution_clock::time_point end =
        std::chrono::high_resolution_clock::now();

    auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start).count();
    std::cout << "All words found in " << duration << " seconds" << std::endl;


    writeResultsToOutputFiles(foundWords, outFileWords, outFileCoords);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7e8, %rsp            # imm = 0x7E8
movq %rsi, %r12
movl %edi, %r14d
callq 0x21a0
movq (%r12), %rsi
leaq -0xd8(%rbp), %rdi
leaq -0x488(%rbp), %rdx
callq 0x20e0
cmpl $0x9, %r14d
jne 0x583c
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0xa8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x88(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x68(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq $-0x1, %r14
leaq -0x488(%rbp), %rbx
movq 0x10(%r12,%r14,8), %rsi
movq %rbx, %rdi
leaq -0x108(%rbp), %rdx
callq 0x20e0
movq %rbx, %rdi
leaq 0x3d3c(%rip), %rsi      # 0x91f0
callq 0x2090
leaq -0x58(%rbp), %r13
testl %eax, %eax
je 0x5510
movq %rbx, %rdi
leaq 0x3d2c(%rip), %rsi      # 0x91f7
callq 0x2090
leaq -0xb8(%rbp), %r13
testl %eax, %eax
je 0x5510
movq %rbx, %rdi
leaq 0x3d1a(%rip), %rsi      # 0x91ff
callq 0x2090
leaq -0x98(%rbp), %r13
testl %eax, %eax
je 0x5510
movq %rbx, %rdi
leaq 0x3d0b(%rip), %rsi      # 0x920a
callq 0x2090
leaq -0x78(%rbp), %r13
testl %eax, %eax
jne 0x5871
movq 0x18(%r12,%r14,8), %r15
movq 0x8(%r13), %rax
movq %rax, -0x30(%rbp)
movq %r15, %rdi
callq 0x2100
movq %r13, %rdi
xorl %esi, %esi
movq -0x30(%rbp), %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x22e0
movq -0x488(%rbp), %rdi
leaq -0x478(%rbp), %rax
cmpq %rax, %rdi
je 0x5551
callq 0x21e0
addq $0x2, %r14
cmpq $0x5, %r14
jbe 0x5496
leaq -0x58(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x98(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x5d87
callq 0x2050
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x47d4
callq 0x2050
movq %rax, %r14
movq 0x7a2a(%rip), %rdi      # 0xcfc8
leaq 0x3c71(%rip), %rsi      # 0x9216
movl $0x15, %edx
callq 0x2260
subq %rbx, %r14
movabsq $0x112e0be826d694b3, %rcx # imm = 0x112E0BE826D694B3
movq %r14, %rax
imulq %rcx
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x1a, %rdx
addq %rdx, %rsi
movq 0x79f1(%rip), %rdi      # 0xcfc8
callq 0x21f0
movq %rax, %rbx
leaq 0x3c46(%rip), %rsi      # 0x922c
movl $0x8, %edx
movq %rax, %rdi
callq 0x2260
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0x488(%rbp), %r14
leaq -0xb8(%rbp), %rsi
movq %r14, %rdi
callq 0x30dc
leaq -0x100(%rbp), %rax
movl $0x0, (%rax)
xorl %r12d, %r12d
movq %r12, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
movq %r12, 0x20(%rax)
leaq -0x808(%rbp), %r13
callq 0x2050
movq %rax, -0x30(%rbp)
xorl %r15d, %r15d
xorl %ebx, %ebx
leaq (%rbx,%r13), %rdi
leaq (%rbx,%r13), %rax
addq $0x10, %rax
movq %rax, -0x10(%rax)
movq (%r14,%rbx), %rsi
movq 0x8(%r14,%rbx), %rdx
addq %rsi, %rdx
callq 0x3da6
movb 0x30(%r14,%rbx), %al
movb %al, 0x30(%r13,%rbx)
movups 0x20(%r14,%rbx), %xmm0
movups %xmm0, 0x20(%r13,%rbx)
addq $0x38, %rbx
cmpq $0xe0, %rbx
jne 0x5665
incq %r15
addq $-0xe0, %r12
movl $0xe0, %eax
addq %rax, %r14
addq %rax, %r13
cmpq $0x4, %r15
jne 0x5663
leaq -0x808(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x605f
movq $-0x380, %rbx           # imm = 0xFC80
leaq -0x4b0(%rbp), %r14
movabsq $0x112e0be826d694b3, %r15 # imm = 0x112E0BE826D694B3
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x5701
callq 0x21e0
addq $-0x38, %r14
addq $0x38, %rbx
jne 0x56f3
callq 0x2050
movq %rax, %r14
movq 0x78ae(%rip), %rdi      # 0xcfc8
leaq 0x3b14(%rip), %rsi      # 0x9235
movl $0x13, %edx
callq 0x2260
subq -0x30(%rbp), %r14
movq %r14, %rax
imulq %r15
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x1a, %rdx
addq %rdx, %rsi
movq 0x787e(%rip), %rdi      # 0xcfc8
callq 0x21f0
movq %rax, %rbx
leaq 0x3ad3(%rip), %rsi      # 0x922c
movl $0x8, %edx
movq %rax, %rdi
callq 0x2260
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
leaq -0x108(%rbp), %rdi
leaq -0x98(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x6220
leaq -0x108(%rbp), %rdi
callq 0x795c
leaq -0x130(%rbp), %rbx
xorl %r14d, %r14d
movq -0x140(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0x57d0
callq 0x21e0
addq $-0x38, %r14
cmpq $-0x380, %r14           # imm = 0xFC80
jne 0x57ba
leaq -0x38(%rbp), %rdi
callq 0x490c
leaq -0x48(%rbp), %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x57fc
callq 0x21e0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x5814
callq 0x21e0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x582c
callq 0x21e0
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x5848
callq 0x21e0
jmp 0x5848
leaq -0xd8(%rbp), %rdi
callq 0x59e7
leaq -0xc8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x585d
callq 0x21e0
xorl %eax, %eax
addq $0x7e8, %rsp            # imm = 0x7E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xd8(%rbp), %rdi
callq 0x59e7
movq -0x488(%rbp), %rdi
leaq -0x478(%rbp), %rax
cmpq %rax, %rdi
leaq -0x48(%rbp), %rbx
je 0x57ea
callq 0x21e0
jmp 0x57ea
jmp 0x58ea
movq %rax, %r14
movq $-0x380, %rbx           # imm = 0xFC80
leaq -0x4b0(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x58c3
callq 0x21e0
addq $-0x38, %r15
addq $0x38, %rbx
jne 0x58b5
jmp 0x593b
jmp 0x58dd
jmp 0x5907
jmp 0x5907
movq %rax, %r14
jmp 0x59ca
movq %rax, %r14
jmp 0x596d
movq %rax, %r14
jmp 0x593b
movq %rax, %r14
movq -0x488(%rbp), %rdi
leaq -0x478(%rbp), %rax
cmpq %rax, %rdi
je 0x590a
callq 0x21e0
jmp 0x590a
movq %rax, %r14
leaq -0x48(%rbp), %rbx
jmp 0x597a
movq %rax, %r14
subq %r12, %rbx
je 0x593b
leaq -0x830(%rbp), %r15
movq -0x840(%rbp,%rbx), %rdi
leaq (%r15,%rbx), %rax
cmpq %rdi, %rax
je 0x5935
callq 0x21e0
addq $-0x38, %rbx
jne 0x591f
leaq -0x108(%rbp), %rdi
callq 0x795c
movq $-0x380, %rbx           # imm = 0xFC80
leaq -0x130(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x5963
callq 0x21e0
addq $-0x38, %r15
addq $0x38, %rbx
jne 0x5955
leaq -0x48(%rbp), %rbx
leaq -0x38(%rbp), %rdi
callq 0x490c
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x598c
callq 0x21e0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x59a4
callq 0x21e0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x59bc
callq 0x21e0
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x59ca
callq 0x21e0
leaq -0xc8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59df
callq 0x21e0
movq %r14, %rdi
callq 0x2360