// File: /workspace/github_cpp_makefile_star2_O1/Kei18[P]pibt/./src/solver/ecbs.cpp
// Function: ECBS::h3(std::vector<std::vector<Node*, std::allocator<Node*>>, std::allocator<std::vector<Node*, std::allocator<Node*>>>>&)
int ECBS::h3(Paths &paths) {

  int collision = 0;
  Nodes p1, p2;

  for (int i = 0; i < paths.size(); ++i) {
    for (int j = i + 1; j < paths.size(); ++j) {
      if (paths[i].size() >= paths[j].size()) {
        p1 = paths[i];
        p2 = paths[j];
      } else {
        p1 = paths[j];
        p2 = paths[i];
      }

      if (p2.empty()) continue;

      for (int t = 0; t < p1.size(); ++t) {
        if (t >= p2.size()) {
          // goal pos
          if (p1[t] == p2[p2.size() - 1]) {
            ++collision;
            break;
          }
          continue;
        }
        if (p1[t] == p2[t]) {  // collision
          ++collision;
          break;
        }
        // intersection
        if (t > 0 && p1[t-1] == p2[t] && p1[t] == p2[t-1]) {
          ++collision;
          break;
        }
      }
    }
  }

  // error check
  if (collision > A.size() * (A.size() - 1) / 2) {
    std::cout << "error@ECBS::h3, invalid value, " << collision << "\n";
    std::exit(1);
  }

  return collision;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %eax, %eax
movq %rax, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
movq %rax, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movq 0x8(%rsi), %rax
cmpq (%rsi), %rax
je 0x2dc22
movq %rsi, %r15
xorl %ebx, %ebx
movl $0x1, %r12d
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
leaq 0x30(%rsp), %r13
movq $0x0, 0x8(%rsp)
leaq 0x1(%rbx), %rdx
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
movq %rdx, 0x58(%rsp)
cmpq %rdx, %rcx
movq %r12, 0x60(%rsp)
jbe 0x2dbfd
leaq (%rbx,%rbx,2), %rbp
movq 0x8(%rax,%rbp,8), %rdx
subq (%rax,%rbp,8), %rdx
leaq (%r12,%r12,2), %rcx
movq 0x8(%rax,%rcx,8), %rsi
subq (%rax,%rcx,8), %rsi
cmpq %rsi, %rdx
jae 0x2db40
leaq (%rax,%rcx,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1b2e2
movq %rbx, %rax
jmp 0x2db51
leaq (%rax,%rbp,8), %rsi
leaq 0x10(%rsp), %rdi
callq 0x1b2e2
movq %r12, %rax
leaq (%rax,%rax,2), %rsi
shlq $0x3, %rsi
addq (%r15), %rsi
movq %r13, %rdi
callq 0x1b2e2
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rcx, %rax
je 0x2dbdf
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
subq %rdx, %rsi
je 0x2dbdf
sarq $0x3, %rsi
subq %rax, %rcx
movq %rcx, %rdi
sarq $0x3, %rdi
cmpq $0x1, %rsi
adcq $0x0, %rsi
xorl %r8d, %r8d
movq (%rdx,%r8,8), %r9
cmpq %r8, %rdi
jbe 0x2dbc2
movq (%rax,%r8,8), %r10
cmpq %r10, %r9
je 0x2dbd3
testq %r8, %r8
je 0x2dbc9
cmpq %r10, -0x8(%rdx,%r8,8)
jne 0x2dbc9
cmpq -0x8(%rax,%r8,8), %r9
jne 0x2dbc9
jmp 0x2dbd3
cmpq -0x8(%rax,%rcx), %r9
je 0x2dbd3
incq %r8
cmpq %r8, %rsi
jne 0x2db9b
jmp 0x2dbdf
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
incq %r12
movq (%r15), %rax
movq 0x8(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
imulq %r14, %rcx
cmpq %r12, %rcx
ja 0x2db12
movq 0x8(%r15), %rax
subq (%r15), %rax
sarq $0x3, %rax
imulq %r14, %rax
movq 0x60(%rsp), %r12
incq %r12
movq 0x58(%rsp), %rbx
cmpq %rbx, %rax
ja 0x2dae5
movq 0x8(%rsp), %rbx
movslq %ebx, %rax
movq 0x50(%rsp), %rdx
movq 0x28(%rdx), %rcx
subq 0x20(%rdx), %rcx
sarq $0x3, %rcx
leaq -0x1(%rcx), %rdx
imulq %rcx, %rdx
shrq %rdx
cmpq %rax, %rdx
jb 0x2dc8a
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2dc62
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2dc79
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x34317(%rip), %rdi     # 0x61fa8
leaq 0x1c803(%rip), %rsi     # 0x4a49b
movl $0x1f, %edx
callq 0x63f0
movq 0x342ff(%rip), %rdi     # 0x61fa8
movq 0x8(%rsp), %rsi
callq 0x6610
leaq 0x1a8a9(%rip), %rsi     # 0x48563
movq %rax, %rdi
callq 0x6360
movl $0x1, %edi
callq 0x6440
jmp 0x2dcce
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x2dce8
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2dcff
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6380
movq %rbx, %rdi
callq 0x6620
nop