// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r9d, %ebp
movl %r8d, %r14d
movl %ecx, %r12d
movq %rdx, 0x10(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
movl %r9d, %eax
subl %ecx, %eax
movl %eax, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x8(%rsp)
movl %ecx, %r15d
movq %rsi, 0x20(%rsp)
movl %r9d, 0xc(%rsp)
cmpl 0x60(%rsp), %r14d
jge 0x5088
movslq %r15d, %rax
movq (%rbx), %rcx
imulq $0x30, %rax, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x849f(%rip)      # 0xd3e8
movslq %r14d, %rdx
movq (%r13), %rsi
imulq $0x30, %rdx, %rdx
leaq (%rsi,%rdx), %rdi
movq %rdi, 0x8491(%rip)      # 0xd3f0
leaq (%rcx,%rax), %rdi
addq $0x4, %rdi
addq %rdx, %rsi
addq $0x4, %rsi
callq 0x38b2
cmpl $0x3, %eax
je 0x4fe2
movb $0x1, %cl
cmpl $0x1, %eax
jne 0x506e
movq %rbx, %rbp
movq 0x8463(%rip), %rsi      # 0xd3f0
movl 0x28(%rsi), %ebx
movq 0x8451(%rip), %rdi      # 0xd3e8
subl 0x28(%rdi), %ebx
jle 0x4fe9
callq 0x610c
testb %al, %al
je 0x4fe9
cmpl $0x1, %ebx
jne 0x4fba
movq 0x8437(%rip), %rax      # 0xd3e8
movb $0x1, %r13b
cmpb $0x0, 0x2c(%rax)
jne 0x4fbd
xorl %r13d, %r13d
cmpb $0x0, 0x68(%rsp)
jne 0x4fce
movq 0x8425(%rip), %rax      # 0xd3f0
movl 0x28(%rax), %ebx
movzbl %r13b, %r8d
cmpl $0x2, 0x1c(%rsp)
jl 0x4ff0
movq 0x8410(%rip), %rax      # 0xd3f0
jmp 0x5000
xorl %ecx, %ecx
jmp 0x506e
xorl %ecx, %ecx
movq %rbp, %rbx
jmp 0x506a
movq 0x83f9(%rip), %rax      # 0xd3f0
cmpb $0x1, 0x83b4(%rip)      # 0xd3b2
jne 0x502a
movl (%rax), %esi
movq 0x83df(%rip), %rdx      # 0xd3e8
movl 0x4(%rdx), %ecx
addq $0x10, %rdx
addq $0x4, %rax
movl %r8d, (%rsp)
movq 0x10(%rsp), %rdi
movq %rax, %r8
movl %ebx, %r9d
callq 0x613e
jmp 0x503f
movl (%rax), %esi
addq $0x4, %rax
movq 0x10(%rsp), %rdi
movq %rax, %rdx
movl %ebx, %ecx
callq 0x6194
cmpb $0x0, 0x816e(%rip)      # 0xd1b4
movq %rbp, %rbx
jne 0x5053
movq 0x10(%rsp), %rax
incl 0x8(%rax)
orb 0x8(%rsp), %r13b
movb $0x1, %al
movl %eax, 0x18(%rsp)
xorl %ecx, %ecx
movl %r13d, 0x8(%rsp)
movq 0x20(%rsp), %r13
movl 0xc(%rsp), %ebp
incl %r15d
cmpl %ebp, %r15d
sete %al
orb %cl, %al
cmovnel %r12d, %r15d
movzbl %al, %eax
addl %eax, %r14d
jmp 0x4f29
testb $0x1, 0x18(%rsp)
je 0x50a0
cmpb $0x1, 0x811e(%rip)      # 0xd1b4
jne 0x50a0
movq 0x10(%rsp), %rax
incl 0x8(%rax)
testb $0x1, 0x8(%rsp)
je 0x50af
movq 0x10(%rsp), %rax
incl 0xc(%rax)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq