// File: /workspace/github_cpp_makefile_star2_O3/Kei18[P]pibt/./src/solver/tp.cpp
// Function: TP::getPath(Agent*, Node*, Node*, int, bool)
Nodes TP::getPath(Agent* a,
                  Node* s,
                  Node* g,
                  int startTime,
                  bool futureCollision)
{
  Nodes path;
  Nodes C;
  AN_OLD *l, *n;
  int t, f, cost;
  std::string key;
  bool prohibited, goalCheck;

  Nodes pathends;
  Node* v;
  for (auto p : paths) {
    v = p[p.size() - 1];
    if (v != s && v != a->getNode()) pathends.push_back(v);
  }

  std::unordered_set<std::string> OPEN;
  std::unordered_map<std::string, AN_OLD*> table;

  t = startTime - 1;
  l = new AN_OLD { s, true, startTime - 1, pathDist(s, g), nullptr };
  key = getKey(t, s);
  table.emplace(key, l);
  OPEN = { key };

  bool invalid = true;
  while (!OPEN.empty()) {
    // argmin
    auto itr1 = std::min_element(OPEN.begin(), OPEN.end(),
                                 [&table] (std::string a, std::string b)
                                 { auto eleA = table.at(a);
                                   auto eleB = table.at(b);
                                   if (eleA->f == eleB->f) {
                                     return eleA->t > eleB->t;
                                   }
                                   return eleA->f < eleB->f;
                                 });
    key = *itr1;
    n = table.at(key);
    t = n->t;

    // check goal
    if (n->v == g) {
      goalCheck = true;

      if (futureCollision) {
        for (auto p : paths) {
          if (t + 1 >= p.size()) continue;

          for (auto itr = p.begin() + t + 1; itr < p.end(); ++itr) {
            if ((*itr) == n->v) {  // collision in future
              goalCheck = false;
              break;
            }
          }
          if (!goalCheck) break;
        }
      }

      if (goalCheck) {
        invalid = false;
        break;
      }
    }

    // update list
    n->open = false;
    OPEN.erase(itr1);

    // search neighbor
    C = { n->v };
    for (auto u : G->neighbor(n->v)) {
      if (!inArray(u, pathends)) C.push_back(u);
    }

    for (auto m : C) {
      t = n->t + 1;

      if (t > 0) {
        prohibited = false;

        for (auto p : paths) {
          if (t + 1 > p.size()) continue;
          if (p[t] == m) { // collision
            prohibited = true;
            break;
          }
          if (p[t] == n->v && p[t-1] == m) {  // intersection
            prohibited = true;
            break;
          }
        }

        if (prohibited) continue;
      }

      key = getKey(t, m);
      auto itr2 = table.find(key);
      if (itr2 == table.end()) {
        table.emplace(key, new AN_OLD { m, true, t, 100000, n });
      }
      l = table.at(key);
      if (!l->open) continue;

      cost = pathDist(m, g);
      f = t + cost;

      if (l->f > f) {
        l->t = t;
        l->f = f;
        l->p = n;
      }

      OPEN.insert(key);
    }
  }

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

  return path;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %r9d, %ebx
movq %r8, 0xa0(%rsp)
movq %rcx, %r14
movq %rcx, 0xb8(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movq %rdi, 0x30(%rsp)
movups %xmm0, (%rdi)
movq %rax, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
leaq 0x50(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq %rax, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq 0x88(%rsi), %r12
movq %rsi, 0x28(%rsp)
movq 0x90(%rsi), %rbp
cmpq %rbp, %r12
je 0x41be6
movq %rdx, %r15
leaq 0xe0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x19aae
movq 0xe8(%rsp), %rax
movq -0x8(%rax), %rax
movq %rax, 0x128(%rsp)
cmpq %r14, %rax
je 0x41bc0
cmpq 0x8(%r15), %rax
je 0x41bc0
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x41bae
movq %rax, (%rsi)
addq $0x8, 0x68(%rsp)
jmp 0x41bc0
leaq 0x60(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x1c5cc
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x41bdd
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r12
cmpq %rbp, %r12
jne 0x41b6d
leaq 0x110(%rsp), %rax
movq %rax, -0x30(%rax)
movl $0x1, %ecx
movq %rcx, -0x28(%rax)
xorps %xmm0, %xmm0
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 $0x20, %edi
callq 0x6370
movq %rax, %r15
decl %ebx
movq %r14, (%rax)
movb $0x1, 0x8(%rax)
movl %ebx, 0xc(%rax)
movq 0x28(%rsp), %rdi
movq %r14, %rsi
movq 0xa0(%rsp), %rdx
callq 0x3efbe
movl %eax, 0x10(%r15)
movq $0x0, 0x18(%r15)
movq %r15, 0xa8(%rsp)
movq %rsp, %rdi
movl %ebx, %esi
movq %r14, %rdx
callq 0x3f2d8
leaq 0x40(%rsp), %rdi
movq %rsp, %rbx
movq %rbx, %rsi
callq 0x6460
movq (%rbx), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x41ca2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x130(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x429b8
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
addq %rsi, %rdx
callq 0xb810
leaq 0xe0(%rsp), %rdi
movq %rsp, %rsi
movl $0x1, %edx
callq 0x42da4
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x41d09
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6380
cmpq $0x0, 0xf8(%rsp)
je 0x42307
movq %rsp, %r13
movq 0xf0(%rsp), %r12
testq %r12, %r12
je 0x41e2f
movq (%r12), %r15
testq %r15, %r15
je 0x41e34
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0xb810
leaq 0xd0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
leaq 0xc0(%rsp), %rdi
callq 0xb810
leaq 0x130(%rsp), %rdi
movq %r13, %rsi
callq 0x43136
testq %rax, %rax
je 0x42388
movq 0x28(%rax), %rbx
leaq 0x130(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x43136
testq %rax, %rax
je 0x42388
movq 0x28(%rax), %rax
movl 0x10(%rax), %ecx
cmpl %ecx, 0x10(%rbx)
jne 0x41dd1
movl 0xc(%rbx), %ecx
cmpl 0xc(%rax), %ecx
setg %bl
jmp 0x41dd4
setl %bl
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x41df9
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x6380
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x41e14
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6380
movq %r15, %r14
testb %bl, %bl
jne 0x41e1e
movq %r12, %r14
movq (%r15), %r15
movq %r14, %r12
testq %r15, %r15
jne 0x41d39
jmp 0x41e37
xorl %r14d, %r14d
jmp 0x41e37
movq %r12, %r14
leaq 0x8(%r14), %rsi
leaq 0x40(%rsp), %rdi
callq 0x6200
leaq 0x130(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x43136
testq %rax, %rax
je 0x423a0
movq 0x28(%rax), %rbx
movq 0xa0(%rsp), %rax
cmpq %rax, (%rbx)
movq %rbx, 0x20(%rsp)
jne 0x41f56
cmpb $0x0, 0x1a0(%rsp)
je 0x4223e
movq 0x28(%rsp), %rax
movq 0x88(%rax), %r15
movq 0x90(%rax), %r13
cmpq %r13, %r15
je 0x4223e
movslq 0xc(%rbx), %rax
leaq 0x1(%rax), %rbp
shlq $0x3, %rax
movq %rax, 0x38(%rsp)
movb $0x1, %r12b
movq %rsp, %rdi
movq %r15, %rsi
callq 0x19aae
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movl $0x7, %ebx
cmpq %rbp, %rcx
jbe 0x41f1c
movq 0x38(%rsp), %rcx
addq %rdi, %rcx
addq $0x8, %rcx
movq 0x20(%rsp), %rsi
movl %r12d, %r8d
cmpq %rax, %rcx
jae 0x41f08
movq (%rcx), %rdx
addq $0x8, %rcx
cmpq (%rsi), %rdx
jne 0x41ef4
xorl %r8d, %r8d
movl %r8d, %r12d
testb $0x1, %r8b
movl $0x6, %ebx
movl $0x0, %eax
cmovnel %eax, %ebx
testq %rdi, %rdi
je 0x41f2e
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
cmpl $0x7, %ebx
je 0x41f37
testl %ebx, %ebx
jne 0x41f44
addq $0x18, %r15
cmpq %r13, %r15
jne 0x41eb8
testb $0x1, %r12b
movq %rsp, %r13
movq 0x20(%rsp), %rbx
jne 0x4223e
movb $0x0, 0x8(%rbx)
leaq 0xe0(%rsp), %rdi
movq %r14, %rsi
callq 0x43170
movq (%rbx), %rax
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
movq %r13, %rsi
leaq 0x8(%rsp), %rdx
callq 0x3dd40
movq 0x28(%rsp), %rax
movq 0x38(%rax), %rsi
movq (%rbx), %rdx
movq %r13, %rdi
callq 0x1a38a
movq (%rsp), %r14
movq 0x8(%rsp), %rbx
cmpq %rbx, %r14
je 0x42023
movq (%r14), %rax
movq %rax, 0xb0(%rsp)
movq %rax, 0xc0(%rsp)
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x19b2e
cmpq 0x68(%rsp), %rax
jne 0x42016
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x42001
movq 0xb0(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x88(%rsp)
jmp 0x42016
leaq 0x80(%rsp), %rdi
leaq 0xb0(%rsp), %rdx
callq 0x1c5cc
addq $0x8, %r14
cmpq %rbx, %r14
jne 0x41fa8
movq (%rsp), %r14
testq %r14, %r14
je 0x42038
movq 0x10(%rsp), %rsi
subq %r14, %rsi
movq %r14, %rdi
callq 0x6380
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rcx, 0x118(%rsp)
cmpq %rcx, %rax
movq 0x20(%rsp), %rbx
je 0x4222a
movq %rax, 0x120(%rsp)
movq (%rax), %r15
movl 0xc(%rbx), %ebx
leal 0x1(%rbx), %eax
movl %eax, 0x38(%rsp)
testl %ebx, %ebx
js 0x420f5
movq 0x28(%rsp), %rax
movq 0x88(%rax), %r13
movq 0x90(%rax), %r14
cmpq %r14, %r13
je 0x420f5
leaq 0x2(%rbx), %r12
movl 0x38(%rsp), %ebp
movq %rsp, %rdi
movq %r13, %rsi
callq 0x19aae
movq (%rsp), %rdi
movq 0x8(%rsp), %rax
subq %rdi, %rax
sarq $0x3, %rax
cmpq %r12, %rax
jae 0x420be
testq %rdi, %rdi
jne 0x420df
jmp 0x420ec
movq (%rdi,%rbp,8), %rax
cmpq %r15, %rax
je 0x421fb
movq 0x20(%rsp), %rcx
cmpq (%rcx), %rax
jne 0x420df
cmpq %r15, (%rdi,%rbx,8)
je 0x421fb
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r13
cmpq %r14, %r13
jne 0x42097
movq %rsp, %r13
movq %r13, %rdi
movl 0x38(%rsp), %ebp
movl %ebp, %esi
movq %r15, %rdx
callq 0x3f2d8
leaq 0x40(%rsp), %rdi
movq %r13, %rsi
callq 0x6460
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x42131
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x130(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x43136
movq 0x20(%rsp), %rbx
testq %rax, %rax
jne 0x42185
movl $0x20, %edi
callq 0x6370
movq %r15, (%rax)
movb $0x1, 0x8(%rax)
movl %ebp, 0xc(%rax)
movl $0x186a0, 0x10(%rax)    # imm = 0x186A0
movq %rbx, 0x18(%rax)
movq %rax, (%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
callq 0x43226
leaq 0x130(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x43136
testq %rax, %rax
je 0x42394
movq 0x28(%rax), %rax
movq %rax, 0xa8(%rsp)
cmpb $0x1, 0x8(%rax)
jne 0x42210
movq 0x28(%rsp), %rdi
movq %r15, %rsi
movq 0xa0(%rsp), %rdx
callq 0x3efbe
addl %ebp, %eax
movq 0xa8(%rsp), %rcx
cmpl %eax, 0x10(%rcx)
jle 0x421e0
movl %ebp, 0xc(%rcx)
movl %eax, 0x10(%rcx)
movq %rbx, 0x18(%rcx)
leaq 0xe0(%rsp), %rdi
movq %rdi, (%rsp)
leaq 0x40(%rsp), %rsi
movq %r13, %rdx
callq 0x43356
jmp 0x42210
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rsp, %r13
movq 0x20(%rsp), %rbx
movq 0x120(%rsp), %rax
addq $0x8, %rax
cmpq 0x118(%rsp), %rax
jne 0x4205e
cmpq $0x0, 0xf8(%rsp)
jne 0x41d1b
jmp 0x42307
cmpq $0x0, 0x18(%rbx)
je 0x4228c
movq 0x20(%rsp), %rax
leaq 0x18(%rax), %rbx
movq 0x30(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4226f
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x42279
movq 0x20(%rsp), %rdx
callq 0x1c5cc
movq (%rbx), %rax
leaq 0x18(%rax), %rbx
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x18(%rax)
jne 0x4224e
movq 0x30(%rsp), %rbx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x422b4
movq 0xb8(%rsp), %rax
movq %rax, (%rsi)
movq 0x8(%rbx), %rax
addq $0x8, %rax
movq %rax, 0x8(%rbx)
jmp 0x422c8
leaq 0xb8(%rsp), %rdx
movq %rbx, %rdi
callq 0x1c5cc
movq 0x8(%rbx), %rax
movq (%rbx), %rcx
cmpq %rax, %rcx
setne %dl
addq $-0x8, %rax
cmpq %rcx, %rax
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x42307
addq $0x8, %rcx
movq -0x8(%rcx), %rdx
movq (%rax), %rsi
movq %rsi, -0x8(%rcx)
movq %rdx, (%rax)
addq $-0x8, %rax
leaq 0x8(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x422e9
leaq 0x130(%rsp), %rdi
callq 0x426c0
leaq 0xe0(%rsp), %rdi
callq 0x2ae7e
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x42338
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x42354
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x42371
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x818c(%rip), %rdi      # 0x4a51b
callq 0x6520
leaq 0x8180(%rip), %rdi      # 0x4a51b
callq 0x6520
leaq 0x8174(%rip), %rdi      # 0x4a51b
callq 0x6520
jmp 0x4247e
jmp 0x42416
jmp 0x4247e
jmp 0x4247e
movq %rax, %rbx
movl $0x20, %esi
movq %r15, %rdi
jmp 0x42475
jmp 0x4247e
jmp 0x4247e
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x4249b
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x4249b
jmp 0x4247e
jmp 0x4247e
jmp 0x4247e
movq %rax, %rbx
jmp 0x4249b
jmp 0x4247e
jmp 0x4247e
jmp 0x4247e
jmp 0x4247e
movq %rax, %rbx
jmp 0x4245f
jmp 0x4247e
jmp 0x4247e
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x42481
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
jmp 0x42475
jmp 0x42437
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x4245f
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x6380
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x42481
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6380
jmp 0x42481
jmp 0x4247e
movq %rax, %rbx
leaq 0x130(%rsp), %rdi
callq 0x426c0
leaq 0xe0(%rsp), %rdi
callq 0x2ae7e
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x424b2
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x424ce
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x424eb
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x30(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x42504
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620