// File: Kei18[P]pibt/./src/solver/cbs.cpp
// Function: CBS::solve()
bool CBS::solve() {
  solveStart();

  Paths PATHS;
  std::vector<Agents> WHOLE;

  // initialize
  for (int i = 0; i < A.size(); ++i) PATHS.push_back({});

  if (!ID) {  // normal CBS
    solvePart(PATHS, A);
    formalizePath(PATHS);

  } else {  // with ID framework
    for (auto a : A) WHOLE.push_back({ a });

    // solve with independent detection
    while (true) {
      for (auto BLOCK : WHOLE) {
        if (!solvePart(PATHS, BLOCK)) {
          solveEnd();
          return false;  // failed
        }
      }
      formalizePath(PATHS);
      if (checkAgents(PATHS, WHOLE)) break;

      // initialize
      PATHS.clear();
      for (int i = 0; i < A.size(); ++i) PATHS.push_back({});
    }
  }

  int maxLength = getMaxLengthPaths(PATHS);
  for (int t = 1; t < maxLength; ++t) {
    for (int i = 0; i < A.size(); ++i) A[i]->setNode(PATHS[i][t]);
    P->update();

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

  solveEnd();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x138(%rbp)
movq (%rdi), %rax
callq *(%rax)
leaq -0x28(%rbp), %rdi
callq 0xd9c0
leaq -0x40(%rbp), %rdi
callq 0x62140
movl $0x0, -0x44(%rbp)
movq -0x138(%rbp), %rdi
movslq -0x44(%rbp), %rax
movq %rax, -0x140(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jae 0x57b71
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x3e880
movq -0x148(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xd700
jmp 0x57b43
leaq -0x60(%rbp), %rdi
callq 0xd7d0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x57ae8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xd7d0
jmp 0x58085
movq -0x138(%rbp), %rax
testb $0x1, 0x68(%rax)
jne 0x57bc3
movq -0x138(%rbp), %rdi
movq %rdi, %rdx
addq $0x20, %rdx
movq (%rdi), %rax
movq 0x30(%rax), %rax
leaq -0x28(%rbp), %rsi
callq *%rax
jmp 0x57b9b
movq -0x138(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x9d330
jmp 0x57bad
jmp 0x57ef9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x58085
movq -0x138(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
callq 0x39b60
movq %rax, -0x80(%rbp)
movq -0x78(%rbp), %rdi
callq 0x399f0
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x51bd0
testb $0x1, %al
jne 0x57c08
jmp 0x57ce7
leaq -0x80(%rbp), %rdi
callq 0x51c10
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0xc0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq $0x1, -0xb0(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0xe6e0
movq -0x150(%rbp), %rcx
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
callq 0x62190
jmp 0x57c78
leaq -0x40(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x62160
jmp 0x57c8a
leaq -0xa8(%rbp), %rdi
callq 0xddf0
leaq -0xc1(%rbp), %rdi
callq 0x38470
leaq -0x80(%rbp), %rdi
callq 0x51c30
jmp 0x57bef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x57cd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xddf0
leaq -0xc1(%rbp), %rdi
callq 0x38470
jmp 0x58085
jmp 0x57ce9
jmp 0x57ceb
leaq -0x40(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x62210
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x62240
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x62270
testb $0x1, %al
jne 0x57d38
jmp 0x57dfc
leaq -0xd8(%rbp), %rdi
callq 0x622b0
movq %rax, %rsi
leaq -0xf8(%rbp), %rdi
callq 0xdbb0
jmp 0x57d55
movq -0x138(%rbp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
leaq -0x28(%rbp), %rsi
leaq -0xf8(%rbp), %rdx
callq *%rax
movb %al, -0x151(%rbp)
jmp 0x57d78
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x57dc3
jmp 0x57d84
movq -0x138(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x57d96
movb $0x0, -0x1(%rbp)
movl $0x1, -0xfc(%rbp)
jmp 0x57dcd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0xddf0
jmp 0x58085
movl $0x0, -0xfc(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0xddf0
movl -0xfc(%rbp), %eax
testl %eax, %eax
jne 0x58065
jmp 0x57de9
jmp 0x57deb
leaq -0xd8(%rbp), %rdi
callq 0x622d0
jmp 0x57d1c
movq -0x138(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x9d330
jmp 0x57e0e
movq -0x138(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x580a0
movb %al, -0x152(%rbp)
jmp 0x57e2a
movb -0x152(%rbp), %al
testb $0x1, %al
jne 0x57e36
jmp 0x57e3b
jmp 0x57ef7
leaq -0x28(%rbp), %rdi
callq 0x3f7a0
movl $0x0, -0x100(%rbp)
movq -0x138(%rbp), %rdi
movslq -0x100(%rbp), %rax
movq %rax, -0x160(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0x160(%rbp), %rax
cmpq %rcx, %rax
jae 0x57ef2
xorps %xmm0, %xmm0
movaps %xmm0, -0x120(%rbp)
movq $0x0, -0x110(%rbp)
leaq -0x120(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x3e880
movq -0x168(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xd700
jmp 0x57eb5
leaq -0x120(%rbp), %rdi
callq 0xd7d0
movl -0x100(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100(%rbp)
jmp 0x57e4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xd7d0
jmp 0x58085
jmp 0x57ce9
jmp 0x57ef9
movq -0x138(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x9d280
movl %eax, -0x16c(%rbp)
jmp 0x57f11
movl -0x16c(%rbp), %eax
movl %eax, -0x124(%rbp)
movl $0x1, -0x128(%rbp)
movl -0x128(%rbp), %eax
cmpl -0x124(%rbp), %eax
jge 0x58045
movl $0x0, -0x12c(%rbp)
movq -0x138(%rbp), %rdi
movslq -0x12c(%rbp), %rax
movq %rax, -0x178(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq %rax, %rcx
movq -0x178(%rbp), %rax
cmpq %rcx, %rax
jae 0x57fd7
movq -0x138(%rbp), %rdi
addq $0x20, %rdi
movslq -0x12c(%rbp), %rsi
callq 0x53720
movq (%rax), %rax
movq %rax, -0x180(%rbp)
movslq -0x12c(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0xda70
movq %rax, %rdi
movslq -0x128(%rbp), %rsi
callq 0xda90
movq -0x180(%rbp), %rdi
movq (%rax), %rsi
callq 0x3a480
jmp 0x57fc1
jmp 0x57fc3
movl -0x12c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
jmp 0x57f43
movq -0x138(%rbp), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
jmp 0x57fed
movq -0x138(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x622f0
movl %eax, -0x184(%rbp)
jmp 0x58005
movq -0x138(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x62310
movl %eax, -0x188(%rbp)
jmp 0x5801d
movl -0x184(%rbp), %eax
movl -0x188(%rbp), %ecx
cmpl %ecx, %eax
jl 0x5802f
jmp 0x58045
jmp 0x58031
movl -0x128(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x128(%rbp)
jmp 0x57f27
movq -0x138(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
jmp 0x58057
movb $0x1, -0x1(%rbp)
movl $0x1, -0xfc(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x62330
leaq -0x28(%rbp), %rdi
callq 0xda10
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x62330
leaq -0x28(%rbp), %rdi
callq 0xda10
movq -0x68(%rbp), %rdi
callq 0x8880