// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/graph/simplegrid.cpp
// Function: SimpleGrid::createEdges()
void SimpleGrid::createEdges() {
  std::ifstream file(filename);
  if (!file) {
    std::cout << "error@SimpleGrid::createEdges, 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 j = 0;  // height
  int id;
  bool mapStart = false;
  Nodes neighbor;
  std::string s;
  Node* v;

  std::regex r_direction = std::regex(R"([a-z])");
  std::regex r_obj   = std::regex(R"([@T])");
  std::regex r_up    = std::regex(R"([\.oaefgkmn])");
  std::regex r_down  = std::regex(R"([\.ocfhjklm])");
  std::regex r_left  = std::regex(R"([\.odgijlmn])");
  std::regex r_right = std::regex(R"([\.obehikln])");

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

    if (mapStart) {
      for (int i = 0; i < w; ++i) {
        id = j * w + i;
        s = line[i];

        // object
        if (std::regex_match(s, results, r_obj)) continue;

        // digraph, default is undirected graph
        if (!isDirected() && std::regex_match(s, results, r_direction)) {
          setDirected(true);
        }

        if (!existNode(id)) {
          std::cout << "error@SimpleGrid::createEdges, "
                    << "corresponding node does not exist, " << id << "\n";
          std::exit(1);
        }
        v = getNode(id);  // target node
        neighbor.clear();

        if (std::regex_match(s, results, r_up)) {
          if (existNode(id - w)) neighbor.push_back(getNode(id - w));
        }
        if (i != 0 && std::regex_match(s, results, r_left)) {
          if (existNode(id - 1)) neighbor.push_back(getNode(id - 1));
        }
        if (i != w - 1 && std::regex_match(s, results, r_right)) {
          if (existNode(id + 1)) neighbor.push_back(getNode(id + 1));
        }
        if (std::regex_match(s, results, r_down)) {
          if (existNode(id + w)) neighbor.push_back(getNode(id + w));
        }
        v->setNeighbor(neighbor);
      }
      ++j;
    }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
movq %rdi, %rbx
leaq 0xa0(%rdi), %rsi
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x6590
movq (%r14), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x1d0(%rsp,%rax)
jne 0x1f8b7
leaq 0x68(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
leaq 0x29090(%rip), %rsi     # 0x48387
leaq 0x190(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq %rax, 0x48(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x40(%rsp)
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0x2ada1(%rip), %rsi     # 0x4a0dd
leaq 0x170(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2ab9c(%rip), %rsi     # 0x49ef1
leaq 0x150(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2ad75(%rip), %rsi     # 0x4a0e3
leaq 0x130(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2ad69(%rip), %rsi     # 0x4a0f0
leaq 0x110(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2ad5d(%rip), %rsi     # 0x4a0fd
leaq 0xf0(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2ad51(%rip), %rsi     # 0x4a10a
leaq 0xd0(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
movq 0x48(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, 0x90(%rsp)
movl %eax, %r12d
movq $0x0, 0x50(%rsp)
leaq 0x58(%rsp), %r15
leaq 0xb0(%rsp), %rbp
movl $0x0, 0xc(%rsp)
movq 0x1b0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6350
movsbl %al, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x6650
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1f769
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
cmpb $0xd, -0x1(%rax,%rcx)
jne 0x1f44e
movq %r15, %rdi
callq 0x6450
testb $0x1, 0xc(%rsp)
je 0x1f72f
cmpl $0x0, 0x48(%rsp)
jle 0x1f716
movq 0x50(%rsp), %rcx
movl %ecx, %r15d
movq 0x48(%rsp), %rax
imull %eax, %r15d
leal -0x1(%r15), %edx
movq %rdx, 0x78(%rsp)
leal -0x1(%rcx), %edx
imull %eax, %edx
movq %rdx, 0x88(%rsp)
incl %ecx
imull %eax, %ecx
movq %rcx, 0x80(%rsp)
xorl %r14d, %r14d
movq 0x58(%rsp), %rax
movsbl (%rax,%r14), %r8d
movq 0x18(%rsp), %rdx
movl $0x1, %ecx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x6660
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x150(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
jne 0x1f70a
cmpb $0x0, 0x8(%rbx)
jne 0x1f512
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x170(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1f512
movb $0x1, 0x8(%rbx)
leal (%r15,%r14), %esi
movq %rbx, %rdi
callq 0x1a268
testb %al, %al
je 0x1f85c
leaq (%r15,%r14), %rsi
movq %rbx, %rdi
callq 0x19fd6
movq %rax, %r13
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x1f546
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x130(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1f5a7
movq 0x88(%rsp), %rax
leal (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x1a268
testb %al, %al
je 0x1f5a7
movq 0x88(%rsp), %rax
leal (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x19fd6
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x1fc22
testq %r14, %r14
je 0x1f607
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0xf0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1f607
movq 0x78(%rsp), %rax
leal (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x1a268
testb %al, %al
je 0x1f607
movq 0x78(%rsp), %rax
leal (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x19fd6
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x1fc22
cmpq %r14, 0x90(%rsp)
je 0x1f666
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0xd0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1f666
leal (%r15,%r14), %esi
incl %esi
movq %rbx, %rdi
callq 0x1a268
testb %al, %al
je 0x1f666
leal (%r15,%r14), %esi
incl %esi
movq %rbx, %rdi
callq 0x19fd6
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x1fc22
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x110(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1f6c7
movq 0x80(%rsp), %rax
leal (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x1a268
testb %al, %al
je 0x1f6c7
movq 0x80(%rsp), %rax
leal (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x19fd6
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdi
movq %rsp, %rsi
callq 0x1fc22
leaq 0x98(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x19a68
addq $0x8, %r13
movq %r13, %rdi
leaq 0x98(%rsp), %rsi
callq 0x1b2e2
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x1f70a
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
incq %r14
cmpq %r14, %r12
jne 0x1f49c
movq 0x50(%rsp), %rax
incl %eax
movq %rax, 0x50(%rsp)
leaq 0x1b0(%rsp), %r14
leaq 0x58(%rsp), %r15
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x190(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
movl 0xc(%rsp), %ecx
movzbl %cl, %ecx
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %ecx
movl %ecx, 0xc(%rsp)
jmp 0x1f3fc
leaq 0x1b0(%rsp), %rdi
callq 0x60c0
leaq 0xd0(%rsp), %rdi
callq 0xb42a
leaq 0xf0(%rsp), %rdi
callq 0xb42a
leaq 0x110(%rsp), %rdi
callq 0xb42a
leaq 0x130(%rsp), %rdi
callq 0xb42a
leaq 0x150(%rsp), %rdi
callq 0xb42a
leaq 0x170(%rsp), %rdi
callq 0xb42a
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1f7e0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1f7f7
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x190(%rsp), %rdi
callq 0xb42a
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f821
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1f83d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x1b0(%rsp), %rdi
callq 0x60f0
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x42745(%rip), %rdi     # 0x61fa8
leaq 0x2a8ad(%rip), %rsi     # 0x4a117
movl $0x1f, %edx
callq 0x63f0
movq 0x4272d(%rip), %rdi     # 0x61fa8
leaq 0x2a6b3(%rip), %rsi     # 0x49f35
movl $0x23, %edx
callq 0x63f0
addq %r14, %r15
movq 0x42712(%rip), %rdi     # 0x61fa8
movl %r15d, %esi
callq 0x6610
leaq 0x28cbe(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x426ea(%rip), %rdi     # 0x61fa8
leaq 0x2a7f3(%rip), %rsi     # 0x4a0b8
movl $0x24, %edx
callq 0x63f0
movq 0xa0(%rbx), %rsi
movq 0xa8(%rbx), %rdx
movq 0x426c4(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x289e5(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x28c5c(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1f8ad
movq %rax, %rbx
jmp 0x1fa4d
jmp 0x1f983
movq %rax, %rbx
jmp 0x1f993
movq %rax, %rbx
jmp 0x1f9a0
movq %rax, %rbx
jmp 0x1f9ad
movq %rax, %rbx
jmp 0x1f9ba
movq %rax, %rbx
jmp 0x1f9c7
movq %rax, %rbx
jmp 0x1f9d4
movq %rax, %rbx
jmp 0x1fa07
movq %rax, %rbx
jmp 0x1fa14
jmp 0x1f983
jmp 0x1f983
jmp 0x1f983
jmp 0x1f983
jmp 0x1f983
jmp 0x1f983
movq %rax, %rbx
movq 0x98(%rsp), %rdi
testq %rdi, %rdi
je 0x1f986
movq 0xa8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x1f986
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0xb42a
leaq 0xf0(%rsp), %rdi
callq 0xb42a
leaq 0x110(%rsp), %rdi
callq 0xb42a
leaq 0x130(%rsp), %rdi
callq 0xb42a
leaq 0x150(%rsp), %rdi
callq 0xb42a
leaq 0x170(%rsp), %rdi
callq 0xb42a
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1f9f0
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1fa07
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x190(%rsp), %rdi
callq 0xb42a
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x1fa31
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1fa4d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x1b0(%rsp), %rdi
callq 0x60f0
movq %rbx, %rdi
callq 0x6620