// File: /workspace/github_cpp_makefile_star2_O2/zakimjz[P]SLEUTH/calcdb.cpp
// Function: Dbase_Ctrl_Blk::get_valid_trans()
void Dbase_Ctrl_Blk::get_valid_trans()
{
   int i, j;
   int newTransSz;
   //const int invalid=-3; //-3 does not appear in original trans
   
   if (PvtTransAry == NULL)
      PvtTransAry = new int [MaxTransSz];
   
   //remove infreq items
   //cout << "ORIG " << endl;
   //for (i=0; i < TransSz; i++)
   //   cout << TransAry[i] << " ";
   //cout << endl;
   //cout << "ORIGV " << endl;
   //for (i=0; i < TransSz; i++)
   //   if (TransAry[i] != -1 && theFreqMap[TransAry[i]] == -1)
   //      cout << "-3 ";
   //   else   cout << TransAry[i] << " ";
   //cout << endl;
   

   for (i=0; i < TransSz; i++){      
      if (TransAry[i] != InvalidIt){
         if (TransAry[i] != BranchIt){   
            if (FreqMap[TransAry[i]] == -1){
               //set item to invalid and the next -1 to invalid
               TransAry[i] = InvalidIt;
               int cnt=0;
               
               for(j=i+1; j < TransSz && cnt >= 0; j++){
                  if (TransAry[j] != InvalidIt){
                     if (TransAry[j] == BranchIt) cnt--;
                     else cnt++;
                  }
               }
               if (!mine_induced) TransAry[--j] = InvalidIt;
            }
         }
      }
   }
   
   //cout << "VALID " << endl;
   //for (i=0; i < TransSz; i++)
   //   cout << TransAry[i] << " ";
   //cout << endl;

   //copy valid items to PvtTransAry
   if (mine_induced){
      //just copy all items (invalid, branch, regular) since we do not
      //want to count embedded occurrences as induced.
      for (i=0, newTransSz=0; i < TransSz; i++){
	 if (TransAry[i] == BranchIt || TransAry[i] == InvalidIt) 
	    PvtTransAry[newTransSz] = TransAry[i]; 
	 else PvtTransAry[newTransSz] = FreqMap[TransAry[i]];
	 newTransSz++;
      }
   }
   else{
      //eliminate invalid items and compress the tree
      for (i=0,newTransSz=0; i < TransSz; i++){
	 if (TransAry[i] != InvalidIt){
	    if (TransAry[i] == BranchIt) PvtTransAry[newTransSz] = TransAry[i];
	    else PvtTransAry[newTransSz] = FreqMap[TransAry[i]];
	    newTransSz++;
	 }
      }
   }
   TransAry = PvtTransAry;
   TransSz = newTransSz;

   //cout << "NEW " << endl;
   //for (i=0; i < TransSz; i++)
   //   cout << TransAry[i] << " ";
   //cout << endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0xa7f3(%rip)      # 0xd200
jne 0x2a34
movslq 0xa7ca(%rip), %rax      # 0xd1e0
leaq (,%rax,4), %rcx
testq %rax, %rax
pushq $-0x1
popq %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0xa7cc(%rip)      # 0xd200
movq 0xa7ad(%rip), %rdx      # 0xd1e8
leaq 0xa766(%rip), %rax      # 0xd1a8
movq (%rax), %rdi
movq 0xa78c(%rip), %r9       # 0xd1d8
leaq 0xa960(%rip), %r8       # 0xd3b3
movb (%r8), %r10b
movl 0xa788(%rip), %ecx      # 0xd1e4
xorl %r11d, %r11d
leaq 0xa73a(%rip), %rsi      # 0xd1a0
movslq %ecx, %rbx
cmpq %rbx, %r11
jge 0x2ae3
movslq (%rdx,%r11,4), %r14
cmpq %r14, %rdi
sete %bpl
movq (%rsi), %rbx
cmpq %r14, %rbx
sete %r15b
orb %bpl, %r15b
jne 0x2ade
cmpl $-0x1, (%r9,%r14,4)
jne 0x2ade
movl %edi, (%rdx,%r11,4)
xorl %r15d, %r15d
movl 0xa748(%rip), %ecx      # 0xd1e4
movq %r11, %r14
leal 0x1(%r14), %ebp
cmpl %ebp, %ecx
jle 0x2acc
testl %r15d, %r15d
js 0x2acc
movslq 0x4(%rdx,%r14,4), %r12
incq %r14
cmpq %r12, %rdi
je 0x2a9f
xorl %r13d, %r13d
cmpq %r12, %rbx
setne %r13b
leal (%r15,%r13,2), %r15d
decl %r15d
jmp 0x2a9f
testb $0x1, %r10b
jne 0x2ade
movl %r14d, %ecx
movl %edi, (%rdx,%rcx,4)
movl 0xa706(%rip), %ecx      # 0xd1e4
incq %r11
jmp 0x2a66
movq 0xa6fe(%rip), %rdx      # 0xd1e8
cmpb $0x0, (%r8)
je 0x2b2e
movq (%rsi), %rdi
movq 0xa6de(%rip), %r8       # 0xd1d8
movq 0xa6ff(%rip), %r9       # 0xd200
xorl %esi, %esi
movslq %ecx, %rcx
cmpq %rcx, %rsi
jge 0x2b78
movl (%rdx,%rsi,4), %ecx
movslq %ecx, %r10
cmpq %r10, %rdi
je 0x2b1f
cmpq %r10, (%rax)
je 0x2b1f
movl (%r8,%r10,4), %ecx
movl %ecx, (%r9,%rsi,4)
incq %rsi
movl 0xa6b8(%rip), %ecx      # 0xd1e4
jmp 0x2b03
movq (%rax), %rax
movq (%rsi), %rdi
movq 0xa69d(%rip), %r8       # 0xd1d8
xorl %r9d, %r9d
movq 0xa6bb(%rip), %r10      # 0xd200
xorl %esi, %esi
movslq %ecx, %r11
cmpq %r11, %r9
jge 0x2b78
movl (%rdx,%r9,4), %r11d
movslq %r11d, %rbx
cmpq %rbx, %rax
je 0x2b73
cmpq %rbx, %rdi
je 0x2b64
movl (%r8,%rbx,4), %r11d
movslq %esi, %rsi
movl %r11d, (%r10,%rsi,4)
incl %esi
movl 0xa671(%rip), %ecx      # 0xd1e4
incq %r9
jmp 0x2b47
movq 0xa681(%rip), %rax      # 0xd200
movq %rax, 0xa662(%rip)      # 0xd1e8
movl %esi, 0xa658(%rip)      # 0xd1e4
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop