// File: /workspace/github_c_makefile_star2_O1/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, %ebp
movq %rdi, %r14
movslq %esi, %r15
cmpl %esi, 0x28(%rdi)
jg 0x292438
leaq 0x1(%r15), %r13
movslq %r13d, %rsi
shlq $0x3, %rsi
movq 0x30(%r14), %rdi
callq 0x27c4f3
movq %rax, %r12
testq %rax, %rax
je 0x29242c
movslq 0x28(%r14), %rax
leaq (%r12,%rax,8), %rdi
movq %r13, %rdx
subq %rax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x173a0
movq %r12, 0x30(%r14)
movl %r13d, 0x28(%r14)
jmp 0x292433
movq $0x0, (%rbx)
testq %r12, %r12
je 0x2924b4
cmpb $0x2, 0x3f(%r14)
jne 0x29247d
movl $0x8000, %edi           # imm = 0x8000
callq 0x27c381
movq %rax, %r12
testq %rax, %rax
je 0x292460
movl $0x8000, %edx           # imm = 0x8000
movq %r12, %rdi
xorl %esi, %esi
callq 0x173a0
movq 0x30(%r14), %rax
movq %r12, (%rax,%r15,8)
movq 0x30(%r14), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax,%r15,8)
movl $0x7, %eax
cmovnel %ecx, %eax
jmp 0x2924e0
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 0x2924bb
cmpb $0x8, %al
jne 0x2924e0
orb $0x2, 0x42(%r14)
xorl %ecx, %ecx
cmpl $0x8, %eax
jmp 0x2924dd
movl $0x7, %eax
jmp 0x2924eb
xorl %eax, %eax
testl %ebp, %ebp
jle 0x2924e0
movq 0x234320(%rip), %rcx    # 0x4c67e8
testq %rcx, %rcx
je 0x2924e0
movl $0x258, %edi            # imm = 0x258
callq *%rcx
movl %eax, %ecx
testl %eax, %eax
movl $0x7, %eax
cmovel %ecx, %eax
movq 0x30(%r14), %rcx
movq (%rcx,%r15,8), %rcx
movq %rcx, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq