// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3Step
static int sqlite3Step(Vdbe *p){
  sqlite3 *db;
  int rc;

  assert(p);
  if( p->magic!=VDBE_MAGIC_RUN ){
    /* We used to require that sqlite3_reset() be called before retrying
    ** sqlite3_step() after any error or after SQLITE_DONE.  But beginning
    ** with version 3.7.0, we changed this so that sqlite3_reset() would
    ** be called automatically instead of throwing the SQLITE_MISUSE error.
    ** This "automatic-reset" change is not technically an incompatibility, 
    ** since any application that receives an SQLITE_MISUSE is broken by
    ** definition.
    **
    ** Nevertheless, some published applications that were originally written
    ** for version 3.6.23 or earlier do in fact depend on SQLITE_MISUSE 
    ** returns, and those were broken by the automatic-reset change.  As a
    ** a work-around, the SQLITE_OMIT_AUTORESET compile-time restores the
    ** legacy behavior of returning SQLITE_MISUSE for cases where the 
    ** previous sqlite3_step() returned something other than a SQLITE_LOCKED
    ** or SQLITE_BUSY error.
    */
#ifdef SQLITE_OMIT_AUTORESET
    if( p->rc==SQLITE_BUSY || p->rc==SQLITE_LOCKED ){
      sqlite3_reset((sqlite3_stmt*)p);
    }else{
      return SQLITE_MISUSE_BKPT;
    }
#else
    sqlite3_reset((sqlite3_stmt*)p);
#endif
  }

  /* Check that malloc() has not failed. If it has, return early. */
  db = p->db;
  if( db->mallocFailed ){
    p->rc = SQLITE_NOMEM;
    return SQLITE_NOMEM;
  }

  if( p->pc<=0 && p->expired ){
    p->rc = SQLITE_SCHEMA;
    rc = SQLITE_ERROR;
    goto end_of_step;
  }
  if( p->pc<0 ){
    /* If there are no other statements currently running, then
    ** reset the interrupt flag.  This prevents a call to sqlite3_interrupt
    ** from interrupting a statement that has not yet started.
    */
    if( db->nVdbeActive==0 ){
      db->u1.isInterrupted = 0;
    }

    assert( db->nVdbeWrite>0 || db->autoCommit==0 
        || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
    );

#ifndef SQLITE_OMIT_TRACE
    if( db->xProfile && !db->init.busy ){
      sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
    }
#endif

    db->nVdbeActive++;
    if( p->readOnly==0 ) db->nVdbeWrite++;
    if( p->bIsReader ) db->nVdbeRead++;
    p->pc = 0;
  }
#ifndef SQLITE_OMIT_EXPLAIN
  if( p->explain ){
    rc = sqlite3VdbeList(p);
  }else
#endif /* SQLITE_OMIT_EXPLAIN */
  {
    db->nVdbeExec++;
    rc = sqlite3VdbeExec(p);
    db->nVdbeExec--;
  }

#ifndef SQLITE_OMIT_TRACE
  /* Invoke the profile callback if there is one
  */
  if( rc!=SQLITE_ROW && db->xProfile && !db->init.busy && p->zSql ){
    sqlite3_int64 iNow;
    sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
    db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000);
  }
#endif

  if( rc==SQLITE_DONE ){
    assert( p->rc==SQLITE_OK );
    p->rc = doWalCallbacks(db);
    if( p->rc!=SQLITE_OK ){
      rc = SQLITE_ERROR;
    }
  }

  db->errCode = rc;
  if( SQLITE_NOMEM==sqlite3ApiExit(p->db, p->rc) ){
    p->rc = SQLITE_NOMEM;
  }
end_of_step:
  /* At this point local variable rc holds the value that should be 
  ** returned if this statement was compiled using the legacy 
  ** sqlite3_prepare() interface. According to the docs, this can only
  ** be one of the values in the first assert() below. Variable p->rc 
  ** contains the value that would be returned if sqlite3_finalize() 
  ** were called on statement p.
  */
  assert( rc==SQLITE_ROW  || rc==SQLITE_DONE   || rc==SQLITE_ERROR 
       || rc==SQLITE_BUSY || rc==SQLITE_MISUSE
  );
  assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE );
  if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
    /* If this statement was prepared using sqlite3_prepare_v2(), and an
    ** error has occurred, then return the error code in p->rc to the
    ** caller. Set the error code in the database handle to the same value.
    */ 
    rc = sqlite3VdbeTransferError(p);
  }
  return (rc&db->errMask);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0xbdf20da3, 0x50(%rax) # imm = 0xBDF20DA3
je 0x11392
movq -0x10(%rbp), %rdi
callq 0xfe90
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0x113c1
movq -0x10(%rbp), %rax
movl $0x7, 0x94(%rax)
movl $0x7, -0x4(%rbp)
jmp 0x11659
movq -0x10(%rbp), %rax
cmpl $0x0, 0x90(%rax)
jg 0x11403
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
shrw $0x5, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x11403
movq -0x10(%rbp), %rax
movl $0x11, 0x94(%rax)
movl $0x1, -0x1c(%rbp)
jmp 0x11619
movq -0x10(%rbp), %rax
cmpl $0x0, 0x90(%rax)
jge 0x114de
movq -0x18(%rbp), %rax
cmpl $0x0, 0x9c(%rax)
jne 0x1142f
movq -0x18(%rbp), %rax
movl $0x0, 0x148(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x11461
movq -0x18(%rbp), %rax
cmpb $0x0, 0x99(%rax)
jne 0x11461
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0xc0, %rsi
callq 0x32110
movq -0x18(%rbp), %rax
movl 0x9c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x9c(%rax)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
shrw $0x8, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x114a2
movq -0x18(%rbp), %rax
movl 0xa4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa4(%rax)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
shrw $0x9, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x114d0
movq -0x18(%rbp), %rax
movl 0xa0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa0(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x90(%rax)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
andw $0x3, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x11503
movq -0x10(%rbp), %rdi
callq 0x32190
movl %eax, -0x1c(%rbp)
jmp 0x11535
movq -0x18(%rbp), %rax
movl 0xa8(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xa8(%rax)
movq -0x10(%rbp), %rdi
callq 0x327c0
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rax
movl 0xa8(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0xa8(%rax)
cmpl $0x64, -0x1c(%rbp)
je 0x115ad
movq -0x18(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x115ad
movq -0x18(%rbp), %rax
cmpb $0x0, 0x99(%rax)
jne 0x115ad
movq -0x10(%rbp), %rax
cmpq $0x0, 0xe0(%rax)
je 0x115ad
movq -0x18(%rbp), %rax
movq (%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x32110
movq -0x18(%rbp), %rax
movq 0xc8(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0xd0(%rcx), %rdi
movq -0x10(%rbp), %rcx
movq 0xe0(%rcx), %rsi
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rdx
subq 0xc0(%rdx), %rcx
imulq $0xf4240, %rcx, %rdx    # imm = 0xF4240
callq *%rax
cmpl $0x65, -0x1c(%rbp)
jne 0x115de
movq -0x18(%rbp), %rdi
callq 0x3a700
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x94(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x94(%rax)
je 0x115dc
movl $0x1, -0x1c(%rbp)
jmp 0x115de
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x94(%rax), %esi
callq 0xfe10
movl %eax, %ecx
movl $0x7, %eax
cmpl %ecx, %eax
jne 0x11617
movq -0x10(%rbp), %rax
movl $0x7, 0x94(%rax)
jmp 0x11619
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
shrw $0xa, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
je 0x1164c
cmpl $0x64, -0x1c(%rbp)
je 0x1164c
cmpl $0x65, -0x1c(%rbp)
je 0x1164c
movq -0x10(%rbp), %rdi
callq 0x2ed60
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
andl 0x48(%rcx), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)