// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3VdbeMakeReady
SQLITE_PRIVATE void sqlite3VdbeMakeReady(
  Vdbe *p,                       /* The VDBE */
  Parse *pParse                  /* Parsing context */
){
  sqlite3 *db;                   /* The database connection */
  int nVar;                      /* Number of parameters */
  int nMem;                      /* Number of VM memory registers */
  int nCursor;                   /* Number of cursors required */
  int nArg;                      /* Number of arguments in subprograms */
  int n;                         /* Loop counter */
  struct ReusableSpace x;        /* Reusable bulk memory */

  assert( p!=0 );
  assert( p->nOp>0 );
  assert( pParse!=0 );
  assert( p->magic==VDBE_MAGIC_INIT );
  assert( pParse==p->pParse );
  db = p->db;
  assert( db->mallocFailed==0 );
  nVar = pParse->nVar;
  nMem = pParse->nMem;
  nCursor = pParse->nTab;
  nArg = pParse->nMaxArg;

  /* Each cursor uses a memory cell.  The first cursor (cursor 0) can
  ** use aMem[0] which is not otherwise used by the VDBE program.  Allocate
  ** space at the end of aMem[] for cursors 1 and greater.
  ** See also: allocateCursor().
  */
  nMem += nCursor;
  if( nCursor==0 && nMem>0 ) nMem++;  /* Space for aMem[0] even if not used */

  /* Figure out how much reusable memory is available at the end of the
  ** opcode array.  This extra memory will be reallocated for other elements
  ** of the prepared statement.
  */
  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode memory used */
  x.pSpace = &((u8*)p->aOp)[n];               /* Unused opcode memory */
  assert( EIGHT_BYTE_ALIGNMENT(x.pSpace) );
  x.nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused memory */
  assert( x.nFree>=0 );
  assert( EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree]) );

  resolveP2Values(p, &nArg);
  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
  if( pParse->explain ){
    static const char * const azColName[] = {
       "addr", "opcode", "p1", "p2", "p3", "p4", "p5", "comment",
       "id", "parent", "notused", "detail"
    };
    int iFirst, mx, i;
    if( nMem<10 ) nMem = 10;
    p->explain = pParse->explain;
    if( pParse->explain==2 ){
      sqlite3VdbeSetNumCols(p, 4);
      iFirst = 8;
      mx = 12;
    }else{
      sqlite3VdbeSetNumCols(p, 8);
      iFirst = 0;
      mx = 8;
    }
    for(i=iFirst; i<mx; i++){
      sqlite3VdbeSetColName(p, i-iFirst, COLNAME_NAME,
                            azColName[i], SQLITE_STATIC);
    }
  }
  p->expired = 0;

  /* Memory for registers, parameters, cursor, etc, is allocated in one or two
  ** passes.  On the first pass, we try to reuse unused memory at the
  ** end of the opcode array.  If we are unable to satisfy all memory
  ** requirements by reusing the opcode array tail, then the second
  ** pass will fill in the remainder using a fresh memory allocation.
  **
  ** This two-pass approach that reuses as much memory as possible from
  ** the leftover memory at the end of the opcode array.  This can significantly
  ** reduce the amount of memory held by a prepared statement.
  */
  x.nNeeded = 0;
  p->aMem = allocSpace(&x, 0, nMem*sizeof(Mem));
  p->aVar = allocSpace(&x, 0, nVar*sizeof(Mem));
  p->apArg = allocSpace(&x, 0, nArg*sizeof(Mem*));
  p->apCsr = allocSpace(&x, 0, nCursor*sizeof(VdbeCursor*));
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
  p->anExec = allocSpace(&x, 0, p->nOp*sizeof(i64));
#endif
  if( x.nNeeded ){
    x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);
    x.nFree = x.nNeeded;
    if( !db->mallocFailed ){
      p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));
      p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
      p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
      p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
      p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));
#endif
    }
  }

  p->pVList = pParse->pVList;
  pParse->pVList =  0;
  if( db->mallocFailed ){
    p->nVar = 0;
    p->nCursor = 0;
    p->nMem = 0;
  }else{
    p->nCursor = nCursor;
    p->nVar = (ynVar)nVar;
    initMemArray(p->aVar, nVar, db, MEM_Null);
    p->nMem = nMem;
    initMemArray(p->aMem, nMem, db, MEM_Undefined);
    memset(p->apCsr, 0, nCursor*sizeof(VdbeCursor*));
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
    memset(p->anExec, 0, p->nOp*sizeof(i64));
#endif
  }
  sqlite3VdbeRewind(p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r13
movq %rdi, %rbx
movq (%rdi), %rax
movq %rax, 0x10(%rsp)
movzwl 0x118(%rsi), %r15d
movslq 0x34(%rsi), %rcx
testq %rcx, %rcx
sete %al
movq %rcx, 0x18(%rsp)
movl %ecx, %edx
movl 0x80(%rsi), %ecx
movl 0x38(%rsi), %ebp
movl %edx, 0x30(%rsp)
addl %edx, %ebp
leaq 0x34(%rsp), %rsi
movl %ecx, (%rsi)
testl %ebp, %ebp
setg %cl
andb %al, %cl
movzbl %cl, %r14d
movl 0x90(%rdi), %eax
shll $0x3, %eax
leal (%rax,%rax,2), %eax
cltq
movq 0x88(%rdi), %rcx
addq %rax, %rcx
movq %rcx, 0x20(%rsp)
movslq 0x3c(%r13), %r12
subq %rax, %r12
callq 0x2a85f9
cmpb $0x0, 0x20(%r13)
je 0x27b878
xorl %eax, %eax
cmpb $0x0, 0x21(%r13)
setne %al
shll $0x6, %eax
jmp 0x27b87a
xorl %eax, %eax
movw %r15w, 0xe(%rsp)
movswq %r15w, %r9
addl %r14d, %ebp
movq %r12, %r8
andq $-0x8, %r8
movzwl 0xc6(%rbx), %ecx
andl $-0x41, %ecx
movzwl %ax, %eax
orl %ecx, %eax
movw %ax, 0xc6(%rbx)
movzbl 0x11b(%r13), %ecx
testw %cx, %cx
movq 0x18(%rsp), %rdx
movq %r13, 0x28(%rsp)
je 0x27b97d
movq %r9, 0x38(%rsp)
movq %r8, 0x40(%rsp)
cmpl $0xb, %ebp
movl $0xa, %edx
cmovll %edx, %ebp
movzwl %cx, %ecx
andl $0x3, %ecx
andl $-0xd, %eax
leal (%rax,%rcx,4), %eax
movw %ax, 0xc6(%rbx)
xorl %r12d, %r12d
xorl %eax, %eax
cmpb $0x2, 0x11b(%r13)
sete %r12b
setne %al
leal 0x4(,%rax,4), %esi
leal (,%r12,8), %r13d
leaq 0x8(,%r12,4), %r14
movq %rbx, %rdi
callq 0x2a871c
shll $0x5, %r12d
leaq 0x15699b(%rip), %rax    # 0x3d22c0
addq %rax, %r12
xorl %r15d, %r15d
movq (%rbx), %rax
cmpb $0x0, 0x61(%rax)
jne 0x27b95e
movslq (%r12), %rsi
leaq 0x156981(%rip), %rax    # 0x3d22c0
addq %rax, %rsi
movq 0x98(%rbx), %rdi
addq %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
xorl %r8d, %r8d
callq 0x278594
incq %r13
addq $0x4, %r12
addq $0x38, %r15
cmpq %r14, %r13
jb 0x27b92b
movq 0x18(%rsp), %rdx
movq 0x40(%rsp), %r8
movq 0x38(%rsp), %r9
andb $-0x4, 0xc6(%rbx)
movslq %ebp, %rax
imulq $0x38, %rax, %r12
xorl %eax, %eax
movq %r8, %rcx
subq %r12, %rcx
movq 0x20(%rsp), %r10
leaq (%r10,%rcx), %rdi
movl $0x0, %esi
cmovlq %r12, %rsi
cmovlq %r8, %rcx
cmovlq %rax, %rdi
movq %rdi, 0x68(%rbx)
imulq $0x38, %r9, %r11
movq %rcx, %r9
subq %r11, %r9
leaq (%r10,%r9), %rdi
movl $0x0, %r8d
cmovlq %r11, %r8
cmovlq %rcx, %r9
cmovlq %rax, %rdi
addq %rsi, %r8
movq %rdi, 0x80(%rbx)
movslq 0x34(%rsp), %r14
shlq $0x3, %r14
movq %r9, %rcx
subq %r14, %rcx
leaq (%r10,%rcx), %rsi
movl $0x0, %edi
cmovlq %r14, %rdi
cmovlq %r9, %rcx
cmovlq %rax, %rsi
addq %r8, %rdi
movq %rsi, 0x70(%rbx)
shlq $0x3, %rdx
subq %rdx, %rcx
leaq (%r10,%rcx), %rcx
movl $0x0, %r13d
cmovlq %rdx, %r13
cmovlq %rax, %rcx
movq %rcx, 0x78(%rbx)
addq %rdi, %r13
je 0x27ba70
movq %r11, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x282a35
movq %rax, 0xf8(%rbx)
cmpb $0x0, 0x61(%r15)
je 0x27bab0
movq 0x28(%rsp), %rcx
movq 0x130(%rcx), %rax
movq %rax, 0xb0(%rbx)
movq $0x0, 0x130(%rcx)
jmp 0x27ba9d
movq 0x10(%rsp), %rsi
cmpb $0x0, 0x61(%rsi)
movq 0x28(%rsp), %rcx
movq 0x130(%rcx), %rax
movq %rax, 0xb0(%rbx)
movq $0x0, 0x130(%rcx)
je 0x27bb6b
movw $0x0, 0x20(%rbx)
movq $0x0, 0x28(%rbx)
jmp 0x27bbe0
movq 0x68(%rbx), %rcx
testq %rcx, %rcx
je 0x27bac5
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rdi
jmp 0x27bae2
movq %r13, %rsi
subq %r12, %rsi
movq 0x18(%rsp), %rdx
movq 0x20(%rsp), %rdi
jge 0x27badb
xorl %ecx, %ecx
jmp 0x27bae2
leaq (%rax,%rsi), %rcx
movq %rsi, %r13
movq %rcx, 0x68(%rbx)
movq 0x80(%rbx), %rcx
testq %rcx, %rcx
jne 0x27bb05
movq %r13, %rsi
subq %rdi, %rsi
jge 0x27bafe
xorl %ecx, %ecx
jmp 0x27bb05
leaq (%rax,%rsi), %rcx
movq %rsi, %r13
movq %rcx, 0x80(%rbx)
movq 0x70(%rbx), %rcx
testq %rcx, %rcx
jne 0x27bb28
movq %r13, %rsi
subq %r14, %rsi
jge 0x27bb21
xorl %ecx, %ecx
jmp 0x27bb28
leaq (%rax,%rsi), %rcx
movq %rsi, %r13
movq 0x10(%rsp), %rsi
movq %rcx, 0x70(%rbx)
movq 0x78(%rbx), %rcx
testq %rcx, %rcx
jne 0x27bb49
subq %rdx, %r13
jge 0x27bb43
xorl %ecx, %ecx
jmp 0x27bb49
addq %r13, %rax
movq %rax, %rcx
movq %rcx, 0x78(%rbx)
movq 0x28(%rsp), %rcx
movq 0x130(%rcx), %rax
movq %rax, 0xb0(%rbx)
movq $0x0, 0x130(%rcx)
movl 0x30(%rsp), %eax
movl %eax, 0x2c(%rbx)
movzwl 0xe(%rsp), %eax
movw %ax, 0x20(%rbx)
testw %ax, %ax
jle 0x27bba9
cwtl
movq 0x80(%rbx), %rcx
addq $0x28, %rcx
incl %eax
movq %rsi, (%rcx)
movw $0x1, -0x20(%rcx)
movl $0x0, -0x8(%rcx)
addq $0x38, %rcx
decl %eax
cmpl $0x1, %eax
ja 0x27bb8e
movl %ebp, 0x28(%rbx)
testl %ebp, %ebp
jle 0x27bbd5
movq 0x68(%rbx), %rax
addq $0x28, %rax
incl %ebp
movq %rsi, (%rax)
movw $0x80, -0x20(%rax)
movl $0x0, -0x8(%rax)
addq $0x38, %rax
decl %ebp
cmpl $0x1, %ebp
ja 0x27bbba
movq 0x78(%rbx), %rdi
xorl %esi, %esi
callq 0x173a0
movl $0x2df20da3, 0x24(%rbx) # imm = 0x2DF20DA3
movl $0x0, 0x38(%rbx)
movw $0xff02, 0xc2(%rbx)     # imm = 0xFF02
xorl %eax, %eax
movq %rax, 0x3c(%rbx)
movabsq $-0xffffffff, %rcx      # imm = 0xFFFFFFFF00000001
movq %rcx, 0x30(%rbx)
movq %rax, 0x50(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq