// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerSetPagesize
SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager *pPager, u32 *pPageSize, int nReserve){
  int rc = SQLITE_OK;

  /* It is not possible to do a full assert_pager_state() here, as this
  ** function may be called from within PagerOpen(), before the state
  ** of the Pager object is internally consistent.
  **
  ** At one point this function returned an error if the pager was in 
  ** PAGER_ERROR state. But since PAGER_ERROR state guarantees that
  ** there is at least one outstanding page reference, this function
  ** is a no-op for that case anyhow.
  */

  u32 pageSize = *pPageSize;
  assert( pageSize==0 || (pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE) );
  if( (pPager->memDb==0 || pPager->dbSize==0)
   && sqlite3PcacheRefCount(pPager->pPCache)==0 
   && pageSize && pageSize!=(u32)pPager->pageSize 
  ){
    char *pNew = NULL;             /* New temp space */
    i64 nByte = 0;

    if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){
      rc = sqlite3OsFileSize(pPager->fd, &nByte);
    }
    if( rc==SQLITE_OK ){
      pNew = (char *)sqlite3PageMalloc(pageSize);
      if( !pNew ) rc = SQLITE_NOMEM;
    }

    if( rc==SQLITE_OK ){
      pager_reset(pPager);
      pPager->dbSize = (Pgno)((nByte+pageSize-1)/pageSize);
      pPager->pageSize = pageSize;
      sqlite3PageFree(pPager->pTmpSpace);
      pPager->pTmpSpace = pNew;
      sqlite3PcacheSetPageSize(pPager->pPCache, pageSize);
    }
  }

  *pPageSize = pPager->pageSize;
  if( rc==SQLITE_OK ){
    if( nReserve<0 ) nReserve = pPager->nReserve;
    assert( nReserve>=0 && nReserve<1000 );
    pPager->nReserve = (i16)nReserve;
    pagerReportSize(pPager);
    pagerFixMaplimit(pPager);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl (%rsi), %r12d
cmpb $0x0, 0x12(%rdi)
je 0x180da
cmpl $0x0, 0x1c(%rbx)
jne 0x181a0
movq 0x110(%rbx), %rax
cmpl $0x0, 0x18(%rax)
sete %al
testl %r12d, %r12d
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x181a0
cmpl 0xbc(%rbx), %r12d
je 0x181a0
andq $0x0, -0x30(%rbp)
cmpb $0x0, 0x13(%rbx)
je 0x1812c
movq 0x48(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1812c
leaq -0x30(%rbp), %rsi
callq *0x30(%rax)
testl %eax, %eax
jne 0x181da
movl %r12d, %edi
callq 0x1a6eb
testq %rax, %rax
je 0x181d7
movq %rax, %r13
movq %rbx, %rdi
callq 0x1a6c5
movq -0x30(%rbp), %rax
addq %r12, %rax
decq %rax
cqto
idivq %r12
movl %eax, 0x1c(%rbx)
movl %r12d, 0xbc(%rbx)
movq 0x108(%rbx), %rdi
callq 0x1a82f
movq %r13, 0x108(%rbx)
movq 0x110(%rbx), %r13
movq 0x40(%r13), %rdi
testq %rdi, %rdi
je 0x1819c
leaq 0x40(%r13), %rax
movq %rax, -0x38(%rbp)
callq *0x6f36e(%rip)          # 0x87500
xorps %xmm0, %xmm0
movq -0x38(%rbp), %rax
movups %xmm0, (%rax)
movl %r12d, 0x20(%r13)
movl 0xbc(%rbx), %eax
movl %eax, (%r15)
testl %r14d, %r14d
jns 0x181b6
movzwl 0xb2(%rbx), %r14d
movw %r14w, 0xb2(%rbx)
movq %rbx, %rdi
callq 0x1a685
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x7
popq %rax
movl 0xbc(%rbx), %ecx
movl %ecx, (%r15)
jmp 0x181c8