// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerOpenSavepoint
SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
  int rc = SQLITE_OK;                       /* Return code */
  int nCurrent = pPager->nSavepoint;        /* Current number of savepoints */

  assert( pPager->eState>=PAGER_WRITER_LOCKED );
  assert( assert_pager_state(pPager) );

  if( nSavepoint>nCurrent && pPager->useJournal ){
    int ii;                                 /* Iterator variable */
    PagerSavepoint *aNew;                   /* New Pager.aSavepoint array */

    /* Grow the Pager.aSavepoint array using realloc(). Return SQLITE_NOMEM
    ** if the allocation fails. Otherwise, zero the new portion in case a 
    ** malloc failure occurs while populating it in the for(...) loop below.
    */
    aNew = (PagerSavepoint *)sqlite3Realloc(
        pPager->aSavepoint, sizeof(PagerSavepoint)*nSavepoint
    );
    if( !aNew ){
      return SQLITE_NOMEM;
    }
    memset(&aNew[nCurrent], 0, (nSavepoint-nCurrent) * sizeof(PagerSavepoint));
    pPager->aSavepoint = aNew;

    /* Populate the PagerSavepoint structures just allocated. */
    for(ii=nCurrent; ii<nSavepoint; ii++){
      aNew[ii].nOrig = pPager->dbSize;
      if( isOpen(pPager->jfd) && pPager->journalOff>0 ){
        aNew[ii].iOffset = pPager->journalOff;
      }else{
        aNew[ii].iOffset = JOURNAL_HDR_SZ(pPager);
      }
      aNew[ii].iSubRec = pPager->nSubRec;
      aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize);
      if( !aNew[ii].pInSavepoint ){
        return SQLITE_NOMEM;
      }
      if( pagerUseWal(pPager) ){
        sqlite3WalSavepoint(pPager->pWal, aNew[ii].aWalData);
      }
      pPager->nSavepoint = ii+1;
    }
    assert( pPager->nSavepoint==nSavepoint );
    assertTruncateConstraint(pPager);
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq 0x80(%rdi), %r13
xorl %eax, %eax
cmpl %r13d, %esi
jle 0x1fc8d
movq %rdi, %r14
cmpb $0x0, 0xa(%rdi)
je 0x1fc8d
movl %esi, %ebx
movq 0x78(%r14), %rdi
movl %esi, %eax
shll $0x4, %eax
leal (%rax,%rax,2), %esi
callq 0xa45c
movq %rax, %r12
movl $0x7, %eax
testq %r12, %r12
je 0x1fc8d
leaq (,%r13,2), %r15
addq %r13, %r15
shlq $0x4, %r15
leaq (%r12,%r15), %rdi
movl %ebx, %eax
subl %r13d, %eax
cltq
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdx
xorl %esi, %esi
callq 0x8200
movq %r12, 0x78(%r14)
addq %r15, %r12
addq $0x2c, %r12
negl %ebx
incl %r13d
movl 0x1c(%r14), %edi
movl %edi, -0x14(%r12)
movq 0x50(%r14), %rax
cmpq $0x0, (%rax)
je 0x1fc10
movq 0x60(%r14), %rax
testq %rax, %rax
jg 0x1fc17
movl 0xb8(%r14), %eax
movq %rax, -0x2c(%r12)
movl 0x38(%r14), %eax
movl %eax, -0x10(%r12)
callq 0x1b61e
movq %rax, -0x1c(%r12)
testq %rax, %rax
je 0x1fc88
movq 0x118(%r14), %rax
testq %rax, %rax
je 0x1fc62
movl 0x58(%rax), %ecx
movl %ecx, -0xc(%r12)
movl 0x60(%rax), %ecx
movl %ecx, -0x8(%r12)
movl 0x64(%rax), %ecx
movl %ecx, -0x4(%r12)
movl 0x80(%rax), %eax
movl %eax, (%r12)
movl %r13d, 0x80(%r14)
addq $0x30, %r12
leal (%rbx,%r13), %eax
incl %eax
movl %r13d, %ecx
incl %ecx
movl %ecx, %r13d
cmpl $0x1, %eax
jne 0x1fbf4
xorl %eax, %eax
jmp 0x1fc8d
movl $0x7, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq