// File: /workspace/github_cpp_makefile_star2_O3/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 %r14
pushq %rbx
cmpq $0x0, 0xa518(%rip)      # 0xd230
jne 0x2d43
movslq 0xa4ef(%rip), %rax      # 0xd210
leaq (,%rax,4), %rcx
testq %rax, %rax
movq $-0x1, %rdi
cmovnsq %rcx, %rdi
callq 0x2030
movq %rax, 0xa4ed(%rip)      # 0xd230
movl 0xa4cb(%rip), %eax      # 0xd214
testl %eax, %eax
jle 0x2ea3
leaq 0xa68b(%rip), %rcx      # 0xd3e3
movb (%rcx), %sil
movq 0xa4b6(%rip), %rdi      # 0xd218
leaq 0xa477(%rip), %rcx      # 0xd1e0
movq (%rcx), %r8
movq 0xa495(%rip), %r9       # 0xd208
xorl %r10d, %r10d
leaq 0xa45b(%rip), %rdx      # 0xd1d8
movslq (%rdi,%r10,4), %rbx
cmpq %rbx, %r8
sete %bpl
movq (%rdx), %r11
cmpq %rbx, %r11
sete %r14b
orb %bpl, %r14b
jne 0x2df1
cmpl $-0x1, (%r9,%rbx,4)
jne 0x2df1
movl %r8d, (%rdi,%r10,4)
movslq 0xa46b(%rip), %rax      # 0xd214
leaq 0x1(%r10), %r14
movq %r10, %rbx
cmpq %rax, %r14
jge 0x2ddf
xorl %ebp, %ebp
movq %r10, %rbx
movslq 0x4(%rdi,%rbx,4), %r14
cmpq %r14, %r8
je 0x2dcf
cmpq %r14, %r11
jne 0x2dcd
decl %ebp
jmp 0x2dcf
incl %ebp
leal 0x2(%rbx), %r14d
incq %rbx
cmpl %r14d, %eax
jle 0x2ddf
testl %ebp, %ebp
jns 0x2dba
testb $0x1, %sil
jne 0x2df1
movl %ebx, %eax
movl %r8d, (%rdi,%rax,4)
movl 0xa423(%rip), %eax      # 0xd214
incq %r10
movslq %eax, %r11
cmpq %r11, %r10
jl 0x2d7d
testb $0x1, %sil
je 0x2e4e
testl %eax, %eax
jle 0x2ea3
movq 0xa407(%rip), %rax      # 0xd218
movq (%rdx), %rsi
movq 0xa3ed(%rip), %rdi      # 0xd208
movq 0xa40e(%rip), %r8       # 0xd230
xorl %edx, %edx
movl (%rax,%rdx,4), %r9d
movslq %r9d, %r10
cmpq %r10, %rsi
je 0x2e39
cmpq %r10, (%rcx)
je 0x2e39
movl (%rdi,%r10,4), %r9d
movl %r9d, (%r8,%rdx,4)
incq %rdx
movslq 0xa3cd(%rip), %r9       # 0xd214
cmpq %r9, %rdx
jl 0x2e24
jmp 0x2ea5
testl %eax, %eax
jle 0x2ea3
movq 0xa3bf(%rip), %rsi      # 0xd218
movq (%rcx), %rcx
movq (%rdx), %rdi
movq 0xa3a2(%rip), %r8       # 0xd208
xorl %r9d, %r9d
movq 0xa3c0(%rip), %r10      # 0xd230
xorl %edx, %edx
movl (%rsi,%r9,4), %r11d
movslq %r11d, %rbx
cmpq %rbx, %rcx
je 0x2e96
cmpq %rbx, %rdi
je 0x2e87
movl (%r8,%rbx,4), %r11d
movslq %edx, %rdx
movl %r11d, (%r10,%rdx,4)
incl %edx
movl 0xa37e(%rip), %eax      # 0xd214
incq %r9
movslq %eax, %r11
cmpq %r11, %r9
jl 0x2e72
jmp 0x2ea5
xorl %edx, %edx
movq 0xa384(%rip), %rax      # 0xd230
movq %rax, 0xa365(%rip)      # 0xd218
movl %edx, 0xa35b(%rip)      # 0xd214
popq %rbx
popq %r14
popq %rbp
retq