// File: /workspace/github_cpp_makefile_star2_O3/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 0xb810
leaq 0x2cb71(%rip), %rsi     # 0x49f15
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 0x1d917
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 0x2caf6(%rip), %rsi     # 0x49f2f
leaq 0x100(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2cae2(%rip), %rsi     # 0x49f34
leaq 0xc0(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
leaq 0x2cacf(%rip), %rsi     # 0x49f3a
leaq 0x120(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
movl %ebp, 0x14(%rsp)
leaq 0x2cab8(%rip), %rsi     # 0x49f40
leaq 0xe0(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
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 0x1d6dd
movq 0x80(%rsp), %rax
cmpq %rax, 0x68(%rsp)
jne 0x1d859
cmpl $0x0, 0x4(%rsp)
jle 0x1d6c8
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 0x16c4f
testb %al, %al
jne 0x1d6bc
leaq (%r12,%r13), %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1a2cc
testb %al, %al
je 0x1d802
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1a02e
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 0x16c4f
testb %al, %al
je 0x1d60c
movq 0xc8(%rbx), %rsi
cmpq 0xd0(%rbx), %rsi
je 0x1d5fa
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xc8(%rbx)
jmp 0x1d60c
movq 0x98(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x1c5cc
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
leaq 0xc0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1d664
movq 0xe0(%rbx), %rsi
cmpq 0xe8(%rbx), %rsi
je 0x1d652
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xe0(%rbx)
jmp 0x1d664
movq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x1c5cc
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
addq %rdi, %rsi
movq %r15, %rdx
leaq 0xe0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x1d6bc
movq 0xf8(%rbx), %rsi
cmpq 0x100(%rbx), %rsi
je 0x1d6aa
movq 0x8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0xf8(%rbx)
jmp 0x1d6bc
movq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x1c5cc
incq %r13
cmpq %r13, %r14
jne 0x1d547
incq 0x58(%rsp)
addq %r14, %r12
leaq 0x140(%rsp), %r13
jmp 0x1d4eb
leaq 0x140(%rsp), %rdi
callq 0x60c0
movq 0x58(%rsp), %rax
cmpl %eax, 0x14(%rsp)
jne 0x1d970
movq 0xc0(%rbx), %rax
cmpq 0xc8(%rbx), %rax
je 0x1d8aa
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
je 0x1d8aa
movq 0xf0(%rbx), %rax
cmpq 0xf8(%rbx), %rax
je 0x1d8aa
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
leaq 0xe0(%rsp), %rdi
callq 0xb464
leaq 0x120(%rsp), %rdi
callq 0xb464
leaq 0xc0(%rsp), %rdi
callq 0xb464
leaq 0x100(%rsp), %rdi
callq 0xb464
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1d78e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1d7ab
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1d7c7
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 0x1d7f0
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 0x4479f(%rip), %rdi     # 0x61fa8
leaq 0x2c735(%rip), %rsi     # 0x49f45
movl $0x10, %edx
callq 0x63f0
movq 0x44787(%rip), %rdi     # 0x61fa8
leaq 0x2c74b(%rip), %rsi     # 0x49f73
movl $0x23, %edx
callq 0x63f0
movq 0x4476f(%rip), %rdi     # 0x61fa8
movl %ebp, %esi
callq 0x6610
leaq 0x2ad1c(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x44748(%rip), %rdi     # 0x61fa8
leaq 0x2c6de(%rip), %rsi     # 0x49f45
movl $0x10, %edx
callq 0x63f0
movq 0x44730(%rip), %rdi     # 0x61fa8
leaq 0x2c6d7(%rip), %rsi     # 0x49f56
movl $0x1c, %edx
callq 0x63f0
movq 0x44718(%rip), %rdi     # 0x61fa8
movl 0x4(%rsp), %esi
callq 0x6610
leaq 0x2acc3(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x1d84f
movq 0x446f7(%rip), %rdi     # 0x61fa8
leaq 0x2c6fd(%rip), %rsi     # 0x49fb5
movl $0x15, %edx
callq 0x63f0
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x446d5(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x2c6e9(%rip), %rsi     # 0x49fcb
movl $0x15, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x2c6eb(%rip), %rsi     # 0x49fe1
movl $0x28, %edx
movq %rbx, %rdi
callq 0x63f0
leaq 0x2ac59(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1d84f
movq 0x4468a(%rip), %rdi     # 0x61fa8
leaq 0x2c5f4(%rip), %rsi     # 0x49f19
movl $0x15, %edx
callq 0x63f0
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x44668(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x2a989(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x2ac00(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x1d84f
movq 0x44631(%rip), %rdi     # 0x61fa8
leaq 0x2c5c7(%rip), %rsi     # 0x49f45
movl $0x10, %edx
callq 0x63f0
movq 0x44619(%rip), %rdi     # 0x61fa8
leaq 0x2c601(%rip), %rsi     # 0x49f97
movl $0x1d, %edx
callq 0x63f0
movq 0x44601(%rip), %rdi     # 0x61fa8
movl 0x14(%rsp), %esi
callq 0x6610
leaq 0x2abac(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x1d84f
movq %rax, %rbx
jmp 0x1da83
movq %rax, %rbx
jmp 0x1da07
movq %rax, %rbx
jmp 0x1da14
movq %rax, %rbx
jmp 0x1da21
movq %rax, %rbx
jmp 0x1da2e
jmp 0x1d9e2
movq %rax, %rbx
jmp 0x1da4a
jmp 0x1d9e9
movq %rax, %rbx
jmp 0x1da90
jmp 0x1d9f7
jmp 0x1d9f7
jmp 0x1d9f7
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xb464
leaq 0x120(%rsp), %rdi
callq 0xb464
leaq 0xc0(%rsp), %rdi
callq 0xb464
leaq 0x100(%rsp), %rdi
callq 0xb464
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x1da4a
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0xa0(%rsp), %rdi
testq %rdi, %rdi
je 0x1da67
movq 0xb0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1da83
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 0x1daac
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620