// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
movq %rdi, 0xf8(%rsp)
movq %rsi, 0x100(%rsp)
callq 0x3f094
movl %eax, %ebp
leaq 0xc0(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a992
xorl %eax, %eax
movq %rax, 0x90(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq %rax, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq (%r14), %rsi
movq %r14, 0xf0(%rsp)
movq %r14, %rdi
callq 0x2b40e
movq (%rbx), %rsi
cmpq 0x8(%rbx), %rsi
je 0x26587
movl %ebp, %r13d
movb $0x1, %al
movl %eax, 0x4(%rsp)
leaq 0x30(%rsp), %rbx
leaq 0x120(%rsp), %r14
leaq 0x48(%rsp), %r12
movq %rbx, %rdi
callq 0x2aa2c
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb51c
movq %r14, %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x266de
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x260dc
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xc0(%rsp), %rbx
movq 0xc8(%rsp), %rax
movq %rax, 0x108(%rsp)
cmpq %rax, %rbx
je 0x26432
movb $0x1, %al
movl %eax, 0x2c(%rsp)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xb51c
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x118(%rsp)
cmpq %rcx, %rax
je 0x263f1
movq %rbx, 0x110(%rsp)
movq 0xf8(%rsp), %rcx
movq 0x20(%rcx), %rdx
movq 0x28(%rcx), %rcx
movq %rcx, 0x8(%rsp)
subq %rdx, %rcx
movq %rcx, %r8
sarq $0x5, %r8
andq $-0x20, %rcx
addq %rdx, %rcx
movq %rcx, 0x98(%rsp)
movq 0x10(%rsp), %rcx
movq %rcx, 0xa0(%rsp)
movq 0x18(%rsp), %r10
movq 0x100(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0xb8(%rsp)
leaq 0x1(%r8), %rcx
movq %rcx, 0xb0(%rsp)
leaq 0x10(%rdx), %rcx
movq %rcx, 0xa8(%rsp)
movb $0x1, %dil
movl %edi, %r11d
testb $0x1, %dil
je 0x263b1
movq (%rax), %r9
movq %rdx, %r11
testq %r8, %r8
jle 0x261f5
movq 0xa8(%rsp), %rcx
movq 0xb0(%rsp), %r11
cmpq %r9, -0x10(%rcx)
je 0x26238
cmpq %r9, -0x8(%rcx)
je 0x2623e
cmpq %r9, (%rcx)
je 0x26248
cmpq %r9, 0x8(%rcx)
je 0x26244
decq %r11
addq $0x20, %rcx
cmpq $0x1, %r11
jg 0x261c9
movq 0x98(%rsp), %r11
movq 0x8(%rsp), %rbx
subq %r11, %rbx
sarq $0x3, %rbx
cmpq $0x1, %rbx
je 0x2622a
cmpq $0x2, %rbx
je 0x26221
movq 0x8(%rsp), %rcx
cmpq $0x3, %rbx
jne 0x26248
cmpq %r9, (%r11)
je 0x26233
addq $0x8, %r11
cmpq %r9, (%r11)
je 0x26233
addq $0x8, %r11
cmpq %r9, (%r11)
cmovneq 0x8(%rsp), %r11
movq %r11, %rcx
jmp 0x26248
addq $-0x10, %rcx
jmp 0x26248
addq $-0x8, %rcx
jmp 0x26248
addq $0x8, %rcx
movl %edi, %r11d
cmpq %r10, 0xa0(%rsp)
je 0x263b1
subq %rdx, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0xb8(%rsp), %rsi
leaq (%rsi,%rcx,8), %r15
movl %edi, %r14d
movq 0xa0(%rsp), %r9
movl %edi, %r11d
testb $0x1, %r14b
je 0x2639b
movq (%r9), %rcx
movq %rdx, %r11
testq %r8, %r8
jle 0x262d6
movq 0xa8(%rsp), %rbx
movq 0xb0(%rsp), %r11
cmpq %rcx, -0x10(%rbx)
je 0x26309
cmpq %rcx, -0x8(%rbx)
je 0x2630f
cmpq %rcx, (%rbx)
je 0x2633c
cmpq %rcx, 0x8(%rbx)
je 0x26338
decq %r11
addq $0x20, %rbx
cmpq $0x1, %r11
jg 0x262a6
movq 0x98(%rsp), %r11
movq 0x8(%rsp), %r12
subq %r11, %r12
sarq $0x3, %r12
cmpq $0x1, %r12
je 0x26325
cmpq $0x2, %r12
je 0x26315
movq 0x8(%rsp), %rbx
cmpq $0x3, %r12
leaq 0x48(%rsp), %r12
jne 0x2633c
cmpq %rcx, (%r11)
je 0x26333
addq $0x8, %r11
jmp 0x2631a
addq $-0x10, %rbx
jmp 0x2633c
addq $-0x8, %rbx
jmp 0x2633c
leaq 0x48(%rsp), %r12
cmpq %rcx, (%r11)
je 0x26333
addq $0x8, %r11
jmp 0x2632a
leaq 0x48(%rsp), %r12
cmpq %rcx, (%r11)
cmovneq 0x8(%rsp), %r11
movq %r11, %rbx
jmp 0x2633c
addq $0x8, %rbx
movl %r14d, %r11d
testl %ebp, %ebp
jle 0x2639b
movl %ebp, %esi
subq %rdx, %rbx
shrq $0x3, %rbx
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0xb8(%rsp), %r11
movq (%r11,%rcx,8), %rcx
movq (%r15), %r11
xorl %ebx, %ebx
movq (%rcx,%rbx,8), %rbp
movq (%r11,%rbx,8), %r12
cmpq %r12, %rbp
je 0x26391
testq %rbx, %rbx
je 0x26384
cmpq -0x8(%r11,%rbx,8), %rbp
jne 0x26384
cmpq %r12, -0x8(%rcx,%rbx,8)
je 0x26391
incq %rbx
cmpq %rbx, %r13
jne 0x26364
movl %r14d, %r11d
jmp 0x26394
xorl %r11d, %r11d
movl %esi, %ebp
leaq 0x48(%rsp), %r12
testb $0x1, %r14b
je 0x263b1
addq $0x8, %r9
movl %r11d, %r14d
cmpq %r10, %r9
jne 0x26281
testb $0x1, %dil
je 0x263cc
addq $0x8, %rax
movl %r11d, %edi
cmpq 0x118(%rsp), %rax
jne 0x261a1
testb $0x1, %r11b
movq 0x110(%rsp), %rbx
jne 0x263f1
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2ab02
movl $0x0, 0x2c(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x26408
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %rbx
cmpq 0x108(%rsp), %rbx
jne 0x26103
movl 0x4(%rsp), %eax
movzbl %al, %eax
testb $0x1, 0x2c(%rsp)
movl $0x0, %ecx
cmovel %ecx, %eax
movl %eax, 0x4(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
leaq 0x10(%rsp), %rdi
callq 0x2b7ee
movq 0x60(%rsp), %r15
movq 0x68(%rsp), %rbx
cmpq %rbx, %r15
je 0x26501
leaq 0xd8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xb51c
movq %r12, %rdi
movq %r14, %rsi
callq 0xb51c
movq %r12, %rdi
leaq 0xc0(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x266de
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x264bc
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x18(%rsp), %rsi
movq 0xd8(%rsp), %rdx
movq 0xe0(%rsp), %rcx
leaq 0x10(%rsp), %rdi
callq 0x2b7ee
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x264f8
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
jmp 0x26466
movq 0x60(%rsp), %rbx
movq 0x68(%rsp), %r14
cmpq %rbx, %r14
je 0x26535
movq %rbx, %r15
movq (%r15), %rdi
testq %rdi, %rdi
je 0x26527
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %r14, %r15
jne 0x26513
movq %rbx, 0x68(%rsp)
movq 0xf0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x2ab02
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
leaq 0x120(%rsp), %r14
je 0x26566
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xc0(%rsp), %rsi
cmpq 0xc8(%rsp), %rsi
leaq 0x30(%rsp), %rbx
jne 0x26094
movl 0x4(%rsp), %ebp
jmp 0x2658a
movb $0x1, %bpl
movq 0x80(%rsp), %rbx
movq 0x88(%rsp), %r14
cmpq %rbx, %r14
je 0x265c7
movq %rbx, %r15
movq (%r15), %rdi
testq %rdi, %rdi
je 0x265b6
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %r14, %r15
jne 0x265a2
movq %rbx, 0x88(%rsp)
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x265de
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x60(%rsp), %rdi
callq 0x2a944
leaq 0x80(%rsp), %rdi
callq 0x2a944
leaq 0xc0(%rsp), %rdi
callq 0x2a944
andb $0x1, %bpl
movl %ebp, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2665a
jmp 0x2665a
movq %rax, %rbx
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x2669b
movq 0x130(%rsp), %rsi
jmp 0x2668e
jmp 0x26698
jmp 0x2665a
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x26662
movq 0x58(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x26662
jmp 0x2665f
movq %rax, %rbx
jmp 0x2667f
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x2667f
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2669b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x2669b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x266b2
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x60(%rsp), %rdi
callq 0x2a944
leaq 0x80(%rsp), %rdi
callq 0x2a944
leaq 0xc0(%rsp), %rdi
callq 0x2a944
movq %rbx, %rdi
callq 0x6620