// File: /workspace/github_cpp_makefile_star2_O1/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 0x3102
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 0x3446
cmpq $0x4, %r14
je 0x349f
movq %r13, %rdi
movq %r12, %rsi
movl $0x20, %edx
callq 0x2715
movq %r14, -0x50(%rbp)
movq -0x80(%rbp), %rax
subq -0x88(%rbp), %rax
cmpq $0x80, %rax
ja 0x34d3
movq -0x88(%rbp), %r15
cmpq %r15, -0x80(%rbp)
je 0x3415
movq -0x50(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x90(%rbp)
xorl %r14d, %r14d
movq -0x48(%rbp), %r13
movq $0x0, -0x38(%rbp)
movq 0x8(%r15,%r14), %rdx
testq %rdx, %rdx
je 0x347c
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 0x3242
movl $0x2, %r8d
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0x5dff(%rip), %rcx      # 0x903a
callq 0x22e0
jmp 0x325d
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 0x348c
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 0x333d
movl $0x2, %edx
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x2230
movq %r14, %rdi
leaq 0x5d83(%rip), %rsi      # 0x903d
callq 0x2090
testl %eax, %eax
je 0x3309
movq %r14, %rdi
leaq 0x5d73(%rip), %rsi      # 0x9040
callq 0x2090
testl %eax, %eax
je 0x3311
movq %r14, %rdi
leaq 0x5d63(%rip), %rsi      # 0x9043
callq 0x2090
testl %eax, %eax
je 0x3319
movq %r14, %rdi
leaq 0x5d53(%rip), %rsi      # 0x9046
callq 0x2090
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal 0x1(,%rcx,2), %r12d
jmp 0x331f
movl $0x2, %r14d
jmp 0x3325
movl $0x3, %r14d
jmp 0x3325
movl $0x2, %r12d
movl $0x1, %r14d
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x333d
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 0x3da6
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 0x33ca
callq 0x21e0
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
movq -0x98(%rbp), %r14
movq -0x30(%rbp), %rbx
je 0x33e7
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 0x31f6
movq -0x50(%rbp), %r14
incq %r14
leaq -0x88(%rbp), %r13
movq %r13, %rdi
callq 0x3994
addq $0xe0, -0x48(%rbp)
leaq -0x2f8(%rbp), %r15
leaq -0xb8(%rbp), %r12
jmp 0x315a
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x345e
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 0x5c3c(%rip), %rdi      # 0x90bf
xorl %esi, %esi
xorl %eax, %eax
callq 0x22c0
leaq 0x5c2c(%rip), %rdi      # 0x90bf
movl $0x1, %esi
xorl %eax, %eax
callq 0x22c0
movl $0x10, %edi
callq 0x2110
movq %rax, %r15
leaq 0x5b51(%rip), %rsi      # 0x9004
movq %rax, %rdi
callq 0x20d0
movq 0x9b2e(%rip), %rsi      # 0xcff0
movq 0x9af7(%rip), %rdx      # 0xcfc0
movq %r15, %rdi
callq 0x2340
jmp 0x3505
movl $0x10, %edi
callq 0x2110
movq %rax, %r15
leaq 0x5b34(%rip), %rsi      # 0x901b
movq %rax, %rdi
callq 0x20d0
movq 0x9afa(%rip), %rsi      # 0xcff0
movq 0x9ac3(%rip), %rdx      # 0xcfc0
movq %r15, %rdi
callq 0x2340
movq %rax, %r12
jmp 0x35c9
movq %rax, %r12
jmp 0x351d
movq %rax, %r12
movq %r15, %rdi
callq 0x2170
movq -0x30(%rbp), %rbx
jmp 0x3599
movq %rax, %r12
jmp 0x3533
movq %rax, %r12
movq %r15, %rdi
callq 0x2170
movq -0x30(%rbp), %rbx
jmp 0x35a5
jmp 0x356d
movq %rax, %r12
testq %r15, %r15
je 0x35ef
movq -0x30(%rbp), %rbx
leaq -0x28(%rbx), %r14
movq -0x38(%rbx,%r15), %rdi
leaq (%r14,%r15), %rax
cmpq %rdi, %rax
je 0x3562
callq 0x21e0
addq $-0x38, %r15
jne 0x354f
jmp 0x35ef
movq %rax, %r12
jmp 0x35a5
jmp 0x357b
jmp 0x357b
movq %rax, %r12
jmp 0x3599
movq %rax, %r12
jmp 0x3587
movq %rax, %r12
movq -0x30(%rbp), %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3599
callq 0x21e0
leaq -0x88(%rbp), %rdi
callq 0x3994
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x35bd
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 0x35e5
callq 0x21e0
addq $-0x38, %rbx
addq $0x38, %r14
jne 0x35d7
movq %r12, %rdi
callq 0x2360
nop