// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: vdbePmaReaderSeek
static int vdbePmaReaderSeek(
  SortSubtask *pTask,             /* Task context */
  PmaReader *pReadr,              /* Reader whose cursor is to be moved */
  SorterFile *pFile,              /* Sorter file to read from */
  i64 iOff                        /* Offset in pFile */
){
  int rc = SQLITE_OK;

  assert( pReadr->pIncr==0 || pReadr->pIncr->bEof==0 );

  if( sqlite3FaultSim(201) ) return SQLITE_IOERR_READ;
  if( pReadr->aMap ){
    sqlite3OsUnfetch(pReadr->pFd, 0, pReadr->aMap);
    pReadr->aMap = 0;
  }
  pReadr->iReadOff = iOff;
  pReadr->iEof = pFile->iEof;
  pReadr->pFd = pFile->pFd;

  rc = vdbeSorterMapFile(pTask, pFile, &pReadr->aMap);
  if( rc==SQLITE_OK && pReadr->aMap==0 ){
    int pgsz = pTask->pSorter->pgsz;
    int iBuf = pReadr->iReadOff % pgsz;
    if( pReadr->aBuffer==0 ){
      pReadr->aBuffer = (u8*)sqlite3Malloc(pgsz);
      if( pReadr->aBuffer==0 ) rc = SQLITE_NOMEM_BKPT;
      pReadr->nBuffer = pgsz;
    }
    if( rc==SQLITE_OK && iBuf ){
      int nRead = pgsz - iBuf;
      if( (pReadr->iReadOff + nRead) > pReadr->iEof ){
        nRead = (int)(pReadr->iEof - pReadr->iReadOff);
      }
      rc = sqlite3OsRead(
          pReadr->pFd, &pReadr->aBuffer[iBuf], nRead, pReadr->iReadOff
      );
      testcase( rc!=SQLITE_OK );
    }
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0xc9, %edi
callq 0x3d5070
cmpl $0x0, %eax
je 0x40993a
movl $0x10a, -0x4(%rbp)      # imm = 0x10A
jmp 0x409a93
movq -0x18(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x40996a
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
callq 0x3e1110
movq -0x18(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x28(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x40, %rdx
callq 0x409cc0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x409a8d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x409a8d
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movl %eax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x30(%rbp), %rcx
cqto
idivq %rcx
movl %edx, %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x409a23
movslq -0x30(%rbp), %rdi
callq 0x3c0760
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x409a19
movl $0x7, -0x2c(%rbp)
movl -0x30(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x38(%rax)
cmpl $0x0, -0x2c(%rbp)
jne 0x409a8b
cmpl $0x0, -0x34(%rbp)
je 0x409a8b
movl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movslq -0x38(%rbp), %rcx
addq %rcx, %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jle 0x409a62
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
subq (%rcx), %rax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rsi
movslq -0x34(%rbp), %rax
addq %rax, %rsi
movl -0x38(%rbp), %edx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
callq 0x3dfc00
movl %eax, -0x2c(%rbp)
jmp 0x409a8d
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)