// File: Kei18[P]pibt/./src/solver/ecbs.cpp
// Function: ECBS::h3(Agent*, std::vector<Node*, std::allocator<Node*>>&, std::vector<std::vector<Node*, std::allocator<Node*>>, std::allocator<std::vector<Node*, std::allocator<Node*>>>>&)
int ECBS::h3(Agent* a, Nodes &p1, Paths &paths) {
  if (p1.empty()) return 0;

  int collision = 0;
  Nodes p2;

  for (int i = 0; i < paths.size(); ++i) {
    if (a->getId() == i) continue;
    p2 = paths[i];
    if (p2.empty()) continue;
    for (int t = 0; t < p1.size(); ++t) {
      if (t >= p2.size()) {
        if (p1[t] == p2[p2.size() - 1]) {
          ++collision;
          break;
        }
        continue;
      }
      if (p1[t] == p2[t]) {  // collision
        ++collision;
        break;
      }
      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 $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3ec00
testb $0x1, %al
jne 0x71112
jmp 0x7111e
movl $0x0, -0x4(%rbp)
jmp 0x713e8
movl $0x0, -0x2c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3e880
movl $0x0, -0x4c(%rbp)
movslq -0x4c(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rdi
callq 0x37930
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq %rcx, %rax
jae 0x71339
movq -0x18(%rbp), %rdi
callq 0x63b50
movl %eax, -0x74(%rbp)
jmp 0x71164
movl -0x74(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jne 0x7118b
jmp 0x7132b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd7d0
jmp 0x713f4
movq -0x28(%rbp), %rdi
movslq -0x4c(%rbp), %rsi
callq 0xda70
movq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3eca0
jmp 0x711a6
leaq -0x48(%rbp), %rdi
callq 0x3ec00
testb $0x1, %al
jne 0x711b5
jmp 0x711ba
jmp 0x7132b
movl $0x0, -0x60(%rbp)
movslq -0x60(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x71329
movslq -0x60(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0x88(%rbp), %rax
cmpq %rcx, %rax
jb 0x71257
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x90(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rsi
subq $0x1, %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq (%rcx), %rax
jne 0x71252
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x71329
jmp 0x7131b
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movslq -0x60(%rbp), %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq (%rcx), %rax
jne 0x71298
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x71329
cmpl $0x0, -0x60(%rbp)
jle 0x71319
movq -0x20(%rbp), %rdi
movl -0x60(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
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 0x71319
movq -0x20(%rbp), %rdi
movslq -0x60(%rbp), %rsi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movl -0x60(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x48(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x71319
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x71329
jmp 0x7131b
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x711c1
jmp 0x7132b
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x71135
movq -0x68(%rbp), %rdi
movslq -0x2c(%rbp), %rax
movq %rax, -0xb0(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq -0x68(%rbp), %rdi
movq %rax, -0xb8(%rbp)
addq $0x20, %rdi
callq 0x383b0
movq -0xb8(%rbp), %rcx
movq %rax, %rdx
movq -0xb0(%rbp), %rax
subq $0x1, %rdx
imulq %rdx, %rcx
shrq %rcx
cmpq %rcx, %rax
jbe 0x713d9
movq 0x8fc0b(%rip), %rdi     # 0x100f98
leaq 0x445bb(%rip), %rsi     # 0xb594f
callq 0x84d0
movq %rax, -0xc0(%rbp)
jmp 0x713a2
movq -0xc0(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x8860
movq %rax, -0xc8(%rbp)
jmp 0x713ba
movq -0xc8(%rbp), %rdi
leaq 0x421ef(%rip), %rsi     # 0xb35b7
callq 0x84d0
jmp 0x713cf
movl $0x1, %edi
callq 0x85d0
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x48(%rbp), %rdi
callq 0xd7d0
movl -0x4(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x8880
nopl (%rax)