// File: 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
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x358(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0xa, -0xc(%rbp)
jge 0x4c97d
movq -0x358(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x368(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
movq $0x0, -0x20(%rbp)
leaq -0x30(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0x3e880
movq -0x368(%rbp), %rdi
movq -0x360(%rbp), %rsi
callq 0xd700
jmp 0x4c94f
leaq -0x30(%rbp), %rdi
callq 0xd7d0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x4c901
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xd7d0
jmp 0x4d0ce
movq -0x358(%rbp), %rsi
addq $0xa0, %rsi
leaq 0x68ae7(%rip), %rdx     # 0xb5479
leaq -0x60(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x3aec0
movq -0x370(%rbp), %rsi
leaq -0x268(%rbp), %rdi
movl $0x8, %edx
callq 0x8780
jmp 0x4c9bc
movq -0x268(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x268(%rbp,%rax), %rdi
callq 0x8260
movb %al, -0x371(%rbp)
jmp 0x4c9dc
movb -0x371(%rbp), %al
testb $0x1, %al
jne 0x4c9eb
jmp 0x4ca7d
movq 0xb45a6(%rip), %rdi     # 0x100f98
leaq 0x68a84(%rip), %rsi     # 0xb547d
callq 0x84d0
movq %rax, -0x380(%rbp)
jmp 0x4ca07
movq -0x380(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x8470
movq %rax, -0x388(%rbp)
jmp 0x4ca20
movq -0x388(%rbp), %rdi
leaq 0x668fe(%rip), %rsi     # 0xb332c
callq 0x84d0
movq %rax, -0x390(%rbp)
jmp 0x4ca3c
movq -0x390(%rbp), %rdi
leaq 0x66b6d(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x4ca51
movl $0x1, %edi
callq 0x85d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d0c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d0b9
leaq -0x288(%rbp), %rdi
callq 0x86b0
leaq -0x2a8(%rbp), %rdi
callq 0xd430
jmp 0x4ca97
movq -0x358(%rbp), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl %eax, -0x394(%rbp)
jmp 0x4caae
movq -0x358(%rbp), %rdi
movl -0x394(%rbp), %eax
movl %eax, -0x2ac(%rbp)
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0x398(%rbp)
jmp 0x4cad2
movl -0x398(%rbp), %eax
movl %eax, -0x2b0(%rbp)
movl $0x0, -0x2b4(%rbp)
movl $0x0, -0x2b8(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x86b0
leaq 0x686f9(%rip), %rsi     # 0xb51fe
leaq -0x300(%rbp), %rdi
movl $0x10, %edx
callq 0xd390
jmp 0x4cb18
leaq 0x68979(%rip), %rsi     # 0xb5498
leaq -0x320(%rbp), %rdi
movl $0x10, %edx
callq 0xd390
jmp 0x4cb32
jmp 0x4cb34
leaq -0x268(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x80f0
movq %rax, -0x3a0(%rbp)
jmp 0x4cb50
movq -0x3a0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x8620
movb %al, -0x3a1(%rbp)
jmp 0x4cb6e
movb -0x3a1(%rbp), %al
testb $0x1, %al
jne 0x4cb7d
jmp 0x4ce88
leaq -0x288(%rbp), %rdi
callq 0x83b0
movslq -0x2ac(%rbp), %rcx
cmpq %rcx, %rax
je 0x4cc6c
movq 0xb43f8(%rip), %rdi     # 0x100f98
leaq 0x688f7(%rip), %rsi     # 0xb549e
callq 0x84d0
movq %rax, -0x3b0(%rbp)
jmp 0x4cbb5
movq -0x3b0(%rbp), %rdi
leaq 0x68662(%rip), %rsi     # 0xb5225
callq 0x84d0
movq %rax, -0x3b8(%rbp)
jmp 0x4cbd1
movq -0x3b8(%rbp), %rdi
movl -0x2ac(%rbp), %esi
callq 0x8860
movq %rax, -0x3c0(%rbp)
jmp 0x4cbec
movq -0x3c0(%rbp), %rdi
leaq 0x669bd(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x4cc01
movl $0x1, %edi
callq 0x85d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d0ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d0a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d095
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4d089
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x320(%rbp), %rdi
callq 0xd6d0
jmp 0x4d089
movl $0x0, -0x324(%rbp)
movl -0x324(%rbp), %eax
cmpl -0x2ac(%rbp), %eax
jge 0x4ce74
movslq -0x324(%rbp), %rsi
leaq -0x288(%rbp), %rdi
callq 0x8930
movq %rax, -0x3c8(%rbp)
jmp 0x4cca4
movq -0x3c8(%rbp), %rax
movsbl (%rax), %esi
leaq -0x2d8(%rbp), %rdi
callq 0x87d0
jmp 0x4ccbc
movl -0x2b4(%rbp), %eax
movl -0x2ac(%rbp), %ecx
imull %ecx, %eax
movl -0x324(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x2b8(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0x300(%rbp), %rdx
xorl %ecx, %ecx
callq 0xd470
movb %al, -0x3c9(%rbp)
jmp 0x4ccfd
movb -0x3c9(%rbp), %al
testb $0x1, %al
jne 0x4cd09
jmp 0x4cd0e
jmp 0x4ce60
movq -0x358(%rbp), %rdi
movl -0x2b8(%rbp), %esi
callq 0x3c7d0
movb %al, -0x3ca(%rbp)
jmp 0x4cd28
movb -0x3ca(%rbp), %al
testb $0x1, %al
jne 0x4cda6
jmp 0x4cd34
movq 0xb425d(%rip), %rdi     # 0x100f98
leaq 0x684d2(%rip), %rsi     # 0xb5214
callq 0x84d0
movq %rax, -0x3d8(%rbp)
jmp 0x4cd50
movq -0x3d8(%rbp), %rdi
leaq 0x684e4(%rip), %rsi     # 0xb5242
callq 0x84d0
movq %rax, -0x3e0(%rbp)
jmp 0x4cd6c
movq -0x3e0(%rbp), %rdi
movl -0x2b8(%rbp), %esi
callq 0x8860
movq %rax, -0x3e8(%rbp)
jmp 0x4cd87
movq -0x3e8(%rbp), %rdi
leaq 0x66822(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x4cd9c
movl $0x1, %edi
callq 0x85d0
movq -0x358(%rbp), %rdi
movl -0x2b8(%rbp), %esi
callq 0x3c590
movq %rax, -0x3f0(%rbp)
jmp 0x4cdc1
movq -0x3f0(%rbp), %rax
movq %rax, -0x2e0(%rbp)
leaq -0x2d8(%rbp), %rdi
leaq -0x2a8(%rbp), %rsi
leaq -0x320(%rbp), %rdx
xorl %ecx, %ecx
callq 0xd470
movb %al, -0x3f1(%rbp)
jmp 0x4cdf3
movb -0x3f1(%rbp), %al
testb $0x1, %al
jne 0x4cdff
jmp 0x4ce5e
movq -0x358(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x408(%rbp)
movslq -0x324(%rbp), %rsi
leaq -0x288(%rbp), %rdi
callq 0x8930
movq %rax, -0x400(%rbp)
jmp 0x4ce2f
movq -0x408(%rbp), %rdi
movq -0x400(%rbp), %rax
movsbl (%rax), %eax
addl $-0x30, %eax
movslq %eax, %rsi
callq 0xda70
movq %rax, %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x3f490
jmp 0x4ce5c
jmp 0x4ce5e
jmp 0x4ce60
movl -0x324(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x324(%rbp)
jmp 0x4cc76
movl -0x2b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2b4(%rbp)
jmp 0x4cb34
leaq -0x268(%rbp), %rdi
callq 0x8120
jmp 0x4ce96
movl -0x2b4(%rbp), %eax
cmpl -0x2b0(%rbp), %eax
je 0x4cf16
movq 0xb40ed(%rip), %rdi     # 0x100f98
leaq 0x685ec(%rip), %rsi     # 0xb549e
callq 0x84d0
movq %rax, -0x410(%rbp)
jmp 0x4cec0
movq -0x410(%rbp), %rdi
leaq 0x68398(%rip), %rsi     # 0xb5266
callq 0x84d0
movq %rax, -0x418(%rbp)
jmp 0x4cedc
movq -0x418(%rbp), %rdi
movl -0x2b0(%rbp), %esi
callq 0x8860
movq %rax, -0x420(%rbp)
jmp 0x4cef7
movq -0x420(%rbp), %rdi
leaq 0x666b2(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x4cf0c
movl $0x1, %edi
callq 0x85d0
movq -0x358(%rbp), %rdi
addq $0xc8, %rdi
callq 0x377e0
movq %rax, -0x330(%rbp)
movq -0x358(%rbp), %rdi
addq $0xc8, %rdi
callq 0x37500
movq %rax, -0x338(%rbp)
leaq -0x330(%rbp), %rdi
leaq -0x338(%rbp), %rsi
callq 0x4e640
testb $0x1, %al
jne 0x4cf66
jmp 0x4d00c
leaq -0x330(%rbp), %rdi
callq 0x4e680
movq %rax, %rdi
callq 0x3ec00
testb $0x1, %al
jne 0x4cf80
jmp 0x4cffb
movq -0x358(%rbp), %rax
addq $0xc8, %rax
movq %rax, -0x430(%rbp)
leaq -0x340(%rbp), %rdi
leaq -0x330(%rbp), %rsi
callq 0x4e710
movq -0x430(%rbp), %rdi
movq -0x340(%rbp), %rsi
callq 0x4e6a0
movq %rax, -0x428(%rbp)
jmp 0x4cfc3
movq -0x358(%rbp), %rdi
movq -0x428(%rbp), %rax
movq %rax, -0x348(%rbp)
addq $0xc8, %rdi
callq 0x377e0
movq %rax, -0x350(%rbp)
movq -0x350(%rbp), %rax
movq %rax, -0x330(%rbp)
jmp 0x4d007
leaq -0x330(%rbp), %rdi
callq 0x4e750
jmp 0x4cf30
movq -0x358(%rbp), %rdi
movq (%rdi), %rax
movq 0x68(%rax), %rax
callq *%rax
jmp 0x4d01e
movq -0x358(%rbp), %rax
movl $0x0, 0xc0(%rax)
leaq -0x320(%rbp), %rdi
callq 0xd6d0
leaq -0x300(%rbp), %rdi
callq 0xd6d0
leaq -0x2d8(%rbp), %rdi
callq 0x8330
leaq -0x2a8(%rbp), %rdi
callq 0xd6b0
leaq -0x288(%rbp), %rdi
callq 0x8330
leaq -0x268(%rbp), %rdi
callq 0x8170
leaq -0x60(%rbp), %rdi
callq 0x8330
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq
leaq -0x300(%rbp), %rdi
callq 0xd6d0
leaq -0x2d8(%rbp), %rdi
callq 0x8330
leaq -0x2a8(%rbp), %rdi
callq 0xd6b0
leaq -0x288(%rbp), %rdi
callq 0x8330
leaq -0x268(%rbp), %rdi
callq 0x8170
leaq -0x60(%rbp), %rdi
callq 0x8330
movq -0x38(%rbp), %rdi
callq 0x8880
nopw (%rax,%rax)