// File: /workspace/github_cpp_makefile_star2_O1/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), %rsi
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x6590
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xb0(%rsp,%rax)
jne 0x1f15c
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
leaq 0x2949c(%rip), %rsi     # 0x48387
leaq 0x70(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
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
leaq 0x10(%rbx), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movl %eax, %r13d
movq $0x0, 0x8(%rsp)
leaq 0x18(%rsp), %r12
xorl %r14d, %r14d
movq 0x90(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x6350
movsbl %al, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x6650
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1f08c
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
cmpb $0xd, -0x1(%rax,%rcx)
jne 0x1ef8a
movq %r12, %rdi
callq 0x6450
testb $0x1, %r14b
je 0x1f059
movq 0x38(%rsp), %rax
cmpq %rax, 0x20(%rsp)
jne 0x1f104
cmpl $0x0, (%rsp)
jle 0x1f040
movq 0x8(%rsp), %rax
movl %eax, %r15d
imull (%rsp), %r15d
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x14(%rsp)
xorl %r12d, %r12d
movq 0x18(%rsp), %rax
movzbl (%rax,%r12), %eax
cmpl $0x40, %eax
je 0x1f038
cmpl $0x54, %eax
je 0x1f038
movl $0x28, %edi
callq 0x6370
movq %rax, %rbp
leal (%r15,%r12), %esi
movq %rax, %rdi
callq 0x1d2e8
movq %rbp, 0x48(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %r12d, %xmm0
movss %xmm0, 0x20(%rbp)
movss 0x14(%rsp), %xmm0
movss %xmm0, 0x24(%rbp)
movq 0x18(%rbx), %rsi
cmpq 0x20(%rbx), %rsi
je 0x1f029
movq %rbp, (%rsi)
addq $0x8, 0x18(%rbx)
jmp 0x1f038
movq 0x40(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x1c69a
incq %r12
cmpq %r12, %r13
jne 0x1efcb
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
leaq 0x90(%rsp), %r15
leaq 0x18(%rsp), %r12
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
leaq 0x50(%rsp), %rdx
leaq 0x70(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
movzbl %r14b, %r14d
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %r14d
jmp 0x1ef38
leaq 0x90(%rsp), %rdi
callq 0x60c0
movq 0x8(%rsp), %rax
cmpl 0x4(%rsp), %eax
jne 0x1f1b6
leaq 0x70(%rsp), %rdi
callq 0xb42a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1f0c9
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1f0e5
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x90(%rsp), %rdi
callq 0x60f0
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x42e9d(%rip), %rdi     # 0x61fa8
leaq 0x2af86(%rip), %rsi     # 0x4a098
movl $0x1f, %edx
callq 0x63f0
movq 0x42e85(%rip), %rdi     # 0x61fa8
leaq 0x2adee(%rip), %rsi     # 0x49f18
movl $0x1c, %edx
callq 0x63f0
movq 0x42e6d(%rip), %rdi     # 0x61fa8
movl (%rsp), %esi
callq 0x6610
leaq 0x29419(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x42e45(%rip), %rdi     # 0x61fa8
leaq 0x2af09(%rip), %rsi     # 0x4a073
movl $0x24, %edx
callq 0x63f0
movq 0xa0(%rbx), %rsi
movq 0xa8(%rbx), %rdx
movq 0x42e1f(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x29140(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x293b7(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1f152
movq 0x42deb(%rip), %rdi     # 0x61fa8
leaq 0x2aed4(%rip), %rsi     # 0x4a098
movl $0x1f, %edx
callq 0x63f0
movq 0x42dd3(%rip), %rdi     # 0x61fa8
leaq 0x2ad7d(%rip), %rsi     # 0x49f59
movl $0x1d, %edx
callq 0x63f0
movq 0x42dbb(%rip), %rdi     # 0x61fa8
movl 0x4(%rsp), %esi
callq 0x6610
leaq 0x29366(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x1f152
movq %rax, %rbx
jmp 0x1f26e
jmp 0x1f22e
jmp 0x1f22e
movq %rax, %rbx
jmp 0x1f23b
jmp 0x1f22e
jmp 0x1f22e
movq %rax, %rbx
movl $0x28, %esi
movq %rbp, %rdi
callq 0x6380
jmp 0x1f231
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0xb42a
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1f252
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1f26e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x90(%rsp), %rdi
callq 0x60f0
movq %rbx, %rdi
callq 0x6620
nop