// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/graph/graph.cpp
// Function: Graph::getPath(Node*, Node*, std::vector<Node*, std::allocator<Node*>>&, int (*)(Node*, Node*))
Nodes Graph::getPath(Node* _s, Node* _g,
                     Nodes &prohibitedNodes, int (*dist) (Node*, Node*))
{
  bool prohibited = !prohibitedNodes.empty();
  Nodes path, C;
  std::string key;

  // ==== fast implementation ====
  if (regFlg && !prohibited) {
    key = getKey(_s, _g);
    auto itrK = knownPaths.find(key);
    if (itrK != knownPaths.end()) {  // known
      path = itrK->second->path;
      return path;
    }
  }
  // =============================

  int f;
  bool invalid = true;

  // prepare node open hashtable
  boost::heap::fibonacci_heap<Fib_AN> OPEN;
  std::unordered_map<int, boost::heap::fibonacci_heap<Fib_AN>::handle_type> SEARCHED;
  std::unordered_set<int> CLOSE;
  AN* n = new AN { _s, 0, dist(_s, _g), nullptr };
  auto handle = OPEN.push(Fib_AN(n));
  SEARCHED.emplace(n->v->getId(), handle);

  while (!OPEN.empty()) {
    // argmin
    n = OPEN.top().node;

    // check goal condition
    if (n->v == _g) {
      invalid = false;
      break;
    }

    // ==== fast implementation ====
    key = getKey(n->v, _g);
    auto itrK = knownPaths.find(key);
    if (itrK != knownPaths.end()) {  // known
      Nodes kPath = itrK->second->path;
      bool valid = true;
      if (prohibited) {
        for (auto v : kPath) {
          if (inArray(v, prohibitedNodes)) {
            valid = false;
            break;
          }
        }
      }
      if (valid) {
        for (int i = 1; i < kPath.size(); ++i) {
          n = new AN { kPath[i], 0, 0, n };
        }
        invalid = false;
        break;
      }
    }
    // =============================

    // update list
    OPEN.pop();
    CLOSE.emplace(n->v->getId());

    // search neighbor
    C = neighbor(n->v);

    for (auto m : C) {
      if (prohibited && inArray(m, prohibitedNodes)) continue;
      if (CLOSE.find(m->getId()) != CLOSE.end()) continue;
      f = n->g + 1 + dist(m, _g);

      // ==== fast implementation ====
      if (regFlg) {
        key = getKey(m, _g);
        auto itrK = knownPaths.find(key);
        if (itrK != knownPaths.end()) {
          f = n->g + 1 + itrK->second->path.size() - 1;
        }
      }
      // =============================

      auto itrS = SEARCHED.find(m->getId());
      if (itrS == SEARCHED.end()) {  // new node
        AN* l = new AN { m, n->g + 1, f, n };
        auto handle = OPEN.push(Fib_AN(l));
        SEARCHED.emplace(l->v->getId(), handle);
      } else {
        auto handle = itrS->second;
        AN* l = (*handle).node;
        if (l->f > f) {
          l->g = n->g + 1;
          l->f = f;
          l->p = n;
          OPEN.increase(handle);
        }
      }
    }
  }

  if (invalid) return path;

  // back tracking
  while (n != nullptr) {
    path.push_back(n->v);
    n = n->p;
  }
  std::reverse(path.begin(), path.end());

  // register path
  if (regFlg && !prohibited) registerPath(path);

  return path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %r9, 0xb0(%rsp)
movq %r8, %r12
movq %rcx, 0x88(%rsp)
movq %rdx, %r15
movq %rsi, 0x80(%rsp)
movq (%r8), %rdx
movq 0x8(%r8), %rsi
xorl %eax, %eax
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movq %rdi, 0x8(%rsp)
movups %xmm0, (%rdi)
leaq 0x68(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq %rdx, 0xa0(%rsp)
movq %rsi, 0x98(%rsp)
cmpq %rsi, %rdx
jne 0x1a486
movq 0x80(%rsp), %rax
cmpb $0x0, 0x9(%rax)
je 0x1a486
leaq 0xf0(%rsp), %rdi
movq %r15, %rdx
movq 0x88(%rsp), %rcx
callq 0x1ac92
leaq 0x58(%rsp), %rdi
leaq 0xf0(%rsp), %r14
movq %r14, %rsi
callq 0x6460
movq (%r14), %rdi
leaq 0x100(%rsp), %rax
cmpq %rax, %rdi
je 0x1a433
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x80(%rsp), %rax
leaq 0x28(%rax), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1b9aa
testq %rax, %rax
je 0x1a486
movq 0x28(%rax), %rsi
addq $0x10, %rsi
movq 0x8(%rsp), %rdi
callq 0x1b2e2
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1a47c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x8(%rsp), %r14
jmp 0x1ab6b
leaq 0xd8(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x8(%rax)
movaps %xmm0, -0x18(%rax)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
leaq 0x120(%rsp), %rax
movq %rax, -0x30(%rax)
movl $0x1, %ecx
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x160(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
movl $0x18, %edi
callq 0x6370
movq %rax, %rbp
movq %r15, (%rax)
movl $0x0, 0x8(%rax)
movq %r15, %rdi
movq 0x88(%rsp), %rsi
callq *0xb0(%rsp)
movl %eax, 0xc(%rbp)
movq $0x0, 0x10(%rbp)
leaq 0x30(%rsp), %rsi
movq %rbp, (%rsi)
leaq 0xc0(%rsp), %rdi
callq 0x1b3b8
leaq 0x128(%rsp), %rdx
movq %rax, (%rdx)
movq (%rbp), %rax
movl (%rax), %eax
leaq 0x30(%rsp), %rsi
movl %eax, (%rsi)
leaq 0xf0(%rsp), %rdi
callq 0x1bcce
xorl %r13d, %r13d
cmpq $0x0, 0xc0(%rsp)
je 0x1aa46
movq 0x80(%rsp), %rax
addq $0x28, %rax
movq %rax, 0xa8(%rsp)
movb $0x1, %al
movl %eax, 0x2c(%rsp)
leaq 0x30(%rsp), %rbx
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq 0xc8(%rsp), %rax
movq 0x10(%rax), %rbp
movq 0x88(%rsp), %rcx
cmpq %rcx, (%rbp)
je 0x1aa56
movq (%rbp), %rdx
movq %rbx, %rdi
callq 0x1ac92
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
callq 0x6460
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1a5e4
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0xa8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1b9aa
testq %rax, %rax
je 0x1a70b
movq 0x28(%rax), %rsi
addq $0x10, %rsi
movq %rbx, %rdi
callq 0x19a68
movb $0x1, %bl
movq 0x98(%rsp), %rax
cmpq %rax, 0xa0(%rsp)
je 0x1a674
movq 0x30(%rsp), %r15
movq 0x38(%rsp), %r14
cmpq %r14, %r15
je 0x1a674
addq $0x8, %r15
movb $0x1, %bl
movq -0x8(%r15), %rax
movq %rax, 0x90(%rsp)
movq (%r12), %rdi
movq 0x8(%r12), %rsi
leaq 0x90(%rsp), %rdx
callq 0x19ae8
movzbl %bl, %ebx
cmpq 0x8(%r12), %rax
cmovnel %r13d, %ebx
jne 0x1a674
leaq 0x8(%r15), %rax
cmpq %r14, %r15
movq %rax, %r15
jne 0x1a638
movl $0x0, 0x7c(%rsp)
testb $0x1, %bl
je 0x1a6e6
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %r15
subq %r14, %r15
sarq $0x3, %r15
movl $0x3, 0x7c(%rsp)
cmpq $0x2, %r15
jb 0x1a6de
movl $0x1, %r13d
movl $0x18, %edi
callq 0x6370
movq (%r14,%r13,8), %rcx
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movq %rbp, 0x10(%rax)
incq %r13
movq %rax, %rbp
cmpq %r13, %r15
jne 0x1a6a6
movl $0x0, 0x2c(%rsp)
movq %rax, %rbp
xorl %r13d, %r13d
jmp 0x1a6e6
movl $0x0, 0x2c(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1a6fd
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
testb $0x1, %bl
leaq 0x30(%rsp), %rbx
jne 0x1aa2e
leaq 0xc0(%rsp), %rdi
callq 0x1b440
movq (%rbp), %rax
movl (%rax), %eax
movl %eax, 0x30(%rsp)
leaq 0x130(%rsp), %rdi
movq %rbx, %rsi
callq 0x1c310
movq (%rbp), %rsi
addq $0x8, %rsi
movq %rbx, %rdi
callq 0x19a68
movq 0x30(%rsp), %r14
movq 0x38(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1a786
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1a79d
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl $0x0, 0x7c(%rsp)
movq %r14, %rbx
movq %r14, 0x10(%rsp)
cmpq 0xb8(%rsp), %r14
je 0x1aa1c
movq (%rbx), %r15
movq 0x98(%rsp), %rax
cmpq %rax, 0xa0(%rsp)
je 0x1a7f3
movq %r15, 0x30(%rsp)
movq (%r12), %rdi
movq 0x8(%r12), %rsi
leaq 0x30(%rsp), %rdx
callq 0x19ae8
cmpq 0x8(%r12), %rax
jne 0x1aa0a
movslq (%r15), %rcx
movq 0x130(%rsp), %rdi
movq 0x138(%rsp), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x1a857
movq (%rdx), %r9
movq %rdx, %rax
cmpl 0x8(%r9), %ecx
je 0x1a857
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x1a855
movslq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x1a857
movq %r10, %rax
cmpl %edi, %ecx
jne 0x1a82b
jmp 0x1a857
xorl %eax, %eax
testq %rax, %rax
je 0x1a866
cmpq $0x0, (%rax)
jne 0x1aa0a
movl 0x8(%rbp), %r14d
movq %r15, %rdi
movq 0x88(%rsp), %rsi
callq *0xb0(%rsp)
leal (%r14,%rax), %r13d
incl %r13d
movq 0x80(%rsp), %rax
cmpb $0x1, 0x9(%rax)
jne 0x1a8fd
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
movq 0x88(%rsp), %rcx
callq 0x1ac92
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x6460
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x1a8d2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0xa8(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x1b9aa
testq %rax, %rax
je 0x1a8fd
movq 0x28(%rax), %rax
movq 0x18(%rax), %r13
subq 0x10(%rax), %r13
shrq $0x3, %r13
addl 0x8(%rbp), %r13d
movslq (%r15), %rcx
movq 0xf0(%rsp), %rdi
movq 0xf8(%rsp), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x1a961
movq (%rdx), %r9
movq %rdx, %rax
cmpl 0x8(%r9), %ecx
je 0x1a961
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x1a95f
movslq 0x8(%r9), %rdi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x1a961
movq %r10, %rax
cmpl %edi, %ecx
jne 0x1a935
jmp 0x1a961
xorl %eax, %eax
testq %rax, %rax
je 0x1a96b
movq (%rax), %rax
jmp 0x1a96d
xorl %eax, %eax
testq %rax, %rax
je 0x1a9a3
movq 0x10(%rax), %rsi
movq 0x10(%rsi), %rax
cmpl %r13d, 0xc(%rax)
jle 0x1aa0a
movl 0x8(%rbp), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movl %r13d, 0xc(%rax)
movq %rbp, 0x10(%rax)
leaq 0xc0(%rsp), %rdi
callq 0x1b4ac
jmp 0x1aa0a
movl $0x18, %edi
callq 0x6370
movq %rax, %r14
movq %r15, (%rax)
movl 0x8(%rbp), %eax
incl %eax
movl %eax, 0x8(%r14)
movl %r13d, 0xc(%r14)
movq %rbp, 0x10(%r14)
movq %r14, 0x90(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x90(%rsp), %r15
movq %r15, %rsi
callq 0x1b3b8
movq %rax, 0x30(%rsp)
movq (%r14), %rax
movl (%rax), %eax
movl %eax, 0x90(%rsp)
leaq 0xf0(%rsp), %rdi
movq %r15, %rsi
leaq 0x30(%rsp), %rdx
callq 0x1bcce
addq $0x8, %rbx
cmpq 0xb8(%rsp), %rbx
jne 0x1a7bb
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
leaq 0x30(%rsp), %rbx
cmpl $0x0, 0x7c(%rsp)
jne 0x1aa5e
cmpq $0x0, 0xc0(%rsp)
jne 0x1a591
jmp 0x1aa5e
movb $0x1, %al
xorl %r12d, %r12d
movq $0x0, 0x10(%rsp)
jmp 0x1aa67
movl $0x0, 0x2c(%rsp)
movq 0x18(%rsp), %r12
movl 0x2c(%rsp), %eax
testb $0x1, %al
movq 0x8(%rsp), %r14
leaq 0x68(%rsp), %r15
jne 0x1ab18
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x1aa91
movq (%rbp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r14)
jmp 0x1aa9c
movq %r14, %rdi
movq %rbp, %rdx
callq 0x1c69a
movq 0x10(%rbp), %rbp
testq %rbp, %rbp
jne 0x1aa79
movq (%r14), %rax
movq 0x8(%r14), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1aae8
addq $0x8, %rax
movq -0x8(%rax), %rdx
movq (%rcx), %rsi
movq %rsi, -0x8(%rax)
movq %rdx, (%rcx)
addq $-0x8, %rcx
leaq 0x8(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x1aaca
movq 0x98(%rsp), %rax
cmpq %rax, 0xa0(%rsp)
jne 0x1ab18
movq 0x80(%rsp), %rax
cmpb $0x0, 0x9(%rax)
je 0x1ab18
movq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x1ae8e
leaq 0x130(%rsp), %rdi
callq 0x1b8ca
leaq 0xf0(%rsp), %rdi
callq 0x1b93a
leaq 0xc0(%rsp), %rdi
callq 0x1b528
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x1ab56
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1ab6b
subq %rdi, %r12
movq %r12, %rsi
callq 0x6380
movq %r14, %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1abbd
jmp 0x1aba5
jmp 0x1ab9a
jmp 0x1ab9a
movq %rax, %rbx
movl $0x18, %esi
movq %rbp, %rdi
callq 0x6380
jmp 0x1ab9d
movq %rax, %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
jmp 0x1ac1a
movq %rax, %rbx
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x8(%rsp), %r14
leaq 0x68(%rsp), %r15
jmp 0x1ac4b
movq %rax, %rbx
jmp 0x1ac06
jmp 0x1abcc
jmp 0x1abcc
jmp 0x1abcc
jmp 0x1abcc
jmp 0x1ac0d
movq %rax, %rbx
jmp 0x1abf7
jmp 0x1ac0d
jmp 0x1ac0d
jmp 0x1ac0d
jmp 0x1ac0d
jmp 0x1ac0d
jmp 0x1abdd
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x1abf7
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x8(%rsp), %r14
leaq 0x68(%rsp), %r15
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %r13
jmp 0x1ac24
movq %rax, %rbx
movq 0x20(%rsp), %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
leaq 0x68(%rsp), %r15
leaq 0x130(%rsp), %rdi
callq 0x1b8ca
leaq 0xf0(%rsp), %rdi
callq 0x1b93a
leaq 0xc0(%rsp), %rdi
callq 0x1b528
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x1ac62
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x6380
testq %r13, %r13
je 0x1ac75
subq %r13, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x6380
movq (%r14), %rdi
testq %rdi, %rdi
je 0x1ac89
movq 0x10(%r14), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop