// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: walIndexPageRealloc
static SQLITE_NOINLINE int walIndexPageRealloc(
  Wal *pWal,               /* The WAL context */
  int iPage,               /* The page we seek */
  volatile u32 **ppPage    /* Write the page pointer here */
){
  int rc = SQLITE_OK;

  /* Enlarge the pWal->apWiData[] array if required */
  if( pWal->nWiData<=iPage ){
    sqlite3_int64 nByte = sizeof(u32*)*(iPage+1);
    volatile u32 **apNew;
    apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte);
    if( !apNew ){
      *ppPage = 0;
      return SQLITE_NOMEM_BKPT;
    }
    memset((void*)&apNew[pWal->nWiData], 0,
           sizeof(u32*)*(iPage+1-pWal->nWiData));
    pWal->apWiData = apNew;
    pWal->nWiData = iPage+1;
  }

  /* Request a pointer to the required page from the VFS */
  assert( pWal->apWiData[iPage]==0 );
  if( pWal->exclusiveMode==WAL_HEAPMEMORY_MODE ){
    pWal->apWiData[iPage] = (u32 volatile *)sqlite3MallocZero(WALINDEX_PGSZ);
    if( !pWal->apWiData[iPage] ) rc = SQLITE_NOMEM_BKPT;
  }else{
    rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ,
        pWal->writeLock, (void volatile **)&pWal->apWiData[iPage]
    );
    assert( pWal->apWiData[iPage]!=0 || rc!=SQLITE_OK || pWal->writeLock==0 );
    testcase( pWal->apWiData[iPage]==0 && rc==SQLITE_OK );
    if( rc==SQLITE_OK ){
      if( iPage>0 && sqlite3FaultSim(600) ) rc = SQLITE_NOMEM;
    }else if( (rc&0xff)==SQLITE_READONLY ){
      pWal->readOnly |= WAL_SHM_RDONLY;
      if( rc==SQLITE_READONLY ){
        rc = SQLITE_OK;
      }
    }
  }

  *ppPage = pWal->apWiData[iPage];
  assert( iPage==0 || *ppPage || rc!=SQLITE_OK );
  return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
cmpl %esi, 0x28(%rdi)
jg 0x288620
movslq %ebp, %r12
incq %r12
movslq %r12d, %rsi
shlq $0x3, %rsi
movq 0x30(%r14), %rdi
callq 0x272c63
testq %rax, %rax
je 0x2886ad
movq %rax, %r15
movslq 0x28(%r14), %rax
leaq (%r15,%rax,8), %rdi
movq %r12, %rdx
subq %rax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x173a0
movq %r15, 0x30(%r14)
movl %r12d, 0x28(%r14)
cmpb $0x2, 0x3f(%r14)
jne 0x28866a
movl $0x8000, %edi           # imm = 0x8000
callq 0x272ae6
movq %rax, %r15
testq %rax, %rax
je 0x288648
movl $0x8000, %edx           # imm = 0x8000
movq %r15, %rdi
xorl %esi, %esi
callq 0x173a0
movq 0x30(%r14), %rax
movslq %ebp, %r12
movq %r15, (%rax,%r12,8)
movq 0x30(%r14), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax,%r12,8)
movl $0x7, %r15d
cmovnel %ecx, %r15d
jmp 0x2886db
movq 0x8(%r14), %rdi
movzbl 0x40(%r14), %ecx
movslq %ebp, %r12
leaq (,%r12,8), %r8
addq 0x30(%r14), %r8
movq (%rdi), %rax
movl %ebp, %esi
movl $0x8000, %edx           # imm = 0x8000
callq *0x68(%rax)
testl %eax, %eax
je 0x2886b7
movl %eax, %r15d
cmpb $0x8, %r15b
jne 0x2886db
orb $0x2, 0x42(%r14)
xorl %eax, %eax
cmpl $0x8, %r15d
cmovel %eax, %r15d
jmp 0x2886db
movl $0x7, %r15d
xorl %eax, %eax
jmp 0x2886e3
xorl %r15d, %r15d
testl %ebp, %ebp
jle 0x2886db
movq 0x233123(%rip), %rax    # 0x4bb7e8
testq %rax, %rax
je 0x2886db
movl $0x258, %edi            # imm = 0x258
callq *%rax
testl %eax, %eax
je 0x2886db
movl $0x7, %r15d
movq 0x30(%r14), %rax
movq (%rax,%r12,8), %rax
movq %rax, (%rbx)
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq