// File: /workspace/github_cpp_makefile_star2_O3/Kei18[P]pibt/./src/solver/tp.cpp
// Function: TP::updatePath2(Agent*, int)
void TP::updatePath2(Agent* a, int startTime) {
  Nodes candidates;
  std::vector<Task*> T = P->getT();
  bool contained;

  // create candidates
  for (auto v : endpoints) {
    contained = std::any_of(T.begin(), T.end(),
                             [v](Task* tau) {
                               return tau->getG()[tau->getG().size() - 1] == v; });
    if (contained) continue;
    contained = std::any_of(paths.begin(), paths.end(),
                            [v](Nodes path) {
                              return path[path.size() - 1] == v; });
    if (contained) continue;
    candidates.push_back(v);
  }

  if (candidates.empty()) {  // failed
    std::cout << "updatePath2, candidates are empty" << a->getId() << "\n";
    status = false;
    return;
  }

  // choose candidates
  Node* u = a->getNode();
  Graph* _G = G;
  auto itr1 = std::min_element(candidates.begin(), candidates.end(),
                               [u, _G](Node* v1, Node* v2) {
                                 return _G->dist(u, v1) < _G->dist(u, v2); });
  a->setGoal(*itr1);
  Nodes path = getPath(a, startTime);

  if (path.empty()) {
    std::cout << "updatePath2, path is empty" << a->getId() << "\n";
    status = false;
    return;
  }

  auto itr2 = std::find(A.begin(), A.end(), a);
  int i = std::distance(A.begin(), itr2);
  paths[i].insert(paths[i].end(), path.begin() + 1, path.end());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, 0x6c(%rsp)
movq %rdi, %rbx
movq %rsi, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x10(%rdi), %rsi
addq $0x30, %rsi
leaq 0x70(%rsp), %rdi
callq 0xb5dc
movq 0x70(%rbx), %rbp
movq %rbx, 0x18(%rsp)
movq 0x78(%rbx), %rax
movq %rax, 0x38(%rsp)
cmpq %rax, %rbp
je 0x40e2d
leaq 0x40(%rsp), %r14
movq (%rbp), %rax
movq %rax, 0x58(%rsp)
movq 0x70(%rsp), %r15
movq 0x78(%rsp), %rbx
movq %rax, 0x40(%rsp)
movq %rbx, 0x10(%rsp)
subq %r15, %rbx
movq %rbx, %r12
sarq $0x5, %r12
testq %r12, %r12
jle 0x40bd4
incq %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x425e6
testb %al, %al
jne 0x40c04
leaq 0x8(%r15), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x425e6
testb %al, %al
jne 0x40c07
leaq 0x10(%r15), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x425e6
testb %al, %al
jne 0x40c07
leaq 0x18(%r15), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x425e6
testb %al, %al
jne 0x40c07
addq $0x20, %r15
decq %r12
addq $-0x20, %rbx
cmpq $0x1, %r12
jg 0x40b7b
sarq $0x3, %rbx
cmpq $0x1, %rbx
je 0x40c28
cmpq $0x2, %rbx
je 0x40c0e
cmpq $0x3, %rbx
jne 0x40c4a
movq %r14, %rdi
movq %r15, %rsi
callq 0x425e6
movq 0x10(%rsp), %rbx
testb %al, %al
jne 0x40c3e
addq $0x8, %r15
jmp 0x40c13
movq %r15, %r13
movq 0x10(%rsp), %rbx
jmp 0x40c41
movq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x425e6
testb %al, %al
jne 0x40c3e
addq $0x8, %r15
jmp 0x40c2d
movq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x425e6
testb %al, %al
cmoveq %rbx, %r15
movq %r15, %r13
cmpq %rbx, %r13
jne 0x40d98
movq 0x18(%rsp), %rax
movq 0x88(%rax), %r13
movq 0x90(%rax), %r12
movq 0x58(%rsp), %rax
movq %rax, 0x40(%rsp)
movq %r12, 0x10(%rsp)
subq %r13, %r12
movq %r12, %rbx
sarq $0x3, %rbx
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rbx
sarq $0x2, %rbx
testq %rbx, %rbx
jle 0x40ced
incq %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x42684
testb %al, %al
jne 0x40d2b
leaq 0x18(%r13), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x42684
testb %al, %al
jne 0x40d2e
leaq 0x30(%r13), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x42684
testb %al, %al
jne 0x40d2e
leaq 0x48(%r13), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x42684
testb %al, %al
jne 0x40d2e
addq $0x60, %r13
decq %rbx
addq $-0x60, %r12
cmpq $0x1, %rbx
jg 0x40c90
sarq $0x3, %r12
movabsq $-0x5555555555555555, %rax # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r12
cmpq $0x1, %r12
je 0x40d4f
cmpq $0x2, %r12
je 0x40d35
cmpq $0x3, %r12
jne 0x40d6d
movq %r14, %rdi
movq %r13, %rsi
callq 0x42684
movq 0x10(%rsp), %rbx
testb %al, %al
jne 0x40d65
addq $0x18, %r13
jmp 0x40d3a
movq %r13, %r15
movq 0x10(%rsp), %rbx
jmp 0x40d68
movq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x42684
testb %al, %al
jne 0x40d65
addq $0x18, %r13
jmp 0x40d54
movq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %r13, %rsi
callq 0x42684
testb %al, %al
cmoveq %rbx, %r13
movq %r13, %r15
cmpq %rbx, %r15
jne 0x40d98
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x40d89
movq 0x58(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x28(%rsp)
jmp 0x40d98
leaq 0x20(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x1c5cc
addq $0x8, %rbp
cmpq 0x38(%rsp), %rbp
jne 0x40b4c
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %r15
cmpq %r15, %rsi
je 0x40e2d
movq 0x60(%rsp), %r12
movq 0x8(%r12), %r9
leaq 0x8(%rsi), %rbx
cmpq %r15, %rbx
je 0x40e7d
movq %r12, 0x38(%rsp)
movq 0x18(%rsp), %rax
movq 0x38(%rax), %r14
movq (%rbx), %rdx
movq %rsi, 0x10(%rsp)
movq (%rsi), %r13
movq (%r14), %rax
movq %r14, %rdi
movq %r9, %rsi
movq %r9, %r12
callq *0x10(%rax)
movl %eax, %ebp
movq (%r14), %rax
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq *0x10(%rax)
movq %rbx, %rcx
cmpl %eax, %ebp
jl 0x40e12
movq 0x10(%rsp), %rcx
addq $0x8, %rbx
movq %rcx, %rsi
cmpq %r15, %rbx
movq %r12, %r9
jne 0x40ddb
movq 0x38(%rsp), %r12
movq 0x8(%r12), %r9
jmp 0x40e80
movq 0x21174(%rip), %rdi     # 0x61fa8
leaq 0xaf8d(%rip), %rsi      # 0x4bdc8
movl $0x21, %edx
callq 0x63f0
movq 0x60(%rsp), %rax
movl (%rax), %esi
movq 0x21155(%rip), %rdi     # 0x61fa8
callq 0x6610
leaq 0x7704(%rip), %rsi      # 0x48563
movl $0x1, %edx
movq %rax, %rdi
callq 0x63f0
movq 0x18(%rsp), %rax
movb $0x0, 0xa0(%rax)
jmp 0x40f56
movq %rsi, %rcx
movq (%rcx), %r8
movq %r8, 0x10(%r12)
movl $0x1, (%rsp)
leaq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
movq %r9, %rcx
movl 0x6c(%rsp), %r9d
callq 0x41ae4
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0x40efc
movq 0x20(%rbx), %rdi
movq 0x28(%rbx), %rsi
leaq 0x60(%rsp), %rdx
callq 0x388d5
subq 0x20(%rbx), %rax
shrq $0x3, %rax
cltq
movq 0x88(%rbx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq 0x8(%rdi), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
addq $0x8, %rdx
callq 0x427fc
jmp 0x40f3f
movq 0x210a5(%rip), %rdi     # 0x61fa8
leaq 0xaee0(%rip), %rsi      # 0x4bdea
movl $0x1a, %edx
callq 0x63f0
movl (%r12), %esi
movq 0x21089(%rip), %rdi     # 0x61fa8
callq 0x6610
leaq 0x7638(%rip), %rsi      # 0x48563
movl $0x1, %edx
movq %rax, %rdi
callq 0x63f0
movb $0x0, 0xa0(%rbx)
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x40f56
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x40f70
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x40f87
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x40f9f
jmp 0x40f9f
jmp 0x40fc8
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x40fcb
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x40fcb
movq %rax, %rbx
jmp 0x40fe5
jmp 0x40fc8
jmp 0x40fc8
jmp 0x40fc8
jmp 0x40fc8
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x40fe5
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x40ffc
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620