// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movl 0x2c(%rdi), %r15d
testl %r15d, %r15d
jne 0x1e6f4
movq %rdi, %rbx
xorl %r15d, %r15d
cmpl %edx, 0x80(%rdi)
jle 0x1e6f4
movl %esi, %r14d
xorl %eax, %eax
cmpl $0x1, %esi
setne %al
addl %edx, %eax
movl %eax, -0x38(%rbp)
cmpl 0x80(%rbx), %eax
jge 0x1e413
xorl %r13d, %r13d
cmpl $0x1, %r14d
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 0x1df1e
incq %r13
movslq 0x80(%rbx), %rax
addq $0x30, %r12
cmpq %rax, %r13
jl 0x1e3f3
movl -0x38(%rbp), %ecx
movl %ecx, 0x80(%rbx)
cmpl $0x1, %r14d
je 0x1e457
cmpq $0x0, 0x118(%rbx)
jne 0x1e43a
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1e6f4
testl %ecx, %ecx
je 0x1e492
movq 0x78(%rbx), %rax
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %r12
addq $-0x30, %r12
jmp 0x1e495
testl %ecx, %ecx
jne 0x1e6f4
movq 0x58(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1e6f4
xorl %r15d, %r15d
leaq 0x749d7(%rip), %rcx     # 0x92e50
cmpq %rcx, %rax
jne 0x1e486
xorl %esi, %esi
callq *0x20(%rax)
movl %eax, %r15d
movl $0x0, 0x38(%rbx)
jmp 0x1e6f4
xorl %r12d, %r12d
testq %r12, %r12
je 0x1e4ca
movl 0x18(%r12), %r14d
movl $0x200, %edi            # imm = 0x200
callq 0xa2a2
testq %rax, %rax
je 0x1e535
movq %rax, %r13
movl $0x200, %edx            # imm = 0x200
movq %rax, %rdi
xorl %esi, %esi
callq 0x8200
movl %r14d, (%r13)
jmp 0x1e4cd
xorl %r13d, %r13d
leaq 0x18(%r12), %rax
leaq 0x20(%rbx), %rcx
testq %r12, %r12
cmoveq %rcx, %rax
movl (%rax), %eax
movl %eax, 0x1c(%rbx)
movb 0x10(%rbx), %al
movb %al, 0x15(%rbx)
je 0x1e515
leaq 0x60(%rbx), %rcx
movq 0x60(%rbx), %rdx
testq %r12, %r12
movq %rcx, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
je 0x1e509
cmpq $0x0, 0x118(%rbx)
je 0x1e540
movq $0x0, (%rcx)
xorl %r15d, %r15d
jmp 0x1e586
cmpq $0x0, 0x118(%rbx)
je 0x1e4ea
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1ec85
movl $0x7, %r15d
jmp 0x1e6f4
movq (%r12), %rax
movq 0x8(%r12), %r14
testq %r14, %r14
cmoveq %rdx, %r14
movq %rax, (%rcx)
cmpq %r14, (%rcx)
jge 0x1e57f
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
movq %r13, %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1edbc
movq -0x38(%rbp), %rcx
testl %eax, %eax
je 0x1e553
movl %eax, %r15d
jmp 0x1e582
xorl %r15d, %r15d
movq -0x30(%rbp), %rdx
movq %r12, -0x48(%rbp)
testl %r15d, %r15d
jne 0x1e66b
cmpq %rdx, 0x60(%rbx)
jge 0x1e66b
movl $0x0, -0x40(%rbp)
movq %rbx, %rdi
xorl %esi, %esi
leaq -0x40(%rbp), %rcx
leaq -0x4c(%rbp), %r8
callq 0x1f0db
movl %eax, %r15d
cmpl $0x0, -0x40(%rbp)
jne 0x1e5ec
movl 0xb8(%rbx), %eax
addq 0x68(%rbx), %rax
movq 0x60(%rbx), %rcx
cmpq %rcx, %rax
jne 0x1e5ec
movq -0x30(%rbp), %rax
subq %rcx, %rax
movslq 0xbc(%rbx), %rcx
addq $0x8, %rcx
cqto
idivq %rcx
movl %eax, -0x40(%rbp)
movq %r13, %r12
movl -0x40(%rbp), %r14d
testl %r15d, %r15d
sete %al
testl %r14d, %r14d
setne %cl
andb %al, %cl
cmpb $0x1, %cl
movq -0x38(%rbp), %rsi
jne 0x1e651
movq -0x30(%rbp), %rdx
cmpq %rdx, (%rsi)
jge 0x1e655
movl $0x1, %r13d
movq %rbx, %rdi
movq %r12, %rdx
movl $0x1, %ecx
movl $0x1, %r8d
callq 0x1edbc
movl %eax, %r15d
testl %eax, %eax
jne 0x1e64d
cmpl %r14d, %r13d
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
jae 0x1e655
incl %r13d
cmpq %rdx, (%rsi)
jl 0x1e619
jmp 0x1e655
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
testl %r15d, %r15d
jne 0x1e668
cmpq %rdx, (%rsi)
movq %r12, %r13
jl 0x1e59d
jmp 0x1e66b
movq %r12, %r13
movq -0x48(%rbp), %r14
testq %r14, %r14
je 0x1e6dc
movl 0x1c(%r14), %eax
movslq 0xbc(%rbx), %rcx
addq $0x4, %rcx
imulq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x1e6a3
leaq 0x20(%r14), %rsi
callq 0x1f28d
xorl %r15d, %r15d
testl %r15d, %r15d
jne 0x1e6dc
movl 0x1c(%r14), %r14d
cmpl 0x38(%rbx), %r14d
jae 0x1e6dc
leaq -0x40(%rbp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x1edbc
movl %eax, %r15d
testl %eax, %eax
jne 0x1e6dc
incl %r14d
cmpl 0x38(%rbx), %r14d
jb 0x1e6b6
movq %r13, %rdi
callq 0x1df1e
testl %r15d, %r15d
jne 0x1e6f4
movq -0x38(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq