// File: 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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0x14(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3e880
leaq -0x48(%rbp), %rdi
callq 0x3e880
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
callq 0x37930
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jae 0x7056c
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movslq -0x50(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x37930
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x7055c
movq -0x10(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0xda70
movq %rax, %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jb 0x7038b
movq -0x10(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0xda70
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3eca0
jmp 0x7034b
movq -0x10(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0xda70
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3eca0
jmp 0x70366
jmp 0x703c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd7d0
leaq -0x30(%rbp), %rdi
callq 0xd7d0
jmp 0x70636
movq -0x10(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0xda70
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x3eca0
jmp 0x703a6
movq -0x10(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0xda70
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3eca0
jmp 0x703c1
jmp 0x703c3
leaq -0x48(%rbp), %rdi
callq 0x3ec00
testb $0x1, %al
jne 0x703d2
jmp 0x703d7
jmp 0x7054e
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jae 0x7054c
movslq -0x60(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jb 0x7047a
movslq -0x60(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rsi
subq $0x1, %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq (%rcx), %rax
jne 0x70475
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7054c
jmp 0x7053e
movslq -0x60(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movslq -0x60(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x704bb
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7054c
cmpl $0x0, -0x60(%rbp)
jle 0x7053c
movl -0x60(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x30(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movslq -0x60(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x7053c
movslq -0x60(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movl -0x60(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x7053c
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x7054c
jmp 0x7053e
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x703de
jmp 0x7054e
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x702d5
jmp 0x7055e
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x702ab
movq -0x68(%rbp), %rdi
movslq -0x14(%rbp), %rax
movq %rax, -0xb8(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq -0x68(%rbp), %rdi
movq %rax, -0xc0(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq -0xc0(%rbp), %rcx
movq %rax, %rdx
movq -0xb8(%rbp), %rax
subq $0x1, %rdx
imulq %rdx, %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x7060c
movq 0x909d8(%rip), %rdi     # 0x100f98
leaq 0x45388(%rip), %rsi     # 0xb594f
callq 0x84d0
movq %rax, -0xc8(%rbp)
jmp 0x705d5
movq -0xc8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x8860
movq %rax, -0xd0(%rbp)
jmp 0x705ed
movq -0xd0(%rbp), %rdi
leaq 0x42fbc(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x70602
movl $0x1, %edi
callq 0x85d0
movl -0x14(%rbp), %eax
movl %eax, -0xd4(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd7d0
leaq -0x30(%rbp), %rdi
callq 0xd7d0
movl -0xd4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x8880
nop