// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeCloseStatement
SQLITE_PRIVATE int sqlite3VdbeCloseStatement(Vdbe *p, int eOp){
  sqlite3 *const db = p->db;
  int rc = SQLITE_OK;

  /* If p->iStatement is greater than zero, then this Vdbe opened a 
  ** statement transaction that should be closed here. The only exception
  ** is that an IO error may have occurred, causing an emergency rollback.
  ** In this case (db->nStatement==0), and there is nothing to do.
  */
  if( db->nStatement && p->iStatement ){
    int i;
    const int iSavepoint = p->iStatement-1;

    assert( eOp==SAVEPOINT_ROLLBACK || eOp==SAVEPOINT_RELEASE);
    assert( db->nStatement>0 );
    assert( p->iStatement==(db->nStatement+db->nSavepoint) );

    for(i=0; i<db->nDb; i++){ 
      int rc2 = SQLITE_OK;
      Btree *pBt = db->aDb[i].pBt;
      if( pBt ){
        if( eOp==SAVEPOINT_ROLLBACK ){
          rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_ROLLBACK, iSavepoint);
        }
        if( rc2==SQLITE_OK ){
          rc2 = sqlite3BtreeSavepoint(pBt, SAVEPOINT_RELEASE, iSavepoint);
        }
        if( rc==SQLITE_OK ){
          rc = rc2;
        }
      }
    }
    db->nStatement--;
    p->iStatement = 0;

    if( rc==SQLITE_OK ){
      if( eOp==SAVEPOINT_ROLLBACK ){
        rc = sqlite3VtabSavepoint(db, SAVEPOINT_ROLLBACK, iSavepoint);
      }
      if( rc==SQLITE_OK ){
        rc = sqlite3VtabSavepoint(db, SAVEPOINT_RELEASE, iSavepoint);
      }
    }

    /* If the statement transaction is being rolled back, also restore the 
    ** database handles deferred constraint counter to the value it had when 
    ** the statement transaction was opened.  */
    if( eOp==SAVEPOINT_ROLLBACK ){
      db->nDeferredCons = p->nStmtDefCons;
      db->nDeferredImmCons = p->nStmtDefImmCons;
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x310(%rax)
je 0x2fa72
movq -0x8(%rbp), %rax
cmpl $0x0, 0xa8(%rax)
je 0x2fa72
movq -0x8(%rbp), %rax
movl 0xa8(%rax), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x2f9e1
movl $0x0, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x2f9d1
cmpl $0x2, -0xc(%rbp)
jne 0x2f9a9
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x2, %esi
callq 0x306d0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x2f9c3
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x1, %esi
callq 0x306d0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x2f9cf
movl -0x28(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x2f9d1
jmp 0x2f9d3
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x2f95a
movq -0x18(%rbp), %rax
movl 0x310(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x310(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xa8(%rax)
cmpl $0x0, -0x1c(%rbp)
jne 0x2fa3e
cmpl $0x2, -0xc(%rbp)
jne 0x2fa22
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x2, %esi
callq 0x30790
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x2fa3c
movq -0x18(%rbp), %rdi
movl -0x24(%rbp), %edx
movl $0x1, %esi
callq 0x30790
movl %eax, -0x1c(%rbp)
jmp 0x2fa3e
cmpl $0x2, -0xc(%rbp)
jne 0x2fa70
movq -0x8(%rbp), %rax
movq 0xd0(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x318(%rax)
movq -0x8(%rbp), %rax
movq 0xd8(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x320(%rax)
jmp 0x2fa72
movl -0x1c(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)