// File: /workspace/github_cpp_makefile_star2_O1/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 $0x188, %rsp            # imm = 0x188
movl %r9d, %ebx
movq %r8, 0x98(%rsp)
movq %rcx, 0x50(%rsp)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movq %rdi, 0x58(%rsp)
movups %xmm0, (%rdi)
movq %rax, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
leaq 0xb8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq %rax, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq 0x88(%rsi), %r15
movq %rsi, 0x48(%rsp)
movq 0x90(%rsi), %r13
cmpq %r13, %r15
je 0x41d92
movq %rdx, %r14
leaq 0xf0(%rsp), %r12
leaq 0x148(%rsp), %rbp
movq %r12, %rdi
movq %r15, %rsi
callq 0x19a68
movq 0xf8(%rsp), %rax
movq -0x8(%rax), %rax
movq %rax, 0x148(%rsp)
cmpq 0x50(%rsp), %rax
je 0x41d6c
cmpq 0x8(%r14), %rax
je 0x41d6c
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x41d5f
movq %rax, (%rsi)
addq $0x8, 0x68(%rsp)
jmp 0x41d6c
leaq 0x60(%rsp), %rdi
movq %rbp, %rdx
callq 0x1c69a
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x41d89
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %r13, %r15
jne 0x41d1c
leaq 0x120(%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 0x180(%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, %r14
decl %ebx
movq 0x50(%rsp), %rsi
movq %rsi, (%rax)
movb $0x1, 0x8(%rax)
movl %ebx, 0xc(%rax)
movq 0x48(%rsp), %rdi
movq 0x98(%rsp), %rdx
callq 0x3f248
movl %eax, 0x10(%r14)
movq $0x0, 0x18(%r14)
movq %r14, 0xa0(%rsp)
movq 0x50(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x3f57e
leaq 0xa8(%rsp), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x6460
movq (%rbx), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x41e59
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6380
leaq 0x150(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x42c56
leaq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
movq %rax, (%rdi)
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
addq %rsi, %rdx
callq 0xb7d0
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
movl $0x1, %edx
callq 0x43046
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x41ece
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6380
cmpq $0x0, 0x108(%rsp)
je 0x424a5
leaq 0xd8(%rsp), %r13
movb $0x1, %al
movl %eax, 0x2c(%rsp)
leaq 0x8(%rsp), %rbp
movq 0x100(%rsp), %r15
testq %r15, %r15
je 0x41ff4
movq (%r15), %r12
testq %r12, %r12
je 0x41ff4
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xb7d0
leaq 0x150(%rsp), %r14
movq %r13, 0xc8(%rsp)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0xb7d0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x433e2
testq %rax, %rax
je 0x425ea
movq 0x28(%rax), %rbx
movq %r14, %rdi
leaq 0xc8(%rsp), %rsi
callq 0x433e2
testq %rax, %rax
je 0x425ea
movq 0x28(%rax), %rax
movl 0x10(%rax), %ecx
cmpl %ecx, 0x10(%rbx)
jne 0x41f9c
movl 0xc(%rbx), %ecx
cmpl 0xc(%rax), %ecx
setg %bl
jmp 0x41f9f
setl %bl
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x41fbc
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x41fd8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6380
movq %r12, %r14
testb %bl, %bl
jne 0x41fe2
movq %r15, %r14
movq (%r12), %r12
movq %r14, %r15
testq %r12, %r12
jne 0x41f0d
jmp 0x41ff7
movq %r15, %r14
leaq 0x8(%r14), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x6200
leaq 0x150(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x433e2
testq %rax, %rax
je 0x42602
movq 0x28(%rax), %rbx
movq 0x98(%rsp), %rax
cmpq %rax, (%rbx)
movq %rbx, 0x30(%rsp)
je 0x4238e
movb $0x0, 0x8(%rbx)
leaq 0xf0(%rsp), %rdi
movq %r14, %rsi
callq 0x4341c
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x80(%rsp), %rdi
movq %rbp, %rsi
leaq 0x10(%rsp), %rdx
callq 0x3e02c
movq 0x48(%rsp), %rax
movq 0x38(%rax), %rsi
movq (%rbx), %rdx
movq %rbp, %rdi
callq 0x1a320
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
cmpq %r14, %rbx
leaq 0xe8(%rsp), %r15
je 0x4210e
movq (%rbx), %rax
movq %rax, 0xe8(%rsp)
movq %rax, 0xc8(%rsp)
movq 0x60(%rsp), %rdi
movq 0x68(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x19ae8
cmpq 0x68(%rsp), %rax
jne 0x42105
movq 0x88(%rsp), %rsi
cmpq 0x90(%rsp), %rsi
je 0x420f5
movq 0xe8(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x88(%rsp)
jmp 0x42105
leaq 0x80(%rsp), %rdi
movq %r15, %rdx
callq 0x1c69a
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x4209c
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x42125
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rcx, 0x128(%rsp)
cmpq %rcx, %rax
leaq 0xa8(%rsp), %rbx
leaq 0x150(%rsp), %r14
je 0x4237a
movq %rax, 0x138(%rsp)
movq (%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rax
movl 0xc(%rax), %ecx
leal 0x1(%rcx), %eax
movl %eax, 0x44(%rsp)
testl %ecx, %ecx
js 0x4225c
movq 0x48(%rsp), %rax
movq 0x88(%rax), %rbp
movq 0x90(%rax), %r12
cmpq %r12, %rbp
je 0x4225c
movq %rcx, 0x130(%rsp)
leaq 0x2(%rcx), %r15
movl 0x44(%rsp), %eax
movq %rax, 0x140(%rsp)
xorl %r14d, %r14d
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x19a68
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rax
subq %rdi, %rax
sarq $0x3, %rax
movl $0x10, %r13d
cmpq %r15, %rax
jb 0x42218
movq 0x140(%rsp), %rax
movq (%rdi,%rax,8), %rax
movb $0x1, %bl
movl $0xf, %r13d
cmpq 0x38(%rsp), %rax
je 0x4221b
movq 0x30(%rsp), %rcx
cmpq (%rcx), %rax
jne 0x42215
movq 0x38(%rsp), %rax
movq 0x130(%rsp), %rcx
cmpq %rax, (%rdi,%rcx,8)
je 0x4221b
xorl %r13d, %r13d
movl %r14d, %ebx
testq %rdi, %rdi
je 0x4222d
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
testb $0xf, %r13b
jne 0x42243
addq $0x18, %rbp
movl %ebx, %r14d
cmpq %r12, %rbp
jne 0x421b4
testb $0x1, %bl
leaq 0xa8(%rsp), %rbx
leaq 0x150(%rsp), %r14
jne 0x42360
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movl 0x44(%rsp), %ebp
movl %ebp, %esi
movq 0x38(%rsp), %rdx
callq 0x3f57e
movq %rbx, %rdi
movq %r15, %rsi
callq 0x6460
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4229b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6380
movq %r14, %rdi
movq %rbx, %rsi
callq 0x433e2
testq %rax, %rax
jne 0x422e7
movl $0x20, %edi
callq 0x6370
movq 0x38(%rsp), %rcx
movq %rcx, (%rax)
movb $0x1, 0x8(%rax)
movl %ebp, 0xc(%rax)
movl $0x186a0, 0x10(%rax)    # imm = 0x186A0
movq 0x30(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq %rax, 0x8(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x434e2
movq %r14, %rdi
movq %rbx, %rsi
callq 0x433e2
testq %rax, %rax
je 0x425f6
movq 0x28(%rax), %rax
movq %rax, 0xa0(%rsp)
cmpb $0x1, 0x8(%rax)
jne 0x42360
movq 0x48(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x98(%rsp), %rdx
callq 0x3f248
leaq 0x8(%rsp), %rdx
movl 0x44(%rsp), %esi
addl %esi, %eax
movq 0xa0(%rsp), %rcx
cmpl %eax, 0x10(%rcx)
jle 0x4234b
movl %esi, 0xc(%rcx)
movl %eax, 0x10(%rcx)
movq 0x30(%rsp), %rax
movq %rax, 0x18(%rcx)
leaq 0xf0(%rsp), %rdi
movq %rdi, 0x8(%rsp)
movq %rbx, %rsi
callq 0x43616
movq 0x138(%rsp), %rax
addq $0x8, %rax
cmpq 0x128(%rsp), %rax
jne 0x42156
xorl %eax, %eax
leaq 0xd8(%rsp), %r13
leaq 0x8(%rsp), %rbp
jmp 0x42487
movb $0x1, %al
cmpb $0x0, 0x1c0(%rsp)
je 0x4247f
movq 0x48(%rsp), %rcx
movq 0x88(%rcx), %r15
movq 0x90(%rcx), %rbx
cmpq %rbx, %r15
je 0x4247f
movq 0x30(%rsp), %rax
movslq 0xc(%rax), %rax
leaq 0x1(%rax), %rbp
shlq $0x3, %rax
movq %rax, 0x38(%rsp)
movb $0x1, %r12b
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x19a68
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rax
movq %rax, %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
movl $0x7, %r13d
cmpq %rbp, %rcx
jbe 0x42437
movq 0x38(%rsp), %rcx
addq %rdi, %rcx
addq $0x8, %rcx
cmpq %rax, %rcx
jae 0x42424
movq (%rcx), %rdx
addq $0x8, %rcx
movq 0x30(%rsp), %rsi
cmpq (%rsi), %rdx
jne 0x4240b
xorl %r12d, %r12d
testb $0x1, %r12b
movl $0x6, %r13d
movl $0x0, %eax
cmovnel %eax, %r13d
testq %rdi, %rdi
je 0x42449
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
cmpl $0x7, %r13d
je 0x42454
testl %r13d, %r13d
jne 0x42461
addq $0x18, %r15
cmpq %rbx, %r15
jne 0x423d3
testb $0x1, %r12b
leaq 0xd8(%rsp), %r13
leaq 0x8(%rsp), %rbp
movq 0x30(%rsp), %rbx
je 0x42040
movb $0x1, %al
movl $0x0, 0x2c(%rsp)
testb %al, %al
jne 0x4249a
cmpq $0x0, 0x108(%rsp)
jne 0x41ef0
movl 0x2c(%rsp), %eax
movq 0x30(%rsp), %rcx
jmp 0x424a7
movb $0x1, %al
testb $0x1, %al
jne 0x42560
cmpq $0x0, 0x18(%rcx)
je 0x424ef
movq %rcx, %rdx
leaq 0x18(%rcx), %rbx
movq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x424d9
movq (%rdx), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x424de
callq 0x1c69a
movq (%rbx), %rax
leaq 0x18(%rax), %rbx
movq %rax, %rdx
cmpq $0x0, 0x18(%rax)
jne 0x424bd
movq 0x58(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x42510
movq %rdi, %rbx
movq 0x50(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
jmp 0x4251d
leaq 0x50(%rsp), %rdx
movq %rdi, %rbx
callq 0x1c69a
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x42560
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 0x42542
leaq 0x150(%rsp), %rdi
callq 0x42926
leaq 0xf0(%rsp), %rdi
callq 0x2af52
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x42591
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x425b6
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x425d3
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7eea(%rip), %rdi      # 0x4a4db
callq 0x6520
leaq 0x7ede(%rip), %rdi      # 0x4a4db
callq 0x6520
leaq 0x7ed2(%rip), %rdi      # 0x4a4db
callq 0x6520
jmp 0x426d7
jmp 0x42677
jmp 0x426d7
jmp 0x426d7
movq %rax, %rbx
movl $0x20, %esi
movq %r14, %rdi
jmp 0x426ce
jmp 0x426d7
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x426f4
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x426f4
jmp 0x426d7
jmp 0x426d7
jmp 0x426d7
jmp 0x426d7
movq %rax, %rbx
jmp 0x426f4
jmp 0x426d7
jmp 0x426d7
jmp 0x426d7
jmp 0x426d7
jmp 0x426d7
movq %rax, %rbx
jmp 0x426b7
jmp 0x426d7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x426da
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
jmp 0x426ce
jmp 0x42697
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r13, %rdi
je 0x426b7
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x426da
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6380
jmp 0x426da
jmp 0x426d7
movq %rax, %rbx
leaq 0x150(%rsp), %rdi
callq 0x42926
leaq 0xf0(%rsp), %rdi
callq 0x2af52
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4270b
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x42730
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x6380
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x4274d
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x58(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x42766
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620