// File: /workspace/github_cpp_makefile_star2_O3/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 %rdi, 0x30(%rsp)
cmpl 0x70(%rsp), %r8d
jge 0x5746
movl %r9d, %ebp
movl %r8d, %r14d
movl %ecx, %ebx
movq %rdx, %r13
movq %rsi, %r12
movl %r9d, %eax
subl %ecx, %eax
movl %eax, 0x1c(%rsp)
movl $0x0, 0x14(%rsp)
movl %ecx, %r15d
movl $0x0, 0x18(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
movslq %r15d, %rax
movq 0x30(%rsp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rcx,%rax), %rdx
movq %rdx, 0x7e49(%rip)      # 0xd418
movslq %r14d, %rdx
movq (%r12), %rsi
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rsi,%rdx), %rdi
movq %rdi, 0x7e37(%rip)      # 0xd420
leaq (%rcx,%rax), %rdi
addq $0x4, %rdi
addq %rdx, %rsi
addq $0x4, %rsi
callq 0x3d2a
cmpl $0x3, %eax
je 0x5676
movb $0x1, %cl
cmpl $0x1, %eax
jne 0x5678
movq 0x7e10(%rip), %r8       # 0xd420
movl 0x28(%r8), %r9d
movq 0x7dfd(%rip), %rdx      # 0xd418
movl %r9d, %eax
subl 0x28(%rdx), %eax
jle 0x5676
movq 0x10(%rdx), %rsi
movq 0x18(%rdx), %rcx
subq %rsi, %rcx
je 0x569d
sarq $0x2, %rcx
cmpq $0x1, %rcx
movq %rcx, %rdi
adcq $0x0, %rdi
movq 0x10(%r8), %r10
movl (%rsi), %r11d
cmpl (%r10), %r11d
jne 0x5676
movl $0x1, %r12d
movq %r12, %r11
cmpq %r12, %rdi
je 0x5667
movl (%rsi,%r11,4), %r13d
leaq 0x1(%r11), %r12
cmpl (%r10,%r11,4), %r13d
je 0x5651
cmpq %r11, %rcx
movq 0x28(%rsp), %r13
movq 0x20(%rsp), %r12
jbe 0x569d
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 0x55b1
jmp 0x5727
cmpl $0x1, %eax
jne 0x56ab
movb $0x1, %r12b
cmpb $0x0, 0x2c(%rdx)
jne 0x56ae
xorl %r12d, %r12d
cmpb $0x0, 0x78(%rsp)
cmovnel %eax, %r9d
movzbl %r12b, %eax
cmpl $0x1, 0x1c(%rsp)
jg 0x56cb
cmpb $0x1, 0x7d19(%rip)      # 0xd3e2
jne 0x56e6
movl (%r8), %esi
movl 0x4(%rdx), %ecx
addq $0x10, %rdx
addq $0x4, %r8
movl %eax, (%rsp)
movq %r13, %rdi
callq 0x6a06
jmp 0x56fe
movl (%r8), %esi
addq $0x4, %r8
movq %r13, %rdi
movq %r8, %rdx
movl %r9d, %ecx
movl %eax, %r8d
callq 0x6a76
cmpb $0x0, 0x7ae7(%rip)      # 0xd1ec
jne 0x570b
incl 0x8(%r13)
orb 0x14(%rsp), %r12b
movb $0x1, %al
movl %eax, 0x18(%rsp)
xorl %ecx, %ecx
movl %r12d, 0x14(%rsp)
movq 0x20(%rsp), %r12
jmp 0x5678
testb $0x1, 0x18(%rsp)
je 0x573b
cmpb $0x1, 0x7ab7(%rip)      # 0xd1ec
jne 0x573b
incl 0x8(%r13)
testb $0x1, 0x14(%rsp)
je 0x5746
incl 0xc(%r13)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq