// File: /workspace/github_cpp_makefile_star2_O3/Kei18[P]pibt/./src/graph/station.cpp
// Function: Station::init()
void Station::init() {
  // initialize
  for (int i = 0; i < 10; ++i) stations.push_back({});

  std::string file_st = filename + ".st";  // station
  std::ifstream file(file_st);
  if (!file) {
    std::cout << "error@Station::init, file "
              << file_st
              << " 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_station = std::regex(R"([0-9])");

  while (getline(file, line)) {
    // error check, width
    if (line.size() != w) {
      std::cout << "error@Station::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_station)) {
        stations[line[i] - '0'].push_back(v);
      }
    }
    ++j;
  }
  file.close();

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

  // formatting
  auto itr = stations.begin();
  while (itr != stations.end()) {
    if (itr->empty()) {
      stations.erase(itr);
      itr = stations.begin();
    } else {
      ++itr;
    }
  }

  setStartGoal();
  startSt = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rdi, %rbx
leaq 0xc8(%rdi), %rax
movq %rax, 0x10(%rsp)
movl $0xa, %ebp
leaq 0xf0(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0xf0(%rsp)
movq $0x0, 0x100(%rsp)
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x18c56
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1fe9e
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
decl %ebp
jne 0x1fe5d
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xa0(%rbx), %rsi
movq 0xa8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0xb810
leaq 0x2a2c4(%rip), %rsi     # 0x4a194
movq %r14, %rdi
callq 0x6690
leaq 0xf0(%rsp), %r14
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
movl $0x8, %edx
callq 0x6590
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x110(%rsp,%rax)
jne 0x202c8
leaq 0x70(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movl %eax, 0x8(%rsp)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl %eax, %ebp
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x29fca(%rip), %rsi     # 0x49f2f
leaq 0xd0(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
movl %ebp, 0xc(%rsp)
leaq 0x2a231(%rip), %rsi     # 0x4a1b3
leaq 0xb0(%rsp), %rdi
movl $0x10, %edx
callq 0xb2a8
movslq 0x8(%rsp), %rax
movq %rax, 0x80(%rsp)
movl %eax, %r12d
xorl %ebp, %ebp
leaq 0x90(%rsp), %r13
xorl %r15d, %r15d
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x6350
movsbl %al, %edx
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq 0x6650
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2011c
movq %r15, 0x88(%rsp)
movq 0x80(%rsp), %rax
cmpq %rax, 0x68(%rsp)
jne 0x20277
cmpl $0x0, 0x8(%rsp)
jle 0x20101
xorl %r15d, %r15d
movq 0x60(%rsp), %rax
movsbl (%rax,%r15), %r8d
movq 0x40(%rsp), %rdx
movl $0x1, %ecx
leaq 0x38(%rsp), %rdi
xorl %esi, %esi
callq 0x6660
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
addq %rdi, %rsi
movq %r13, %rdx
leaq 0xd0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
jne 0x200f5
leaq (%r15,%rbp), %r14
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1a2cc
testb %al, %al
je 0x2021f
movq %rbx, %rdi
movl %r14d, %esi
callq 0x1a02e
movq %rax, 0x58(%rsp)
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
addq %rdi, %rsi
movq %r13, %rdx
leaq 0xb0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16c4f
testb %al, %al
je 0x200f5
movq 0x60(%rsp), %rax
movsbq (%rax,%r15), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq -0x478(%rdi), %rsi
cmpq -0x470(%rdi), %rsi
je 0x200e4
movq 0x58(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, -0x478(%rdi)
jmp 0x200f5
addq $-0x480, %rdi           # imm = 0xFB80
leaq 0x58(%rsp), %rdx
callq 0x1c5cc
incq %r15
cmpq %r15, %r12
jne 0x20015
movq 0x88(%rsp), %r15
incq %r15
addq %r12, %rbp
leaq 0xf0(%rsp), %r14
jmp 0x1ffb1
leaq 0xf0(%rsp), %rdi
callq 0x60c0
cmpl %r15d, 0xc(%rsp)
jne 0x20321
movq 0xc8(%rbx), %rsi
movq 0xd0(%rbx), %rax
cmpq %rax, %rsi
je 0x20162
movq (%rsi), %rcx
cmpq 0x8(%rsi), %rcx
je 0x20156
addq $0x18, %rsi
jmp 0x20142
movq 0x10(%rsp), %rdi
callq 0x2146a
jmp 0x20134
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
movl $0x0, 0xc0(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0xb464
leaq 0xd0(%rsp), %rdi
callq 0xb464
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x201ab
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x201c8
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x201e4
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0xf0(%rsp), %rdi
callq 0x60f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2020d
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x41d82(%rip), %rdi     # 0x61fa8
leaq 0x29d18(%rip), %rsi     # 0x49f45
movl $0x10, %edx
callq 0x63f0
movq 0x41d6a(%rip), %rdi     # 0x61fa8
leaq 0x29d2e(%rip), %rsi     # 0x49f73
movl $0x23, %edx
callq 0x63f0
movq 0x41d52(%rip), %rdi     # 0x61fa8
movl %r14d, %esi
callq 0x6610
leaq 0x282fe(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x41d2a(%rip), %rdi     # 0x61fa8
leaq 0x29f34(%rip), %rsi     # 0x4a1b9
movl $0x15, %edx
callq 0x63f0
movq 0x41d12(%rip), %rdi     # 0x61fa8
leaq 0x29cb9(%rip), %rsi     # 0x49f56
movl $0x1c, %edx
callq 0x63f0
movq 0x41cfa(%rip), %rdi     # 0x61fa8
movl 0x8(%rsp), %esi
callq 0x6610
leaq 0x282a5(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x2026d
movq 0x41cd9(%rip), %rdi     # 0x61fa8
leaq 0x29ec2(%rip), %rsi     # 0x4a198
movl $0x1a, %edx
callq 0x63f0
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x41cb7(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x27fd8(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x2824f(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x2026d
movq 0x41c80(%rip), %rdi     # 0x61fa8
leaq 0x29e8a(%rip), %rsi     # 0x4a1b9
movl $0x15, %edx
callq 0x63f0
movq 0x41c68(%rip), %rdi     # 0x61fa8
leaq 0x29c50(%rip), %rsi     # 0x49f97
movl $0x1d, %edx
callq 0x63f0
movq 0x41c50(%rip), %rdi     # 0x61fa8
movl 0xc(%rsp), %esi
callq 0x6610
leaq 0x281fb(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x2026d
movq %rax, %rbx
jmp 0x20438
jmp 0x203c6
movq %rax, %rbx
jmp 0x203d6
movq %rax, %rbx
jmp 0x203e3
jmp 0x2038b
movq %rax, %rbx
jmp 0x203ff
jmp 0x20392
movq %rax, %rbx
jmp 0x20445
jmp 0x203c6
jmp 0x203c6
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x20461
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
jmp 0x2045c
jmp 0x203c6
jmp 0x203c6
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xb464
leaq 0xd0(%rsp), %rdi
callq 0xb464
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x203ff
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x2041c
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x20438
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0xf0(%rsp), %rdi
callq 0x60f0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x20461
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop