// File: /workspace/github_cpp_makefile_star2_O1/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, 0xa7b6(%rip)      # 0xd239
jne 0x2a94
movb $0x1, 0xa7ad(%rip)      # 0xd239
movq %rbx, %rdi
callq 0x297c
cmpb $0x1, 0xa79d(%rip)      # 0xd238
jne 0x2b1a
movslq 0x21c(%rbx), %rax
leal 0x3(%rax), %edx
movl 0x218(%rbx), %ecx
cmpl %ecx, %edx
jge 0x2ac5
movq 0x210(%rbx), %rdx
movl 0x8(%rdx,%rax,4), %edx
addl %edx, %eax
addl $0x3, %eax
cmpl %ecx, %eax
jle 0x2afc
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x2270
movq %rbx, %rdi
callq 0x2340
cmpl %eax, 0x220(%rbx)
jne 0x2aeb
movb $0x1, 0x224(%rbx)
cmpb $0x0, 0x224(%rbx)
jne 0x2afc
movq %rbx, %rdi
callq 0x2c0e
movzbl 0x224(%rbx), %ecx
movl $0x1, %eax
testl %ecx, %ecx
je 0x2bc3
cmpl $0x1, %ecx
je 0x2b35
jmp 0x2c07
movq %rbx, %rdi
callq 0x2340
movl 0x220(%rbx), %ecx
decl %ecx
cmpl %eax, %ecx
jne 0x2b43
movb $0x1, 0x224(%rbx)
movb $0x0, 0xa6fd(%rip)      # 0xd239
xorl %eax, %eax
jmp 0x2c07
leaq 0xa6da(%rip), %rsi      # 0xd224
movq %rbx, %rdi
callq 0x2120
leaq 0xa6c7(%rip), %rsi      # 0xd220
movq %rbx, %rdi
callq 0x2120
leaq 0xa6ac(%rip), %rsi      # 0xd214
movq %rbx, %rdi
callq 0x2120
cmpl $0x0, 0xa69d(%rip)      # 0xd214
jle 0x2ba4
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x210(%rbx), %rsi
addq %r14, %rsi
movq %rbx, %rdi
callq 0x2120
incq %r15
movslq 0xa679(%rip), %rax      # 0xd214
addq $0x4, %r14
cmpq %rax, %r15
jl 0x2b7f
movq 0x210(%rbx), %rax
movq %rax, 0xa666(%rip)      # 0xd218
movl $0x0, 0x21c(%rbx)
movl $0x1, %eax
jmp 0x2c07
movq 0x210(%rbx), %rcx
movslq 0x21c(%rbx), %rdx
leaq (%rcx,%rdx,4), %rcx
addq $0xc, %rcx
movl -0xc(%rcx), %esi
movl %esi, 0xa642(%rip)      # 0xd224
movl -0x8(%rcx), %esi
movl %esi, 0xa635(%rip)      # 0xd220
movl -0x4(%rcx), %esi
movl %esi, 0xa620(%rip)      # 0xd214
movq %rcx, 0xa61d(%rip)      # 0xd218
leal (%rdx,%rsi), %ecx
addl $0x3, %ecx
movl %ecx, 0x21c(%rbx)
popq %rbx
popq %r14
popq %r15
retq
nop