// File: /workspace/github_cpp_makefile_star2_O2/Kei18[P]pibt/./src/solver/cbs.cpp
// Function: CBS::checkAgents(std::vector<std::vector<Node*, std::allocator<Node*>>, std::allocator<std::vector<Node*, std::allocator<Node*>>>>&, std::vector<std::vector<Agent*, std::allocator<Agent*>>, std::allocator<std::vector<Agent*, std::allocator<Agent*>>>>&)
bool CBS::checkAgents(Paths& paths, std::vector<Agents>& whole) {
  int maxLength = getMaxLengthPaths(paths);
  std::vector<Agents> OPEN = whole;
  std::vector<Agents> CLOSE, TMP;
  Agents block1, block2;
  int i, j;
  bool checkAll = true;
  bool checkPart, checkFrac;
  whole.clear();

  while (!OPEN.empty()) {
    block1 = OPEN[0];
    openToClose(block1, OPEN, CLOSE);

    checkFrac = true;
    for (auto block2 : OPEN) {

      checkPart = true;
      for (auto a : block1) {
        if (!checkPart) break;

        auto itrA = std::find_if(A.begin(), A.end(),
                                 [a](Agent* _a) { return a == _a; });
        i = std::distance(A.begin(), itrA);

        for (auto b : block2) {
          if (!checkPart) break;

          auto itrB = std::find_if(A.begin(), A.end(),
                                   [b](Agent* _b) { return b == _b; });
          j = std::distance(A.begin(), itrB);

          for (int t = 0; t < maxLength; ++t) {
            // detect collision
            if (paths[j][t] == paths[i][t]) {
              checkPart = false;
              break;
            }
            // intersection
            if (t == 0) continue;
            if (paths[j][t] == paths[i][t-1] && paths[j][t-1] == paths[i][t]) {
              checkPart = false;
              break;
            }
          }
        }
      }

      // merge
      if (!checkPart) {
        TMP.push_back(block2);
        checkFrac = false;
      }
    }

    if (!checkFrac) checkAll = false;
    Agents newAgents;
    newAgents.insert(newAgents.end(), block1.begin(), block1.end());
    for (auto block2 : TMP) {
      openToClose(block2, OPEN, CLOSE);
      newAgents.insert(newAgents.end(), block2.begin(), block2.end());
    }
    TMP.clear();
    whole.push_back(newAgents);
  }

  OPEN.clear();
  CLOSE.clear();
  return checkAll;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, %rbx
movq %rdi, 0x88(%rsp)
movq %rsi, 0x90(%rsp)
callq 0x32bac
movl %eax, %r12d
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0x225f0
leaq 0xc0(%rsp), %rax
andq $0x0, 0x10(%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
leaq 0x60(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movaps %xmm0, 0xf0(%rsp)
andq $0x0, 0x100(%rsp)
movq %rbx, 0x80(%rsp)
movq %rbx, %rdi
callq 0x2264a
xorl %eax, %eax
testl %r12d, %r12d
cmovlel %eax, %r12d
movb $0x1, 0x3(%rsp)
leaq 0x108(%rsp), %r13
movq 0x28(%rsp), %rsi
cmpq 0x30(%rsp), %rsi
je 0x1f61c
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x22652
movq %r13, %rdi
movq %rbx, %rsi
callq 0x934a
movq %r13, %rdi
leaq 0x28(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x1f70f
movq %r13, %rdi
callq 0x15420
movq 0x28(%rsp), %rbx
movq 0x30(%rsp), %rax
movq %rax, 0x98(%rsp)
movb $0x1, %al
movl %eax, 0x4(%rsp)
cmpq 0x98(%rsp), %rbx
je 0x1f531
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x934a
movq %rbx, 0xa0(%rsp)
movq 0x40(%rsp), %rcx
movq 0x48(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x88(%rsp), %rax
movq 0x20(%rax), %rbx
movq 0x28(%rax), %r15
movq %r15, 0x8(%rsp)
subq %rbx, %r15
movq %r15, %rsi
sarq $0x5, %rsi
movq 0x10(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x18(%rsp), %r10
movq 0x90(%rsp), %rax
movq (%rax), %r11
movb $0x1, %r13b
cmpq 0xb0(%rsp), %rcx
je 0x1f4f1
testb $0x1, %r13b
je 0x1f4f7
movq (%rcx), %rdx
movq %r15, %r14
movq %rbx, %r9
movq %rsi, %rdi
movq %rcx, 0xb8(%rsp)
testq %rdi, %rdi
jle 0x1f399
cmpq %rdx, (%r9)
je 0x1f3e1
cmpq %rdx, 0x8(%r9)
je 0x1f3d1
cmpq %rdx, 0x10(%r9)
je 0x1f3d7
cmpq %rdx, 0x18(%r9)
je 0x1f3dd
addq $0x20, %r9
decq %rdi
addq $-0x20, %r14
jmp 0x1f370
sarq $0x3, %r14
cmpq $0x1, %r14
je 0x1f3c6
cmpq $0x2, %r14
je 0x1f3bd
movq 0x8(%rsp), %rdi
cmpq $0x3, %r14
jne 0x1f3e4
cmpq %rdx, (%r9)
je 0x1f3e1
addq $0x8, %r9
cmpq %rdx, (%r9)
je 0x1f3e1
addq $0x8, %r9
cmpq %rdx, (%r9)
cmovneq 0x8(%rsp), %r9
jmp 0x1f3e1
addq $0x8, %r9
jmp 0x1f3e1
addq $0x10, %r9
jmp 0x1f3e1
addq $0x18, %r9
movq %r9, %rdi
subq %rbx, %rdi
shrq $0x3, %rdi
movslq %edi, %rax
imulq $0x18, %rax, %rbp
addq %r11, %rbp
movq 0xa8(%rsp), %r9
cmpq %r10, %r9
je 0x1f4e0
testb $0x1, %r13b
je 0x1f4e0
movq (%r9), %r14
movq %r15, %rdi
movq %rbx, %rdx
movq %rsi, %r8
testq %r8, %r8
jle 0x1f445
cmpq %r14, (%rdx)
je 0x1f48d
cmpq %r14, 0x8(%rdx)
je 0x1f47d
cmpq %r14, 0x10(%rdx)
je 0x1f483
cmpq %r14, 0x18(%rdx)
je 0x1f489
addq $0x20, %rdx
decq %r8
addq $-0x20, %rdi
jmp 0x1f41c
sarq $0x3, %rdi
cmpq $0x1, %rdi
je 0x1f472
cmpq $0x2, %rdi
je 0x1f469
movq 0x8(%rsp), %r8
cmpq $0x3, %rdi
jne 0x1f490
cmpq %r14, (%rdx)
je 0x1f48d
addq $0x8, %rdx
cmpq %r14, (%rdx)
je 0x1f48d
addq $0x8, %rdx
cmpq %r14, (%rdx)
cmovneq 0x8(%rsp), %rdx
jmp 0x1f48d
addq $0x8, %rdx
jmp 0x1f48d
addq $0x10, %rdx
jmp 0x1f48d
addq $0x18, %rdx
movq %rdx, %r8
subq %rbx, %r8
shrq $0x3, %r8
movslq %r8d, %rax
imulq $0x18, %rax, %rdx
addq %r11, %rdx
xorl %edi, %edi
cmpq %rdi, %r12
je 0x1f4d7
movq (%rdx), %r8
movq (%r8,%rdi,8), %rcx
movq (%rbp), %rax
movq (%rax,%rdi,8), %r14
cmpq %r14, %rcx
je 0x1f4d4
testq %rdi, %rdi
je 0x1f4cf
cmpq -0x8(%rax,%rdi,8), %rcx
jne 0x1f4cf
cmpq %r14, -0x8(%r8,%rdi,8)
je 0x1f4d4
incq %rdi
jmp 0x1f4a3
xorl %r13d, %r13d
addq $0x8, %r9
jmp 0x1f3fd
movq 0xb8(%rsp), %rcx
addq $0x8, %rcx
jmp 0x1f344
testb $0x1, %r13b
jne 0x1f50e
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2271c
movl $0x0, 0x4(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x15420
movq 0xa0(%rsp), %rbx
addq $0x18, %rbx
leaq 0x108(%rsp), %r13
jmp 0x1f2d0
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
callq 0x22748
movl 0x4(%rsp), %eax
andb 0x3(%rsp), %al
movl %eax, 0x4(%rsp)
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %rbx
leaq 0xd8(%rsp), %rbp
cmpq %rbx, %r14
je 0x1f5e8
movq %rbp, %rdi
movq %r14, %rsi
callq 0x934a
leaq 0x120(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
callq 0x934a
movq %r15, %rdi
leaq 0x28(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x1f70f
movq %r15, %rdi
callq 0x15420
movq 0x18(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xe0(%rsp), %rcx
leaq 0x10(%rsp), %rdi
callq 0x22748
leaq 0xd8(%rsp), %rbp
movq %rbp, %rdi
callq 0x15420
addq $0x18, %r14
jmp 0x1f573
leaq 0x60(%rsp), %rdi
callq 0x2264a
movq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x2271c
movq %rbx, %rdi
callq 0x15420
movl 0x4(%rsp), %eax
movb %al, 0x3(%rsp)
jmp 0x1f273
leaq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x2264a
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0x2264a
leaq 0xf0(%rsp), %rdi
callq 0x15420
leaq 0x40(%rsp), %rdi
callq 0x15420
leaq 0x60(%rsp), %rdi
callq 0x225ce
movq %r14, %rdi
callq 0x225ce
movq %rbx, %rdi
callq 0x225ce
movb 0x3(%rsp), %al
andb $0x1, %al
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f697
jmp 0x1f697
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
jmp 0x1f6c5
jmp 0x1f70a
jmp 0x1f697
movq %rax, %rbx
jmp 0x1f6c0
jmp 0x1f6b0
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
callq 0x15420
jmp 0x1f6b3
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x15420
leaq 0x10(%rsp), %rdi
callq 0x15420
leaq 0xf0(%rsp), %rdi
callq 0x15420
leaq 0x40(%rsp), %rdi
callq 0x15420
leaq 0x60(%rsp), %rdi
callq 0x225ce
leaq 0xc0(%rsp), %rdi
callq 0x225ce
leaq 0x28(%rsp), %rdi
callq 0x225ce
movq %rbx, %rdi
callq 0x6650
movq %rax, %rbx
jmp 0x1f6ca