// File: Kei18[P]pibt/./src/solver/cbs.cpp
// Function: CBS::isDuplicatedCTNode(CTNode*, std::vector<CTNode*, std::allocator<CTNode*>>&)
bool CBS::isDuplicatedCTNode(CTNode* newCT, std::vector<CTNode*> &cts) {
  Constraint newC = getConstraints(newCT);
  std::sort(newC.begin(), newC.end(), [] (Conflict* c1, Conflict* c2)
                                      { if (c1->t != c2->t) return c1->t < c2->t;
                                        if (c1->a != c2->a) return c1->a->getId() < c2->a->getId();
                                        if (c1->onNode != c2->onNode) return c1->onNode;
                                        if (c1->v != c2->v) return c1->v->getId() < c2->v->getId();
                                        if (c1->u != c2->u) return c1->u->getId() < c2->u->getId();
                                        return true;
                                      });
  bool duplicated;
  Constraint oldC;
  for (auto ct : cts) {
    oldC = getConstraints(ct);
    if (newC.size() != oldC.size()) continue;
    std::sort(oldC.begin(), oldC.end(), [] (Conflict* c1, Conflict* c2)
                                        { if (c1->t != c2->t) return c1->t < c2->t;
                                          if (c1->a != c2->a) return c1->a->getId() < c2->a->getId();
                                          if (c1->onNode != c2->onNode) return c1->onNode;
                                          if (c1->v != c2->v) return c1->v->getId() < c2->v->getId();
                                          if (c1->u != c2->u) return c1->u->getId() < c2->u->getId();
                                          return true;
                                        });
    duplicated = true;
    for (int i = 0; i < newC.size(); ++i) {
      if (!isDuplicatedConflict(newC[i], oldC[i])) {
        duplicated = false;
        break;
      }
    }
    if (duplicated) return true;
  }
  return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rsi
movq %rsi, -0xe0(%rbp)
movq -0x18(%rbp), %rdx
leaq -0x38(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x5b030
movq -0xd8(%rbp), %rdi
callq 0x63230
movq -0xd8(%rbp), %rdi
movq %rax, -0x40(%rbp)
callq 0x63260
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x5cc30
jmp 0x5c9f5
leaq -0x78(%rbp), %rdi
callq 0x62930
movq -0x20(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x62a00
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
callq 0x62a30
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x63970
testb $0x1, %al
jne 0x5ca42
jmp 0x5cbe4
leaq -0x88(%rbp), %rdi
callq 0x62a60
movq -0xe0(%rbp), %rsi
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdx
leaq -0xb0(%rbp), %rdi
callq 0x5b030
jmp 0x5ca74
leaq -0x78(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x639b0
leaq -0xb0(%rbp), %rdi
callq 0x62ea0
leaq -0x38(%rbp), %rdi
callq 0x639e0
movq %rax, -0xe8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x639e0
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq %rcx, %rax
je 0x5cae8
jmp 0x5cbd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x5cc12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x62ea0
jmp 0x5cc12
leaq -0x78(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x63230
movq -0xf0(%rbp), %rdi
movq %rax, -0xb8(%rbp)
callq 0x63260
movq %rax, -0xc0(%rbp)
movq -0xb8(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x5cc70
jmp 0x5cb27
movb $0x1, -0x5d(%rbp)
movl $0x0, -0xc8(%rbp)
movslq -0xc8(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x639e0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
cmpq %rcx, %rax
jae 0x5cbbb
movslq -0xc8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x63a00
movq (%rax), %rax
movq %rax, -0x100(%rbp)
movslq -0xc8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x63a00
movq -0xe0(%rbp), %rdi
movq -0x100(%rbp), %rsi
movq (%rax), %rdx
callq 0x5c8e0
testb $0x1, %al
jne 0x5cba5
movb $0x0, -0x5d(%rbp)
jmp 0x5cbbb
jmp 0x5cba7
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x5cb35
testb $0x1, -0x5d(%rbp)
je 0x5cbd1
movb $0x1, -0x1(%rbp)
movl $0x1, -0xcc(%rbp)
jmp 0x5cbf2
jmp 0x5cbd3
leaq -0x88(%rbp), %rdi
callq 0x63a20
jmp 0x5ca26
movb $0x0, -0x1(%rbp)
movl $0x1, -0xcc(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x62ea0
leaq -0x38(%rbp), %rdi
callq 0x62ea0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x62ea0
movq -0x58(%rbp), %rdi
callq 0x8880
nopw %cs:(%rax,%rax)