// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movl 0x2c(%rdi), %ebp
testl %ebp, %ebp
jne 0x23383d
movq %rdi, %rbx
movl 0x80(%rdi), %eax
xorl %ebp, %ebp
cmpl %edx, %eax
jle 0x23383d
movl %esi, %r14d
xorl %r12d, %r12d
cmpl $0x1, %esi
setne %r12b
addl %edx, %r12d
movslq %r12d, %r13
imulq $0x30, %r13, %rcx
movq %rcx, 0x8(%rsp)
leaq 0x10(%rcx), %r15
cltq
cmpq %rax, %r13
jge 0x23352a
movq 0x78(%rbx), %rax
movq (%rax,%r15), %rdi
callq 0x233e95
incq %r13
movl 0x80(%rbx), %eax
addq $0x30, %r15
jmp 0x233507
movl %r12d, 0x80(%rbx)
cmpl $0x1, %r14d
je 0x233585
cmpq $0x0, 0x120(%rbx)
jne 0x23354f
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x23383d
testl %r12d, %r12d
movq 0x8(%rsp), %r14
je 0x2335be
addq 0x78(%rbx), %r14
movq %r14, %r13
addq $-0x30, %r13
je 0x2335be
movl -0x18(%r14), %edi
callq 0x231168
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x23373b
addq $-0x18, %r14
xorl %ecx, %ecx
jmp 0x2335d0
testl %r12d, %r12d
jne 0x23383d
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x23383d
xorl %ebp, %ebp
leaq 0x202559(%rip), %rcx    # 0x435b00
cmpq %rcx, %rax
jne 0x2335b5
xorl %esi, %esi
callq 0x230fc2
movl %eax, %ebp
andl $0x0, 0x38(%rbx)
jmp 0x23383d
leaq 0x20(%rbx), %r14
movb $0x1, %cl
movq $0x0, 0x10(%rsp)
xorl %r13d, %r13d
movl (%r14), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x16(%rbx)
testb %cl, %cl
movq %rbx, 0x8(%rsp)
je 0x2336af
movq 0x120(%rbx), %r15
testq %r15, %r15
je 0x233722
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
cmpb $0x0, 0x40(%r15)
je 0x233743
movabsq $0xffffffff000, %r12    # imm = 0xFFFFFFFF000
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 $0x1001, %r13d          # imm = 0x1001
addl 0x58(%r15), %r13d
xorl %ebp, %ebp
testl %ebp, %ebp
jne 0x233712
leal -0x1000(%r13), %ecx
cmpl %r14d, %ecx
ja 0x233712
movl %r13d, %eax
leaq (%r12,%rax), %rdx
addq $0x21, %rdx
movq 0x30(%r15), %rax
testq %r12, %rdx
je 0x23368e
shrq $0xc, %rdx
movslq %edx, %rdx
leal -0xfdf(%r13), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
shll $0x2, %ecx
addq (%rax,%rdx,8), %rcx
jmp 0x23369e
movq (%rax), %rax
movl %ecx, %ecx
leaq (%rax,%rcx,4), %rcx
addq $0x84, %rcx
movl (%rcx), %esi
movq %rbx, %rdi
callq 0x23433e
movl %eax, %ebp
incl %r13d
jmp 0x233645
movl %ecx, 0x1c(%rsp)
leaq 0x60(%rbx), %r15
movq 0x60(%rbx), %rdx
cmpq $0x0, 0x120(%rbx)
jne 0x23372e
movq 0x8(%r13), %r12
testq %r12, %r12
movq %rdx, %rbx
cmoveq %rdx, %r12
movq (%r13), %rax
movq %rax, (%r15)
xorl %ebp, %ebp
pushq $0x1
popq %r14
movq %r13, 0x28(%rsp)
testl %ebp, %ebp
jne 0x23377a
cmpq %r12, (%r15)
jge 0x233778
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq 0x10(%rsp), %rdx
movl %r14d, %ecx
movl %r14d, %r8d
callq 0x233ecf
movl %eax, %ebp
jmp 0x2336e5
cmpl 0x58(%r15), %r14d
je 0x233745
movq %r15, %rdi
callq 0x232697
jmp 0x233745
movl %ecx, 0x1c(%rsp)
leaq 0x60(%rbx), %r15
movq 0x60(%rbx), %rdx
movq %r13, 0x28(%rsp)
andq $0x0, (%r15)
xorl %ebp, %ebp
jmp 0x23377d
pushq $0x7
popq %rbp
jmp 0x23383d
xorl %ebp, %ebp
movq 0x118(%rbx), %rdi
callq 0x234394
testq %rax, %rax
je 0x23383d
testl %ebp, %ebp
jne 0x23383d
movq 0x20(%rax), %r14
movl 0x30(%rax), %esi
movq %rbx, %rdi
callq 0x23433e
movl %eax, %ebp
movq %r14, %rax
jmp 0x233751
xorl %ebp, %ebp
movq %rbx, %rdx
pushq $0x1
popq %r13
movq %rdx, %rbx
testl %ebp, %ebp
jne 0x233823
cmpq %rdx, (%r15)
jge 0x233823
andl $0x0, 0x20(%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
leaq 0x20(%rsp), %rcx
leaq 0x34(%rsp), %r8
callq 0x2341b5
movl %eax, %ebp
movl 0x20(%rsp), %r14d
testl %r14d, %r14d
jne 0x2337f0
movl 0xb8(%r12), %ecx
addq 0x68(%r12), %rcx
xorl %r14d, %r14d
cmpq 0x60(%r12), %rcx
jne 0x2337f0
movq %rbx, %rax
subq %rcx, %rax
movslq 0xbc(%r12), %rcx
addq $0x8, %rcx
cqto
idivq %rcx
movq %rax, %r14
xorl %r12d, %r12d
testl %ebp, %ebp
movq %rbx, %rdx
jne 0x233784
cmpl %r14d, %r12d
jae 0x233784
cmpq %rdx, (%r15)
jge 0x233784
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq 0x10(%rsp), %rdx
movl %r13d, %ecx
movl %r13d, %r8d
callq 0x233ecf
movl %eax, %ebp
incl %r12d
jmp 0x2337f3
cmpb $0x0, 0x1c(%rsp)
je 0x23384e
movq 0x10(%rsp), %rdi
callq 0x233e95
testl %ebp, %ebp
jne 0x23383d
movq %rbx, (%r15)
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rsp), %r12
movl 0x1c(%r12), %r14d
movq 0x8(%rsp), %rcx
movslq 0xbc(%rcx), %rax
addq $0x4, %rax
imulq %r14, %rax
movq %rax, 0x20(%rsp)
movq 0x120(%rcx), %rdi
testq %rdi, %rdi
je 0x2338c8
movl 0x2c(%r12), %eax
cmpl 0x88(%rdi), %eax
jne 0x233891
movl 0x20(%r12), %eax
jmp 0x2338a4
andl $0x0, 0x20(%r12)
movl 0x88(%rdi), %eax
movl %eax, 0x2c(%r12)
xorl %eax, %eax
xorl %ebp, %ebp
cmpl 0x58(%rdi), %eax
jae 0x2338c8
movl %eax, 0x58(%rdi)
movl 0x24(%r12), %eax
movl %eax, 0x60(%rdi)
movl 0x28(%r12), %eax
movl %eax, 0x64(%rdi)
callq 0x232697
movl 0x1c(%r12), %r14d
leaq 0x20(%rsp), %r12
pushq $0x1
popq %r13
testl %ebp, %ebp
movq 0x8(%rsp), %rdi
jne 0x23382a
cmpl 0x38(%rdi), %r14d
jae 0x23382a
movq %r12, %rsi
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
movl %r13d, %r8d
callq 0x233ecf
movl %eax, %ebp
incl %r14d
jmp 0x2338d1