// File: /workspace/github_cpp_makefile_star2_O3/nachogoro[P]wordcrack-herminia/src/Board.cpp
// Function: Board::Board(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
Board::Board(const std::string& fileName)
{
    std::ifstream inputfile(fileName);

    std::string line;
    int y = 0;

    while (std::getline(inputfile, line))
    {
        if (y >= VERTICAL_SIZE) {
            throw std::runtime_error("Input file is too long");
        }

        std::vector<std::string> tokens = split(line, ' ');

        if (tokens.size() > HORIZONTAL_SIZE) {
            throw std::runtime_error("Line in input file is too long");
        }

        for (size_t x = 0; x < tokens.size(); ++x)
        {
            const std::string& token = tokens[x];
            const char tmp = token.at(0);
            std::string letter;
            if (tmp == 'Q') {
                letter = "qu";
            } else {
                letter = ::tolower(tmp);
            }
            const int value = token.at(1) - '0';

            WordMultiplier wordMult = SINGLE_WORD;
            LetterMultiplier letterMult = SINGLE_LETTER;

            if (token.length() == 4)
            {
                const std::string& modifier = token.substr(2);

                if (modifier == "DW") {
                    wordMult = DOUBLE_WORD;
                } else if (modifier == "TW") {
                    wordMult = TRIPLE_WORD;
                } else if (modifier == "DL") {
                    letterMult = DOUBLE_LETTER;
                } else if (modifier == "TL") {
                    letterMult = TRIPLE_LETTER;
                }
            }

            mLetters[y][x] = Letter(letter, value, Coordinate(x, y), 
                                        wordMult, letterMult);
        }

        ++y;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rsi, %r14
movq %rdi, %rbx
callq 0x21a0
xorl %r15d, %r15d
movq %rbx, -0x30(%rbp)
leaq (%rbx,%r15), %rdi
callq 0x276a
addq $0x38, %r15
cmpq $0x380, %r15            # imm = 0x380
jne 0x30fe
leaq -0x2f8(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x2300
leaq -0xa8(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %r14d, %r14d
leaq -0xb8(%rbp), %r12
leaq -0x88(%rbp), %r13
movq %rbx, -0x48(%rbp)
movq -0x2f8(%rbp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x2390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x343f
cmpq $0x4, %r14
je 0x349a
movq %r13, %rdi
movq %r12, %rsi
movl $0x20, %edx
callq 0x2715
movq %r14, -0x50(%rbp)
movq -0x88(%rbp), %r15
movq -0x80(%rbp), %rax
movq %rax, %rcx
subq %r15, %rcx
cmpq $0x80, %rcx
ja 0x34ce
cmpq %r15, %rax
je 0x340e
movq -0x50(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x90(%rbp)
xorl %r14d, %r14d
movq -0x48(%rbp), %r13
movq $0x0, -0x38(%rbp)
cmpq $0x0, 0x8(%r15,%r14)
je 0x3475
addq %r14, %r15
movq (%r15), %rax
movsbl (%rax), %edi
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x60(%rbp)
cmpl $0x51, %edi
jne 0x323b
movl $0x2, %r8d
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x5e06(%rip), %rcx      # 0x903a
callq 0x22e0
jmp 0x3256
callq 0x2290
movsbl %al, %r8d
movl $0x1, %ecx
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x23a0
movq 0x8(%r15), %rdx
cmpq $0x1, %rdx
jbe 0x3487
movq %r14, -0x98(%rbp)
movq (%r15), %rax
movsbl 0x1(%rax), %eax
movl %eax, -0x3c(%rbp)
movl $0x1, %r14d
movl $0x1, %r12d
cmpq $0x4, %rdx
jne 0x3336
movl $0x2, %edx
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x2230
movq %r14, %rdi
leaq 0x5d8a(%rip), %rsi      # 0x903d
callq 0x2090
testl %eax, %eax
je 0x3302
movq %r14, %rdi
leaq 0x5d7a(%rip), %rsi      # 0x9040
callq 0x2090
testl %eax, %eax
je 0x330a
movq %r14, %rdi
leaq 0x5d6a(%rip), %rsi      # 0x9043
callq 0x2090
testl %eax, %eax
je 0x3312
movq %r14, %rdi
leaq 0x5d5a(%rip), %rsi      # 0x9046
callq 0x2090
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal 0x1(,%rcx,2), %r12d
jmp 0x3318
movl $0x2, %r14d
jmp 0x331e
movl $0x3, %r14d
jmp 0x331e
movl $0x2, %r12d
movl $0x1, %r14d
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x3336
callq 0x21e0
movq %r13, %rbx
movl %r14d, %r13d
leaq -0xe0(%rbp), %r15
movq %r15, -0xf0(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
callq 0x3dac
movl -0x3c(%rbp), %eax
addl $-0x30, %eax
imull %eax, %r12d
movl -0x38(%rbp), %eax
orq -0x90(%rbp), %rax
movl %r12d, -0xd0(%rbp)
movl %r13d, -0xcc(%rbp)
movq %rax, -0xc8(%rbp)
movb $0x1, -0xc0(%rbp)
movq %rbx, %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2280
movb 0x20(%r15), %al
movb %al, 0x30(%rbx)
movups 0x10(%r15), %xmm0
movups %xmm0, 0x20(%rbx)
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0x33c3
callq 0x21e0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
movq -0x98(%rbp), %r14
movq -0x30(%rbp), %rbx
je 0x33e0
callq 0x21e0
movq -0x38(%rbp), %rdx
incq %rdx
movq -0x88(%rbp), %r15
movq -0x80(%rbp), %rax
subq %r15, %rax
sarq $0x5, %rax
addq $0x38, %r13
addq $0x20, %r14
movq %rdx, -0x38(%rbp)
cmpq %rax, %rdx
jb 0x31f1
movq -0x50(%rbp), %r14
incq %r14
leaq -0x88(%rbp), %r13
movq %r13, %rdi
callq 0x398e
addq $0xe0, -0x48(%rbp)
leaq -0x2f8(%rbp), %r15
leaq -0xb8(%rbp), %r12
jmp 0x3156
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x3457
callq 0x21e0
leaq -0x2f8(%rbp), %rdi
callq 0x2070
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5c43(%rip), %rdi      # 0x90bf
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x22c0
leaq 0x5c31(%rip), %rdi      # 0x90bf
movl $0x1, %esi
xorl %eax, %eax
callq 0x22c0
movl $0x10, %edi
callq 0x2110
movq %rax, %r15
leaq 0x5b56(%rip), %rsi      # 0x9004
movq %rax, %rdi
callq 0x20d0
movq 0x9b33(%rip), %rsi      # 0xcff0
movq 0x9afc(%rip), %rdx      # 0xcfc0
movq %r15, %rdi
callq 0x2340
jmp 0x3500
movl $0x10, %edi
callq 0x2110
movq %rax, %r15
leaq 0x5b39(%rip), %rsi      # 0x901b
movq %rax, %rdi
callq 0x20d0
movq 0x9aff(%rip), %rsi      # 0xcff0
movq 0x9ac8(%rip), %rdx      # 0xcfc0
movq %r15, %rdi
callq 0x2340
movq %rax, %r12
jmp 0x35c4
movq %rax, %r12
jmp 0x3518
movq %rax, %r12
movq %r15, %rdi
callq 0x2170
movq -0x30(%rbp), %rbx
jmp 0x3594
movq %rax, %r12
jmp 0x352e
movq %rax, %r12
movq %r15, %rdi
callq 0x2170
movq -0x30(%rbp), %rbx
jmp 0x35a0
jmp 0x3568
movq %rax, %r12
testq %r15, %r15
je 0x35ea
movq -0x30(%rbp), %rbx
leaq -0x28(%rbx), %r14
movq -0x38(%rbx,%r15), %rdi
leaq (%r14,%r15), %rax
cmpq %rdi, %rax
je 0x355d
callq 0x21e0
addq $-0x38, %r15
jne 0x354a
jmp 0x35ea
movq %rax, %r12
jmp 0x35a0
jmp 0x3576
jmp 0x3576
movq %rax, %r12
jmp 0x3594
movq %rax, %r12
jmp 0x3582
movq %rax, %r12
movq -0x30(%rbp), %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3594
callq 0x21e0
leaq -0x88(%rbp), %rdi
callq 0x398e
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x35b8
callq 0x21e0
leaq -0x2f8(%rbp), %rdi
callq 0x2070
addq $0x358, %rbx            # imm = 0x358
movq $-0x380, %r14           # imm = 0xFC80
movq -0x10(%rbx), %rdi
cmpq %rdi, %rbx
je 0x35e0
callq 0x21e0
addq $-0x38, %rbx
addq $0x38, %r14
jne 0x35d2
movq %r12, %rdi
callq 0x2360