// File: Kei18[P]pibt/./src/solver/cbs.cpp
// Function: CBS::countCollisions(CTNode*, std::vector<std::vector<Node*, std::allocator<Node*>>, std::allocator<std::vector<Node*, std::allocator<Node*>>>>&)
int CBS::countCollisions(CTNode* c, Paths& paths) {
  int collision = 0;
  for (auto p1 : paths) {
    if (p1.empty()) continue;
    for (auto p2 : c->paths) {
      if (p2.empty() || p1[0] == p2[0]) continue;
      for (int t = 0; t < p1.size(); ++t) {
        if (p2.size() < t) {
          if (p1[t] == p2[p2.size() - 1]) ++collision;
          continue;
        }
        if (p1[t] == p2[t]) {
          ++collision;
          continue;
        }
        if (t > 0 && p1[t-1] == p2[t] && p1[t] == p2[t-2]) {
          ++collision;
          continue;
        }
      }
    }
  }

  return collision;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x377e0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x37500
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x4e640
testb $0x1, %al
jne 0x59df6
jmp 0x5a0e3
leaq -0x30(%rbp), %rdi
callq 0x37d00
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x3aff0
leaq -0x50(%rbp), %rdi
callq 0x3ec00
testb $0x1, %al
jne 0x59e1a
jmp 0x59e26
movl $0x3, -0x54(%rbp)
jmp 0x5a0bf
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x377e0
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x37500
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4e640
testb $0x1, %al
jne 0x59e62
jmp 0x5a0b8
leaq -0x68(%rbp), %rdi
callq 0x37d00
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0x3aff0
jmp 0x59e7c
leaq -0x88(%rbp), %rdi
callq 0x3ec00
testb $0x1, %al
jne 0x59ec2
leaq -0x50(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
leaq -0x88(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xda90
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x59eee
movl $0x5, -0x54(%rbp)
jmp 0x5a091
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xd7d0
jmp 0x5a0ef
movl $0x0, -0x98(%rbp)
movslq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x5a08a
leaq -0x88(%rbp), %rdi
callq 0x3b0e0
movslq -0x98(%rbp), %rcx
cmpq %rcx, %rax
jae 0x59f90
movslq -0x98(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x3b0e0
movq %rax, %rsi
subq $0x1, %rsi
leaq -0x88(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xb0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x59f8b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5a076
movslq -0x98(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xb8(%rbp)
movslq -0x98(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xb8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x59fda
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5a076
cmpl $0x0, -0x98(%rbp)
jle 0x5a074
movl -0x98(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x50(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movslq -0x98(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xc0(%rbp), %rax
cmpq (%rcx), %rax
jne 0x5a074
movslq -0x98(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0xda90
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movl -0x98(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rsi
leaq -0x88(%rbp), %rdi
callq 0xda90
movq %rax, %rcx
movq -0xc8(%rbp), %rax
cmpq (%rcx), %rax
jne 0x5a074
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5a076
jmp 0x5a076
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x59ef8
movl $0x0, -0x54(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xd7d0
movl -0x54(%rbp), %eax
testl %eax, %eax
je 0x5a0a8
jmp 0x5a0a6
jmp 0x5a0aa
jmp 0x5a0aa
leaq -0x68(%rbp), %rdi
callq 0x4e750
jmp 0x59e4c
movl $0x0, -0x54(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xd7d0
movl -0x54(%rbp), %eax
testl %eax, %eax
je 0x5a0d3
jmp 0x5a0d1
jmp 0x5a0d5
jmp 0x5a0d5
leaq -0x30(%rbp), %rdi
callq 0x4e750
jmp 0x59de0
movl -0x1c(%rbp), %eax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x90(%rbp), %rdi
callq 0x8880
nopl (%rax,%rax)