// File: 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 %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpb $0x0, 0x1b765(%rip)     # 0x1e1b0
je 0x2a5d
movq -0x40(%rbp), %rdi
movb $0x0, 0x1b758(%rip)     # 0x1e1b0
callq 0x2920
testb $0x1, 0x1b7c4(%rip)     # 0x1e228
je 0x2bd4
movq -0x40(%rbp), %rcx
movl 0x21c(%rcx), %eax
addl $0x3, %eax
cmpl 0x218(%rcx), %eax
jge 0x2aad
movq -0x40(%rbp), %rcx
movl 0x21c(%rcx), %eax
movq 0x210(%rcx), %rdx
movl 0x21c(%rcx), %esi
addl $0x3, %esi
subl $0x1, %esi
movslq %esi, %rsi
addl (%rdx,%rsi,4), %eax
addl $0x3, %eax
cmpl 0x218(%rcx), %eax
jle 0x2b08
movq -0x40(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x2200
movq -0x40(%rbp), %rdi
callq 0x22c0
movq %rax, -0x20(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x3540
movq -0x40(%rbp), %rcx
cmpl 0x220(%rcx), %eax
jne 0x2af0
movq -0x40(%rbp), %rax
movb $0x1, 0x224(%rax)
movq -0x40(%rbp), %rax
cmpb $0x0, 0x224(%rax)
jne 0x2b06
movq -0x40(%rbp), %rdi
callq 0x2cc0
jmp 0x2b08
movq -0x40(%rbp), %rdi
callq 0x35d0
cmpl $0x0, %eax
je 0x2b29
movb $0x1, 0x1b693(%rip)     # 0x1e1b0
movl $0x0, -0x4(%rbp)
jmp 0x2ca8
movq -0x40(%rbp), %rax
cmpb $0x0, 0x224(%rax)
jne 0x2bc8
movq -0x40(%rbp), %rax
movq 0x210(%rax), %rcx
movslq 0x21c(%rax), %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, 0x1b6bf(%rip)     # 0x1e214
movq 0x210(%rax), %rcx
movl 0x21c(%rax), %edx
addl $0x3, %edx
subl $0x2, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, 0x1b69c(%rip)     # 0x1e210
movq 0x210(%rax), %rcx
movl 0x21c(%rax), %edx
addl $0x3, %edx
subl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, 0x1b671(%rip)     # 0x1e204
movq 0x210(%rax), %rcx
movslq 0x21c(%rax), %rdx
shlq $0x2, %rdx
addq %rdx, %rcx
addq $0xc, %rcx
movq %rcx, 0x1b655(%rip)     # 0x1e208
movl 0x1b64b(%rip), %ecx     # 0x1e204
addl $0x3, %ecx
addl 0x21c(%rax), %ecx
movl %ecx, 0x21c(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x2ca8
movq -0x40(%rbp), %rdi
callq 0x22c0
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3540
movq -0x40(%rbp), %rcx
movl 0x220(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2c1d
movq -0x40(%rbp), %rax
movb $0x1, 0x224(%rax)
movb $0x1, 0x1b59f(%rip)     # 0x1e1b0
movl $0x0, -0x4(%rbp)
jmp 0x2ca8
movq -0x40(%rbp), %rdi
leaq 0x1b5ec(%rip), %rsi     # 0x1e214
callq 0x2110
movq -0x40(%rbp), %rdi
leaq 0x1b5d8(%rip), %rsi     # 0x1e210
callq 0x2110
movq -0x40(%rbp), %rdi
leaq 0x1b5bc(%rip), %rsi     # 0x1e204
callq 0x2110
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl 0x1b5a7(%rip), %eax     # 0x1e204
jge 0x2c85
movq -0x40(%rbp), %rdi
movq 0x210(%rdi), %rsi
movslq -0x34(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x2110
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x2c54
movq -0x40(%rbp), %rax
movq 0x210(%rax), %rcx
movq %rcx, 0x1b571(%rip)     # 0x1e208
movl $0x0, 0x21c(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)