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

   bool found_flg = false;
   bool induced, induced_flg = false;
   int pos1 = st1; //temporary position holder for n1 ival
   bool next2; //should we go to next n2 ival?
   int depth;
   
   //for each ival in n2, find the closest parent in n1
   int tpos = ins->tlist.size();
   while(st2 < en2){
      n1 = &(*l1)[pos1];
      n2 = &(*l2)[st2];

      next2 = true; //by default we go to next n2 ival
      cmpval = ival::compare(n1->itscope, n2->itscope);
      switch (cmpval){
      case sup: 
         //n2 was under some n1

         depth = n2->depth-n1->depth;
         if (depth >= 1 && n1->path_equal(*n2)){
            //if (f2) depth = n2->depth-n1->depth;
            //else depth = n2->depth;
            //if (n2->depth == n1->depth+1 && n1->induced)
            //   induced = true;
            if (depth == 1 && n1->induced) induced = true;
            else induced = false;
            if (!f2) depth = n2->depth;
            
            if (en1-st1 > 1 || use_fullpath){
               //  ins->tlist.push_back(idnode(n2->cid, n1->parscope, 
               //                            n1->itscope.lb, n2->itscope));
               ins->add_list(n2->cid, n1->parscope, 
                             n1->itscope.lb, n2->itscope, depth, induced);
            }
            else{
               //ins->tlist.push_back(idnode(n2->cid,n2->itscope));
               ins->add_list(n2->cid,n2->itscope, depth, induced);
            }
            if (!count_unique) ins->sup++;
            found_flg = true;
            if (induced) induced_flg = true;
         }
         
         next2 = false;
         break;
      case before: 
         //check next n1 ival for same n2 ival
         next2 = false; 
         break;
      }

      if (next2 || pos1+1 == en1){ //go to next n2 ival
         pos1 = st1;
         st2++;
      }
      else pos1++; //go to next n1 ival
   }
   
   if (found_flg && count_unique) ins->sup++;
   if (induced_flg) ins->isup++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb 0x18(%rbp), %al
movl 0x10(%rbp), %r10d
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
andb $0x1, %al
movb %al, -0x25(%rbp)
movb $0x0, -0x26(%rbp)
movb $0x0, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x5480
movl %eax, -0x38(%rbp)
movl -0x20(%rbp), %eax
cmpl 0x10(%rbp), %eax
jge 0xa2e0
movq -0x8(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x61c0
movq %rax, 0x142cf(%rip)     # 0x1e408
movq -0x10(%rbp), %rdi
movslq -0x20(%rbp), %rsi
callq 0x61c0
movq %rax, 0x142c3(%rip)     # 0x1e410
movb $0x1, -0x2d(%rbp)
movq 0x142b0(%rip), %rdi     # 0x1e408
addq $0x4, %rdi
movq 0x142ad(%rip), %rsi     # 0x1e410
addq $0x4, %rsi
callq 0x62d0
movl %eax, 0x142a6(%rip)     # 0x1e418
movl 0x142a0(%rip), %eax     # 0x1e418
movl %eax, -0x3c(%rbp)
subl $0x1, %eax
je 0xa193
jmp 0xa182
movl -0x3c(%rbp), %eax
subl $0x3, %eax
je 0xa2ac
jmp 0xa2b0
movq 0x14276(%rip), %rax     # 0x1e410
movl 0x28(%rax), %eax
movq 0x14264(%rip), %rcx     # 0x1e408
subl 0x28(%rcx), %eax
movl %eax, -0x34(%rbp)
cmpl $0x1, -0x34(%rbp)
jl 0xa2a6
movq 0x1424d(%rip), %rdi     # 0x1e408
movq 0x1424e(%rip), %rsi     # 0x1e410
callq 0xc1a0
testb $0x1, %al
jne 0xa1d0
jmp 0xa2a6
cmpl $0x1, -0x34(%rbp)
jne 0xa1e9
movq 0x1422b(%rip), %rax     # 0x1e408
testb $0x1, 0x2c(%rax)
je 0xa1e9
movb $0x1, -0x27(%rbp)
jmp 0xa1ed
movb $0x0, -0x27(%rbp)
testb $0x1, -0x25(%rbp)
jne 0xa200
movq 0x14216(%rip), %rax     # 0x1e410
movl 0x28(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x24(%rbp), %eax
subl -0x1c(%rbp), %eax
cmpl $0x1, %eax
jg 0xa214
testb $0x1, 0x141c0(%rip)     # 0x1e3d2
je 0xa257
movq -0x18(%rbp), %rdi
movq 0x141f1(%rip), %rax     # 0x1e410
movl (%rax), %esi
movq 0x141e0(%rip), %rdx     # 0x1e408
addq $0x10, %rdx
movq 0x141d5(%rip), %rax     # 0x1e408
movl 0x4(%rax), %ecx
movq 0x141d3(%rip), %r8      # 0x1e410
addq $0x4, %r8
movl -0x34(%rbp), %r9d
movb -0x27(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, (%rsp)
callq 0xc240
jmp 0xa280
movq -0x18(%rbp), %rdi
movq 0x141ae(%rip), %rax     # 0x1e410
movl (%rax), %esi
movq 0x141a5(%rip), %rdx     # 0x1e410
addq $0x4, %rdx
movl -0x34(%rbp), %ecx
movb -0x27(%rbp), %al
andb $0x1, %al
movzbl %al, %r8d
callq 0xc2e0
testb $0x1, 0x13f4d(%rip)     # 0x1e1d4
jne 0xa296
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
movb $0x1, -0x26(%rbp)
testb $0x1, -0x27(%rbp)
je 0xa2a4
movb $0x1, -0x28(%rbp)
jmp 0xa2a6
movb $0x0, -0x2d(%rbp)
jmp 0xa2b0
movb $0x0, -0x2d(%rbp)
testb $0x1, -0x2d(%rbp)
jne 0xa2c1
movl -0x2c(%rbp), %eax
addl $0x1, %eax
cmpl -0x24(%rbp), %eax
jne 0xa2d2
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0xa2db
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xa119
testb $0x1, -0x26(%rbp)
je 0xa2fc
testb $0x1, 0x13ee7(%rip)     # 0x1e1d4
je 0xa2fc
movq -0x18(%rbp), %rax
movl 0x8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x8(%rax)
testb $0x1, -0x28(%rbp)
je 0xa30f
movq -0x18(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)