// File: zakimjz[P]SLEUTH/treeminer.cpp
// Function: check_outs(idlist*, idlist*, Eqnode*, int, int, int, int, int, int)
void check_outs(idlist *l1, idlist *l2, Eqnode *outs,
                int st1, int st2, int en1, int en2,
                int n1depth, int n2depth){
   static idnode *n1, *n2;
   static ival_type cmpval;

   bool found_flg = false;
   bool induced, induced_flg = false;
   bool next2;
   int pos1 = st1;
   
   //for each n2 ival find if there is a sibling to the left
   int tpos = outs->tlist.size();
   while(st2 < en2){
      n1 = &(*l1)[pos1];
      n2 = &(*l2)[st2];

      //next2 = true;
      cmpval = ival::compare(n1->itscope, n2->itscope);
      switch (cmpval){
      case sup:
         //next2 = false;
         break;
      case before: 
//          //n1 is before n2. Check if n1.par is subset of or equal to n2.par
//          if (n1->path_equal(*n2)){
//             if (en1 - st1 > 1 || use_fullpath){
//                //outs->tlist.push_back(idnode(n2->cid, n1->parscope, 
//                //                            n1->itscope.lb, n2->itscope));
//                outs->add_list(n2->cid, n1->parscope, 
//                               n1->itscope.lb, n2->itscope, n2->depth);
//             }
//             else{
//                //outs->tlist.push_back(idnode(n2->cid,n2->itscope));
//                outs->add_list(n2->cid,n2->itscope, n2->depth);
//             }
//             if (!count_unique) outs->sup++;
//             found_flg = true;
//             if (n2->depth == rdepth) induced_flg = true;
//          }
//          //next2 = false;
//          break;
      case after:
         if (mine_ordered && cmpval == after) break;
         
         //n1 is before n2. Check if n1.par is subset of or equal to n2.par
         if (n1->path_equal(*n2)){
            //if (n1->depth == n1depth && n2->depth == n2depth &&
            if(n1->induced && n2->induced)
               induced = true;
            else induced = false;
            
            if (en1 - st1 > 1 || use_fullpath){
               //outs->tlist.push_back(idnode(n2->cid, n1->parscope, 
               //                            n1->itscope.lb, n2->itscope));
               outs->add_list(n2->cid, n1->parscope, 
                              n1->itscope.lb, n2->itscope, n2->depth, induced);
            }
            else{
               //outs->tlist.push_back(idnode(n2->cid,n2->itscope));
               outs->add_list(n2->cid,n2->itscope,n2->depth, induced);
            }
            if (!count_unique) outs->sup++;
            found_flg = true;
            if (induced) induced_flg = true;
         }
         //next2 = false;         
         break;
      case sub:
         break;
      }
      if (pos1+1 == en1){ //go to next n2 ival
         pos1 = st1;
         st2++;
      }
      else pos1++; //go to next n1 ival
   }
   if (found_flg && count_unique) outs->sup++;
   if (induced_flg) outs->isup++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
movb $0x0, -0x27(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x5480
movl %eax, -0x30(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0xa527
movq -0x8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x61c0
movq %rax, 0x1409a(%rip)     # 0x1e420
movq -0x10(%rbp), %rdi
movslq -0x20(%rbp), %rsi
callq 0x61c0
movq %rax, 0x1408e(%rip)     # 0x1e428
movq 0x1407f(%rip), %rdi     # 0x1e420
addq $0x4, %rdi
movq 0x1407c(%rip), %rsi     # 0x1e428
addq $0x4, %rsi
callq 0x62d0
movl %eax, 0x14075(%rip)     # 0x1e430
movl 0x1406f(%rip), %eax     # 0x1e430
movl %eax, -0x34(%rbp)
subl $0x1, %eax
je 0xa3e9
jmp 0xa3cb
movl -0x34(%rbp), %eax
subl $0x2, %eax
je 0xa4fb
jmp 0xa3d9
movl -0x34(%rbp), %eax
addl $-0x3, %eax
subl $0x2, %eax
jb 0xa3ee
jmp 0xa4fd
jmp 0xa4fd
testb $0x1, 0x13fdf(%rip)     # 0x1e3d4
je 0xa405
cmpl $0x4, 0x14032(%rip)     # 0x1e430
jne 0xa405
jmp 0xa4fd
movq 0x14014(%rip), %rdi     # 0x1e420
movq 0x14015(%rip), %rsi     # 0x1e428
callq 0xc1a0
testb $0x1, %al
jne 0xa421
jmp 0xa4f9
movq 0x13ff8(%rip), %rax     # 0x1e420
testb $0x1, 0x2c(%rax)
je 0xa441
movq 0x13ff3(%rip), %rax     # 0x1e428
testb $0x1, 0x2c(%rax)
je 0xa441
movb $0x1, -0x26(%rbp)
jmp 0xa445
movb $0x0, -0x26(%rbp)
movl -0x24(%rbp), %eax
subl -0x1c(%rbp), %eax
cmpl $0x1, %eax
jg 0xa459
testb $0x1, 0x13f7b(%rip)     # 0x1e3d2
je 0xa4a3
movq -0x18(%rbp), %rdi
movq 0x13fc4(%rip), %rax     # 0x1e428
movl (%rax), %esi
movq 0x13fb3(%rip), %rdx     # 0x1e420
addq $0x10, %rdx
movq 0x13fa8(%rip), %rax     # 0x1e420
movl 0x4(%rax), %ecx
movq 0x13fa6(%rip), %r8      # 0x1e428
addq $0x4, %r8
movq 0x13f9b(%rip), %rax     # 0x1e428
movl 0x28(%rax), %r9d
movb -0x26(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, (%rsp)
callq 0xc240
jmp 0xa4d3
movq -0x18(%rbp), %rdi
movq 0x13f7a(%rip), %rax     # 0x1e428
movl (%rax), %esi
movq 0x13f71(%rip), %rdx     # 0x1e428
addq $0x4, %rdx
movq 0x13f66(%rip), %rax     # 0x1e428
movl 0x28(%rax), %ecx
movb -0x26(%rbp), %al
andb $0x1, %al
movzbl %al, %r8d
callq 0xc2e0
testb $0x1, 0x13cfa(%rip)     # 0x1e1d4
jne 0xa4e9
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movb $0x1, -0x25(%rbp)
testb $0x1, -0x26(%rbp)
je 0xa4f7
movb $0x1, -0x27(%rbp)
jmp 0xa4f9
jmp 0xa4fd
jmp 0xa4fd
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cmpl -0x24(%rbp), %eax
jne 0xa519
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xa522
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa366
testb $0x1, -0x25(%rbp)
je 0xa543
testb $0x1, 0x13ca0(%rip)     # 0x1e1d4
je 0xa543
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
testb $0x1, -0x27(%rbp)
je 0xa556
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)