// File: roberto-bayardo[P]google-extremal-sets/all-maximal-sets-cardinality.cc
// Function: google_extremal_sets::AllMaximalSetsCardinality::DeleteSubsumedCandidates(std::vector<unsigned int, std::allocator<unsigned int>> const&)
void AllMaximalSetsCardinality::DeleteSubsumedCandidates(
    const std::vector<uint32_t>& current_set) {
  std::vector<uint32_t>::const_iterator current_begin = current_set.begin();
  std::vector<uint32_t>::const_iterator current_end = current_set.end();
  SetProperties* candidate = 0;
  for (unsigned int i = 0; i < current_set.size(); ++i, ++current_begin) {
    if (candidates_.size() <= current_set[i])
      return;
    CandidateList& candidates = candidates_[current_set[i]];
    int candidate_index = -1;
    while ((candidate =
           NextCandidate(
               candidates,
               current_set,
               i,
               &candidate_index))) {
      // We must explicitly check subsumption. We need not check every
      // item in each set because we already know:
      // (1) the candidate does not contain any items within
      // current_set[0] through current_set[i - 1].
      // (2) the candidate's first item is already known to be
      // the same as current_set[i].
      // We adjust the iterators accordingly.
      if (DoesSubsume(
             current_begin, current_end,
             candidate->begin() + 1, candidate->end())) {
        // Candidate is not maximal, so we delete it. Note that we
        // must preserve the cardinality based ordering, so we NULL
        // out the pointer to the deleted entry rather than performing
        // any swapping. TODO: Occasionally it might be beneficial to
        // compress out the holes left by the NULL entries if we have
        // accumulated a significant number of them.
        candidates[candidate_index] = 0;
        SetProperties::Delete(candidate);
      }
      ++subsumption_checks_count_;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3270
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x32a0
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2f10
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b19
movq -0x58(%rbp), %rdi
addq $0x18, %rdi
callq 0x3040
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %esi
callq 0x32d0
movq %rax, %rcx
movq -0x68(%rbp), %rax
movl (%rcx), %ecx
cmpq %rcx, %rax
ja 0x2a36
jmp 0x2b19
movq -0x58(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %esi
callq 0x32d0
movq -0x70(%rbp), %rdi
movl (%rax), %eax
movl %eax, %esi
callq 0x31c0
movq %rax, -0x38(%rbp)
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movq -0x58(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl -0x2c(%rbp), %ecx
leaq -0x3c(%rbp), %r8
callq 0x32f0
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x2b00
movq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
callq 0x33b0
addq $0x4, %rax
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rdi
callq 0x33d0
movq -0x78(%rbp), %rdx
movq %rax, %rcx
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x2d70
testb $0x1, %al
jne 0x2ace
jmp 0x2aeb
movq -0x38(%rbp), %rdi
movslq -0x3c(%rbp), %rsi
callq 0x33f0
movq $0x0, (%rax)
movq -0x28(%rbp), %rdi
callq 0x75e0
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x10(%rax)
jmp 0x2a68
jmp 0x2b02
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x3410
jmp 0x29e4
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)