// File: /workspace/github_cpp_makefile_star2_O2/zakimjz[P]SLEUTH/calcdb.cpp
// Function: Dbase_Ctrl_Blk::get_next_trans()
int Dbase_Ctrl_Blk::get_next_trans ()
{
   static char first=1;  

   if (first){
      first = 0;
      get_first_blk();
   }

   if (binary_input){
      if (cur_buf_pos+TRANSOFF >= cur_blk_size ||
          cur_buf_pos+buf[cur_buf_pos+TRANSOFF-1]+TRANSOFF > cur_blk_size){
         fd.seekg(0,ios::cur);
         if (((int)fd.tellg()) == endpos) readall = 1;      
         if (!readall){
            // Need to get more items from file
            get_next_trans_ext();
         }      
      }
      
      if (eof()){
         first = 1;
         return 0;
      }                     
      
      if (!readall){
         Cid = buf[cur_buf_pos];
         Tid = buf[cur_buf_pos+TRANSOFF-2];
         TransSz = buf[cur_buf_pos+TRANSOFF-1];
         TransAry = buf + cur_buf_pos + TRANSOFF;
         cur_buf_pos += TransSz + TRANSOFF;
      }
      return 1;
   }
   else{
      //fd.seekg(0,ios::cur);
      //if (fd.tellg() == endpos) readall = 1;

      if ((int)fd.tellg() == endpos-1){
         readall = 1;
         first = 1;
         return 0;
      }
      else{
         int i;
         fd >> Cid;
         fd >> Tid;
         fd >> TransSz;
         for (i=0; i < TransSz; ++i){
            fd >> buf[i];
         }
         TransAry = buf;
         cur_buf_pos = 0;

         //cout << "ENDPOS " << fd.tellg() << " " << endpos << endl;

         return 1;
      }
   }
   
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0xaa6a(%rip)      # 0xd209
jne 0x27b0
movb $0x1, 0xaa61(%rip)      # 0xd209
movq %rbx, %rdi
callq 0x26d0
cmpb $0x1, 0xaa51(%rip)      # 0xd208
jne 0x280d
movslq 0x21c(%rbx), %rax
leal 0x3(%rax), %ecx
movl 0x218(%rbx), %edx
cmpl %edx, %ecx
jge 0x27e0
movq 0x210(%rbx), %rsi
addl 0x8(%rsi,%rax,4), %ecx
cmpl %edx, %ecx
jle 0x28ab
pushq $0x1
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21f0
movq %rbx, %rdi
callq 0x22d0
cmpl %eax, 0x220(%rbx)
jne 0x289a
movb $0x1, 0x224(%rbx)
jmp 0x28ab
movq %rbx, %rdi
callq 0x22d0
movl 0x220(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jne 0x282d
movb $0x1, 0x224(%rbx)
jmp 0x28be
leaq 0xa9c0(%rip), %rsi      # 0xd1f4
movq %rbx, %rdi
callq 0x20f0
leaq 0xa9ad(%rip), %rsi      # 0xd1f0
movq %rbx, %rdi
callq 0x20f0
leaq 0xa992(%rip), %rsi      # 0xd1e4
movq %rbx, %rdi
callq 0x20f0
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0xa97d(%rip), %rax      # 0xd1e4
movq 0x210(%rbx), %rsi
cmpq %rax, %r15
jge 0x2887
addq %r14, %rsi
movq %rbx, %rdi
callq 0x20f0
incq %r15
addq $0x4, %r14
jmp 0x2860
movq %rsi, 0xa95a(%rip)      # 0xd1e8
andl $0x0, 0x21c(%rbx)
pushq $0x1
popq %rax
jmp 0x290d
cmpb $0x0, 0x224(%rbx)
jne 0x28ab
movq %rbx, %rdi
callq 0x2914
movzbl 0x224(%rbx), %ecx
pushq $0x1
popq %rax
testl %ecx, %ecx
je 0x28c9
cmpl $0x1, %ecx
jne 0x290d
movb $0x0, 0xa944(%rip)      # 0xd209
xorl %eax, %eax
jmp 0x290d
movq 0x210(%rbx), %rcx
movslq 0x21c(%rbx), %rdx
leaq (%rcx,%rdx,4), %rcx
addq $0xc, %rcx
movl -0xc(%rcx), %esi
movl %esi, 0xa90c(%rip)      # 0xd1f4
movl -0x8(%rcx), %esi
movl %esi, 0xa8ff(%rip)      # 0xd1f0
movl -0x4(%rcx), %esi
movl %esi, 0xa8ea(%rip)      # 0xd1e4
movq %rcx, 0xa8e7(%rip)      # 0xd1e8
leal (%rdx,%rsi), %ecx
addl $0x3, %ecx
movl %ecx, 0x21c(%rbx)
popq %rbx
popq %r14
popq %r15
retq
nop