// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl 0x2c(%rdi), %ebp
testl %ebp, %ebp
jne 0x293c66
movq %rdi, %rbx
xorl %ebp, %ebp
cmpl %edx, 0x80(%rdi)
jle 0x293c66
movl %esi, %r14d
xorl %r15d, %r15d
cmpl $0x1, %esi
setne %r15b
addl %edx, %r15d
cmpl 0x80(%rbx), %r15d
jge 0x293845
xorl %r12d, %r12d
cmpl $0x1, %r14d
setne %r12b
movslq %edx, %rax
addq %rax, %r12
leaq (%r12,%r12,2), %r13
shlq $0x4, %r13
addq $0x10, %r13
movq 0x78(%rbx), %rax
movq (%rax,%r13), %rdi
callq 0x294293
incq %r12
movslq 0x80(%rbx), %rax
addq $0x30, %r13
cmpq %rax, %r12
jl 0x293825
movl %r15d, 0x80(%rbx)
cmpl $0x1, %r14d
je 0x293888
cmpq $0x0, 0x120(%rbx)
jne 0x29386a
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x293c66
testl %r15d, %r15d
je 0x2938c2
movq 0x78(%rbx), %rax
movslq %r15d, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %r14
addq $-0x30, %r14
jmp 0x2938c5
testl %r15d, %r15d
jne 0x293c66
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x293c66
xorl %ebp, %ebp
leaq 0x22e276(%rip), %rcx    # 0x4c1b20
cmpq %rcx, %rax
jne 0x2938b6
xorl %esi, %esi
callq *0x20(%rax)
movl %eax, %ebp
movl $0x0, 0x38(%rbx)
jmp 0x293c66
xorl %r14d, %r14d
testq %r14, %r14
je 0x2938f9
movl 0x18(%r14), %ebp
movl $0x200, %edi            # imm = 0x200
callq 0x27c381
testq %rax, %rax
je 0x293a2f
movq %rax, %r13
movl $0x200, %edx            # imm = 0x200
movq %rax, %rdi
xorl %esi, %esi
callq 0x173a0
movl %ebp, (%r13)
jmp 0x2938fc
xorl %r13d, %r13d
leaq 0x18(%r14), %rax
leaq 0x20(%rbx), %rcx
testq %r14, %r14
cmoveq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x16(%rbx)
je 0x29394b
leaq 0x60(%rbx), %r15
movq 0x60(%rbx), %rdx
testq %r14, %r14
movq %r14, 0x18(%rsp)
movq %rdx, 0x8(%rsp)
je 0x29393d
cmpq $0x0, 0x120(%rbx)
je 0x293a39
movq $0x0, (%r15)
xorl %ebp, %ebp
jmp 0x293a7c
movq 0x120(%rbx), %r15
testq %r15, %r15
je 0x293918
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
cmpb $0x0, 0x40(%r15)
je 0x293b5b
movl 0x58(%r15), %r14d
movq 0x30(%r15), %rax
movq (%rax), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm1, 0x58(%r15)
movups %xmm0, 0x48(%r15)
movups %xmm2, 0x68(%r15)
movl 0x58(%r15), %r12d
leal 0x1(%r12), %eax
xorl %ebp, %ebp
cmpl %r14d, %eax
ja 0x293a18
movabsq $0xffffffff000, %r13    # imm = 0xFFFFFFFF000
addl $0x1001, %r12d          # imm = 0x1001
movl %r12d, %eax
leaq (%rax,%r13), %rcx
addq $0x21, %rcx
movq 0x30(%r15), %rax
testq %r13, %rcx
je 0x2939e0
shrq $0xc, %rcx
movslq %ecx, %rdx
leal -0xfdf(%r12), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
shll $0x2, %ecx
addq (%rax,%rdx,8), %rcx
jmp 0x2939f8
leal -0x1000(%r12), %ecx
movq (%rax), %rax
movl %ecx, %ecx
leaq (%rax,%rcx,4), %rcx
addq $0x84, %rcx
movl (%rcx), %esi
movq %rbx, %rdi
callq 0x29479f
movl %eax, %ebp
testl %eax, %eax
jne 0x293a18
leal -0xfff(%r12), %eax
incl %r12d
cmpl %r14d, %eax
jbe 0x2939ae
cmpl 0x58(%r15), %r14d
je 0x293b5d
movq %r15, %rdi
callq 0x2927e9
jmp 0x293b5d
movl $0x7, %ebp
jmp 0x293c66
movq (%r14), %rax
movq 0x8(%r14), %r14
testq %r14, %r14
cmoveq %rdx, %r14
movq %rax, (%r15)
cmpq %r14, (%r15)
jge 0x293a70
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x2942cd
testl %eax, %eax
je 0x293a4a
movl %eax, %ebp
jmp 0x293a72
xorl %ebp, %ebp
movq 0x18(%rsp), %r14
movq 0x8(%rsp), %rdx
testl %ebp, %ebp
movq %r13, %r12
jne 0x293bab
cmpq %rdx, 0x60(%rbx)
jge 0x293bab
movl $0x0, 0x10(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
leaq 0x10(%rsp), %rcx
leaq 0x24(%rsp), %r8
callq 0x2945ed
movl %eax, %ebp
cmpl $0x0, 0x10(%rsp)
jne 0x293ae5
movl 0xb8(%rbx), %eax
addq 0x68(%rbx), %rax
movq 0x60(%rbx), %rcx
cmpq %rcx, %rax
jne 0x293ae5
movq 0x8(%rsp), %rax
subq %rcx, %rax
movslq 0xbc(%rbx), %rcx
addq $0x8, %rcx
cqto
idivq %rcx
movl %eax, 0x10(%rsp)
movl 0x10(%rsp), %r13d
testl %ebp, %ebp
sete %al
testl %r13d, %r13d
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x293b3f
movq 0x8(%rsp), %rdx
cmpq %rdx, (%r15)
jge 0x293b44
movl $0x1, %r14d
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x2942cd
movl %eax, %ebp
testl %eax, %eax
jne 0x293b3f
cmpl %r13d, %r14d
movq 0x8(%rsp), %rdx
jae 0x293b44
incl %r14d
cmpq %rdx, (%r15)
jl 0x293b0c
jmp 0x293b44
movq 0x8(%rsp), %rdx
testl %ebp, %ebp
jne 0x293ba3
cmpq %rdx, (%r15)
movq %r12, %r13
movq 0x18(%rsp), %r14
jl 0x293a91
jmp 0x293bab
xorl %ebp, %ebp
movq 0x118(%rbx), %rdi
callq 0x294805
movq %rax, %r14
testq %rax, %rax
sete %al
testl %ebp, %ebp
setne %cl
orb %al, %cl
jne 0x293c66
movl 0x30(%r14), %esi
movq 0x20(%r14), %r14
movq %rbx, %rdi
callq 0x29479f
movl %eax, %ebp
testq %r14, %r14
je 0x293c66
testl %ebp, %ebp
je 0x293b7f
jmp 0x293c66
movq %r12, %r13
movq 0x18(%rsp), %r14
testq %r14, %r14
je 0x293c52
movl 0x1c(%r14), %eax
movslq 0xbc(%rbx), %rcx
addq $0x4, %rcx
imulq %rax, %rcx
movq %rcx, 0x10(%rsp)
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x293c17
movl 0x2c(%r14), %eax
cmpl 0x88(%rdi), %eax
je 0x293bf6
movl $0x0, 0x20(%r14)
movl 0x88(%rdi), %eax
movl %eax, 0x2c(%r14)
movl 0x20(%r14), %eax
xorl %ebp, %ebp
cmpl 0x58(%rdi), %eax
jae 0x293c17
movl %eax, 0x58(%rdi)
movl 0x24(%r14), %eax
movl %eax, 0x60(%rdi)
movl 0x28(%r14), %eax
movl %eax, 0x64(%rdi)
callq 0x2927e9
testl %ebp, %ebp
jne 0x293c4f
movl 0x1c(%r14), %r13d
cmpl 0x38(%rbx), %r13d
jae 0x293c4f
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x2942cd
movl %eax, %ebp
testl %eax, %eax
jne 0x293c4f
incl %r13d
cmpl 0x38(%rbx), %r13d
jb 0x293c2a
movq %r12, %r13
movq %r13, %rdi
callq 0x294293
testl %ebp, %ebp
jne 0x293c66
movq 0x8(%rsp), %rax
movq %rax, (%r15)
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq