// File: /workspace/github_c_makefile_star2_O2/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 0x1bcf3
movl %esi, %r15d
movq %rdi, %rsi
movl 0x80(%rdi), %eax
xorl %r14d, %r14d
cmpl %edx, %eax
jle 0x1bcf3
xorl %r13d, %r13d
cmpl $0x1, %r15d
setne %r13b
addl %edx, %r13d
movslq %r13d, %rbx
imulq $0x30, %rbx, %rcx
movq %rcx, -0x40(%rbp)
leaq 0x10(%rcx), %r12
movq %rsi, -0x30(%rbp)
cltq
cmpq %rax, %rbx
jge 0x1b9bf
movq 0x78(%rsi), %rax
movq (%rax,%r12), %rdi
callq 0x1b557
movq -0x30(%rbp), %rsi
incq %rbx
movl 0x80(%rsi), %eax
addq $0x30, %r12
jmp 0x1b998
movl %r13d, 0x80(%rsi)
cmpl $0x1, %r15d
je 0x1ba1b
cmpq $0x0, 0x118(%rsi)
jne 0x1b9e4
movq 0x50(%rsi), %rax
cmpq $0x0, (%rax)
je 0x1bcf3
testl %r13d, %r13d
movq -0x40(%rbp), %rbx
je 0x1ba58
addq 0x78(%rsi), %rbx
movq %rbx, %r14
addq $-0x30, %r14
je 0x1ba58
movl -0x18(%rbx), %edi
callq 0x19221
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x1bbe2
addq $-0x18, %rbx
xorl %ecx, %ecx
movq -0x30(%rbp), %rsi
jmp 0x1ba69
testl %r13d, %r13d
jne 0x1bcf3
movq 0x58(%rsi), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1bcf3
xorl %r14d, %r14d
leaq 0x6a462(%rip), %rcx     # 0x85ea0
cmpq %rcx, %rax
jne 0x1ba4f
callq 0x1905e
movq -0x30(%rbp), %rsi
movl %eax, %r14d
andl $0x0, 0x38(%rsi)
jmp 0x1bcf3
leaq 0x20(%rsi), %rbx
movb $0x1, %cl
movq $0x0, -0x38(%rbp)
xorl %r14d, %r14d
movl (%rbx), %eax
movl %eax, 0x1c(%rsi)
movb 0x10(%rsi), %al
movb %al, 0x15(%rsi)
testb %cl, %cl
je 0x1bb4e
movq 0x118(%rsi), %r12
testq %r12, %r12
je 0x1bbc9
movl 0x20(%rsi), %eax
movl %eax, 0x1c(%rsi)
cmpb $0x0, 0x40(%r12)
je 0x1bbeb
movabsq $0xffffffff000, %rbx    # imm = 0xFFFFFFFF000
movl 0x58(%r12), %r15d
movq 0x30(%r12), %rax
movq (%rax), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm1, 0x58(%r12)
movups %xmm0, 0x48(%r12)
movups %xmm2, 0x68(%r12)
movl $0x1001, %r13d          # imm = 0x1001
addl 0x58(%r12), %r13d
xorl %r14d, %r14d
testl %r14d, %r14d
jne 0x1bbb4
leal -0x1000(%r13), %ecx
cmpl %r15d, %ecx
ja 0x1bbb4
movl %r13d, %eax
leaq (%rbx,%rax), %rdx
addq $0x21, %rdx
movq 0x30(%r12), %rax
testq %rbx, %rdx
movq -0x30(%rbp), %rdi
je 0x1bb2f
shrq $0xc, %rdx
movslq %edx, %rdx
leal -0xfdf(%r13), %ecx
andl $0xfff, %ecx            # imm = 0xFFF
shll $0x2, %ecx
addq (%rax,%rdx,8), %rcx
jmp 0x1bb3f
movq (%rax), %rax
movl %ecx, %ecx
leaq (%rax,%rcx,4), %rcx
addq $0x84, %rcx
movl (%rcx), %esi
callq 0x1c7c0
movl %eax, %r14d
incl %r13d
jmp 0x1bae0
movl %ecx, -0x44(%rbp)
leaq 0x60(%rsi), %r12
movq 0x60(%rsi), %rdx
cmpq $0x0, 0x118(%rsi)
movq %r14, -0x58(%rbp)
jne 0x1bbd8
movq 0x8(%r14), %rbx
testq %rbx, %rbx
movq %rdx, %r13
cmoveq %rdx, %rbx
movq (%r14), %rax
movq %rax, (%r12)
xorl %r14d, %r14d
pushq $0x1
popq %r15
testl %r14d, %r14d
jne 0x1bc24
cmpq %rbx, (%r12)
movq -0x30(%rbp), %rsi
jge 0x1bc2a
movq %rsi, %rdi
movq %r12, %rsi
movq -0x38(%rbp), %rdx
movl %r15d, %ecx
movl %r15d, %r8d
callq 0x1c326
movl %eax, %r14d
jmp 0x1bb83
cmpl 0x58(%r12), %r15d
je 0x1bbc3
movq %r12, %rdi
callq 0x1a153
movq -0x30(%rbp), %rsi
jmp 0x1bbee
movl %ecx, -0x44(%rbp)
movq %r14, -0x58(%rbp)
leaq 0x60(%rsi), %r12
movq 0x60(%rsi), %rdx
andq $0x0, (%r12)
xorl %r14d, %r14d
jmp 0x1bc30
pushq $0x7
popq %r14
jmp 0x1bcf3
xorl %r14d, %r14d
movq 0x110(%rsi), %rdi
callq 0x1c848
testq %rax, %rax
je 0x1bcf3
testl %r14d, %r14d
movq -0x30(%rbp), %rdi
jne 0x1bcf3
movq 0x18(%rax), %rbx
movl 0x28(%rax), %esi
callq 0x1c7c0
movl %eax, %r14d
movq %rbx, %rax
jmp 0x1bbfa
movq -0x30(%rbp), %rsi
jmp 0x1bc2d
xorl %r14d, %r14d
movq %r13, %rdx
pushq $0x1
popq %r15
movq %rdx, -0x40(%rbp)
testl %r14d, %r14d
jne 0x1bcd4
cmpq %rdx, (%r12)
jge 0x1bcd4
andl $0x0, -0x50(%rbp)
movq %rsi, %rdi
xorl %esi, %esi
leaq -0x50(%rbp), %rcx
leaq -0x5c(%rbp), %r8
callq 0x1c634
movq -0x30(%rbp), %rsi
movl %eax, %r14d
movl -0x50(%rbp), %r13d
testl %r13d, %r13d
jne 0x1bc9e
movl 0xb8(%rsi), %ecx
addq 0x68(%rsi), %rcx
xorl %r13d, %r13d
cmpq 0x60(%rsi), %rcx
jne 0x1bc9e
movq -0x40(%rbp), %rax
subq %rcx, %rax
movslq 0xbc(%rsi), %rcx
addq $0x8, %rcx
cqto
idivq %rcx
movq %rax, %r13
xorl %ebx, %ebx
testl %r14d, %r14d
movq -0x40(%rbp), %rdx
jne 0x1bc38
cmpl %r13d, %ebx
jae 0x1bc38
cmpq %rdx, (%r12)
jge 0x1bc38
movq %rsi, %rdi
movq %r12, %rsi
movq -0x38(%rbp), %rdx
movl %r15d, %ecx
movl %r15d, %r8d
callq 0x1c326
movq -0x30(%rbp), %rsi
movl %eax, %r14d
incl %ebx
jmp 0x1bca0
cmpb $0x0, -0x44(%rbp)
je 0x1bd05
movq -0x38(%rbp), %rdi
callq 0x1b557
testl %r14d, %r14d
jne 0x1bcf3
movq -0x40(%rbp), %rax
movq %rax, (%r12)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x58(%rbp), %rcx
movl 0x1c(%rcx), %r15d
movslq 0xbc(%rsi), %rax
addq $0x4, %rax
imulq %r15, %rax
movq %rax, -0x50(%rbp)
movq 0x118(%rsi), %rdi
testq %rdi, %rdi
je 0x1bd7b
movl 0x2c(%rcx), %eax
cmpl 0x80(%rdi), %eax
movq %rcx, %rdx
jne 0x1bd42
movq %rdx, %rcx
movl 0x20(%rdx), %eax
jmp 0x1bd54
andl $0x0, 0x20(%rdx)
movl 0x80(%rdi), %eax
movq %rdx, %rcx
movl %eax, 0x2c(%rdx)
xorl %eax, %eax
xorl %r14d, %r14d
cmpl 0x58(%rdi), %eax
jae 0x1bd7b
movl %eax, 0x58(%rdi)
movq %rcx, %rbx
movl 0x24(%rcx), %eax
movl %eax, 0x60(%rdi)
movl 0x28(%rcx), %eax
movl %eax, 0x64(%rdi)
callq 0x1a153
movq -0x30(%rbp), %rsi
movl 0x1c(%rbx), %r15d
leaq -0x50(%rbp), %rbx
pushq $0x1
popq %r13
testl %r14d, %r14d
jne 0x1bcda
cmpl 0x38(%rsi), %r15d
jae 0x1bcda
movq %rsi, %rdi
movq %rbx, %rsi
movq -0x38(%rbp), %rdx
xorl %ecx, %ecx
movl %r13d, %r8d
callq 0x1c326
movq -0x30(%rbp), %rsi
movl %eax, %r14d
incl %r15d
jmp 0x1bd83