// File: /workspace/github_cpp_makefile_star2_O2/Kei18[P]pibt/./src/graph/simplegrid.cpp
// Function: SimpleGrid::createNodes()
void SimpleGrid::createNodes() {
  std::ifstream file(filename);
  if (!file) {
    std::cout << "error@SimpleGrid::createNodes, file "
              << filename
              << " does not exist" << "\n";
    std::exit(1);
  }

  std::string line;
  std::smatch results;
  std::regex r_map = std::regex(R"(map)");
  int w  = getW();
  int h = getH();
  int id;
  int j = 0;  // height
  bool mapStart = false;
  char s;

  while (getline(file, line)) {
    // for CRLF coding
    if (*(line.end()-1) == 0x0d) line.pop_back();

    if (mapStart) {
      // width check
      if (line.size() != w) {
        std::cout << "error@SimpleGrid::createNodes, "
                  << "width is invalid, should be " << w <<  "\n";
        std::exit(1);
      }
      for (int i = 0; i < w; ++i) {
        s = line[i];
        id = j * w + i;
        if (s == 'T' or s == '@') continue;
        Node* v = new Node(id);
        v->setPos(i, j);
        nodes.push_back(v);
      }
      ++j;
    }

    if (std::regex_match(line, results, r_map)) mapStart = true;
  }
  file.close();

  // height check
  if (j != h) {
    std::cout << "error@SimpleGrid::createNodes, "
              << "height is invalid, shoudl be " << h <<  "\n";
    std::exit(1);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, %rbx
leaq 0xa0(%rdi), %r14
leaq 0x90(%rsp), %r15
pushq $0x8
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x65a0
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0x1a407
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
leaq 0x20178(%rip), %rsi     # 0x3a387
leaq 0x70(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movl %eax, (%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl %eax, 0x4(%rsp)
movslq (%rsp), %rax
addq $0x10, %rbx
xorl %r14d, %r14d
testl %eax, %eax
movl $0x0, %r12d
movq %rax, 0x38(%rsp)
cmovgl %eax, %r12d
leaq 0x90(%rsp), %r13
leaq 0x18(%rsp), %r15
leaq 0x50(%rsp), %rbp
movq $0x0, 0x8(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x60b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1a36e
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpb $0xd, -0x1(%rax,%rcx)
jne 0x1a2a1
movq %r15, %rdi
callq 0x6460
testb $0x1, 0x8(%rsp)
je 0x1a34b
movq 0x38(%rsp), %rax
cmpq %rax, 0x20(%rsp)
jne 0x1a3c3
movq %r13, %r15
movl %r14d, %r13d
imull (%rsp), %r13d
movq %r14, 0x40(%rsp)
cvtsi2ss %r14d, %xmm0
movss %xmm0, 0x14(%rsp)
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x1a336
movq 0x18(%rsp), %rax
movzbl (%rax,%rbp), %eax
cmpl $0x40, %eax
je 0x1a331
cmpl $0x54, %eax
je 0x1a331
pushq $0x28
popq %rdi
callq 0x63b0
movq %rax, %r14
leal (%r13,%rbp), %esi
movq %rax, %rdi
callq 0x18f84
cvtsi2ss %ebp, %xmm0
movq %r14, 0x48(%rsp)
movss %xmm0, 0x20(%r14)
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x24(%r14)
movq %rbx, %rdi
leaq 0x48(%rsp), %rsi
callq 0x171da
incq %rbp
jmp 0x1a2d9
movq 0x40(%rsp), %r14
incl %r14d
movq %r15, %r13
leaq 0x18(%rsp), %r15
leaq 0x50(%rsp), %rbp
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x70(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
movq 0x8(%rsp), %rcx
orb %al, %cl
movq %rcx, 0x8(%rsp)
jmp 0x1a26b
leaq 0x90(%rsp), %rdi
callq 0x60d0
cmpl 0x4(%rsp), %r14d
jne 0x1a445
leaq 0x70(%rsp), %rdi
callq 0x9260
leaq 0x50(%rsp), %rdi
callq 0x9690
leaq 0x18(%rsp), %rdi
callq 0x61d0
leaq 0x90(%rsp), %rdi
callq 0x6120
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3fbce(%rip), %rdi     # 0x59f98
leaq 0x21dad(%rip), %rsi     # 0x3c17e
callq 0x63a0
leaq 0x21c21(%rip), %rsi     # 0x3bffe
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl (%rsp), %esi
callq 0x6630
leaq 0x2016c(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
movq 0x3fb8a(%rip), %rdi     # 0x59f98
leaq 0x21d44(%rip), %rsi     # 0x3c159
callq 0x63a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x6360
leaq 0x1feac(%rip), %rsi     # 0x3a2d8
movq %rax, %rdi
callq 0x63a0
leaq 0x20128(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x1a3ff
movq 0x3fb4c(%rip), %rdi     # 0x59f98
leaq 0x21d2b(%rip), %rsi     # 0x3c17e
callq 0x63a0
leaq 0x21be0(%rip), %rsi     # 0x3c03f
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl 0x4(%rsp), %esi
callq 0x6630
leaq 0x200e9(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x1a3ff
movq %rax, %rbx
jmp 0x1a4ca
jmp 0x1a4a9
jmp 0x1a4a9
movq %rax, %rbx
jmp 0x1a4b6
jmp 0x1a4a9
jmp 0x1a4a9
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %r14, %rdi
callq 0x63c0
jmp 0x1a4ac
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x9260
leaq 0x50(%rsp), %rdi
callq 0x9690
leaq 0x18(%rsp), %rdi
callq 0x61d0
leaq 0x90(%rsp), %rdi
callq 0x6120
movq %rbx, %rdi
callq 0x6650
nop