// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x28(%rax), %eax
cmpl -0x14(%rbp), %eax
jg 0x3dfa94
movl -0x14(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x3c0910
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3dfa4d
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl $0x7, -0x4(%rbp)
jmp 0x3dfb7f
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq 0x28(%rax), %rax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x14(%rbp), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
subl 0x28(%rcx), %eax
movslq %eax, %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x19360
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x10(%rbp), %rax
movzbl 0x3f(%rax), %eax
cmpl $0x2, %eax
jne 0x3dfadd
movl $0x8000, %edi           # imm = 0x8000
callq 0x3c51d0
movq %rax, %rdx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x3dfad8
movl $0x7, -0x24(%rbp)
jmp 0x3dfb62
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rax
movzbl 0x40(%rax), %ecx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %r8
movslq -0x14(%rbp), %rax
shlq $0x3, %rax
addq %rax, %r8
movl $0x8000, %edx           # imm = 0x8000
callq 0x3dfb90
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x3dfb34
cmpl $0x0, -0x14(%rbp)
jle 0x3dfb32
movl $0x258, %edi            # imm = 0x258
callq 0x3d5070
cmpl $0x0, %eax
je 0x3dfb32
movl $0x7, -0x24(%rbp)
jmp 0x3dfb60
movl -0x24(%rbp), %eax
andl $0xff, %eax
cmpl $0x8, %eax
jne 0x3dfb5e
movq -0x10(%rbp), %rax
movzbl 0x42(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x42(%rax)
cmpl $0x8, -0x24(%rbp)
jne 0x3dfb5c
movl $0x0, -0x24(%rbp)
jmp 0x3dfb5e
jmp 0x3dfb60
jmp 0x3dfb62
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)