// File: zakimjz[P]SLEUTH/treeminer.cpp
// Function: enumerate_freq(Eqclass*, int)
void enumerate_freq(Eqclass *eq, int iter)
{
   TimeTracker tt;
   Eqclass *neq;
   list<Eqnode *>::iterator ni, nj;
   Eqnode *ins, *outs;
   int ni_depth, nj_depth; //required depth for induced mining
   
   if (prune_type == noprune) eq->sort_nodes(); //doesn't work with pruning

   //cout << endl << "FX " << *eq << "------ " << endl;

   for (ni = eq->nlist().begin(); ni != eq->nlist().end(); ++ni){
      eq->get_scope((*ni)->pos, ni_depth);
      neq = new Eqclass;
      neq->set_prefix(eq->prefix(),*(*ni));

      bool res;
      res = ((!mine_induced || (*ni)->isup >= MINSUPPORT) && 
             check_canonical(neq->prefix(), neq->prefix().size()-1)); 
      if (!res){
         delete neq;
         continue;
      }
      
      stats.incrlarge(iter-2);
      if (output){
         //cout << "INDUCED ";
         neq->print_prefix();
         cout << *(*ni);
      }


      tt.Start();
      for (nj = eq->nlist().begin(); nj != eq->nlist().end(); ++nj){ 
         if ((*ni)->pos < (*nj)->pos) continue;

         ins = outs = NULL;
         if ((*ni)->pos > (*nj)->pos){
            outs = test_node(iter, neq, (*nj)->val, (*nj)->pos);
         }
         else{ 
            outs = test_node(iter, neq, (*nj)->val, (*nj)->pos);
            ins = test_node(iter, neq, (*nj)->val, neq->prefix().size()-1);
         }  

         
         eq->get_scope((*nj)->pos, nj_depth);
         //cout << "prefix ";
         //eq->print_prefix();
         //cout << " -- " << flush << *(*nj) << " ,,, " <<  sss << endl;
         
         if (ins || outs)
            get_intersect(&(*ni)->tlist, &(*nj)->tlist, ins, outs, 
                          ni_depth, nj_depth);

         if (outs){
            stats.incrcand(iter-1);
            //cout << "OUTS " << *outs;
            if (notfrequent(*outs, iter)) delete outs;
            else{
               neq->add_node(outs);
               //if (!mine_induced || outs->isup >= MINSUPPORT)
               //   stats.incrlarge(iter-1);
            }
         }
         if (ins){
            // cout << "INS " << *ins;
            stats.incrcand(iter-1);
            if (notfrequent(*ins, iter)) delete ins;
            else{
               neq->add_node(ins);
               //if (!mine_induced)
               //   stats.incrlarge(iter-1);
            }
         }
      }
      stats.incrtime(iter-1, tt.Stop());
      if (!neq->nlist().empty()){
//          if (output){
//             if (mine_induced) neq->print(true);
//             else neq->print();
//          }
         
         if (prune_type == prune) FK.add(iter,neq);
         enumerate_freq(neq, iter+1);
      }
      delete neq;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xbe90
leaq -0x48(%rbp), %rdi
callq 0xc390
leaq -0x50(%rbp), %rdi
callq 0xc390
cmpl $0x0, 0x1333c(%rip)     # 0x1e3e0
jne 0xb0af
movq -0x8(%rbp), %rdi
callq 0xc3b0
movq -0x8(%rbp), %rdi
callq 0x63f0
movq %rax, %rdi
callq 0x6410
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x63f0
movq %rax, %rdi
callq 0x6440
movq %rax, -0x78(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x6830
testb $0x1, %al
jne 0xb0f7
jmp 0xb659
movq -0x8(%rbp), %rax
movq %rax, -0xb0(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6860
movq -0xb0(%rbp), %rdi
movq (%rax), %rax
movl 0x4(%rax), %esi
leaq -0x64(%rbp), %rdx
callq 0x5dc0
movl $0x30, %edi
callq 0x2170
movq %rax, %rdi
movq %rdi, -0xa8(%rbp)
callq 0xc120
movq -0xa8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rdi
callq 0xc150
movq %rax, -0x98(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6860
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq (%rax), %rdx
callq 0x5e60
testb $0x1, 0x1324d(%rip)     # 0x1e3d3
je 0xb1a7
leaq -0x48(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
movl 0xc(%rax), %ecx
xorl %eax, %eax
cmpl 0x13031(%rip), %ecx     # 0x1e1d0
movb %al, -0xb1(%rbp)
jl 0xb1e0
movq -0x40(%rbp), %rdi
callq 0xc150
movq %rax, -0xc0(%rbp)
movq -0x40(%rbp), %rdi
callq 0xc150
movq %rax, %rdi
callq 0x4b80
movq -0xc0(%rbp), %rdi
subq $0x1, %rax
movl %eax, %esi
callq 0xa9f0
movb %al, -0xb1(%rbp)
movb -0xb1(%rbp), %al
andb $0x1, %al
movb %al, -0x79(%rbp)
testb $0x1, -0x79(%rbp)
jne 0xb224
movq -0x40(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0xb21f
movq -0xc8(%rbp), %rdi
callq 0x5be0
movq -0xc8(%rbp), %rdi
movl $0x30, %esi
callq 0x2180
jmp 0xb64b
movl -0xc(%rbp), %esi
subl $0x2, %esi
leaq 0x13177(%rip), %rdi     # 0x1e3a8
movl $0x1, %edx
callq 0x7f20
testb $0x1, 0x1318e(%rip)     # 0x1e3d0
je 0xb26c
movq -0x40(%rbp), %rdi
movq 0x12d81(%rip), %rsi     # 0x1dfd0
callq 0x5ee0
leaq -0x48(%rbp), %rdi
callq 0x6860
movq (%rax), %rsi
movq 0x12d69(%rip), %rdi     # 0x1dfd0
callq 0x5b30
leaq -0x38(%rbp), %rdi
callq 0xbf30
movq -0x8(%rbp), %rdi
callq 0x63f0
movq %rax, %rdi
callq 0x6410
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rdi
callq 0x63f0
movq %rax, %rdi
callq 0x6440
movq %rax, -0x90(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x6830
testb $0x1, %al
jne 0xb2c9
jmp 0xb5b4
leaq -0x48(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0xcc(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq %rax, %rcx
movl -0xcc(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jge 0xb2fd
jmp 0xb5a6
movq $0x0, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
movl 0x4(%rax), %eax
movl %eax, -0xd0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq %rax, %rcx
movl -0xd0(%rbp), %eax
movq (%rcx), %rcx
cmpl 0x4(%rcx), %eax
jle 0xb394
movl -0xc(%rbp), %eax
movl %eax, -0xe4(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0xd4(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movl -0xe4(%rbp), %edi
movq -0xe0(%rbp), %rsi
movl -0xd4(%rbp), %edx
movq (%rax), %rax
movl 0x4(%rax), %ecx
callq 0xabb0
movq %rax, -0x60(%rbp)
jmp 0xb442
movl -0xc(%rbp), %eax
movl %eax, -0x104(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0xf8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movl -0x104(%rbp), %edi
movq -0x100(%rbp), %rsi
movl -0xf8(%rbp), %edx
movq (%rax), %rax
movl 0x4(%rax), %ecx
callq 0xabb0
movq %rax, -0x60(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xf4(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0xe8(%rbp)
movq -0x40(%rbp), %rdi
callq 0xc150
movq %rax, %rdi
callq 0x4b80
movl -0xf4(%rbp), %edi
movq -0xf0(%rbp), %rsi
movl -0xe8(%rbp), %edx
subq $0x1, %rax
movl %eax, %ecx
callq 0xabb0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq -0x110(%rbp), %rdi
movq (%rax), %rax
movl 0x4(%rax), %esi
leaq -0x68(%rbp), %rdx
callq 0x5dc0
cmpq $0x0, -0x58(%rbp)
jne 0xb47a
cmpq $0x0, -0x60(%rbp)
je 0xb4c6
leaq -0x48(%rbp), %rdi
callq 0x6860
movq (%rax), %rax
addq $0x10, %rax
movq %rax, -0x118(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x6860
movq -0x118(%rbp), %rdi
movq (%rax), %rsi
addq $0x10, %rsi
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl -0x64(%rbp), %r8d
movl -0x68(%rbp), %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0xa560
cmpq $0x0, -0x60(%rbp)
je 0xb535
movl -0xc(%rbp), %esi
subl $0x1, %esi
leaq 0x12ece(%rip), %rdi     # 0x1e3a8
movl $0x1, %edx
callq 0x7ea0
movq -0x60(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xc3f0
testb $0x1, %al
jne 0xb4f6
jmp 0xb526
movq -0x60(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0xb524
movq -0x120(%rbp), %rdi
callq 0x7710
movq -0x120(%rbp), %rdi
movl $0x28, %esi
callq 0x2180
jmp 0xb533
movq -0x40(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0x5cf0
jmp 0xb535
cmpq $0x0, -0x58(%rbp)
je 0xb5a4
movl -0xc(%rbp), %esi
subl $0x1, %esi
leaq 0x12e5f(%rip), %rdi     # 0x1e3a8
movl $0x1, %edx
callq 0x7ea0
movq -0x58(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xc3f0
testb $0x1, %al
jne 0xb565
jmp 0xb595
movq -0x58(%rbp), %rax
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
je 0xb593
movq -0x128(%rbp), %rdi
callq 0x7710
movq -0x128(%rbp), %rdi
movl $0x28, %esi
callq 0x2180
jmp 0xb5a2
movq -0x40(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x5cf0
jmp 0xb5a4
jmp 0xb5a6
leaq -0x50(%rbp), %rdi
callq 0x76f0
jmp 0xb298
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x12c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xc060
movl -0x12c(%rbp), %esi
leaq 0x12dd2(%rip), %rdi     # 0x1e3a8
callq 0x7fa0
movq -0x40(%rbp), %rdi
callq 0x63f0
movq %rax, %rdi
callq 0xc420
testb $0x1, %al
jne 0xb61b
cmpl $0x1, 0x12de9(%rip)     # 0x1e3e0
jne 0xb60c
movl -0xc(%rbp), %esi
movq -0x40(%rbp), %rdx
leaq 0x12de1(%rip), %rdi     # 0x1e3e8
callq 0x10a60
movq -0x40(%rbp), %rdi
movl -0xc(%rbp), %esi
addl $0x1, %esi
callq 0xb070
movq -0x40(%rbp), %rax
movq %rax, -0x138(%rbp)
cmpq $0x0, %rax
je 0xb649
movq -0x138(%rbp), %rdi
callq 0x5be0
movq -0x138(%rbp), %rdi
movl $0x30, %esi
callq 0x2180
jmp 0xb64b
leaq -0x48(%rbp), %rdi
callq 0x76f0
jmp 0xb0cc
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)