// File: /workspace/github_cpp_makefile_star2_O3/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 $0x3c8, %rsp            # imm = 0x3C8
movq %rdi, %rbx
leaq 0xa0(%rdi), %rsi
leaq 0x1c0(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x6590
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x1e0(%rsp,%rax)
jne 0x1f806
leaq 0x78(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
leaq 0x2914c(%rip), %rsi     # 0x48387
leaq 0x1a0(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
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 0x2ae9b(%rip), %rsi     # 0x4a11b
leaq 0x180(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2ac96(%rip), %rsi     # 0x49f2f
leaq 0x160(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2ae6f(%rip), %rsi     # 0x4a121
leaq 0x140(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2ae63(%rip), %rsi     # 0x4a12e
leaq 0x120(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2ae57(%rip), %rsi     # 0x4a13b
leaq 0x100(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2ae4b(%rip), %rsi     # 0x4a148
leaq 0xe0(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
movq 0x48(%rsp), %rax
leal -0x1(%rax), %ecx
movq %rcx, 0xa0(%rsp)
movl %eax, %r14d
movq $0x0, 0x50(%rsp)
leaq 0x68(%rsp), %r12
leaq 0xc0(%rsp), %rbp
movq $0x0, 0x58(%rsp)
movq 0x1c0(%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 0x1f6b6
movq 0x68(%rsp), %rax
movq 0x70(%rsp), %rcx
cmpb $0xd, -0x1(%rax,%rcx)
jne 0x1f393
movq %r12, %rdi
callq 0x6450
testb $0x1, 0x58(%rsp)
je 0x1f685
cmpl $0x0, 0x48(%rsp)
jle 0x1f66c
movq 0x50(%rsp), %rcx
movl %ecx, %edx
movq 0x48(%rsp), %rax
imull %eax, %edx
leal 0x1(%rcx), %esi
imull %eax, %esi
movq %rsi, 0x90(%rsp)
movq %rdx, 0x60(%rsp)
decl %edx
movq %rdx, 0x88(%rsp)
decl %ecx
imull %eax, %ecx
movq %rcx, 0x98(%rsp)
xorl %r15d, %r15d
movq 0x68(%rsp), %rax
movsbl (%rax,%r15), %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 0x160(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
jne 0x1f660
cmpb $0x0, 0x8(%rbx)
jne 0x1f45b
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x180(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1f45b
movb $0x1, 0x8(%rbx)
movq 0x60(%rsp), %rax
leaq (%rax,%r15), %r13
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1a2cc
testb %al, %al
je 0x1f7a9
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1a02e
movq %rax, %r13
movq 0x30(%rsp), %rax
cmpq %rax, 0x38(%rsp)
je 0x1f496
movq %rax, 0x38(%rsp)
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x140(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1f4f4
movq 0x98(%rsp), %rax
leaq (%rax,%r15), %r12
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a2cc
testb %al, %al
je 0x1f4f4
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a02e
movq %rax, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1fb6e
testq %r15, %r15
je 0x1f557
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x100(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1f557
movq 0x88(%rsp), %rax
leaq (%rax,%r15), %r12
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a2cc
testb %al, %al
je 0x1f557
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a02e
movq %rax, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1fb6e
cmpq %r15, 0xa0(%rsp)
je 0x1f5bf
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0xe0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1f5bf
movq 0x60(%rsp), %rax
leaq (%rax,%r15), %r12
incq %r12
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a2cc
testb %al, %al
je 0x1f5bf
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a02e
movq %rax, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1fb6e
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x120(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1f61d
movq 0x90(%rsp), %rax
leaq (%rax,%r15), %r12
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a2cc
testb %al, %al
je 0x1f61d
movq %rbx, %rdi
movl %r12d, %esi
callq 0x1a02e
movq %rax, 0x8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x1fb6e
leaq 0xa8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x19aae
addq $0x8, %r13
movq %r13, %rdi
leaq 0xa8(%rsp), %rsi
callq 0x1b2e0
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x1f660
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
incq %r15
cmpq %r15, %r14
jne 0x1f3e5
movq 0x50(%rsp), %rax
incl %eax
movq %rax, 0x50(%rsp)
leaq 0x1c0(%rsp), %r15
leaq 0x68(%rsp), %r12
movq 0x68(%rsp), %rdi
movq 0x70(%rsp), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
leaq 0x1a0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
movq 0x58(%rsp), %rcx
orb %al, %cl
movq %rcx, 0x58(%rsp)
jmp 0x1f341
leaq 0x1c0(%rsp), %rdi
callq 0x60c0
leaq 0xe0(%rsp), %rdi
callq 0xb464
leaq 0x100(%rsp), %rdi
callq 0xb464
leaq 0x120(%rsp), %rdi
callq 0xb464
leaq 0x140(%rsp), %rdi
callq 0xb464
leaq 0x160(%rsp), %rdi
callq 0xb464
leaq 0x180(%rsp), %rdi
callq 0xb464
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1f72d
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1f744
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x1a0(%rsp), %rdi
callq 0xb464
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f76e
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x1f78a
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x1c0(%rsp), %rdi
callq 0x60f0
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x427f8(%rip), %rdi     # 0x61fa8
leaq 0x2a99e(%rip), %rsi     # 0x4a155
movl $0x1f, %edx
callq 0x63f0
movq 0x427e0(%rip), %rdi     # 0x61fa8
leaq 0x2a7a4(%rip), %rsi     # 0x49f73
movl $0x23, %edx
callq 0x63f0
movq 0x60(%rsp), %rsi
addq %r15, %rsi
movq 0x427c0(%rip), %rdi     # 0x61fa8
callq 0x6610
leaq 0x28d6f(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x4279b(%rip), %rdi     # 0x61fa8
leaq 0x2a8e2(%rip), %rsi     # 0x4a0f6
movl $0x24, %edx
callq 0x63f0
movq 0xa0(%rbx), %rsi
movq 0xa8(%rbx), %rdx
movq 0x42775(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x28a96(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x28d0d(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1f7fc
movq %rax, %rbx
jmp 0x1f99c
jmp 0x1f8d2
movq %rax, %rbx
jmp 0x1f8e2
movq %rax, %rbx
jmp 0x1f8ef
movq %rax, %rbx
jmp 0x1f8fc
movq %rax, %rbx
jmp 0x1f909
movq %rax, %rbx
jmp 0x1f916
movq %rax, %rbx
jmp 0x1f923
movq %rax, %rbx
jmp 0x1f956
movq %rax, %rbx
jmp 0x1f963
jmp 0x1f8d2
jmp 0x1f8d2
jmp 0x1f8d2
jmp 0x1f8d2
jmp 0x1f8d2
jmp 0x1f8d2
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
testq %rdi, %rdi
je 0x1f8d5
movq 0xb8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x1f8d5
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xb464
leaq 0x100(%rsp), %rdi
callq 0xb464
leaq 0x120(%rsp), %rdi
callq 0xb464
leaq 0x140(%rsp), %rdi
callq 0xb464
leaq 0x160(%rsp), %rdi
callq 0xb464
leaq 0x180(%rsp), %rdi
callq 0xb464
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x1f93f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1f956
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x1a0(%rsp), %rdi
callq 0xb464
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1f980
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x1f99c
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x1c0(%rsp), %rdi
callq 0x60f0
movq %rbx, %rdi
callq 0x6620
nop