// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x108(%rbp)
movq (%rdi), %rax
callq *(%rax)
leaq -0x20(%rbp), %rdi
callq 0xd9c0
movq -0x108(%rbp), %rax
movl $0x0, -0x24(%rbp)
movb $0x0, -0x29(%rbp)
addq $0x20, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x39b60
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x399f0
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x51bd0
testb $0x1, %al
jne 0xaac32
jmp 0xaad25
leaq -0x40(%rbp), %rdi
callq 0x51c10
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x51cb0
movq %rax, -0x110(%rbp)
jmp 0xaac54
movq -0x110(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x78(%rbp)
movq $0x1, -0x70(%rbp)
leaq -0x8d(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0xd730
movq -0x118(%rbp), %rcx
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0xd750
jmp 0xaac9c
leaq -0x20(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xd700
jmp 0xaacab
leaq -0x68(%rbp), %rdi
callq 0xd7d0
leaq -0x8d(%rbp), %rdi
callq 0xd830
leaq -0x40(%rbp), %rdi
callq 0x51c30
jmp 0xaac1c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xab26e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xaad14
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xd7d0
leaq -0x8d(%rbp), %rdi
callq 0xd830
jmp 0xab26e
jmp 0xaad27
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movb %al, -0x119(%rbp)
jmp 0xaad43
movb -0x119(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xaad54
jmp 0xab22d
movl $0x0, -0x94(%rbp)
movq -0x108(%rbp), %rdi
movslq -0x94(%rbp), %rax
movq %rax, -0x128(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0x128(%rbp), %rax
cmpq %rcx, %rax
jae 0xab01a
movq -0x108(%rbp), %rdi
addq $0x20, %rdi
movslq -0x94(%rbp), %rsi
callq 0x53720
movq -0x108(%rbp), %rsi
movq (%rax), %rdx
movl -0x24(%rbp), %ecx
leaq -0xb0(%rbp), %rdi
leaq -0x20(%rbp), %r8
callq 0xab290
jmp 0xaadc5
leaq -0xb0(%rbp), %rdi
callq 0x3ec00
testb $0x1, %al
jne 0xaadd7
jmp 0xaadea
movb $0x1, -0x29(%rbp)
movl $0x6, -0xb4(%rbp)
jmp 0xaafd9
movq -0x108(%rbp), %rax
testb $0x1, 0x68(%rax)
jne 0xaaeff
movl $0x18, %edi
callq 0x84e0
movq %rax, -0x130(%rbp)
jmp 0xaae0e
movq -0x108(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x148(%rbp)
movslq -0x94(%rbp), %rsi
callq 0x53720
movq %rax, %rcx
movq -0x130(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, (%rax)
leaq -0xb0(%rbp), %rdi
callq 0x3b0e0
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movq -0x130(%rbp), %rax
decl %ecx
movl %ecx, 0x8(%rax)
addq $0x10, %rax
movq %rax, -0x140(%rbp)
movslq -0x94(%rbp), %rsi
callq 0x53720
movq (%rax), %rdi
callq 0x56820
movq %rax, -0x138(%rbp)
jmp 0xaae86
movq -0x108(%rbp), %rdi
movq -0x130(%rbp), %rax
movq -0x140(%rbp), %rcx
movq -0x138(%rbp), %rdx
movq %rdx, (%rcx)
movq %rax, -0xc0(%rbp)
addq $0x70, %rdi
leaq -0xc0(%rbp), %rsi
callq 0xac540
jmp 0xaaebe
jmp 0xaaeff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0xab009
movq -0x130(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
movl $0x18, %esi
callq 0x84f0
jmp 0xab009
movslq -0x94(%rbp), %rsi
leaq -0x20(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0xda70
movq -0x168(%rbp), %rdi
movq %rax, -0x158(%rbp)
movslq -0x94(%rbp), %rsi
callq 0xda70
movq %rax, %rdi
callq 0x3b760
movq %rax, -0xd0(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3f680
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x3b730
movq %rax, -0xe0(%rbp)
leaq -0xe0(%rbp), %rdi
movl $0x1, %esi
callq 0x413f0
movq -0x160(%rbp), %rdi
movq %rax, -0xd8(%rbp)
callq 0x3b760
movq -0x158(%rbp), %rdi
movq %rax, -0xe8(%rbp)
movq -0xc8(%rbp), %rsi
movq -0xd8(%rbp), %rdx
movq -0xe8(%rbp), %rcx
callq 0xa54a0
movq %rax, -0x150(%rbp)
jmp 0xaafc1
movq -0x150(%rbp), %rax
movq %rax, -0xf0(%rbp)
movl $0x0, -0xb4(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xd7d0
movl -0xb4(%rbp), %eax
testl %eax, %eax
je 0xaaff3
jmp 0xaaff1
jmp 0xab01a
jmp 0xaaff5
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0xaad5e
leaq -0xb0(%rbp), %rdi
callq 0xd7d0
jmp 0xab26e
testb $0x1, -0x29(%rbp)
je 0xab025
jmp 0xab22d
movq -0x108(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x9d330
jmp 0xab037
movq -0x108(%rbp), %rax
addq $0x6c, %rax
movq %rax, -0x178(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x20(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq -0x178(%rbp), %rdi
movl -0x24(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0xf4(%rbp)
leaq -0xf4(%rbp), %rsi
callq 0xac5b0
movq %rax, -0x170(%rbp)
jmp 0xab085
movq -0x170(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0xab1e6
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0xfc(%rbp)
movq -0x108(%rbp), %rdi
movslq -0xfc(%rbp), %rax
movq %rax, -0x180(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0x180(%rbp), %rax
cmpq %rcx, %rax
jae 0xab14e
movq -0x108(%rbp), %rdi
addq $0x20, %rdi
movslq -0xfc(%rbp), %rsi
callq 0x53720
movq (%rax), %rax
movq %rax, -0x188(%rbp)
movslq -0xfc(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0x24(%rbp), %rsi
callq 0xda90
movq -0x188(%rbp), %rdi
movq (%rax), %rsi
callq 0x3a480
jmp 0xab138
jmp 0xab13a
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0xab0bd
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0xab164
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movb %al, -0x189(%rbp)
jmp 0xab180
movb -0x189(%rbp), %al
testb $0x1, %al
jne 0xab18c
jmp 0xab18e
jmp 0xab1e6
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x622f0
movl %eax, -0x190(%rbp)
jmp 0xab1a6
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x62310
movl %eax, -0x194(%rbp)
jmp 0xab1be
movl -0x190(%rbp), %eax
movl -0x194(%rbp), %ecx
cmpl %ecx, %eax
jl 0xab1d0
jmp 0xab1e6
jmp 0xab1d2
movl -0xf8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf8(%rbp)
jmp 0xab09b
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x622f0
movl %eax, -0x198(%rbp)
jmp 0xab1fe
movq -0x108(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x62310
movl %eax, -0x19c(%rbp)
jmp 0xab216
movl -0x198(%rbp), %eax
movl -0x19c(%rbp), %ecx
cmpl %ecx, %eax
jl 0xab228
jmp 0xab22d
jmp 0xaad27
movq -0x108(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0xab23f
movb -0x29(%rbp), %al
xorb $-0x1, %al
movb %al, -0x19d(%rbp)
movl $0x1, -0xb4(%rbp)
leaq -0x20(%rbp), %rdi
callq 0xda10
movb -0x19d(%rbp), %al
andb $0x1, %al
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0x20(%rbp), %rdi
callq 0xda10
movq -0x88(%rbp), %rdi
callq 0x8880
nopw %cs:(%rax,%rax)