// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
callq *(%rax)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq %rax, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movq 0x20(%rbx), %rbp
movq 0x28(%rbx), %r12
cmpq %rbp, %r12
je 0x25d42
xorl %r13d, %r13d
leaq 0x20(%rsp), %r14
movq %rsp, %r15
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0x18be6
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25d28
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
incq %r13
movq 0x20(%rbx), %rbp
movq 0x28(%rbx), %r12
movq %r12, %rax
subq %rbp, %rax
sarq $0x3, %rax
cmpq %r13, %rax
ja 0x25cf7
cmpb $0x1, 0x68(%rbx)
jne 0x25ed7
cmpq %r12, %rbp
je 0x25e37
movq %rsp, %r14
leaq 0x1f(%rsp), %r15
leaq 0x40(%rsp), %r13
movq (%rbp), %rax
movq %rax, 0x60(%rsp)
movl $0x1, %edx
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
movq %r15, %rcx
callq 0x2a8fe
movq %r13, %rdi
movq %r14, %rsi
callq 0x2b0f6
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25da1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x8, %rbp
cmpq %r12, %rbp
jne 0x25d62
jmp 0x25e37
movq 0x20(%rsp), %r14
movq 0x28(%rsp), %r15
cmpq %r14, %r15
je 0x25de5
movq %r14, %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x25dd7
movq 0x10(%r12), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r12
cmpq %r15, %r12
jne 0x25dc1
movq %r14, 0x28(%rsp)
movq 0x28(%rbx), %rax
cmpq 0x20(%rbx), %rax
je 0x25e37
xorl %r14d, %r14d
xorps %xmm0, %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movq $0x0, 0x10(%rsi)
leaq 0x20(%rsp), %rdi
callq 0x18be6
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25e23
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
incq %r14
movq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
sarq $0x3, %rax
cmpq %r14, %rax
ja 0x25df2
movq 0x40(%rsp), %r14
movq 0x48(%rsp), %r15
cmpq %r15, %r14
je 0x25eae
movq %rsp, %rdi
movq %r14, %rsi
callq 0xb51c
movq (%rbx), %rax
leaq 0x20(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq *0x30(%rax)
movl %eax, %ebp
testb %al, %al
je 0x25e80
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25ea8
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x25ea8
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25e9f
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
testb %bpl, %bpl
je 0x25f7e
addq $0x18, %r14
jmp 0x25e41
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3f16a
leaq 0x20(%rsp), %rsi
leaq 0x40(%rsp), %rdx
movq %rbx, %rdi
callq 0x25ff2
testb %al, %al
je 0x25daf
jmp 0x25ef6
leaq 0x20(%rbx), %rdx
movq (%rbx), %rax
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq *0x30(%rax)
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3f16a
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0x3f094
cmpl $0x2, %eax
jl 0x25f70
movl %eax, %r14d
movl $0x1, %r15d
movq 0x20(%rbx), %rax
cmpq %rax, 0x28(%rbx)
je 0x25f52
xorl %r12d, %r12d
xorl %r13d, %r13d
movq (%rax,%r13,8), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%r12), %rax
movq (%rax,%r15,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 0x25f21
movq 0x10(%rbx), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%rbx), %rax
movl 0x8(%rax), %ecx
cmpl 0xc(%rax), %ecx
jge 0x25f70
incq %r15
cmpq %r14, %r15
jne 0x25f11
movq (%rbx), %rax
movb $0x1, %bpl
movq %rbx, %rdi
callq *0x8(%rax)
jmp 0x25f80
xorl %ebp, %ebp
leaq 0x40(%rsp), %rdi
callq 0x2a944
leaq 0x20(%rsp), %rdi
callq 0xb4ce
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x25fd2
jmp 0x25fd2
jmp 0x25fd2
jmp 0x25fd2
jmp 0x25fd2
jmp 0x25fb7
jmp 0x25fb7
jmp 0x25fd2
jmp 0x25fb7
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x25fd5
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x25fd5
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x2a944
leaq 0x20(%rsp), %rdi
callq 0xb4ce
movq %rbx, %rdi
callq 0x6620
nop