// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %r12d
movq %rdi, %r14
movslq %esi, %r15
cmpl %esi, 0x28(%rdi)
jg 0x23231d
leaq 0x1(%r15), %rbp
movslq %ebp, %rsi
shlq $0x3, %rsi
movq 0x30(%r14), %rdi
callq 0x21f85c
testq %rax, %rax
je 0x23238a
movq %rax, %r13
movslq 0x28(%r14), %rax
leaq (,%rax,8), %rdi
addq %r13, %rdi
movq %rbp, %rdx
subq %rax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x17380
movq %r13, 0x30(%r14)
movl %ebp, 0x28(%r14)
cmpb $0x2, 0x3f(%r14)
jne 0x23234c
movl $0x8000, %edi           # imm = 0x8000
callq 0x2227e2
movq 0x30(%r14), %rcx
movslq %r12d, %r15
movq %rax, (%rcx,%r15,8)
movq 0x30(%r14), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax,%r15,8)
pushq $0x7
popq %rbp
cmovnel %ecx, %ebp
jmp 0x2323b2
movq 0x8(%r14), %rdi
movzbl 0x40(%r14), %ecx
leaq (,%r15,8), %r8
addq 0x30(%r14), %r8
movq (%rdi), %rax
movl %r15d, %esi
movl $0x8000, %edx           # imm = 0x8000
callq *0x68(%rax)
testl %eax, %eax
je 0x232391
movl %eax, %ebp
cmpb $0x8, %bpl
jne 0x2323b2
orb $0x2, 0x42(%r14)
xorl %eax, %eax
cmpl $0x8, %ebp
cmovel %eax, %ebp
jmp 0x2323b2
pushq $0x7
popq %rbp
xorl %eax, %eax
jmp 0x2323ba
xorl %ebp, %ebp
testl %r12d, %r12d
jle 0x2323b2
movq 0x2083f9(%rip), %rax    # 0x43a798
testq %rax, %rax
je 0x2323b2
movl $0x258, %edi            # imm = 0x258
callq *%rax
testl %eax, %eax
je 0x2323b2
pushq $0x7
popq %rbp
movq 0x30(%r14), %rax
movq (%rax,%r15,8), %rax
movq %rax, (%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq