// File: roberto-bayardo[P]google-extremal-sets/all-maximal-sets-lexicographic.cc
// Function: google_extremal_sets::AllMaximalSetsLexicographic::FindAllMaximalSets(google_extremal_sets::DataSourceIterator*, unsigned int)
bool AllMaximalSetsLexicographic::FindAllMaximalSets(DataSourceIterator* data, uint32_t) {
  Init();

  // Vars set by the data source iterator.
  int result;
  uint32_t set_id;
  ItemSet current_set;

  // This outer loop supports multiple passes over the data in the
  // case where the dataset exceeds the bound on max_items_in_ram_. As
  // long as resume_offset == 0, we will continue retaining itemsets
  // in RAM.
  off_t start_offset = 0;
  off_t resume_offset = 0;
  do {  // while (resume_offset != 0)
    if (!PrepareForDataScan(data, resume_offset))
      return false;  // IO error
    start_offset = resume_offset;

    if (!ReadNextChunk(data, &resume_offset))
      return false;  // IO error

    DeleteTriviallySubsumedCandidates();

    BuildIndex();

    std::cerr << "; Potential maximal sets: " << candidates_.size() << '\n'
              << "; Beginning subsumption checking scan." << std::endl;
    for (unsigned int i = 0; i < candidates_.size() - 1; ++i) {
      if (candidates_[i])  // check to make sure not already deleted.
        DeleteSubsumedCandidates(i);
    }
    if (start_offset != 0) {
      if (!PrepareForDataScan(data, 0))
        return false;  // IO error
      while (data->Tell() < start_offset &&
             (result = data->Next(&set_id, &current_set)) > 0) {
        DeleteSubsumedCandidates(current_set);
      }
      if (result < 0)  // IO error
        return false;
    }
    std::cerr << "; Dumping maximal sets." << std::endl;
    DumpMaximalSets();
  } while (resume_offset != 0);
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x2900
leaq -0x40(%rbp), %rdi
callq 0x3980
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x2980
movb %al, -0x71(%rbp)
jmp 0x2652
movb -0x71(%rbp), %al
testb $0x1, %al
jne 0x2685
jmp 0x265b
movb $0x0, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x28db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x39e0
jmp 0x28f2
movq -0x70(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x29e0
movb %al, -0x72(%rbp)
jmp 0x26a3
movb -0x72(%rbp), %al
testb $0x1, %al
jne 0x26bc
jmp 0x26ac
movb $0x0, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x28db
movq -0x70(%rbp), %rdi
callq 0x2bc0
jmp 0x26c7
movq -0x70(%rbp), %rdi
callq 0x2d30
jmp 0x26d2
movq 0xb917(%rip), %rdi      # 0xdff0
leaq 0x6924(%rip), %rsi      # 0x9004
callq 0x2200
movq %rax, -0x80(%rbp)
jmp 0x26eb
movq -0x70(%rbp), %rdi
addq $0x18, %rdi
callq 0x39a0
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x2070
movq %rax, -0x88(%rbp)
jmp 0x270d
movq -0x88(%rbp), %rdi
movl $0xa, %esi
callq 0x2290
movq %rax, -0x90(%rbp)
jmp 0x2727
movq -0x90(%rbp), %rdi
leaq 0x68ea(%rip), %rsi      # 0x901f
callq 0x2200
movq %rax, -0x98(%rbp)
jmp 0x2743
movq -0x98(%rbp), %rdi
movq 0xb867(%rip), %rsi      # 0xdfb8
callq 0x2240
jmp 0x2758
movl $0x0, -0x64(%rbp)
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %eax
movq %rax, -0xa0(%rbp)
addq $0x18, %rdi
callq 0x39a0
movq %rax, %rcx
movq -0xa0(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jae 0x27be
movq -0x70(%rbp), %rdi
addq $0x18, %rdi
movl -0x64(%rbp), %eax
movl %eax, %esi
callq 0x39c0
cmpq $0x0, (%rax)
je 0x27b1
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x2f50
jmp 0x27af
jmp 0x27b1
jmp 0x27b3
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x275f
cmpq $0x0, -0x48(%rbp)
je 0x2887
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2980
movb %al, -0xa1(%rbp)
jmp 0x27e2
movb -0xa1(%rbp), %al
testb $0x1, %al
jne 0x27fe
jmp 0x27ee
movb $0x0, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x28db
jmp 0x2800
movq -0x18(%rbp), %rdi
callq 0x6b20
movq %rax, -0xb0(%rbp)
jmp 0x2812
movq -0xb0(%rbp), %rcx
xorl %eax, %eax
cmpq -0x48(%rbp), %rcx
movb %al, -0xb1(%rbp)
jge 0x2855
movq -0x18(%rbp), %rdi
leaq -0x24(%rbp), %rsi
leaq -0x40(%rbp), %rdx
callq 0x6b40
movl %eax, -0xb8(%rbp)
jmp 0x2840
movl -0xb8(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, %eax
setg %al
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x2861
jmp 0x2872
movq -0x70(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3040
jmp 0x2870
jmp 0x2800
cmpl $0x0, -0x20(%rbp)
jge 0x2885
movb $0x0, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
jmp 0x28db
jmp 0x2887
movq 0xb762(%rip), %rdi      # 0xdff0
leaq 0x67b1(%rip), %rsi      # 0x9046
callq 0x2200
movq %rax, -0xc0(%rbp)
jmp 0x28a3
movq -0xc0(%rbp), %rdi
movq 0xb707(%rip), %rsi      # 0xdfb8
callq 0x2240
jmp 0x28b8
movq -0x70(%rbp), %rdi
callq 0x30e0
jmp 0x28c3
jmp 0x28c5
cmpq $0x0, -0x50(%rbp)
jne 0x263c
movb $0x1, -0x1(%rbp)
movl $0x1, -0x60(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x39e0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x2370
nopl (%rax,%rax)