// File: /workspace/github_cpp_makefile_star2_O1/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 0x43daa
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 0xb44a
movq %r13, %rdi
movq %r14, %rsi
callq 0x18be6
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x43da1
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %rbp
cmpq %r15, %rbp
jne 0x43d5d
leaq 0x70(%rbx), %rax
movq %rax, 0x50(%rsp)
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testb %al, %al
jne 0x43f87
movq 0x20(%rbx), %rax
cmpq %rax, 0x28(%rbx)
je 0x43ec7
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 0x44008
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %r14
cmpq %r14, %r15
je 0x43e5d
cmpb $0x0, 0x68(%rbx)
jne 0x43e75
movl $0x18, %edi
callq 0x6370
movq 0x20(%rbx), %rcx
movq (%rcx,%r12,8), %rdx
movq %rdx, (%rax)
movq %r14, %rdx
subq %r15, %rdx
shrq $0x3, %rdx
decl %edx
movl %edx, 0x8(%rax)
movq (%rcx,%r12,8), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, 0x18(%rsp)
movq 0x78(%rbx), %rsi
cmpq 0x80(%rbx), %rsi
je 0x43e66
movq %rax, (%rsi)
addq $0x8, 0x78(%rbx)
jmp 0x43e75
movb $0x1, %al
movq %rax, 0x10(%rsp)
jmp 0x43e8e
movq 0x50(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x44e2a
movq 0x20(%rsp), %rdi
movq 0x8(%rdi,%r13), %rsi
addq %r13, %rdi
leaq 0x8(%r15), %rdx
movq %r14, %rcx
callq 0x42a62
testq %r15, %r15
je 0x43ea3
movq 0x48(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x6380
cmpq %r14, %r15
je 0x43ec7
incq %r12
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $0x18, %r13
cmpq %r12, %rcx
ja 0x43de4
testb $0x1, 0x10(%rsp)
jne 0x43f87
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x3f16a
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 0x43f77
movslq %ebp, %rbp
xorl %r15d, %r15d
incq %rbp
movq 0x20(%rbx), %rax
cmpq %rax, 0x28(%rbx)
je 0x43f4b
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 0x191a6
incq %r13
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
addq $0x18, %r12
cmpq %r13, %rcx
ja 0x43f1a
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testb %al, %al
jne 0x43f77
movq 0x10(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl 0xc(%rax), %ecx
jge 0x43f77
incl %r15d
cmpl %r14d, %r15d
jl 0x43f07
movq 0x10(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl 0xc(%rax), %ecx
jl 0x43dbe
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq 0x10(%rsp), %rbx
notb %bl
leaq 0x20(%rsp), %rdi
callq 0xb4ce
andb $0x1, %bl
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x43ff2
jmp 0x43ff2
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x43ff5
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
jmp 0x43fe7
jmp 0x43ff2
jmp 0x43fd4
movq %rax, %rbx
testq %r15, %r15
je 0x43ff5
movq 0x48(%rsp), %rsi
subq %r15, %rsi
movq %r15, %rdi
callq 0x6380
jmp 0x43ff5
jmp 0x43ff2
jmp 0x43ff2
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xb4ce
movq %rbx, %rdi
callq 0x6620
nop