// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl 0x2c(%rdi), %r14d
testl %r14d, %r14d
jne 0x1e5be
movq %rdi, %rbx
movl 0x80(%rdi), %eax
xorl %r14d, %r14d
cmpl %edx, %eax
jle 0x1e5be
movl %esi, %r15d
xorl %ecx, %ecx
cmpl $0x1, %esi
setne %cl
addl %edx, %ecx
movl %ecx, -0x30(%rbp)
cmpl %eax, %ecx
jge 0x1e207
xorl %r13d, %r13d
cmpl $0x1, %r15d
setne %r13b
movslq %edx, %rax
addq %rax, %r13
leaq (,%r13,2), %r12
addq %r13, %r12
shlq $0x4, %r12
addq $0x10, %r12
movq 0x78(%rbx), %rax
movq (%rax,%r12), %rdi
callq 0x1dcec
incq %r13
movslq 0x80(%rbx), %rax
addq $0x30, %r12
cmpq %rax, %r13
jl 0x1e1e7
movl -0x30(%rbp), %ecx
movl %ecx, 0x80(%rbx)
cmpl $0x1, %r15d
je 0x1e2a1
movq 0x118(%rbx), %r15
testq %r15, %r15
jne 0x1e234
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1e5be
testl %ecx, %ecx
je 0x1e308
movslq %ecx, %rax
leaq (%rax,%rax,2), %r14
shlq $0x4, %r14
addq 0x78(%rbx), %r14
movq %r14, %rax
addq $-0x30, %rax
je 0x1e308
movq %rax, -0x50(%rbp)
movl -0x18(%r14), %edi
callq 0x1b61e
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x1e554
movl -0x18(%r14), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x15(%rbx)
leaq 0x60(%rbx), %rsi
movq 0x60(%rbx), %r12
cmpq $0x0, 0x118(%rbx)
je 0x1e5d0
movl $0x0, -0x34(%rbp)
jmp 0x1e410
testl %ecx, %ecx
jne 0x1e5be
movq 0x58(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x1e5be
leaq 0x74b90(%rip), %r14     # 0x92e50
cmpq %r14, %rax
jne 0x1e2fc
leaq 0x8(%r15), %r12
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x1e2e2
movq (%rdi), %r13
callq 0xa3c7
movq %r13, %rdi
testq %r13, %r13
jne 0x1e2d2
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movq $0x0, 0x20(%r12)
movq %r14, (%r15)
movl $0x0, 0x38(%rbx)
jmp 0x1e5bb
movl 0x20(%rbx), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x15(%rbx)
testq %r15, %r15
je 0x1e3f3
cmpb $0x0, 0x40(%r15)
je 0x1e55c
movl 0x58(%r15), %ecx
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), %r13d
leal 0x1(%r13), %eax
xorl %r14d, %r14d
movl %ecx, -0x30(%rbp)
cmpl %ecx, %eax
ja 0x1e3dc
movabsq $0xffffffff000, %r12    # imm = 0xFFFFFFFF000
addl $0x1001, %r13d          # imm = 0x1001
movl %r13d, %eax
leaq (%r12,%rax), %rcx
addq $0x21, %rcx
movq 0x30(%r15), %rax
testq %r12, %rcx
je 0x1e3a1
shrq $0xc, %rcx
movslq %ecx, %rdx
leal -0xfdf(%r13), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
shll $0x2, %ecx
addq (%rax,%rdx,8), %rcx
jmp 0x1e3b8
leal -0x1000(%r13), %ecx
movq (%rax), %rax
movl %ecx, %ecx
leaq (%rax,%rcx,4), %rcx
addq $0x84, %rcx
movl (%rcx), %esi
movq %rbx, %rdi
callq 0x1f0d9
movl %eax, %r14d
testl %eax, %eax
jne 0x1e3d8
leal -0xfff(%r13), %eax
incl %r13d
cmpl -0x30(%rbp), %eax
jbe 0x1e370
movl 0x58(%r15), %r13d
cmpl %r13d, -0x30(%rbp)
je 0x1e55f
movq %r15, %rdi
callq 0x1c6df
jmp 0x1e55f
leaq 0x60(%rbx), %rsi
movq 0x60(%rbx), %r12
movb $0x1, %al
movl %eax, -0x34(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, (%rsi)
movq %r12, %r15
movq %rsi, -0x30(%rbp)
cmpq %r12, (%rsi)
jge 0x1e4d9
movl $0x0, -0x48(%rbp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
leaq -0x48(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x1eef1
movl %eax, %r14d
movl -0x48(%rbp), %r13d
testl %r13d, %r13d
jne 0x1e478
movl 0xb8(%rbx), %ecx
addq 0x68(%rbx), %rcx
cmpq 0x60(%rbx), %rcx
jne 0x1e4c2
subq %rcx, %r12
movslq 0xbc(%rbx), %rcx
addq $0x8, %rcx
movq %r12, %rax
cqto
idivq %rcx
movq %rax, %r13
testl %r14d, %r14d
jne 0x1e4c2
testl %r13d, %r13d
movq -0x30(%rbp), %rsi
je 0x1e4cb
movl $0x1, %r12d
cmpq %r15, (%rsi)
jge 0x1e4c8
movq %rbx, %rdi
movq -0x40(%rbp), %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1eb8f
movl %eax, %r14d
testl %eax, %eax
jne 0x1e4c2
leal 0x1(%r12), %eax
cmpl %r13d, %r12d
movl %eax, %r12d
movq -0x30(%rbp), %rsi
jb 0x1e48c
jmp 0x1e4cb
movq -0x30(%rbp), %rsi
jmp 0x1e4cb
xorl %r14d, %r14d
testl %r14d, %r14d
movq %r15, %r12
je 0x1e41e
jmp 0x1e4dc
xorl %r14d, %r14d
cmpb $0x0, -0x34(%rbp)
jne 0x1e5a6
movq -0x50(%rbp), %rcx
movl 0x1c(%rcx), %r13d
movslq 0xbc(%rbx), %rax
addq $0x4, %rax
imulq %r13, %rax
movq %rax, -0x48(%rbp)
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x1e59d
movq %rcx, %r14
leaq 0x20(%rcx), %rsi
callq 0x1f099
movl 0x1c(%r14), %r13d
decl %r13d
leaq -0x48(%rbp), %r15
xorl %r14d, %r14d
incl %r13d
cmpl 0x38(%rbx), %r13d
jae 0x1e5a6
movq %rbx, %rdi
movq %r15, %rsi
movq -0x40(%rbp), %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x1eb8f
testl %eax, %eax
je 0x1e52b
movl %eax, %r14d
jmp 0x1e5a6
movl $0x7, %r14d
jmp 0x1e5be
xorl %r14d, %r14d
movq 0x110(%rbx), %rdi
callq 0x1f18c
movq %rax, %r15
testq %rax, %rax
sete %al
testl %r14d, %r14d
setne %cl
orb %al, %cl
jne 0x1e5be
movl 0x28(%r15), %esi
movq 0x18(%r15), %r15
movq %rbx, %rdi
callq 0x1f0d9
movl %eax, %r14d
testq %r15, %r15
je 0x1e5be
testl %r14d, %r14d
je 0x1e57e
jmp 0x1e5be
testl %r14d, %r14d
je 0x1e521
movq -0x40(%rbp), %rdi
callq 0x1dcec
testl %r14d, %r14d
jne 0x1e5be
movq -0x30(%rbp), %rax
movq %r12, (%rax)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%r14), %rax
movq %r12, %rcx
movq -0x28(%r14), %r12
testq %r12, %r12
movq %rcx, %r15
cmoveq %rcx, %r12
movq %rax, (%rsi)
movq %rsi, -0x30(%rbp)
cmpq %r12, (%rsi)
jge 0x1e61f
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1eb8f
movq -0x30(%rbp), %rsi
testl %eax, %eax
je 0x1e5ec
movl %eax, %r14d
movq %r15, %r12
jmp 0x1e4e6
movl $0x0, -0x34(%rbp)
movq %r15, %r12
jmp 0x1e417