// File: /workspace/github_cpp_makefile_star2_O2/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 $0x358, %rsp            # imm = 0x358
movq %rdi, %rbx
leaq 0xa0(%rdi), %rsi
leaq 0x22f2d(%rip), %rdx     # 0x3bfbd
leaq 0xb0(%rsp), %r14
movq %r14, %rdi
callq 0x15d01
leaq 0x150(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x65a0
movq 0x150(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x170(%rsp,%rax)
jne 0x194c2
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movl %eax, %r14d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl %eax, %ebp
leaq 0x120(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x22eb8(%rip), %rsi     # 0x3bfd7
leaq 0xf0(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
leaq 0x22ea6(%rip), %rsi     # 0x3bfdc
leaq 0x90(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
leaq 0x22e95(%rip), %rsi     # 0x3bfe2
leaq 0x130(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
movl %ebp, 0x4(%rsp)
leaq 0x22e80(%rip), %rsi     # 0x3bfe8
leaq 0xd0(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
movl %r14d, 0x14(%rsp)
movslq %r14d, %rax
leaq 0xc0(%rbx), %rcx
movq %rcx, 0x48(%rsp)
leaq 0xd8(%rbx), %rcx
movq %rcx, 0x40(%rsp)
leaq 0xf0(%rbx), %rcx
movq %rcx, 0x38(%rsp)
movq $0x0, 0x18(%rsp)
testl %eax, %eax
movl $0x0, %r12d
cmovgl %eax, %r12d
movq %rax, 0x28(%rsp)
movl %eax, %eax
movq %rax, 0x20(%rsp)
leaq 0x110(%rsp), %rbp
leaq 0x70(%rsp), %r14
xorl %r15d, %r15d
leaq 0x150(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x60b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1930c
movq %r15, 0x30(%rsp)
movq 0x28(%rsp), %rax
cmpq %rax, 0x58(%rsp)
jne 0x1942e
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x192f5
movq 0x50(%rsp), %rax
movsbl (%rax,%r15), %esi
movq %rbp, %rdi
callq 0x65e0
movq %rbp, %rdi
movq %r14, %rsi
leaq 0xf0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
testb %al, %al
jne 0x192ed
movq 0x18(%rsp), %rax
leaq (%rax,%r15), %r13
movq %rbx, %rdi
movl %r13d, %esi
callq 0x16428
testb %al, %al
je 0x193ea
movq %rbx, %rdi
movl %r13d, %esi
callq 0x16206
movq %rax, 0x8(%rsp)
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x90(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
testb %al, %al
je 0x1929d
movq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x171da
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x90(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
testb %al, %al
je 0x192c5
movq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x171da
movq %rbp, %rdi
movq %r14, %rsi
leaq 0xd0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
testb %al, %al
je 0x192ed
movq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x171da
incq %r15
jmp 0x19211
movq 0x30(%rsp), %r15
incq %r15
movq 0x20(%rsp), %rax
addq %rax, 0x18(%rsp)
jmp 0x191d5
leaq 0x150(%rsp), %rdi
callq 0x60d0
cmpl %r15d, 0x4(%rsp)
jne 0x19508
movq 0xc0(%rbx), %rax
cmpq 0xc8(%rbx), %rax
je 0x1946d
movq 0xd8(%rbx), %rax
cmpq 0xe0(%rbx), %rax
je 0x1946d
movq 0xf0(%rbx), %rax
cmpq 0xf8(%rbx), %rax
je 0x1946d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
leaq 0xd0(%rsp), %rdi
callq 0x9260
leaq 0x130(%rsp), %rdi
callq 0x9260
leaq 0x90(%rsp), %rdi
callq 0x9260
leaq 0xf0(%rsp), %rdi
callq 0x9260
leaq 0x110(%rsp), %rdi
callq 0x61d0
leaq 0x70(%rsp), %rdi
callq 0x9690
leaq 0x50(%rsp), %rdi
callq 0x61d0
leaq 0x150(%rsp), %rdi
callq 0x6120
leaq 0xb0(%rsp), %rdi
callq 0x61d0
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x40ba7(%rip), %rdi     # 0x59f98
leaq 0x22bf5(%rip), %rsi     # 0x3bfed
callq 0x63a0
leaq 0x22c17(%rip), %rsi     # 0x3c01b
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl %r13d, %esi
callq 0x6630
leaq 0x21145(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
movq 0x40b63(%rip), %rdi     # 0x59f98
leaq 0x22bb1(%rip), %rsi     # 0x3bfed
callq 0x63a0
leaq 0x22bb6(%rip), %rsi     # 0x3bffe
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl 0x14(%rsp), %esi
callq 0x6630
leaq 0x21100(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x19426
movq 0x40b24(%rip), %rdi     # 0x59f98
leaq 0x22be2(%rip), %rsi     # 0x3c05d
callq 0x63a0
leaq 0xb0(%rsp), %rsi
movq %rax, %rdi
callq 0x6360
leaq 0x22bdc(%rip), %rsi     # 0x3c073
movq %rax, %rdi
callq 0x63a0
leaq 0x22be3(%rip), %rsi     # 0x3c089
movq %rax, %rdi
callq 0x63a0
leaq 0x210ae(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x19426
movq 0x40acf(%rip), %rdi     # 0x59f98
leaq 0x22af1(%rip), %rsi     # 0x3bfc1
callq 0x63a0
leaq 0xb0(%rsp), %rsi
movq %rax, %rdi
callq 0x6360
leaq 0x20dec(%rip), %rsi     # 0x3a2d8
movq %rax, %rdi
callq 0x63a0
leaq 0x21068(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x19426
movq 0x40a89(%rip), %rdi     # 0x59f98
leaq 0x22ad7(%rip), %rsi     # 0x3bfed
callq 0x63a0
leaq 0x22b1d(%rip), %rsi     # 0x3c03f
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl 0x4(%rsp), %esi
callq 0x6630
leaq 0x21026(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x19426
movq %rax, %rbx
jmp 0x195cd
movq %rax, %rbx
jmp 0x19585
movq %rax, %rbx
jmp 0x19592
movq %rax, %rbx
jmp 0x1959f
movq %rax, %rbx
jmp 0x195ac
jmp 0x19565
movq %rax, %rbx
jmp 0x195b9
movq %rax, %rbx
jmp 0x195da
jmp 0x19575
jmp 0x19575
jmp 0x19575
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x9260
leaq 0x130(%rsp), %rdi
callq 0x9260
leaq 0x90(%rsp), %rdi
callq 0x9260
leaq 0xf0(%rsp), %rdi
callq 0x9260
leaq 0x110(%rsp), %rdi
callq 0x61d0
leaq 0x70(%rsp), %rdi
callq 0x9690
leaq 0x50(%rsp), %rdi
callq 0x61d0
leaq 0x150(%rsp), %rdi
callq 0x6120
leaq 0xb0(%rsp), %rdi
callq 0x61d0
movq %rbx, %rdi
callq 0x6650
nop