// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, 0x28(%rsp)
cmpl 0x70(%rsp), %r8d
jge 0x5706
movl %r9d, %ebp
movl %r8d, %r14d
movl %ecx, %ebx
movl %r9d, %eax
subl %ecx, %eax
movl %eax, 0x20(%rsp)
xorl %r13d, %r13d
movl %ecx, %r15d
movl $0x0, 0x1c(%rsp)
movslq %r15d, %rax
movq 0x28(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x7e90(%rip)      # 0xd418
movslq %r14d, %rdx
movq 0x30(%rsp), %rsi
movq (%rsi), %rsi
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rsi,%rdx), %rdi
movq %rdi, 0x7e7a(%rip)      # 0xd420
leaq (%rcx,%rax), %rdi
addq $0x4, %rdi
addq %rdx, %rsi
addq $0x4, %rsi
callq 0x3d8c
cmpl $0x3, %eax
je 0x56de
movb $0x1, %cl
cmpl $0x1, %eax
jne 0x56e0
movq 0x7e4b(%rip), %r8       # 0xd420
movl 0x28(%r8), %r9d
movq 0x7e38(%rip), %rdx      # 0xd418
movl %r9d, %eax
subl 0x28(%rdx), %eax
jle 0x56de
movq 0x10(%rdx), %rsi
movq 0x18(%rdx), %rcx
subq %rsi, %rcx
sete %dil
je 0x5649
sarq $0x2, %rcx
cmpq $0x1, %rcx
movq %rcx, %rdi
adcq $0x0, %rdi
movq 0x10(%r8), %r10
movl (%rsi), %r11d
cmpl (%r10), %r11d
jne 0x56de
movl %r13d, 0x24(%rsp)
movl $0x1, %r12d
movq %r12, %r11
cmpq %r12, %rdi
je 0x563d
movl (%rsi,%r11,4), %r13d
leaq 0x1(%r11), %r12
cmpl (%r10,%r11,4), %r13d
je 0x5627
cmpq %r11, %rcx
setbe %dil
movl 0x24(%rsp), %r13d
testb %dil, %dil
je 0x56de
cmpl $0x1, %eax
jne 0x565f
movb $0x1, %cl
cmpb $0x0, 0x2c(%rdx)
jne 0x5661
xorl %ecx, %ecx
cmpb $0x0, 0x78(%rsp)
cmovnel %eax, %r9d
movl %ecx, %r12d
movzbl %cl, %eax
cmpl $0x1, 0x20(%rsp)
jg 0x5680
cmpb $0x1, 0x7d64(%rip)      # 0xd3e2
jne 0x569d
movl (%r8), %esi
movl 0x4(%rdx), %ecx
addq $0x10, %rdx
addq $0x4, %r8
movl %eax, (%rsp)
movq 0x10(%rsp), %rdi
callq 0x69e0
jmp 0x56b7
movl (%r8), %esi
addq $0x4, %r8
movq 0x10(%rsp), %rdi
movq %r8, %rdx
movl %r9d, %ecx
movl %eax, %r8d
callq 0x6a50
cmpb $0x0, 0x7b2e(%rip)      # 0xd1ec
jne 0x56c8
movq 0x10(%rsp), %rax
incl 0x8(%rax)
movzbl %r13b, %r13d
testb %r12b, %r12b
movl $0x1, %eax
cmovnel %eax, %r13d
movb $0x1, %al
movl %eax, 0x1c(%rsp)
xorl %ecx, %ecx
incl %r15d
cmpl %ebp, %r15d
sete %al
orb %cl, %al
cmovnel %ebx, %r15d
movzbl %al, %eax
addl %eax, %r14d
cmpl 0x70(%rsp), %r14d
jl 0x556a
movl 0x1c(%rsp), %eax
jmp 0x570b
xorl %eax, %eax
xorl %r13d, %r13d
testb $0x1, %al
je 0x5720
cmpb $0x1, 0x7ad6(%rip)      # 0xd1ec
jne 0x5720
movq 0x10(%rsp), %rax
incl 0x8(%rax)
testb $0x1, %r13b
je 0x572e
movq 0x10(%rsp), %rax
incl 0xc(%rax)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq