// File: /workspace/github_cpp_makefile_star2_O1/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), %r15
movl $0xa, %ebp
leaq 0xf0(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, 0xf0(%rsp)
movq $0x0, 0x100(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x18be6
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1ff43
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
decl %ebp
jne 0x1ff04
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0xa0(%rbx), %rsi
movq 0xa8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0xb7d0
leaq 0x2a1e1(%rip), %rsi     # 0x4a156
movq %r14, %rdi
callq 0x6690
leaq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movl $0x8, %edx
callq 0x6590
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x110(%rsp,%rax)
jne 0x20372
leaq 0x68(%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 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x29eea(%rip), %rsi     # 0x49ef1
leaq 0xd0(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
movl %ebp, 0xc(%rsp)
movq %r15, 0x78(%rsp)
leaq 0x2a14c(%rip), %rsi     # 0x4a175
leaq 0xb0(%rsp), %rdi
movl $0x10, %edx
callq 0xb26e
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
leaq 0xf0(%rsp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0x6350
movsbl %al, %edx
movq %r14, %rdi
leaq 0x58(%rsp), %rsi
callq 0x6650
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x201c3
movq %r15, 0x88(%rsp)
movq 0x80(%rsp), %rax
cmpq %rax, 0x60(%rsp)
jne 0x20321
cmpl $0x0, 0x8(%rsp)
jle 0x201b0
xorl %r15d, %r15d
movq 0x58(%rsp), %rax
movsbl (%rax,%r15), %r8d
movq 0x38(%rsp), %rdx
movl $0x1, %ecx
leaq 0x30(%rsp), %rdi
xorl %esi, %esi
callq 0x6660
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
addq %rdi, %rsi
movq %r13, %rdx
leaq 0xd0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
jne 0x201a4
leal (%r15,%rbp), %esi
movq %rbx, %rdi
callq 0x1a268
leaq (%r15,%rbp), %r14
testb %al, %al
je 0x202c9
movq %rbx, %rdi
movl %r14d, %esi
callq 0x19fd6
movq %rax, 0x50(%rsp)
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
addq %rdi, %rsi
movq %r13, %rdx
leaq 0xb0(%rsp), %rcx
xorl %r8d, %r8d
callq 0x16bf5
testb %al, %al
je 0x201a4
movq 0x58(%rsp), %rax
movsbq (%rax,%r15), %rax
movq 0xc8(%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq -0x478(%rdi), %rsi
cmpq -0x470(%rdi), %rsi
je 0x20193
movq 0x50(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, -0x478(%rdi)
jmp 0x201a4
addq $-0x480, %rdi           # imm = 0xFB80
leaq 0x50(%rsp), %rdx
callq 0x1c69a
incq %r15
cmpq %r15, %r12
jne 0x200c4
movq 0x88(%rsp), %r15
incq %r15
addq %r12, %rbp
jmp 0x20058
leaq 0xf0(%rsp), %rdi
callq 0x60c0
cmpl %r15d, 0xc(%rsp)
movq 0x78(%rsp), %r14
jne 0x203cb
movq 0xc8(%rbx), %rsi
cmpq 0xd0(%rbx), %rsi
je 0x2020c
movq (%rsi), %rax
cmpq 0x8(%rsi), %rax
je 0x201ff
addq $0x18, %rsi
jmp 0x201e7
movq %r14, %rdi
callq 0x214cc
movq (%r14), %rsi
jmp 0x201e7
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
movl $0x0, 0xc0(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0xb42a
leaq 0xd0(%rsp), %rdi
callq 0xb42a
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x20255
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x20272
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x2028e
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0xf0(%rsp), %rdi
callq 0x60f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x202b7
movq 0x20(%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 0x41cd8(%rip), %rdi     # 0x61fa8
leaq 0x29c30(%rip), %rsi     # 0x49f07
movl $0x10, %edx
callq 0x63f0
movq 0x41cc0(%rip), %rdi     # 0x61fa8
leaq 0x29c46(%rip), %rsi     # 0x49f35
movl $0x23, %edx
callq 0x63f0
movq 0x41ca8(%rip), %rdi     # 0x61fa8
movl %r14d, %esi
callq 0x6610
leaq 0x28254(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
movq 0x41c80(%rip), %rdi     # 0x61fa8
leaq 0x29e4c(%rip), %rsi     # 0x4a17b
movl $0x15, %edx
callq 0x63f0
movq 0x41c68(%rip), %rdi     # 0x61fa8
leaq 0x29bd1(%rip), %rsi     # 0x49f18
movl $0x1c, %edx
callq 0x63f0
movq 0x41c50(%rip), %rdi     # 0x61fa8
movl 0x8(%rsp), %esi
callq 0x6610
leaq 0x281fb(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x20317
movq 0x41c2f(%rip), %rdi     # 0x61fa8
leaq 0x29dda(%rip), %rsi     # 0x4a15a
movl $0x1a, %edx
callq 0x63f0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x41c0d(%rip), %rdi     # 0x61fa8
callq 0x63f0
movq %rax, %rbx
leaq 0x27f2e(%rip), %rsi     # 0x482d8
movl $0xf, %edx
movq %rax, %rdi
callq 0x63f0
leaq 0x281a5(%rip), %rsi     # 0x48563
movq %rbx, %rdi
callq 0x6360
jmp 0x20317
movq 0x41bd6(%rip), %rdi     # 0x61fa8
leaq 0x29da2(%rip), %rsi     # 0x4a17b
movl $0x15, %edx
callq 0x63f0
movq 0x41bbe(%rip), %rdi     # 0x61fa8
leaq 0x29b68(%rip), %rsi     # 0x49f59
movl $0x1d, %edx
callq 0x63f0
movq 0x41ba6(%rip), %rdi     # 0x61fa8
movl 0xc(%rsp), %esi
callq 0x6610
leaq 0x28151(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
jmp 0x20317
movq %rax, %rbx
jmp 0x204e2
jmp 0x20470
movq %rax, %rbx
jmp 0x20480
movq %rax, %rbx
jmp 0x2048d
jmp 0x20435
movq %rax, %rbx
jmp 0x204a9
jmp 0x2043c
movq %rax, %rbx
jmp 0x204ef
jmp 0x20470
jmp 0x20470
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x2050b
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
jmp 0x20506
jmp 0x20470
jmp 0x20470
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xb42a
leaq 0xd0(%rsp), %rdi
callq 0xb42a
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x204a9
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x204c6
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x204e2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0xf0(%rsp), %rdi
callq 0x60f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2050b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop