// File: /workspace/github_cpp_makefile_star2_O2/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 $0x308, %rsp            # imm = 0x308
movq %rdi, %r13
leaq 0xc8(%rdi), %r15
pushq $0xa
popq %rbx
leaq 0x100(%rsp), %r14
subl $0x1, %ebx
jb 0x1af74
xorps %xmm0, %xmm0
movaps %xmm0, 0x100(%rsp)
andq $0x0, 0x110(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x15146
movq %r14, %rdi
callq 0x990e
jmp 0x1af46
leaq 0xa0(%r13), %rsi
leaq 0x212ba(%rip), %rdx     # 0x3c23c
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
callq 0x15d01
leaq 0x100(%rsp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x65a0
movq 0x100(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x120(%rsp,%rax)
jne 0x1b2b9
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq (%r13), %rax
movq %r13, %rdi
callq *(%rax)
movl %eax, %ebp
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
movl %eax, %ebx
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x20fc8(%rip), %rsi     # 0x3bfd7
leaq 0xa0(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
movl %ebx, 0x8(%rsp)
movq %r15, 0x10(%rsp)
leaq 0x2122c(%rip), %rsi     # 0x3c25b
leaq 0x80(%rsp), %rdi
pushq $0x10
popq %rdx
callq 0x9162
movl %ebp, 0xc(%rsp)
movslq %ebp, %rax
movq $0x0, 0x18(%rsp)
testl %eax, %eax
movl $0x0, %ebx
cmovgl %eax, %ebx
movq %rax, 0x28(%rsp)
movl %eax, %eax
movq %rax, 0x20(%rsp)
leaq 0xc0(%rsp), %rbp
leaq 0x60(%rsp), %r15
xorl %r14d, %r14d
leaq 0x100(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x60b0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1b174
movq %r14, 0x30(%rsp)
movq 0x28(%rsp), %rax
cmpq %rax, 0x48(%rsp)
jne 0x1b27a
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0x1b15d
movq 0x40(%rsp), %rax
movsbl (%rax,%r12), %esi
movq %rbp, %rdi
callq 0x65e0
movq %rbp, %rdi
movq %r15, %rsi
leaq 0xa0(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
testb %al, %al
jne 0x1b155
movq 0x18(%rsp), %rax
leaq (%rax,%r12), %r14
movq %r13, %rdi
movl %r14d, %esi
callq 0x16428
testb %al, %al
je 0x1b236
movq %r13, %rdi
movl %r14d, %esi
callq 0x16206
movq %rax, 0x38(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
callq 0x91c8
testb %al, %al
je 0x1b155
movq 0x40(%rsp), %rax
movsbq (%rax,%r12), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $-0x480, %rdi           # imm = 0xFB80
leaq 0x38(%rsp), %rsi
callq 0x171da
incq %r12
jmp 0x1b0b1
movq 0x30(%rsp), %r14
incq %r14
movq 0x20(%rsp), %rax
addq %rax, 0x18(%rsp)
jmp 0x1b075
leaq 0x100(%rsp), %rdi
callq 0x60d0
cmpl %r14d, 0x8(%rsp)
movq 0x10(%rsp), %rbx
jne 0x1b2ff
movq 0xc8(%r13), %rsi
cmpq 0xd0(%r13), %rsi
je 0x1b1bd
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x1b1b0
addq $0x18, %rsi
jmp 0x1b198
movq %rbx, %rdi
callq 0x1bdfa
movq (%rbx), %rsi
jmp 0x1b198
movq (%r13), %rax
movq %r13, %rdi
callq *0x68(%rax)
andl $0x0, 0xc0(%r13)
leaq 0x80(%rsp), %rdi
callq 0x9260
leaq 0xa0(%rsp), %rdi
callq 0x9260
leaq 0xc0(%rsp), %rdi
callq 0x61d0
leaq 0x60(%rsp), %rdi
callq 0x9690
leaq 0x40(%rsp), %rdi
callq 0x61d0
leaq 0x100(%rsp), %rdi
callq 0x6120
leaq 0xe0(%rsp), %rdi
callq 0x61d0
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3ed5b(%rip), %rdi     # 0x59f98
leaq 0x20da9(%rip), %rsi     # 0x3bfed
callq 0x63a0
leaq 0x20dcb(%rip), %rsi     # 0x3c01b
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl %r14d, %esi
callq 0x6630
leaq 0x1f2f9(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
pushq $0x1
popq %rdi
callq 0x6450
movq 0x3ed17(%rip), %rdi     # 0x59f98
leaq 0x20fd9(%rip), %rsi     # 0x3c261
callq 0x63a0
leaq 0x20d6a(%rip), %rsi     # 0x3bffe
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x6630
leaq 0x1f2b4(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x1b272
movq 0x3ecd8(%rip), %rdi     # 0x59f98
leaq 0x20f79(%rip), %rsi     # 0x3c240
callq 0x63a0
leaq 0xe0(%rsp), %rsi
movq %rax, %rdi
callq 0x6360
leaq 0x1eff5(%rip), %rsi     # 0x3a2d8
movq %rax, %rdi
callq 0x63a0
leaq 0x1f271(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x1b272
movq 0x3ec92(%rip), %rdi     # 0x59f98
leaq 0x20f54(%rip), %rsi     # 0x3c261
callq 0x63a0
leaq 0x20d26(%rip), %rsi     # 0x3c03f
movq %rax, %rdi
callq 0x63a0
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x6630
leaq 0x1f22f(%rip), %rsi     # 0x3a563
movq %rax, %rdi
callq 0x63a0
jmp 0x1b272
movq %rax, %rbx
jmp 0x1b3b6
jmp 0x1b378
movq %rax, %rbx
jmp 0x1b388
movq %rax, %rbx
jmp 0x1b395
jmp 0x1b354
movq %rax, %rbx
jmp 0x1b3a2
movq %rax, %rbx
jmp 0x1b3c3
jmp 0x1b378
jmp 0x1b378
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
callq 0x990e
jmp 0x1b3d0
jmp 0x1b378
jmp 0x1b378
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x9260
leaq 0xa0(%rsp), %rdi
callq 0x9260
leaq 0xc0(%rsp), %rdi
callq 0x61d0
leaq 0x60(%rsp), %rdi
callq 0x9690
leaq 0x40(%rsp), %rdi
callq 0x61d0
leaq 0x100(%rsp), %rdi
callq 0x6120
leaq 0xe0(%rsp), %rdi
callq 0x61d0
movq %rbx, %rdi
callq 0x6650