// File: /workspace/github_cpp_makefile_star2_O3/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 $0x148, %rsp            # imm = 0x148
movq %rdx, %r14
movq %rdi, 0xe8(%rsp)
movq %rsi, 0xf0(%rsp)
callq 0x3ee0c
movl %eax, %ebp
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2a884
xorl %eax, %eax
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq %rax, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq (%r14), %rsi
movq %r14, 0xe0(%rsp)
movq %r14, %rdi
callq 0x2b316
movq (%rbx), %rsi
cmpq 0x8(%rbx), %rsi
je 0x26520
movl %ebp, 0x4c(%rsp)
movl %ebp, %r13d
movb $0x1, 0xb(%rsp)
leaq 0x30(%rsp), %rbx
leaq 0x10(%rsp), %rbp
movq %rbx, %rdi
callq 0x2a91e
leaq 0x130(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb55c
movq %r14, %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x26641
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x2608d
movq 0x140(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xb0(%rsp), %rbx
movq 0xb8(%rsp), %rax
movq %rax, 0xf8(%rsp)
cmpq %rax, %rbx
je 0x26398
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xb55c
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, 0x110(%rsp)
cmpq %rcx, %rax
je 0x26363
movq %rbx, 0x100(%rsp)
movq 0xe8(%rsp), %rcx
movq 0x20(%rcx), %rsi
movq 0x28(%rcx), %rcx
movq %rcx, %r8
subq %rsi, %r8
movq %r8, %rbx
sarq $0x5, %rbx
movq %r8, %rdx
andq $-0x20, %rdx
addq %rsi, %rdx
movq %rcx, 0x28(%rsp)
movq %rdx, 0x98(%rsp)
subq %rdx, %rcx
movq %rcx, 0x90(%rsp)
movq 0x10(%rsp), %r11
movq 0x18(%rsp), %r12
movq 0xf0(%rsp), %rcx
movq (%rcx), %rcx
movq %rcx, 0xa8(%rsp)
leaq 0x1(%rbx), %rcx
movq %rcx, 0xa0(%rsp)
leaq 0x10(%rsi), %rbp
movb $0x1, %r14b
movq %r11, 0x108(%rsp)
testb $0x1, %r14b
je 0x2633b
movq (%rax), %r10
movq %r8, %rdx
movq %rsi, %rcx
testq %rbx, %rbx
jle 0x261b0
movq %rbp, %r9
movq 0xa0(%rsp), %rcx
cmpq %r10, -0x10(%r9)
je 0x261eb
cmpq %r10, -0x8(%r9)
je 0x261f1
cmpq %r10, (%r9)
je 0x261fb
cmpq %r10, 0x8(%r9)
je 0x261f7
decq %rcx
addq $0x20, %r9
cmpq $0x1, %rcx
jg 0x2617c
movq 0x90(%rsp), %rdx
movq 0x98(%rsp), %rcx
sarq $0x3, %rdx
cmpq $0x1, %rdx
je 0x261dd
cmpq $0x2, %rdx
je 0x261d4
movq 0x28(%rsp), %r9
cmpq $0x3, %rdx
jne 0x261fb
cmpq %r10, (%rcx)
je 0x261e6
addq $0x8, %rcx
cmpq %r10, (%rcx)
je 0x261e6
addq $0x8, %rcx
cmpq %r10, (%rcx)
cmovneq 0x28(%rsp), %rcx
movq %rcx, %r9
jmp 0x261fb
addq $-0x10, %r9
jmp 0x261fb
addq $-0x8, %r9
jmp 0x261fb
addq $0x8, %r9
cmpq %r12, %r11
je 0x26321
subq %rsi, %r9
shrq $0x3, %r9
movslq %r9d, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0xa8(%rsp), %rdx
leaq (%rdx,%rcx,8), %r10
testb $0x1, %r14b
je 0x26321
movq (%r11), %r9
movq %r8, %rdi
movq %rsi, %rdx
testq %rbx, %rbx
jle 0x26275
movq %rbp, %rcx
movq 0xa0(%rsp), %rdx
cmpq %r9, -0x10(%rcx)
je 0x262b0
cmpq %r9, -0x8(%rcx)
je 0x262b6
cmpq %r9, (%rcx)
je 0x262c0
cmpq %r9, 0x8(%rcx)
je 0x262bc
decq %rdx
addq $0x20, %rcx
cmpq $0x1, %rdx
jg 0x26241
movq 0x90(%rsp), %rdi
movq 0x98(%rsp), %rdx
sarq $0x3, %rdi
cmpq $0x1, %rdi
je 0x262a2
cmpq $0x2, %rdi
je 0x26299
movq 0x28(%rsp), %rcx
cmpq $0x3, %rdi
jne 0x262c0
cmpq %r9, (%rdx)
je 0x262ab
addq $0x8, %rdx
cmpq %r9, (%rdx)
je 0x262ab
addq $0x8, %rdx
cmpq %r9, (%rdx)
cmovneq 0x28(%rsp), %rdx
movq %rdx, %rcx
jmp 0x262c0
addq $-0x10, %rcx
jmp 0x262c0
addq $-0x8, %rcx
jmp 0x262c0
addq $0x8, %rcx
cmpl $0x0, 0x4c(%rsp)
jle 0x26314
subq %rsi, %rcx
shrq $0x3, %rcx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0xa8(%rsp), %rdx
movq (%rdx,%rcx,8), %rcx
movq (%r10), %rdx
xorl %r9d, %r9d
movq (%rcx,%r9,8), %r15
movq (%rdx,%r9,8), %rdi
cmpq %rdi, %r15
je 0x26311
testq %r9, %r9
je 0x26307
cmpq -0x8(%rdx,%r9,8), %r15
jne 0x26307
cmpq %rdi, -0x8(%rcx,%r9,8)
je 0x26311
incq %r9
cmpq %r9, %r13
jne 0x262e7
jmp 0x26314
xorl %r14d, %r14d
addq $0x8, %r11
cmpq %r12, %r11
jne 0x2621e
addq $0x8, %rax
cmpq 0x110(%rsp), %rax
movq 0x108(%rsp), %r11
jne 0x26159
testb $0x1, %r14b
leaq 0x10(%rsp), %rbp
movq 0x100(%rsp), %rbx
jne 0x26363
leaq 0x50(%rsp), %rdi
movq %rbp, %rsi
callq 0x2aa02
movl $0x0, 0xc(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2637a
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %rbx
cmpq 0xf8(%rsp), %rbx
jne 0x260b4
movl 0xc(%rsp), %eax
andb 0xb(%rsp), %al
movb %al, 0xb(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x2b6e0
movq 0x50(%rsp), %r15
movq 0x58(%rsp), %rbx
cmpq %rbx, %r15
je 0x264a3
leaq 0xc8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0xb55c
leaq 0x118(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0xb55c
movq %r12, %rdi
leaq 0xb0(%rsp), %rsi
leaq 0x70(%rsp), %rdx
callq 0x26641
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x26428
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x18(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movq %rbp, %rdi
callq 0x2b6e0
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x26462
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %rbx, %r15
jne 0x263d0
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %r14
cmpq %rbx, %r14
je 0x264a3
movq %rbx, %r15
movq (%r15), %rdi
testq %rdi, %rdi
je 0x26495
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %r14, %r15
jne 0x26481
movq %rbx, 0x58(%rsp)
movq 0xe0(%rsp), %rdi
movq %rbp, %rsi
callq 0x2aa02
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x264ca
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0xb0(%rsp), %rsi
cmpq 0xb8(%rsp), %rsi
leaq 0x30(%rsp), %rbx
jne 0x26040
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r14
cmpq %rbx, %r14
je 0x26525
movq %rbx, %r15
movb 0xb(%rsp), %bpl
movq (%r15), %rdi
testq %rdi, %rdi
je 0x26510
movq 0x10(%r15), %rsi
subq %rdi, %rsi
callq 0x6380
addq $0x18, %r15
cmpq %r14, %r15
jne 0x264fc
movq %rbx, 0x78(%rsp)
jmp 0x2652a
movb $0x1, %bpl
jmp 0x2652a
movb 0xb(%rsp), %bpl
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x26541
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x50(%rsp), %rdi
callq 0x2a830
leaq 0x70(%rsp), %rdi
callq 0x2a830
leaq 0xb0(%rsp), %rdi
callq 0x2a830
andb $0x1, %bpl
movl %ebp, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2659c
jmp 0x2659c
movq %rax, %rbx
movq 0x130(%rsp), %rdi
testq %rdi, %rdi
je 0x26601
movq 0x140(%rsp), %rsi
jmp 0x265f4
jmp 0x265fe
jmp 0x2659c
movq %rax, %rbx
jmp 0x265e5
movq %rax, %rbx
movq 0x118(%rsp), %rdi
testq %rdi, %rdi
je 0x265c8
movq 0x128(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x265c8
jmp 0x265c5
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x265e5
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x26601
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
jmp 0x26601
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x26618
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
leaq 0x50(%rsp), %rdi
callq 0x2a830
leaq 0x70(%rsp), %rdi
callq 0x2a830
leaq 0xb0(%rsp), %rdi
callq 0x2a830
movq %rbx, %rdi
callq 0x6620