// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3PagerSavepoint
SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
  int rc = pPager->errCode;

#ifdef SQLITE_ENABLE_ZIPVFS
  if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;
#endif

  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( sqlite3JournalIsInMemory(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);
    }

#ifdef SQLITE_ENABLE_ZIPVFS
    /* If the cache has been modified but the savepoint cannot be rolled
    ** back journal_mode=off, put the pager in the error state. This way,
    ** if the VFS used by this pager includes ZipVFS, the entire transaction
    ** can be rolled back at the ZipVFS level.  */
    else if(
        pPager->journalMode==PAGER_JOURNALMODE_OFF
     && pPager->eState>=PAGER_WRITER_CACHEMOD
    ){
      pPager->errCode = SQLITE_ABORT;
      pPager->eState = PAGER_ERROR;
      setGetterMethod(pPager);
    }
#endif
  }

  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 0x3e1ee9
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x80(%rcx), %eax
jge 0x3e1ee9
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 0x3e1e2d
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x3e2290
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x3e1df7
movl -0x1c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x80(%rax)
cmpl $0x1, -0xc(%rbp)
jne 0x3e1e87
cmpl $0x0, -0x1c(%rbp)
jne 0x3e1e85
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, (%rax)
je 0x3e1e85
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x3e22f0
cmpl $0x0, %eax
je 0x3e1e7a
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3e01f0
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
jmp 0x3e1ee7
movq -0x8(%rbp), %rax
cmpq $0x0, 0x120(%rax)
jne 0x3e1ea3
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, (%rax)
je 0x3e1ee5
cmpl $0x0, -0x1c(%rbp)
jne 0x3e1eb1
xorl %eax, %eax
movq %rax, -0x30(%rbp)
jmp 0x3e1ecd
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 0x3e2310
movl %eax, -0x14(%rbp)
jmp 0x3e1ee7
jmp 0x3e1ee9
movl -0x14(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)