// File: /workspace/github_c_makefile_star2_O0/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
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x80(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x14(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jle 0x29b35
movq -0x10(%rbp), %rax
movzbl 0xa(%rax), %eax
cmpl $0x0, %eax
je 0x29b35
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rdi
movslq -0x14(%rbp), %rax
imulq $0x30, %rax, %rax
movl %eax, %esi
callq 0xa540
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x299de
movl $0x7, -0x4(%rbp)
jmp 0x29b3b
movq -0x28(%rbp), %rdi
movslq -0x1c(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rdi
movl -0x14(%rbp), %eax
subl -0x1c(%rbp), %eax
cltq
imulq $0x30, %rax, %rdx
xorl %esi, %esi
callq 0x8200
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x29b33
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, (%rax)
je 0x29a6c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
jle 0x29a6c
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rcx
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
jmp 0x29a8a
movq -0x10(%rbp), %rax
movl 0xb8(%rax), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %ecx
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x1c(%rax)
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x22360
movq %rax, %rcx
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpq $0x0, 0x10(%rax)
jne 0x29ae4
movl $0x7, -0x4(%rbp)
jmp 0x29b3b
movq -0x10(%rbp), %rdi
callq 0x211a0
cmpl $0x0, %eax
je 0x29b15
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movq -0x28(%rbp), %rsi
movslq -0x20(%rbp), %rax
imulq $0x30, %rax, %rax
addq %rax, %rsi
addq $0x20, %rsi
callq 0x2aac0
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x80(%rax)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x29a12
jmp 0x29b35
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)