// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: memjrnlRead
static int memjrnlRead(
  sqlite3_file *pJfd,    /* The journal file from which to read */
  void *zBuf,            /* Put the results here */
  int iAmt,              /* Number of bytes to read */
  sqlite_int64 iOfst     /* Begin reading at this offset */
){
  MemJournal *p = (MemJournal *)pJfd;
  u8 *zOut = zBuf;
  int nRead = iAmt;
  int iChunkOffset;
  FileChunk *pChunk;

  if( (iAmt+iOfst)>p->endpoint.iOffset ){
    return SQLITE_IOERR_SHORT_READ;
  }
  assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 );
  if( p->readpoint.iOffset!=iOfst || iOfst==0 ){
    sqlite3_int64 iOff = 0;
    for(pChunk=p->pFirst;
        ALWAYS(pChunk) && (iOff+p->nChunkSize)<=iOfst;
        pChunk=pChunk->pNext
    ){
      iOff += p->nChunkSize;
    }
  }else{
    pChunk = p->readpoint.pChunk;
    assert( pChunk!=0 );
  }

  iChunkOffset = (int)(iOfst%p->nChunkSize);
  do {
    int iSpace = p->nChunkSize - iChunkOffset;
    int nCopy = MIN(nRead, (p->nChunkSize - iChunkOffset));
    memcpy(zOut, (u8*)pChunk->zChunk + iChunkOffset, nCopy);
    zOut += nCopy;
    nRead -= iSpace;
    iChunkOffset = 0;
  } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 );
  p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0;
  p->readpoint.pChunk = pChunk;

  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movslq -0x1c(%rbp), %rax
addq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jle 0x3dcc7b
movl $0x20a, -0x4(%rbp)      # imm = 0x20A
jmp 0x3dce00
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x28(%rbp), %rax
jne 0x3dcc90
cmpq $0x0, -0x28(%rbp)
jne 0x3dccf1
movq $0x0, -0x50(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x48(%rbp)
movb %al, -0x59(%rbp)
je 0x3dccc9
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
cmpq -0x28(%rbp), %rax
setle %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x3dccd2
jmp 0x3dccef
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x3dcca4
jmp 0x3dccfd
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq 0x8(%rcx), %rcx
cqto
idivq %rcx
movl %edx, %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
movl 0x8(%rcx), %ecx
subl -0x40(%rbp), %ecx
cmpl %ecx, %eax
jge 0x3dcd39
movl -0x3c(%rbp), %eax
movl %eax, -0x60(%rbp)
jmp 0x3dcd46
movq -0x30(%rbp), %rax
movl 0x8(%rax), %eax
subl -0x40(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
addq $0x8, %rsi
movslq -0x40(%rbp), %rax
addq %rax, %rsi
movslq -0x58(%rbp), %rdx
callq 0x19610
movl -0x58(%rbp), %ecx
movq -0x38(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x54(%rbp), %ecx
movl -0x3c(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x3c(%rbp)
movb %al, -0x61(%rbp)
jl 0x3dcdb6
movq -0x48(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0x61(%rbp)
je 0x3dcdb6
cmpl $0x0, -0x3c(%rbp)
setg %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x3dcd13
cmpq $0x0, -0x48(%rbp)
je 0x3dcdd9
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
jmp 0x3dcde1
xorl %eax, %eax
movq %rax, -0x70(%rbp)
jmp 0x3dcde1
movq -0x70(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x48(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x38(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)