// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/graph/pd.cpp
// Function: PD::init()
void PD::init() {
  std::string file_pd = filename + ".pd";  // pickup and delivery
  std::ifstream file(file_pd);
  if (!file) {
    std::cout << "error@PD::init, file "
              << file_pd
              << " does not exist" << "\n";
    std::exit(1);
  }

  std::string line;
  std::smatch results;
  int w = getW();
  int h = getH();
  int j = 0;  // height
  int id = 0;
  std::string s;
  Node* v;

  std::regex r_obj   = std::regex(R"([@T])");
  std::regex r_pickup = std::regex(R"([psa])");  // pickup loc.
  std::regex r_deliv  = std::regex(R"([dsa])");  // delivery loc.
  std::regex r_end    = std::regex(R"([ea])");  // end loc.

  while (getline(file, line)) {
    // error check, width
    if (line.size() != w) {
      std::cout << "error@PD::init, "
                << "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 (std::regex_match(s, results, r_obj)) continue;

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

      if (std::regex_match(s, results, r_pickup)) {
        pickup.push_back(v);
      }
      if (std::regex_match(s, results, r_pickup)) {
        delivery.push_back(v);
      }
      if (std::regex_match(s, results, r_end)) {
        endpoints.push_back(v);
      }
    }
    ++j;
  }
  file.close();

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

  if (pickup.empty() || delivery.empty() || endpoints.empty()) {
    std::cout << "error@TP::init, file "
              << file_pd << ".pd is not for MAPD, "
              << "there is no pickup/delivery/end location" << "\n";
    std::exit(1);
  }

  setStartGoal();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq %rdi, %rbx
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xa0(%rdi), %rsi
movq 0xa8(%rdi), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %r14
movq %r14, %rdi
callq 0xb7d0
leaq 0x2ca8b(%rip), %rsi     # 0x49ed7
movq %r14, %rdi
callq 0x6690
leaq 0x140(%rsp), %r13
leaq 0x38(%rsp), %rsi
movq %r13, %rdi
movl $0x8, %edx
callq 0x6590
movq 0x140(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x160(%rsp,%rax)
jne 0x1d9c1
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0xa0(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movl %eax, 0x4(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl %eax, %ebp
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x2ca10(%rip), %rsi     # 0x49ef1
leaq 0x100(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2c9fc(%rip), %rsi     # 0x49ef6
leaq 0xc0(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
leaq 0x2c9e9(%rip), %rsi     # 0x49efc
leaq 0x120(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
movl %ebp, 0x14(%rsp)
leaq 0x2c9d2(%rip), %rsi     # 0x49f02
leaq 0xe0(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
movslq 0x4(%rsp), %rax
leaq 0xc0(%rbx), %rcx
movq %rcx, 0x98(%rsp)
leaq 0xd8(%rbx), %rcx
movq %rcx, 0x90(%rsp)
leaq 0xf0(%rbx), %rcx
movq %rcx, 0x88(%rsp)
movq %rax, 0x80(%rsp)
movl %eax, %r14d
xorl %r12d, %r12d
leaq 0xa0(%rsp), %r15
movq $0x0, 0x58(%rsp)
movq 0x140(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x6350
movsbl %al, %edx
movq %r13, %rdi
leaq 0x60(%rsp), %rsi
callq 0x6650
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1d787
movq 0x80(%rsp), %rax
cmpq %rax, 0x68(%rsp)
jne 0x1d903
cmpl $0x0, 0x4(%rsp)
jle 0x1d772
xorl %r13d, %r13d
movq 0x60(%rsp), %rax
movsbl (%rax,%r13), %r8d
movq 0x20(%rsp), %rdx
movl $0x1, %ecx
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x6660
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
leaq 0x100(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
jne 0x1d766
leal (%r12,%r13), %esi
movq %rbx, %rdi
callq 0x1a268
leaq (%r12,%r13), %rbp
testb %al, %al
je 0x1d8ac
movq %rbx, %rdi
movl %ebp, %esi
callq 0x19fd6
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
leaq 0xc0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1d6b6
movq 0xc8(%rbx), %rsi
cmpq 0xd0(%rbx), %rsi
je 0x1d6a4
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xc8(%rbx)
jmp 0x1d6b6
movq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x1c69a
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
leaq 0xc0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1d70e
movq 0xe0(%rbx), %rsi
cmpq 0xe8(%rbx), %rsi
je 0x1d6fc
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe0(%rbx)
jmp 0x1d70e
movq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x1c69a
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
leaq 0xe0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x1d766
movq 0xf8(%rbx), %rsi
cmpq 0x100(%rbx), %rsi
je 0x1d754
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xf8(%rbx)
jmp 0x1d766
movq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x1c69a
incq %r13
cmpq %r13, %r14
jne 0x1d5ef
incq 0x58(%rsp)
addq %r14, %r12
leaq 0x140(%rsp), %r13
jmp 0x1d593
leaq 0x140(%rsp), %rdi
callq 0x60c0
movq 0x58(%rsp), %rax
cmpl %eax, 0x14(%rsp)
jne 0x1da1a
movq 0xc0(%rbx), %rax
cmpq 0xc8(%rbx), %rax
je 0x1d954
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
je 0x1d954
movq 0xf0(%rbx), %rax
cmpq 0xf8(%rbx), %rax
je 0x1d954
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
leaq 0xe0(%rsp), %rdi
callq 0xb42a
leaq 0x120(%rsp), %rdi
callq 0xb42a
leaq 0xc0(%rsp), %rdi
callq 0xb42a
leaq 0x100(%rsp), %rdi
callq 0xb42a
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1d838
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1d855
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1d871
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x140(%rsp), %rdi
callq 0x60f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1d89a
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6380
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x446f5(%rip), %rdi     # 0x61fa8
leaq 0x2c64d(%rip), %rsi     # 0x49f07
movl $0x10, %edx
callq 0x63f0
movq 0x446dd(%rip), %rdi     # 0x61fa8
leaq 0x2c663(%rip), %rsi     # 0x49f35
movl $0x23, %edx
callq 0x63f0
movq 0x446c5(%rip), %rdi     # 0x61fa8
movl %ebp, %esi
callq 0x6610
leaq 0x2ac72(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x4469e(%rip), %rdi     # 0x61fa8
leaq 0x2c5f6(%rip), %rsi     # 0x49f07
movl $0x10, %edx
callq 0x63f0
movq 0x44686(%rip), %rdi     # 0x61fa8
leaq 0x2c5ef(%rip), %rsi     # 0x49f18
movl $0x1c, %edx
callq 0x63f0
movq 0x4466e(%rip), %rdi     # 0x61fa8
movl 0x4(%rsp), %esi
callq 0x6610
leaq 0x2ac19(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x1d8f9
movq 0x4464d(%rip), %rdi     # 0x61fa8
leaq 0x2c615(%rip), %rsi     # 0x49f77
movl $0x15, %edx
callq 0x63f0
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x4462b(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x2c601(%rip), %rsi     # 0x49f8d
movl $0x15, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x2c603(%rip), %rsi     # 0x49fa3
movl $0x28, %edx
movq %rbx, %rdi
callq 0x63f0
leaq 0x2abaf(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1d8f9
movq 0x445e0(%rip), %rdi     # 0x61fa8
leaq 0x2c50c(%rip), %rsi     # 0x49edb
movl $0x15, %edx
callq 0x63f0
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x445be(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x2a8df(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x2ab56(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1d8f9
movq 0x44587(%rip), %rdi     # 0x61fa8
leaq 0x2c4df(%rip), %rsi     # 0x49f07
movl $0x10, %edx
callq 0x63f0
movq 0x4456f(%rip), %rdi     # 0x61fa8
leaq 0x2c519(%rip), %rsi     # 0x49f59
movl $0x1d, %edx
callq 0x63f0
movq 0x44557(%rip), %rdi     # 0x61fa8
movl 0x14(%rsp), %esi
callq 0x6610
leaq 0x2ab02(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x1d8f9
movq %rax, %rbx
jmp 0x1db2d
movq %rax, %rbx
jmp 0x1dab1
movq %rax, %rbx
jmp 0x1dabe
movq %rax, %rbx
jmp 0x1dacb
movq %rax, %rbx
jmp 0x1dad8
jmp 0x1da8c
movq %rax, %rbx
jmp 0x1daf4
jmp 0x1da93
movq %rax, %rbx
jmp 0x1db3a
jmp 0x1daa1
jmp 0x1daa1
jmp 0x1daa1
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xb42a
leaq 0x120(%rsp), %rdi
callq 0xb42a
leaq 0xc0(%rsp), %rdi
callq 0xb42a
leaq 0x100(%rsp), %rdi
callq 0xb42a
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1daf4
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1db11
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1db2d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x140(%rsp), %rdi
callq 0x60f0
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x1db56
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620