// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerSavepoint
SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
  int rc = pPager->errCode;       /* Return code */

  assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
  assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );

  if( rc==SQLITE_OK && iSavepoint<pPager->nSavepoint ){
    int ii;            /* Iterator variable */
    int nNew;          /* Number of remaining savepoints after this op. */

    /* Figure out how many savepoints will still be active after this
    ** operation. Store this value in nNew. Then free resources associated 
    ** with any savepoints that are destroyed by this operation.
    */
    nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);
    for(ii=nNew; ii<pPager->nSavepoint; ii++){
      sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);
    }
    pPager->nSavepoint = nNew;

    /* If this is a release of the outermost savepoint, truncate 
    ** the sub-journal to zero bytes in size. */
    if( op==SAVEPOINT_RELEASE ){
      if( nNew==0 && isOpen(pPager->sjfd) ){
        /* Only truncate if it is an in-memory sub-journal. */
        if( sqlite3IsMemJournal(pPager->sjfd) ){
          rc = sqlite3OsTruncate(pPager->sjfd, 0);
          assert( rc==SQLITE_OK );
        }
        pPager->nSubRec = 0;
      }
    }
    /* Else this is a rollback operation, playback the specified savepoint.
    ** If this is a temp-file, it is possible that the journal file has
    ** not yet been opened. In this case there have been no changes to
    ** the database file, so the playback operation can be skipped.
    */
    else if( pagerUseWal(pPager) || isOpen(pPager->jfd) ){
      PagerSavepoint *pSavepoint = (nNew==0)?0:&pPager->aSavepoint[nNew-1];
      rc = pagerPlaybackSavepoint(pPager, pSavepoint);
      assert(rc!=SQLITE_DONE);
    }
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x26d39
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jge 0x26d39
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %esi
movl $0x1, %ecx
xorl %edx, %edx
cmpl $0x1, %esi
cmovel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jge 0x26c7d
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x26630
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x26c47
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
cmpl $0x1, -0xc(%rbp)
jne 0x26cd7
cmpl $0x0, -0x1c(%rbp)
jne 0x26cd5
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, (%rax)
je 0x26cd5
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x267f0
cmpl $0x0, %eax
je 0x26cca
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x241d0
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
jmp 0x26d37
movq -0x8(%rbp), %rdi
callq 0x211a0
cmpl $0x0, %eax
jne 0x26cf3
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, (%rax)
je 0x26d35
cmpl $0x0, -0x1c(%rbp)
jne 0x26d01
xorl %eax, %eax
movq %rax, -0x30(%rbp)
jmp 0x26d1d
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x270b0
movl %eax, -0x14(%rbp)
jmp 0x26d37
jmp 0x26d39
movl -0x14(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)