// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/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 ){
    int nByte = sizeof(u32*)*(iPage+1);
    volatile u32 **apNew;
    apNew = (volatile u32 **)sqlite3_realloc64((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&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 $0x30, %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 0x424a83
movl -0x14(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movslq -0x28(%rbp), %rsi
callq 0x4064f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x424a3c
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl $0x7, -0x4(%rbp)
jmp 0x424b45
movq -0x30(%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 0x4010b0
movq -0x30(%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 0x424ac9
movl $0x8000, %edi           # imm = 0x8000
callq 0x40aa30
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 0x424ac7
movl $0x7, -0x24(%rbp)
jmp 0x424b28
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 0x424b50
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl $0xff, %eax
cmpl $0x8, %eax
jne 0x424b26
movq -0x10(%rbp), %rax
movzbl 0x42(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x42(%rax)
cmpl $0x8, -0x24(%rbp)
jne 0x424b24
movl $0x0, -0x24(%rbp)
jmp 0x424b26
jmp 0x424b28
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 $0x30, %rsp
popq %rbp
retq
nop