// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
leaq 0x58(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x21e0
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x78(%rsp,%rax), %ebp
testb $0x5, %bpl
jne 0x294c
leaq 0x58(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x2220
leaq 0x8(%rsp), %rsi
movq %rax, %rdi
callq 0x2220
leaq 0x8(%rbx), %r14
movl 0x4(%rsp), %esi
movq %r14, %rdi
callq 0x3412
leaq 0x20(%rbx), %r15
movl 0x8(%rsp), %esi
movq %r15, %rdi
callq 0x3412
movl 0x4(%rsp), %esi
movl %esi, (%rbx)
movl 0x8(%rsp), %eax
movl %eax, 0x4(%rbx)
addq $0x38, %rbx
movq %rbx, %rdi
callq 0x344e
cmpl $0x0, 0x4(%rsp)
je 0x26f8
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rbx), %rdi
addq %r12, %rdi
movl 0x8(%rsp), %esi
callq 0x348a
incq %r13
movl 0x4(%rsp), %eax
addq $0x18, %r12
cmpq %rax, %r13
jb 0x26d9
movl %ebp, 0x28(%rsp)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x260(%rsp), %r12
leaq 0x80(%r12), %rax
movq %rax, 0x30(%rsp)
movl $0x1, %r13d
leaq 0xc(%rsp), %rbp
leaq 0x58(%rsp), %rbx
movq 0x58(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2160
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
callq 0x2250
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x292c
cmpl $0x2, %r13d
jb 0x2924
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x3, %r13d
movl %r13d, 0x2c(%rsp)
je 0x285b
cmpl $0x2, %r13d
jne 0x2910
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x29e4
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x2910
xorl %ebx, %ebx
movq %rbx, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %r12, %rdi
movl $0x18, %edx
callq 0x21d0
leaq (%rbx,%rbx,2), %r13
movq %r12, %rdi
movq %rbp, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2821
movq (%r14), %rax
leaq (%rax,%r13,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2817
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x27dd
movq %rbp, %rdx
callq 0x4048
jmp 0x27dd
movq %r12, %rdi
movq 0x5785(%rip), %rsi      # 0x7fb0
callq 0x2110
movq 0x30(%rsp), %rdi
callq 0x2060
incl %ebx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rbx, %rcx
ja 0x27c2
jmp 0x2910
leaq 0x38(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x29e4
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x2910
xorl %ebx, %ebx
movq %rbx, %rsi
shlq $0x5, %rsi
addq %rax, %rsi
movq %r12, %rdi
movl $0x18, %edx
callq 0x21d0
leaq (%rbx,%rbx,2), %r13
movq %r12, %rdi
movq %rbp, %rsi
callq 0x20c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x28db
movq (%r15), %rax
leaq (%rax,%r13,8), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x28d1
movl 0xc(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x2897
movq %rbp, %rdx
callq 0x4048
jmp 0x2897
movq %r12, %rdi
movq 0x56cb(%rip), %rsi      # 0x7fb0
callq 0x2110
movq 0x30(%rsp), %rdi
callq 0x2060
incl %ebx
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
cmpq %rbx, %rcx
ja 0x287c
leaq 0x10(%rsp), %rdi
callq 0x34bc
leaq 0x58(%rsp), %rbx
movl 0x2c(%rsp), %r13d
incl %r13d
jmp 0x2735
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x2948
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2180
movl 0x28(%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 0x2975
jmp 0x2981
movq %rax, %rbx
jmp 0x29d2
movq %rax, %rbx
jmp 0x29b6
jmp 0x2981
movq %rax, %rbx
jmp 0x29ac
jmp 0x2988
movq %rax, %rbx
movq 0x561e(%rip), %rsi      # 0x7fb0
leaq 0x260(%rsp), %rdi
callq 0x2110
leaq 0x2e0(%rsp), %rdi
callq 0x2060
leaq 0x10(%rsp), %rdi
callq 0x34bc
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x29d2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2180
leaq 0x58(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x2230