// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
callq *(%rax)
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r15
andq $0x0, 0x10(%r15)
movaps %xmm0, (%r15)
andq $0x0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
leaq 0x20(%rbx), %rax
movq %rax, 0x68(%rsp)
xorl %r14d, %r14d
leaq 0x10(%rsp), %r12
movq 0x20(%rbx), %r13
movq 0x28(%rbx), %rbp
movq %rbp, %rax
subq %r13, %rax
sarq $0x3, %rax
cmpq %r14, %rax
jbe 0x1efb0
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x15146
movq %r12, %rdi
callq 0x990e
incq %r14
jmp 0x1ef73
cmpb $0x1, 0x68(%rbx)
jne 0x1f003
leaq 0x10(%rsp), %r14
leaq 0xf(%rsp), %r15
leaq 0x30(%rsp), %r12
cmpq %rbp, %r13
je 0x1f09f
movq (%r13), %rax
movq %rax, 0x70(%rsp)
movq %r14, %rdi
leaq 0x70(%rsp), %rsi
pushq $0x1
popq %rdx
movq %r15, %rcx
callq 0x22598
movq %r12, %rdi
movq %r14, %rsi
callq 0x22cd0
movq %r14, %rdi
callq 0x15420
addq $0x8, %r13
jmp 0x1efc5
movq (%rbx), %rax
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
movq 0x68(%rsp), %rdx
callq *0x30(%rax)
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x32c58
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x32bac
movslq %eax, %r14
pushq $0x1
popq %r15
cmpq %r14, %r15
jge 0x1f08e
xorl %r12d, %r12d
xorl %r13d, %r13d
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x1f075
movq (%rax,%r13,8), %rdi
movq 0x50(%rsp), %rax
movq (%rax,%r12), %rax
movq (%rax,%r15,8), %rsi
callq 0x158b4
incq %r13
addq $0x18, %r12
jmp 0x1f042
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%rbx), %rax
movl 0x8(%rax), %ecx
incq %r15
cmpl 0xc(%rax), %ecx
jl 0x1f037
movq (%rbx), %rax
movb $0x1, %bpl
movq %rbx, %rdi
callq *0x8(%rax)
jmp 0x1f161
leaq 0x50(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0x10(%rsp), %r12
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %rbp
cmpq %rbp, %r13
je 0x1f0e9
movq %r12, %rdi
movq %r13, %rsi
callq 0x934a
movq (%rbx), %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq *0x30(%rax)
testb %al, %al
je 0x1f14c
movq %r12, %rdi
callq 0x15420
addq $0x18, %r13
jmp 0x1f0b8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x32c58
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1f1d6
testb %al, %al
jne 0x1f023
movq %r14, %rdi
callq 0x17268
xorl %r13d, %r13d
movq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
sarq $0x3, %rax
cmpq %r13, %rax
jbe 0x1f0ae
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x15146
movq %r12, %rdi
callq 0x990e
incq %r13
jmp 0x1f115
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
leaq 0x10(%rsp), %rdi
callq 0x15420
xorl %ebp, %ebp
leaq 0x30(%rsp), %rdi
callq 0x225ce
leaq 0x50(%rsp), %rdi
callq 0x92ec
movl %ebp, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f198
jmp 0x1f1b6
jmp 0x1f1b6
jmp 0x1f1b6
jmp 0x1f1b6
jmp 0x1f1a7
jmp 0x1f198
jmp 0x1f1b6
jmp 0x1f1b6
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x15420
jmp 0x1f1b9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x990e
jmp 0x1f1b9
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x225ce
leaq 0x50(%rsp), %rdi
callq 0x92ec
movq %rbx, %rdi
callq 0x6650
nop