// File: /workspace/github_c_makefile_star2_O2/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 0x1d341
movq %rdi, %r14
cmpb $0x0, 0xa(%rdi)
je 0x1d341
movl %esi, %r15d
movq 0x78(%r14), %rdi
imull $0x30, %esi, %esi
callq 0x9d10
movq %rax, %r12
pushq $0x7
popq %rax
testq %r12, %r12
je 0x1d341
imulq $0x30, %r13, %rbx
leaq (%r12,%rbx), %rdi
movl %r15d, %eax
subl %r13d, %eax
cltq
imulq $0x30, %rax, %rdx
xorl %esi, %esi
callq 0x81e0
movq %r12, 0x78(%r14)
movslq %r15d, %r15
addq %rbx, %r12
addq $0x2c, %r12
leal 0x1(%r13), %ebx
cmpq %r15, %r13
jge 0x1d33a
movl 0x1c(%r14), %edi
movl %edi, -0x14(%r12)
movq 0x50(%r14), %rax
cmpq $0x0, (%rax)
je 0x1d2d3
movq 0x60(%r14), %rax
testq %rax, %rax
jg 0x1d2da
movl 0xb8(%r14), %eax
movq %rax, -0x2c(%r12)
movl 0x38(%r14), %eax
movl %eax, -0x10(%r12)
callq 0x19221
movq %rax, -0x1c(%r12)
testq %rax, %rax
je 0x1d33e
movq 0x118(%r14), %rax
testq %rax, %rax
je 0x1d325
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)
incq %r13
movl %ebx, 0x80(%r14)
addq $0x30, %r12
incl %ebx
jmp 0x1d2ae
xorl %eax, %eax
jmp 0x1d341
pushq $0x7
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq