// File: /workspace/github_cpp_makefile_star2_O3/Kei18[P]pibt/./src/solver/whca.cpp
// Function: WHCA::solve()
bool WHCA::solve() {
  solveStart();

  Paths PATHS;  // paths for all agents
  int t = 0;
  int limit;
  bool failed = false;

  // initialize path
  for (auto a : A) PATHS.push_back({ a->getNode() });

  while (!P->isSolved()) {
    for (int i = 0; i < A.size(); ++i) {
      Nodes path = getPath(A[i], t, PATHS);

      // check whether success for computing path or not
      if (path.empty()) {
        failed = true;
        break;
      }

      // reach goal
      if (!hasWindow) {
        CG* cg = new CG { A[i], (int)path.size() - 1, A[i]->getGoal() };
        CGOAL.push_back(cg);
      }

      PATHS[i].insert(PATHS[i].end(), path.begin() + 1, path.end());
    }

    if (failed) break;

    formalizePath(PATHS);
    limit = std::min(window, (int)PATHS[0].size() - t);
    for (int _t = 0; _t < limit; ++_t) {
      ++t;
      for (int i = 0; i < A.size(); ++i) A[i]->setNode(PATHS[i][t]);
      P->update();
      if (P->isSolved()) break;
      if (P->getTimestep() >= P->getTimestepLimit()) break;
    }

    if (P->getTimestep() >= P->getTimestepLimit()) break;
  }

  solveEnd();
  return !failed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
callq *(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
movq 0x20(%rbx), %rbp
movq 0x28(%rbx), %r15
cmpq %r15, %rbp
je 0x43ae4
leaq 0x38(%rsp), %r14
leaq 0xf(%rsp), %r12
leaq 0x20(%rsp), %r13
movq (%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
movq %r12, %rcx
callq 0xb484
movq %r13, %rdi
movq %r14, %rsi
callq 0x18c56
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x43adb
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %rbp
cmpq %r15, %rbp
jne 0x43a97
leaq 0x70(%rbx), %rax
movq %rax, 0x50(%rsp)
movq 0x10(%rbx), %rdi
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq (%rdi), %rax
callq *0x10(%rax)
testb %al, %al
jne 0x43cbd
movq 0x20(%rbx), %rax
cmpq %rax, 0x28(%rbx)
je 0x43bfd
xorl %r13d, %r13d
xorl %r12d, %r12d
movq (%rax,%r12,8), %rdx
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %ecx
leaq 0x20(%rsp), %r8
callq 0x43d3e
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %r14
cmpq %r14, %r15
je 0x43b93
cmpb $0x0, 0x68(%rbx)
jne 0x43bab
movl $0x18, %edi
callq 0x6370
movq 0x20(%rbx), %rcx
movq (%rcx,%r12,8), %rcx
movq %rcx, (%rax)
movq %r14, %rdx
subq %r15, %rdx
shrq $0x3, %rdx
decl %edx
movl %edx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, 0x18(%rsp)
movq 0x78(%rbx), %rsi
cmpq 0x80(%rbx), %rsi
je 0x43b9c
movq %rax, (%rsi)
addq $0x8, 0x78(%rbx)
jmp 0x43bab
movb $0x1, %al
movq %rax, 0x10(%rsp)
jmp 0x43bc4
movq 0x50(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x44aa6
movq 0x20(%rsp), %rdi
movq 0x8(%rdi,%r13), %rsi
addq %r13, %rdi
leaq 0x8(%r15), %rdx
movq %r14, %rcx
callq 0x427fc
testq %r15, %r15
je 0x43bd9
movq 0x48(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x6380
cmpq %r14, %r15
je 0x43bfd
incq %r12
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $0x18, %r13
cmpq %r12, %rcx
ja 0x43b1e
testb $0x1, 0x10(%rsp)
jne 0x43cbd
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3eeec
movq 0x20(%rsp), %rax
movq 0x8(%rax), %r14
subq (%rax), %r14
shrq $0x3, %r14
subl %ebp, %r14d
movl 0x6c(%rbx), %eax
cmpl %eax, %r14d
cmovgel %eax, %r14d
testl %r14d, %r14d
jle 0x43cad
movslq %ebp, %rbp
xorl %r15d, %r15d
incq %rbp
movq 0x20(%rbx), %rax
cmpq %rax, 0x28(%rbx)
je 0x43c81
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rax,%r13,8), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r12), %rax
movq (%rax,%rbp,8), %rsi
callq 0x191f2
incq %r13
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $0x18, %r12
cmpq %r13, %rcx
ja 0x43c50
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testb %al, %al
jne 0x43cad
movq 0x10(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl 0xc(%rax), %ecx
jge 0x43cad
incl %r15d
cmpl %r14d, %r15d
jl 0x43c3d
movq 0x10(%rbx), %rdi
movl 0x8(%rdi), %eax
cmpl 0xc(%rdi), %eax
jl 0x43afc
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq 0x10(%rsp), %rbx
notb %bl
leaq 0x20(%rsp), %rdi
callq 0xb508
andb $0x1, %bl
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x43d28
jmp 0x43d28
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x43d2b
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
jmp 0x43d1d
jmp 0x43d28
jmp 0x43d0a
movq %rax, %rbx
testq %r15, %r15
je 0x43d2b
movq 0x48(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x6380
jmp 0x43d2b
jmp 0x43d28
jmp 0x43d28
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb508
movq %rbx, %rdi
callq 0x6620
nop