// File: /workspace/github_cpp_makefile_star2_O3/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 $0x3f8, %rsp            # imm = 0x3F8
movq %rdi, %rbx
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x21e0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x88(%rsp,%rax), %ebp
testb $0x5, %bpl
jne 0x2954
leaq 0x68(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2220
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0x2220
leaq 0x8(%rbx), %r14
movl 0x8(%rsp), %esi
movq %r14, %rdi
callq 0x3410
leaq 0x20(%rbx), %r15
movl 0x10(%rsp), %esi
movq %r15, %rdi
callq 0x3410
movl 0x8(%rsp), %esi
movl %esi, (%rbx)
movl 0x10(%rsp), %eax
movl %eax, 0x4(%rbx)
addq $0x38, %rbx
movq %rbx, %rdi
callq 0x344c
cmpl $0x0, 0x8(%rsp)
je 0x26fb
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx), %rdi
addq %r12, %rdi
movl 0x10(%rsp), %esi
callq 0x3488
incq %r13
movl 0x8(%rsp), %eax
addq $0x18, %r12
cmpq %rax, %r13
jb 0x26dc
movl %ebp, 0x44(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x270(%rsp), %r13
leaq 0x80(%r13), %rax
movq %rax, 0x18(%rsp)
movl $0x1, 0xc(%rsp)
leaq 0x14(%rsp), %rbp
movq 0x5875(%rip), %r12      # 0x7fb0
leaq 0x68(%rsp), %rbx
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x48(%rsp), %rsi
callq 0x2250
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2934
movl 0xc(%rsp), %eax
cmpl $0x2, %eax
jb 0x2929
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
cmpl $0x3, %eax
je 0x285e
cmpl $0x2, %eax
jne 0x2916
leaq 0x48(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x29e9
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0x2916
xorl %ebx, %ebx
movq %rbx, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %r13, %rdi
movl $0x18, %edx
callq 0x21d0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2828
movq (%r14), %rax
leaq (%rbx,%rbx,2), %rcx
leaq (%rax,%rcx,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x281e
movl 0x14(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x27e0
movq %rbp, %rdx
callq 0x400e
jmp 0x27e0
movq %r13, %rdi
movq %r12, %rsi
callq 0x2110
movq 0x18(%rsp), %rdi
callq 0x2060
incl %ebx
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rbx, %rcx
ja 0x27c9
jmp 0x2916
leaq 0x48(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x29e9
movq 0x20(%rsp), %rax
cmpq %rax, 0x28(%rsp)
je 0x2916
xorl %ebx, %ebx
movq %rbx, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %r13, %rdi
movl $0x18, %edx
callq 0x21d0
leaq (%rbx,%rbx,2), %r12
movq %r13, %rdi
movq %rbp, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28de
movq (%r15), %rax
leaq (%rax,%r12,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x28d4
movl 0x14(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x289a
movq %rbp, %rdx
callq 0x400e
jmp 0x289a
movq %r13, %rdi
movq 0x56c8(%rip), %r12      # 0x7fb0
movq %r12, %rsi
callq 0x2110
movq 0x18(%rsp), %rdi
callq 0x2060
incl %ebx
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rbx, %rcx
ja 0x287f
leaq 0x20(%rsp), %rdi
callq 0x34ba
leaq 0x68(%rsp), %rbx
movl 0xc(%rsp), %eax
incl %eax
movl %eax, 0xc(%rsp)
jmp 0x2740
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x2950
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2180
movl 0x44(%rsp), %ebp
testb $0x5, %bpl
sete %bl
leaq 0x68(%rsp), %rdi
callq 0x2040
movl %ebx, %eax
addq $0x3f8, %rsp            # imm = 0x3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x297d
jmp 0x2989
movq %rax, %rbx
jmp 0x29d7
movq %rax, %rbx
jmp 0x29bb
jmp 0x2989
movq %rax, %rbx
jmp 0x29b1
jmp 0x2990
movq %rax, %rbx
movq 0x5616(%rip), %rsi      # 0x7fb0
leaq 0x270(%rsp), %rdi
callq 0x2110
movq 0x18(%rsp), %rdi
callq 0x2060
leaq 0x20(%rsp), %rdi
callq 0x34ba
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x29d7
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0x68(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2230