// File: Razakhel[P]RaZonogram/src/Grid.cpp
// Function: Grid::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
const bool Grid::loadFromFile(const std::string& fileName) {
  if (std::ifstream fs{fileName}) { // If the file could have been opened
    unsigned int height, width;

    // Fetching height & width of the grid from the first 2 characters
    fs >> height >> width;
    colClues.resize(height);
    rowClues.resize(width);
    boardHeight = height;
    boardWidth = width;

    // Resizing the grid accordingly
    board.resize(height);
    for (unsigned int i = 0; i < height; ++i)
      board[i].resize(width);

    // Fetching grid's clues
    int value, lineNumber = 1;
    std::string line;

    // Reads every clues for each row & column from the file
    // Clues are written as following:
    //
    // a;b;c d;e f;g    <- Columns' clues
    // h i;j;k;l;m n    <- Rows' clues
    //
    // When finding a ';' char, the algorithm moves to the next line
    // Within the same line, each clue is separated by a space
    while (std::getline(fs, line)) {
      if (lineNumber > 1) { // If the line isn't the first one (which is <height width>)
        std::vector<std::string> vals;

        if (lineNumber == 2) { // Second line is column's
          // Filling columns' clues
          Utils::split(line, ';', vals);

          for (unsigned int i = 0; i < vals.size(); ++i) {
            std::stringstream ss{vals[i]};
            while (ss >> value)
              colClues[i].push_back(value);
          }
        } else if (lineNumber == 3) { // Third line is row's
          // Filling rows' clues
          Utils::split(line, ';', vals);

          for (unsigned int i = 0; i < vals.size(); ++i) {
            std::stringstream ss{vals[i]};
            while (ss >> value)
              rowClues[i].push_back(value);
          }
        } // End of if (lineNumber == 3)
      } // End of if (lineNumber > 1)
      lineNumber++;
    } // End of while (std::getline(fs, line))
  } else { // If the file couldn't have been opened
    return false;
  }
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x610, %rsp            # imm = 0x610
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x5a8(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x220(%rbp), %rdi
movl $0x8, %edx
callq 0x22a0
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x2240
movb %al, -0x59d(%rbp)
jmp 0x27e3
movb -0x59d(%rbp), %al
testb $0x1, %al
jne 0x27f2
jmp 0x2ca6
leaq -0x220(%rbp), %rdi
leaq -0x230(%rbp), %rsi
callq 0x2030
movq %rax, -0x5b0(%rbp)
jmp 0x280e
movq -0x5b0(%rbp), %rdi
leaq -0x234(%rbp), %rsi
callq 0x2030
jmp 0x2823
movq -0x5a8(%rbp), %rdi
addq $0x8, %rdi
movl -0x230(%rbp), %eax
movl %eax, %esi
callq 0x3b90
jmp 0x283d
movq -0x5a8(%rbp), %rdi
addq $0x20, %rdi
movl -0x234(%rbp), %eax
movl %eax, %esi
callq 0x3b90
jmp 0x2857
movq -0x5a8(%rbp), %rdi
movl -0x230(%rbp), %eax
movl %eax, (%rdi)
movl -0x234(%rbp), %eax
movl %eax, 0x4(%rdi)
addq $0x38, %rdi
movl -0x230(%rbp), %eax
movl %eax, %esi
callq 0x3c20
jmp 0x2882
movl $0x0, -0x238(%rbp)
movl -0x238(%rbp), %eax
cmpl -0x230(%rbp), %eax
jae 0x28ee
movq -0x5a8(%rbp), %rdi
addq $0x38, %rdi
movl -0x238(%rbp), %eax
movl %eax, %esi
callq 0x2710
movq %rax, %rdi
movl -0x234(%rbp), %eax
movl %eax, %esi
callq 0x3cb0
jmp 0x28c4
jmp 0x28c6
movl -0x238(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x238(%rbp)
jmp 0x288c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x2ce0
movl $0x1, -0x240(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x2260
leaq -0x220(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x2050
movq %rax, -0x5b8(%rbp)
jmp 0x2920
movq -0x5b8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, -0x5b9(%rbp)
jmp 0x293e
movb -0x5b9(%rbp), %al
testb $0x1, %al
jne 0x294d
jmp 0x2c8a
cmpl $0x1, -0x240(%rbp)
jle 0x2c76
leaq -0x278(%rbp), %rdi
callq 0x3d40
cmpl $0x2, -0x240(%rbp)
jne 0x2af9
leaq -0x260(%rbp), %rdi
movl $0x3b, %esi
leaq -0x278(%rbp), %rdx
callq 0x2d10
jmp 0x298d
movl $0x0, -0x27c(%rbp)
movl -0x27c(%rbp), %eax
movq %rax, -0x5c8(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x3d60
movq %rax, %rcx
movq -0x5c8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2af4
movl -0x27c(%rbp), %eax
movl %eax, %esi
leaq -0x278(%rbp), %rdi
callq 0x3d80
movq %rax, -0x5d8(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0x3da0
movl %eax, -0x5cc(%rbp)
jmp 0x29f5
movl -0x5cc(%rbp), %edx
movq -0x5d8(%rbp), %rsi
leaq -0x408(%rbp), %rdi
callq 0x2290
jmp 0x2a10
jmp 0x2a12
leaq -0x408(%rbp), %rdi
leaq -0x23c(%rbp), %rsi
callq 0x20f0
movq %rax, -0x5e0(%rbp)
jmp 0x2a2e
movq -0x5e0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, -0x5e1(%rbp)
jmp 0x2a4c
movb -0x5e1(%rbp), %al
testb $0x1, %al
jne 0x2a58
jmp 0x2ad4
movq -0x5a8(%rbp), %rdi
addq $0x8, %rdi
movl -0x27c(%rbp), %eax
movl %eax, %esi
callq 0x3dc0
movq %rax, %rdi
leaq -0x23c(%rbp), %rsi
callq 0x3de0
jmp 0x2a81
jmp 0x2a12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x2c98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x2c68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x408(%rbp), %rdi
callq 0x2140
jmp 0x2c68
leaq -0x408(%rbp), %rdi
callq 0x2140
movl -0x27c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x27c(%rbp)
jmp 0x2997
jmp 0x2c5a
cmpl $0x3, -0x240(%rbp)
jne 0x2c58
leaq -0x260(%rbp), %rdi
movl $0x3b, %esi
leaq -0x278(%rbp), %rdx
callq 0x2d10
jmp 0x2b20
movl $0x0, -0x40c(%rbp)
movl -0x40c(%rbp), %eax
movq %rax, -0x5f0(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x3d60
movq %rax, %rcx
movq -0x5f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2c56
movl -0x40c(%rbp), %eax
movl %eax, %esi
leaq -0x278(%rbp), %rdi
callq 0x3d80
movq %rax, -0x600(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0x3da0
movl %eax, -0x5f4(%rbp)
jmp 0x2b88
movl -0x5f4(%rbp), %edx
movq -0x600(%rbp), %rsi
leaq -0x598(%rbp), %rdi
callq 0x2290
jmp 0x2ba3
jmp 0x2ba5
leaq -0x598(%rbp), %rdi
leaq -0x23c(%rbp), %rsi
callq 0x20f0
movq %rax, -0x608(%rbp)
jmp 0x2bc1
movq -0x608(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2240
movb %al, -0x609(%rbp)
jmp 0x2bdf
movb -0x609(%rbp), %al
testb $0x1, %al
jne 0x2beb
jmp 0x2c36
movq -0x5a8(%rbp), %rdi
addq $0x20, %rdi
movl -0x40c(%rbp), %eax
movl %eax, %esi
callq 0x3dc0
movq %rax, %rdi
leaq -0x23c(%rbp), %rsi
callq 0x3de0
jmp 0x2c14
jmp 0x2ba5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x598(%rbp), %rdi
callq 0x2140
jmp 0x2c68
leaq -0x598(%rbp), %rdi
callq 0x2140
movl -0x40c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40c(%rbp)
jmp 0x2b2a
jmp 0x2c58
jmp 0x2c5a
leaq -0x278(%rbp), %rdi
callq 0x3e50
jmp 0x2c76
leaq -0x278(%rbp), %rdi
callq 0x3e50
jmp 0x2c98
movl -0x240(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x240(%rbp)
jmp 0x2904
leaq -0x260(%rbp), %rdi
callq 0x2100
jmp 0x2cb6
leaq -0x260(%rbp), %rdi
callq 0x2100
jmp 0x2ce0
movb $0x0, -0x1(%rbp)
movl $0x1, -0x59c(%rbp)
jmp 0x2cc0
movl $0x0, -0x59c(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x2060
movl -0x59c(%rbp), %eax
testl %eax, %eax
je 0x2cda
jmp 0x2cd8
jmp 0x2cee
movb $0x1, -0x1(%rbp)
jmp 0x2cee
leaq -0x220(%rbp), %rdi
callq 0x2060
jmp 0x2cfc
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x610, %rsp            # imm = 0x610
popq %rbp
retq
movq -0x228(%rbp), %rdi
callq 0x22f0
nopl (%rax,%rax)