// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/solver/winpibt.cpp
// Function: winPIBT::getPath(Agent*, Node*, int, int)
Nodes winPIBT::getPath(Agent* a, Node* _g, int t1, int t2) {
  if (t2 <= t1 || t2 <= ell(a)) {
    std::cout << "error@winPIBT::getPath"
              << ", ell : " << ell(a)
              << ", t1 : " << t1
              << ", t2 : " << t2
              << "\n";
    std::exit(1);
  }

  int id = a->getId();
  Node* _s = PATHS[a->getId()][t1];  // start pos
  Nodes path, tmpPath, C;
  int f, g;
  std::string key;
  bool invalid = true;  // success or not

  boost::heap::fibonacci_heap<Fib_AN> OPEN;
  std::unordered_map<std::string,
                     boost::heap::fibonacci_heap<Fib_AN>::handle_type> SEARCHED;
  std::unordered_set<std::string> CLOSE;  // key
  AN* n = new AN { _s, t1, pathDist(_s, _g), nullptr };
  auto handle = OPEN.push(Fib_AN(n));
  key = getKey(n);
  SEARCHED.emplace(key, handle);

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

    // check goal
    if (n->g >= t2) {
      invalid = false;
      break;
    }

    // ==== fast implementation ====
    tmpPath = G->getPath(n->v, _g);
    while (n->g + tmpPath.size() - 1 < t2) tmpPath.push_back(_g);
    while (n->g + tmpPath.size() - 1 > t2) tmpPath.pop_back();
    if (checkValidPath(id, tmpPath, n->g, t2)) {
      tmpPath.erase(tmpPath.begin());
      for (auto v : tmpPath) n = new AN { v, n->g + 1, 0, n };
      invalid = false;
      break;
    }
    // =============================

    // update list
    OPEN.pop();
    CLOSE.emplace(getKey(n));

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

    for (auto m : C) {
      g = n->g + 1;
      key = getKey(g, m);
      if (CLOSE.find(key) != CLOSE.end()) continue;

      // collision check
      tmpPath = { n->v, m };
      if (!checkValidPath(id, tmpPath, n->g, t2)) continue;

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

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

  return path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %r9d, %ebp
movl %r8d, %ebx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, (%rsp)
movq %rcx, 0x70(%rsp)
cmpl %r8d, %r9d
jle 0x466a3
movq %rcx, %r12
movslq (%r14), %rcx
movq 0x88(%r15), %rax
cmpl %ebp, (%rax,%rcx,4)
jge 0x466a3
movq 0x70(%r15), %rax
movq %rcx, 0x98(%rsp)
leaq (%rcx,%rcx,2), %rcx
movslq %ebx, %rdx
movq (%rax,%rcx,8), %rax
movq (%rax,%rdx,8), %r13
xorl %eax, %eax
movq (%rsp), %rcx
movq %rax, 0x10(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, (%rcx)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
leaq 0x88(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0xb8(%rsp), %rax
movaps %xmm0, -0x8(%rax)
movaps %xmm0, -0x18(%rax)
movq %rax, (%rax)
movq %rax, 0x8(%rax)
leaq 0x118(%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 0x150(%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, %r14
movq %r13, (%rax)
movl %ebx, 0x8(%rax)
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3f248
movl %eax, 0xc(%r14)
movq $0x0, 0x10(%r14)
leaq 0x10(%rsp), %rsi
movq %r14, (%rsi)
leaq 0xa0(%rsp), %rdi
movq (%rsp), %r13
callq 0x1b3b8
movq %rax, 0xe0(%rsp)
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x3f77a
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x6460
movq (%rbx), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x46139
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq %r15, 0x48(%rsp)
movl %ebp, 0xc(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x2c2f0
cmpq $0x0, 0xa0(%rsp)
sete %r15b
je 0x465a0
movslq 0xc(%rsp), %rbp
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rbx
movq %rbp, 0xd0(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %r14
movl 0xc(%rsp), %eax
cmpl %eax, 0x8(%r14)
jge 0x465a0
movq 0x48(%rsp), %rax
movq 0x38(%rax), %rsi
movq (%r14), %rdx
movq 0x70(%rsp), %rcx
movq (%rsi), %rax
callq *0x18(%rax)
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rax
movq %rax, 0x30(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x461f3
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4620a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl 0x8(%r14), %ecx
movslq %ecx, %rax
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %rsi
movq %rsi, %rdx
subq %r12, %rdx
sarq $0x3, %rdx
addq %rax, %rdx
decq %rdx
cmpq %rbp, %rdx
jae 0x46256
cmpq 0x40(%rsp), %rsi
je 0x46247
movq 0x70(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x38(%rsp)
jmp 0x4620a
movq %rbx, %rdi
leaq 0x70(%rsp), %rdx
callq 0x1c69a
jmp 0x4620a
movq 0x38(%rsp), %rbx
movq %rbx, %rdx
subq %r12, %rdx
sarq $0x3, %rdx
addq %rax, %rdx
decq %rdx
cmpq %rbp, %rdx
jbe 0x4629f
decq %rax
movq $-0x8, %rdx
subq %r12, %rdx
movq %rbx, %r13
addq $-0x8, %rbx
leaq (%rdx,%r13), %rsi
sarq $0x3, %rsi
addq %rax, %rsi
addq $-0x8, %r13
cmpq %rbp, %rsi
ja 0x46280
movq %rbx, 0x38(%rsp)
jmp 0x462a2
movq %rbx, %r13
movq 0x48(%rsp), %rdi
movq 0x98(%rsp), %rsi
leaq 0x30(%rsp), %rdx
movl 0xc(%rsp), %r8d
callq 0x469c6
testb %al, %al
jne 0x46539
leaq 0xa0(%rsp), %rdi
callq 0x1b440
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f77a
leaq 0x120(%rsp), %rdi
movq %rbx, %rsi
callq 0x2c6e0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x4630f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x48(%rsp), %rax
movq 0x38(%rax), %rsi
movq (%r14), %rdx
movq %rbx, %rdi
callq 0x1a320
movq 0x50(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x10(%rsp), %rax
movq %rax, 0x50(%rsp)
movups 0x18(%rsp), %xmm0
movups %xmm0, 0x58(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x4635f
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x46376
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x46390
movq (%r14), %rax
movq %rax, (%rsi)
addq $0x8, 0x58(%rsp)
jmp 0x4639d
leaq 0x50(%rsp), %rdi
movq %r14, %rdx
callq 0x1c69a
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %rbp
cmpq %rbp, %rbx
je 0x4650e
movq (%rbx), %r13
movl 0x8(%r14), %r12d
incl %r12d
leaq 0x10(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
movq %r13, %rdx
callq 0x3f57e
leaq 0x78(%rsp), %rdi
movq %r15, %rsi
callq 0x6460
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x463f6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x120(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x2caaa
testq %rax, %rax
jne 0x46505
movq (%r14), %rax
movq %rax, 0x10(%rsp)
movq %r13, 0x18(%rsp)
leaq 0x30(%rsp), %r15
movq %r15, %rdi
leaq 0x10(%rsp), %rsi
leaq 0x20(%rsp), %rdx
callq 0x3e02c
movl 0x8(%r14), %ecx
movq 0x48(%rsp), %rdi
movq 0x98(%rsp), %rsi
movq %r15, %rdx
movl 0xc(%rsp), %r8d
callq 0x469c6
testb %al, %al
je 0x46505
movq 0x70(%rsp), %rdx
movq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x3f248
movl %eax, %r15d
leaq 0xe8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x2cae4
addl %r12d, %r15d
testq %rax, %rax
je 0x464b3
movq 0x28(%rax), %rsi
movq 0x10(%rsi), %rax
cmpl %r15d, 0xc(%rax)
jle 0x464a4
movl %r12d, 0x8(%rax)
movl %r15d, 0xc(%rax)
movq %r14, 0x10(%rax)
leaq 0xa0(%rsp), %rdi
callq 0x1b4ac
jmp 0x46505
movl $0x18, %edi
callq 0x6370
movq %r13, (%rax)
movl %r12d, 0x8(%rax)
movl %r15d, 0xc(%rax)
movq %r14, 0x10(%rax)
movq %rax, 0xd8(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x1b3b8
movq %rax, 0x10(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x2c2f0
addq $0x8, %rbx
jmp 0x463a7
cmpq $0x0, 0xa0(%rsp)
sete %r15b
movq (%rsp), %r13
movq 0xd0(%rsp), %rbp
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rbx
jne 0x46186
jmp 0x465a0
leaq 0x8(%r12), %rsi
cmpq %rbx, %rsi
je 0x46551
subq %rsi, %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x65b0
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r12
addq $-0x8, %r12
movq %r12, 0x38(%rsp)
cmpq %r12, %rbx
je 0x4659c
movq (%rbx), %r13
movl $0x18, %edi
callq 0x6370
movq %r13, (%rax)
movl 0x8(%r14), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movl $0x0, 0xc(%rax)
movq %r14, 0x10(%rax)
addq $0x8, %rbx
movq %rax, %r14
cmpq %r12, %rbx
jne 0x46569
movq %rax, %r14
movq (%rsp), %r13
testb $0x1, %r15b
jne 0x46617
testq %r14, %r14
je 0x465d3
movq 0x8(%r13), %rsi
cmpq 0x10(%r13), %rsi
je 0x465c2
movq (%r14), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%r13)
jmp 0x465cd
movq %r13, %rdi
movq %r14, %rdx
callq 0x1c69a
movq 0x10(%r14), %r14
jmp 0x465a6
movq (%r13), %rax
movq 0x8(%r13), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x46617
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 0x465f9
leaq 0x120(%rsp), %rdi
callq 0x2af52
leaq 0xe8(%rsp), %rdi
callq 0x2aff0
leaq 0xa0(%rsp), %rdi
callq 0x1b528
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x46660
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x46677
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4668e
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %r13, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1b8fe(%rip), %rdi     # 0x61fa8
leaq 0x574e(%rip), %rsi      # 0x4bdff
callq 0x6360
leaq 0x5759(%rip), %rsi      # 0x4be16
movq %rax, %rdi
callq 0x6360
movslq (%r14), %rcx
movq 0x88(%r15), %rdx
movl (%rdx,%rcx,4), %esi
movq %rax, %rdi
callq 0x6610
leaq 0x573e(%rip), %rsi      # 0x4be1f
movq %rax, %rdi
callq 0x6360
movq %rax, %rdi
movl %ebx, %esi
callq 0x6610
leaq 0x572d(%rip), %rsi      # 0x4be27
movq %rax, %rdi
callq 0x6360
movq %rax, %rdi
movl %ebp, %esi
callq 0x6610
leaq 0x1e50(%rip), %rsi      # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
jmp 0x46773
jmp 0x46773
jmp 0x46773
movq %rax, %rbx
movl $0x18, %esi
movq %r14, %rdi
jmp 0x4675a
jmp 0x4677c
jmp 0x46773
jmp 0x4677c
jmp 0x4677c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x4677f
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6380
jmp 0x4677f
jmp 0x4677c
jmp 0x46773
jmp 0x4677c
jmp 0x4677c
jmp 0x4677c
jmp 0x4677c
jmp 0x4677c
jmp 0x4677c
jmp 0x4677c
movq %rax, %rbx
jmp 0x46783
jmp 0x4677c
jmp 0x4677c
movq %rax, %rbx
movq (%rsp), %r13
leaq 0x120(%rsp), %rdi
callq 0x2af52
leaq 0xe8(%rsp), %rdi
callq 0x2aff0
leaq 0xa0(%rsp), %rdi
callq 0x1b528
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x467cc
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x467e3
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x467fa
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq (%r13), %rdi
testq %rdi, %rdi
je 0x4680f
movq 0x10(%r13), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop