// File: /workspace/github_cpp_makefile_star2_O3/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 0x5830
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 0x3d48(%rip), %rsi      # 0x91f0
callq 0x2090
leaq -0x58(%rbp), %r13
testl %eax, %eax
je 0x5504
movq %rbx, %rdi
leaq 0x3d38(%rip), %rsi      # 0x91f7
callq 0x2090
leaq -0xb8(%rbp), %r13
testl %eax, %eax
je 0x5504
movq %rbx, %rdi
leaq 0x3d26(%rip), %rsi      # 0x91ff
callq 0x2090
leaq -0x98(%rbp), %r13
testl %eax, %eax
je 0x5504
movq %rbx, %rdi
leaq 0x3d17(%rip), %rsi      # 0x920a
callq 0x2090
leaq -0x78(%rbp), %r13
testl %eax, %eax
jne 0x5865
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 0x5545
callq 0x21e0
addq $0x2, %r14
cmpq $0x5, %r14
jbe 0x548a
leaq -0x58(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
leaq -0x98(%rbp), %rdx
leaq -0x78(%rbp), %rcx
callq 0x5d7b
callq 0x2050
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x47bc
callq 0x2050
movq %rax, %r14
movq 0x7a36(%rip), %rdi      # 0xcfc8
leaq 0x3c7d(%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 0x79fd(%rip), %rdi      # 0xcfc8
callq 0x21f0
movq %rax, %rbx
leaq 0x3c52(%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 0x30d8
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 0x3dac
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 0x5659
incq %r15
addq $-0xe0, %r12
movl $0xe0, %eax
addq %rax, %r14
addq %rax, %r13
cmpq $0x4, %r15
jne 0x5657
leaq -0x808(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x6050
movq $-0x380, %rbx           # imm = 0xFC80
leaq -0x4b0(%rbp), %r14
movabsq $0x112e0be826d694b3, %r15 # imm = 0x112E0BE826D694B3
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0x56f5
callq 0x21e0
addq $-0x38, %r14
addq $0x38, %rbx
jne 0x56e7
callq 0x2050
movq %rax, %r14
movq 0x78ba(%rip), %rdi      # 0xcfc8
leaq 0x3b20(%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 0x788a(%rip), %rdi      # 0xcfc8
callq 0x21f0
movq %rax, %rbx
leaq 0x3adf(%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 0x6211
leaq -0x108(%rbp), %rdi
callq 0x7940
leaq -0x130(%rbp), %rbx
xorl %r14d, %r14d
movq -0x140(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0x57c4
callq 0x21e0
addq $-0x38, %r14
cmpq $-0x380, %r14           # imm = 0xFC80
jne 0x57ae
leaq -0x38(%rbp), %rdi
callq 0x48f4
leaq -0x48(%rbp), %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x57f0
callq 0x21e0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x5808
callq 0x21e0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x5820
callq 0x21e0
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x583c
callq 0x21e0
jmp 0x583c
leaq -0xd8(%rbp), %rdi
callq 0x59db
leaq -0xc8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5851
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 0x59db
movq -0x488(%rbp), %rdi
leaq -0x478(%rbp), %rax
cmpq %rax, %rdi
leaq -0x48(%rbp), %rbx
je 0x57de
callq 0x21e0
jmp 0x57de
jmp 0x58de
movq %rax, %r14
movq $-0x380, %rbx           # imm = 0xFC80
leaq -0x4b0(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x58b7
callq 0x21e0
addq $-0x38, %r15
addq $0x38, %rbx
jne 0x58a9
jmp 0x592f
jmp 0x58d1
jmp 0x58fb
jmp 0x58fb
movq %rax, %r14
jmp 0x59be
movq %rax, %r14
jmp 0x5961
movq %rax, %r14
jmp 0x592f
movq %rax, %r14
movq -0x488(%rbp), %rdi
leaq -0x478(%rbp), %rax
cmpq %rax, %rdi
je 0x58fe
callq 0x21e0
jmp 0x58fe
movq %rax, %r14
leaq -0x48(%rbp), %rbx
jmp 0x596e
movq %rax, %r14
subq %r12, %rbx
je 0x592f
leaq -0x830(%rbp), %r15
movq -0x840(%rbp,%rbx), %rdi
leaq (%r15,%rbx), %rax
cmpq %rdi, %rax
je 0x5929
callq 0x21e0
addq $-0x38, %rbx
jne 0x5913
leaq -0x108(%rbp), %rdi
callq 0x7940
movq $-0x380, %rbx           # imm = 0xFC80
leaq -0x130(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x5957
callq 0x21e0
addq $-0x38, %r15
addq $0x38, %rbx
jne 0x5949
leaq -0x48(%rbp), %rbx
leaq -0x38(%rbp), %rdi
callq 0x48f4
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x5980
callq 0x21e0
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x5998
callq 0x21e0
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x59b0
callq 0x21e0
movq -0x58(%rbp), %rdi
cmpq %rbx, %rdi
je 0x59be
callq 0x21e0
leaq -0xc8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59d3
callq 0x21e0
movq %r14, %rdi
callq 0x2360