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

  /* If the VM did not run to completion or if it encountered an
  ** error, then it might not have been halted properly.  So halt
  ** it now.
  */
  sqlite3VdbeHalt(p);

  /* If the VDBE has be run even partially, then transfer the error code
  ** and error message from the VDBE into the main database structure.  But
  ** if the VDBE has just been set to run but has not actually executed any
  ** instructions yet, leave the main database error information unchanged.
  */
  if( p->pc>=0 ){
    vdbeInvokeSqllog(p);
    sqlite3VdbeTransferError(p);
    sqlite3DbFree(db, p->zErrMsg);
    p->zErrMsg = 0;
    if( p->runOnlyOnce ) p->expired = 1;
  }else if( p->rc && p->expired ){
    /* The expired flag was set on the VDBE before the first call
    ** to sqlite3_step(). For consistency (since sqlite3_step() was
    ** called), set the database error in this case as well.
    */
    sqlite3Error(db, p->rc, 0);
    sqlite3ValueSetStr(db->pErr, -1, p->zErrMsg, SQLITE_UTF8, SQLITE_TRANSIENT);
    sqlite3DbFree(db, p->zErrMsg);
    p->zErrMsg = 0;
  }

  /* Reclaim all memory used by the VDBE
  */
  Cleanup(p);

  /* Save profiling information from this VDBE run.
  */
#ifdef VDBE_PROFILE
  {
    FILE *out = fopen("vdbe_profile.out", "a");
    if( out ){
      int i;
      fprintf(out, "---- ");
      for(i=0; i<p->nOp; i++){
        fprintf(out, "%02x", p->aOp[i].opcode);
      }
      fprintf(out, "\n");
      for(i=0; i<p->nOp; i++){
        fprintf(out, "%6d %10lld %8lld ",
           p->aOp[i].cnt,
           p->aOp[i].cycles,
           p->aOp[i].cnt>0 ? p->aOp[i].cycles/p->aOp[i].cnt : 0
        );
        sqlite3VdbePrintOp(out, i, &p->aOp[i]);
      }
      fclose(out);
    }
  }
#endif
  p->magic = VDBE_MAGIC_INIT;
  return p->rc & db->errMask;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2e820
movq -0x8(%rbp), %rax
cmpl $0x0, 0x90(%rax)
jl 0xff7d
movq -0x8(%rbp), %rdi
callq 0x2ed60
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0x9cd0
movq -0x8(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x8(%rbp), %rax
movw 0x9a(%rax), %ax
shrw $0x6, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0xff78
movq -0x8(%rbp), %rax
movw 0x9a(%rax), %cx
andw $-0x21, %cx
orw $0x20, %cx
movw %cx, 0x9a(%rax)
jmp 0x10006
movq -0x8(%rbp), %rax
cmpl $0x0, 0x94(%rax)
je 0x10004
movq -0x8(%rbp), %rax
movw 0x9a(%rax), %ax
shrw $0x5, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x10004
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x94(%rax), %esi
xorl %eax, %eax
movl %eax, %edx
movb $0x0, %al
callq 0xd720
movq -0x10(%rbp), %rax
movq 0x130(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %ecx
movq $-0x1, %r8
callq 0x16fd0
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rsi
callq 0x9cd0
movq -0x8(%rbp), %rax
movq $0x0, 0x58(%rax)
jmp 0x10006
movq -0x8(%rbp), %rdi
callq 0x2ee00
movq -0x8(%rbp), %rax
movl $0x26bceaa5, 0x50(%rax) # imm = 0x26BCEAA5
movq -0x8(%rbp), %rax
movl 0x94(%rax), %eax
movq -0x10(%rbp), %rcx
andl 0x48(%rcx), %eax
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)