// File: /workspace/github_c_makefile_star2_O1/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 0x1a435
xorl %r13d, %r13d
cmpl $0x0, 0x1c(%rbx)
jne 0x1a53e
movq 0x110(%rbx), %rax
cmpl $0x0, 0x18(%rax)
sete %al
testl %r12d, %r12d
setne %cl
andb %al, %cl
xorl %r13d, %r13d
cmpb $0x1, %cl
jne 0x1a53e
cmpl 0xbc(%rbx), %r12d
je 0x1a53e
movq $0x0, -0x38(%rbp)
xorl %r13d, %r13d
cmpb $0x0, 0x13(%rbx)
je 0x1a48b
movq 0x48(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1a48b
leaq -0x38(%rbp), %rsi
callq *0x30(%rax)
movl %eax, %r13d
xorl %eax, %eax
testl %r13d, %r13d
jne 0x1a4a9
movl %r12d, %edi
xorl %r13d, %r13d
callq 0x1ce52
testq %rax, %rax
movl $0x7, %ecx
cmovel %ecx, %r13d
testl %r13d, %r13d
jne 0x1a53e
movq %rax, -0x30(%rbp)
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1a4cc
movl $0x1, 0x18(%rax)
movq 0x40(%rax), %rax
jmp 0x1a4ba
movq 0x110(%rbx), %rdi
xorl %esi, %esi
callq 0x1cf10
movq -0x38(%rbp), %rax
addq %r12, %rax
decq %rax
cqto
idivq %r12
movl %eax, 0x1c(%rbx)
movl %r12d, 0xbc(%rbx)
movq 0x108(%rbx), %rdi
callq 0x1cf8c
movq -0x30(%rbp), %rax
movq %rax, 0x108(%rbx)
movq 0x110(%rbx), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x1a53a
leaq 0x40(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq %rax, -0x30(%rbp)
callq *0x79fd4(%rip)          # 0x94500
movq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
movq -0x40(%rbp), %rcx
movups %xmm0, (%rcx)
movl %r12d, 0x20(%rax)
movl 0xbc(%rbx), %eax
movl %eax, (%r15)
testl %r13d, %r13d
jne 0x1a569
testl %r14d, %r14d
jns 0x1a559
movzwl 0xb2(%rbx), %r14d
movw %r14w, 0xb2(%rbx)
movq %rbx, %rdi
callq 0x1cde1
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq