// File: /workspace/github_c_makefile_star2_O3/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 0x289e49
movq %rdi, %rbx
movl 0x80(%rdi), %eax
xorl %ebp, %ebp
cmpl %edx, %eax
jle 0x289e49
movl %esi, %r14d
xorl %r15d, %r15d
cmpl $0x1, %esi
setne %r15b
addl %edx, %r15d
cmpl %eax, %r15d
jge 0x289a34
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 0x28a41d
incq %r12
movslq 0x80(%rbx), %rax
addq $0x30, %r13
cmpq %rax, %r12
jl 0x289a14
movl %r15d, 0x80(%rbx)
cmpl $0x1, %r14d
je 0x289b2a
movq 0x120(%rbx), %r14
testq %r14, %r14
jne 0x289a5f
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x289e49
testl %r15d, %r15d
je 0x289b78
movslq %r15d, %rax
leaq (%rax,%rax,2), %r13
shlq $0x4, %r13
addq 0x78(%rbx), %r13
movq %r13, %rax
addq $-0x30, %rax
je 0x289b78
movq %rax, 0x18(%rsp)
movl -0x18(%r13), %ebp
movl $0x200, %edi            # imm = 0x200
callq 0x272ae6
testq %rax, %rax
je 0x289d7d
movq %rax, %r14
movq %rax, %rdi
addq $0x4, %rdi
movl $0x0, 0x4(%rsp)
movl $0x1fc, %edx            # imm = 0x1FC
xorl %esi, %esi
callq 0x173a0
movq %r14, 0x8(%rsp)
movl %ebp, (%r14)
movl -0x18(%r13), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x16(%rbx)
leaq 0x60(%rbx), %r15
movq 0x60(%rbx), %r12
cmpq $0x0, 0x120(%rbx)
jne 0x289c82
movq -0x30(%r13), %rax
movq -0x28(%r13), %r14
testq %r14, %r14
cmoveq %r12, %r14
movq %rax, (%r15)
cmpq %r14, (%r15)
jge 0x289e5a
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x28a481
testl %eax, %eax
je 0x289afb
movl %eax, %ebp
jmp 0x289d42
testl %r15d, %r15d
jne 0x289e49
movq 0x58(%rbx), %r14
movq (%r14), %rax
testq %rax, %rax
je 0x289e49
leaq 0x22cfc6(%rip), %rcx    # 0x4b6b10
cmpq %rcx, %rax
jne 0x289b6c
movq %r14, %rdi
callq 0x286f50
movl $0x0, 0x10(%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movups %xmm0, 0x30(%r14)
movl $0x0, 0x38(%rbx)
jmp 0x289e47
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x16(%rbx)
testq %r14, %r14
je 0x289c62
cmpb $0x0, 0x40(%r14)
je 0x289d87
movl 0x58(%r14), %r15d
movq 0x30(%r14), %rax
movq (%rax), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm1, 0x58(%r14)
movups %xmm0, 0x48(%r14)
movups %xmm2, 0x68(%r14)
movl 0x58(%r14), %r12d
leal 0x1(%r12), %eax
xorl %ebp, %ebp
cmpl %r15d, %eax
ja 0x289c4c
movabsq $0xffffffff000, %r13    # imm = 0xFFFFFFFF000
addl $0x1001, %r12d          # imm = 0x1001
movl %r12d, %eax
leaq (%rax,%r13), %rcx
addq $0x21, %rcx
movq 0x30(%r14), %rax
testq %r13, %rcx
je 0x289c10
shrq $0xc, %rcx
movslq %ecx, %rdx
leal -0xfdf(%r12), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
shll $0x2, %ecx
addq (%rax,%rdx,8), %rcx
jmp 0x289c28
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 0x28a955
movl %eax, %ebp
testl %eax, %eax
jne 0x289c48
leal -0xfff(%r12), %eax
incl %r12d
cmpl %r15d, %eax
jbe 0x289bde
movl 0x58(%r14), %r12d
cmpl %r12d, %r15d
je 0x289d89
movq %r14, %rdi
callq 0x2889c8
jmp 0x289d89
leaq 0x60(%rbx), %r15
movq 0x60(%rbx), %r12
movb $0x1, %al
movl %eax, 0x4(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, (%r15)
cmpq %r12, (%r15)
jge 0x289d35
movl $0x0, 0x10(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
leaq 0x10(%rsp), %rcx
leaq 0x24(%rsp), %r8
callq 0x28a7b2
movl %eax, %ebp
movl 0x10(%rsp), %r13d
testl %r13d, %r13d
jne 0x289ce6
movl 0xb8(%rbx), %ecx
addq 0x68(%rbx), %rcx
cmpq 0x60(%rbx), %rcx
jne 0x289d2b
movq %r12, %rax
subq %rcx, %rax
movslq 0xbc(%rbx), %rcx
addq $0x8, %rcx
cqto
idivq %rcx
movq %rax, %r13
testl %ebp, %ebp
jne 0x289d2b
testl %r13d, %r13d
je 0x289d2b
movl $0x1, %r14d
cmpq %r12, (%r15)
jge 0x289d29
movq %rbx, %rdi
movq %r15, %rsi
movq 0x8(%rsp), %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x28a481
movl %eax, %ebp
testl %eax, %eax
jne 0x289d2b
leal 0x1(%r14), %eax
cmpl %r13d, %r14d
movl %eax, %r14d
jb 0x289cf5
jmp 0x289d2b
xorl %ebp, %ebp
testl %ebp, %ebp
je 0x289c89
jmp 0x289d37
xorl %ebp, %ebp
cmpb $0x0, 0x4(%rsp)
jne 0x289e36
movq 0x18(%rsp), %r14
movl 0x1c(%r14), %r13d
movslq 0xbc(%rbx), %rax
addq $0x4, %rax
imulq %r13, %rax
movq %rax, 0x10(%rsp)
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x289dcc
movl 0x2c(%r14), %eax
cmpl 0x88(%rdi), %eax
jne 0x289dd2
movl 0x20(%r14), %eax
jmp 0x289de6
movl $0x7, %ebp
jmp 0x289e49
xorl %ebp, %ebp
movq 0x118(%rbx), %rdi
callq 0x28a9bb
movq %rax, %r14
testq %rax, %rax
sete %al
testl %ebp, %ebp
setne %cl
orb %al, %cl
jne 0x289e49
movl 0x30(%r14), %esi
movq 0x20(%r14), %r14
movq %rbx, %rdi
callq 0x28a955
movl %eax, %ebp
testq %r14, %r14
je 0x289e49
testl %ebp, %ebp
je 0x289dab
jmp 0x289e49
testl %ebp, %ebp
jne 0x289e36
jmp 0x289e05
movl $0x0, 0x20(%r14)
movl 0x88(%rdi), %eax
movl %eax, 0x2c(%r14)
xorl %eax, %eax
cmpl 0x58(%rdi), %eax
jae 0x289e05
movl %eax, 0x58(%rdi)
movl 0x24(%r14), %eax
movl %eax, 0x60(%rdi)
movl 0x28(%r14), %eax
movl %eax, 0x64(%rdi)
callq 0x2889c8
movl 0x1c(%r14), %r13d
decl %r13d
leaq 0x10(%rsp), %r14
xorl %ebp, %ebp
incl %r13d
cmpl 0x38(%rbx), %r13d
jae 0x289e36
movq %rbx, %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x28a481
testl %eax, %eax
je 0x289e0f
movl %eax, %ebp
movq 0x8(%rsp), %rdi
callq 0x28a41d
testl %ebp, %ebp
jne 0x289e49
movq %r12, (%r15)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x4(%rsp)
jmp 0x289c89