// File: /workspace/github_cpp_makefile_star2_O3/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, 0xa7cc(%rip)      # 0xd239
jne 0x2a7e
movb $0x1, 0xa7c3(%rip)      # 0xd239
movq %rbx, %rdi
callq 0x2966
cmpb $0x1, 0xa7b3(%rip)      # 0xd238
jne 0x2add
movslq 0x21c(%rbx), %rax
leal 0x3(%rax), %ecx
movl 0x218(%rbx), %edx
cmpl %edx, %ecx
jge 0x2aae
movq 0x210(%rbx), %rsi
addl 0x8(%rsi,%rax,4), %ecx
cmpl %edx, %ecx
jle 0x2b8e
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x2270
movq %rbx, %rdi
callq 0x2340
cmpl %eax, 0x220(%rbx)
jne 0x2b7d
movb $0x1, 0x224(%rbx)
jmp 0x2b8e
movq %rbx, %rdi
callq 0x2340
movl 0x220(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jne 0x2afd
movb $0x1, 0x224(%rbx)
jmp 0x2ba3
leaq 0xa720(%rip), %rsi      # 0xd224
movq %rbx, %rdi
callq 0x2120
leaq 0xa70d(%rip), %rsi      # 0xd220
movq %rbx, %rdi
callq 0x2120
leaq 0xa6f2(%rip), %rsi      # 0xd214
movq %rbx, %rdi
callq 0x2120
cmpl $0x0, 0xa6e3(%rip)      # 0xd214
jle 0x2b5e
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x210(%rbx), %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x2120
incq %r15
movslq 0xa6bf(%rip), %rax      # 0xd214
addq $0x4, %r14
cmpq %rax, %r15
jl 0x2b39
movq 0x210(%rbx), %rax
movq %rax, 0xa6ac(%rip)      # 0xd218
movl $0x0, 0x21c(%rbx)
movl $0x1, %eax
jmp 0x2bf2
cmpb $0x0, 0x224(%rbx)
jne 0x2b8e
movq %rbx, %rdi
callq 0x2bf8
movzbl 0x224(%rbx), %ecx
movl $0x1, %eax
testl %ecx, %ecx
je 0x2bae
cmpl $0x1, %ecx
jne 0x2bf2
movb $0x0, 0xa68f(%rip)      # 0xd239
xorl %eax, %eax
jmp 0x2bf2
movq 0x210(%rbx), %rcx
movslq 0x21c(%rbx), %rdx
leaq (%rcx,%rdx,4), %rcx
addq $0xc, %rcx
movl -0xc(%rcx), %esi
movl %esi, 0xa657(%rip)      # 0xd224
movl -0x8(%rcx), %esi
movl %esi, 0xa64a(%rip)      # 0xd220
movl -0x4(%rcx), %esi
movl %esi, 0xa635(%rip)      # 0xd214
movq %rcx, 0xa632(%rip)      # 0xd218
leal (%rdx,%rsi), %ecx
addl $0x3, %ecx
movl %ecx, 0x21c(%rbx)
popq %rbx
popq %r14
popq %r15
retq