// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %rdi, %r15
leaq 0x58(%rsp), %rbx
pushq $0x8
popq %rdx
movq %rbx, %rdi
callq 0x21f0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x78(%rsp,%rax), %ebp
testb $0x5, %bpl
jne 0x2735
leaq 0x58(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2230
movq %rsp, %rsi
movq %rax, %rdi
callq 0x2230
leaq 0x8(%r15), %rbx
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x2e48
leaq 0x20(%r15), %r14
movl (%rsp), %esi
movq %r14, %rdi
callq 0x2e48
movl 0x4(%rsp), %esi
movl %esi, (%r15)
movl (%rsp), %eax
movl %eax, 0x4(%r15)
addq $0x38, %r15
movq %r15, %rdi
callq 0x2e7e
xorl %r12d, %r12d
xorl %r13d, %r13d
movl 0x4(%rsp), %eax
cmpq %rax, %r13
jae 0x25a0
movq (%r15), %rdi
addq %r12, %rdi
movl (%rsp), %esi
callq 0x2eb4
incq %r13
addq $0x18, %r12
jmp 0x2580
movl %ebp, 0x8(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
pushq $0x1
popq %r12
leaq 0x260(%rsp), %rbp
leaq 0x34(%rsp), %r15
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2727
cmpl $0x2, %r12d
jb 0x271f
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
cmpl $0x3, %r12d
movl %r12d, 0xc(%rsp)
je 0x2696
cmpl $0x2, %r12d
jne 0x2710
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x27a7
xorl %r12d, %r12d
movl %r12d, %r12d
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0x2710
movq %r12, %rax
shlq $0x5, %rax
addq %rax, %rsi
movq %rbp, %rdi
pushq $0x18
popq %rdx
callq 0x21e0
imulq $0x18, %r12, %r13
movq %rbp, %rdi
movq %r15, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2689
movq (%rbx), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x2ee6
jmp 0x2660
movq %rbp, %rdi
callq 0x2100
incl %r12d
jmp 0x262a
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x27a7
xorl %r12d, %r12d
movl %r12d, %r12d
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0x2710
movq %r12, %rax
shlq $0x5, %rax
addq %rax, %rsi
movq %rbp, %rdi
pushq $0x18
popq %rdx
callq 0x21e0
imulq $0x18, %r12, %r13
movq %rbp, %rdi
movq %r15, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2703
movq (%r14), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x2ee6
jmp 0x26da
movq %rbp, %rdi
callq 0x2100
incl %r12d
jmp 0x26a8
leaq 0x10(%rsp), %rdi
callq 0x2f04
movl 0xc(%rsp), %r12d
incl %r12d
jmp 0x25c6
leaq 0x38(%rsp), %rdi
callq 0x2090
movl 0x8(%rsp), %ebp
testb $0x5, %bpl
sete %bl
leaq 0x58(%rsp), %rdi
callq 0x2040
movl %ebx, %eax
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x275e
jmp 0x276a
movq %rax, %rbx
jmp 0x2795
movq %rax, %rbx
jmp 0x278b
jmp 0x276a
movq %rax, %rbx
jmp 0x2781
jmp 0x2771
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
callq 0x2100
leaq 0x10(%rsp), %rdi
callq 0x2f04
leaq 0x38(%rsp), %rdi
callq 0x2090
leaq 0x58(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2240