// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movswl 0x118(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x80(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x3cbd98
cmpl $0x0, -0x20(%rbp)
jle 0x3cbd98
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movslq 0x90(%rax), %rax
imulq $0x18, %rax, %rax
addq $0x7, %rax
andq $-0x8, %rax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movl 0x3c(%rax), %eax
subl -0x2c(%rbp), %eax
andl $-0x8, %eax
cltq
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x410470
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x55(%rbp)
je 0x3cbe0b
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movzbl %al, %ecx
movq -0x8(%rbp), %rax
movw %cx, %dx
movw 0xc6(%rax), %cx
andw $0x1, %dx
shlw $0x6, %dx
andw $-0x41, %cx
orw %dx, %cx
movw %cx, 0xc6(%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x11b(%rax)
je 0x3cbf11
cmpl $0xa, -0x20(%rbp)
jge 0x3cbe58
movl $0xa, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x11b(%rax), %ecx
movq -0x8(%rbp), %rax
movw %cx, %dx
movw 0xc6(%rax), %cx
andw $0x3, %dx
shlw $0x2, %dx
andw $-0xd, %cx
orw %dx, %cx
movw %cx, 0xc6(%rax)
movq -0x10(%rbp), %rax
movzbl 0x11b(%rax), %eax
cmpl $0x2, %eax
jne 0x3cbeb5
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x4106b0
movl $0x8, -0x4c(%rbp)
movl $0xc, -0x50(%rbp)
jmp 0x3cbed1
movq -0x8(%rbp), %rdi
movl $0x8, %esi
callq 0x4106b0
movl $0x0, -0x4c(%rbp)
movl $0x8, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x3cbf0f
movq -0x8(%rbp), %rdi
movl -0x54(%rbp), %esi
subl -0x4c(%rbp), %esi
movslq -0x54(%rbp), %rcx
leaq 0x26dd8c(%rip), %rax    # 0x639c80
movq (%rax,%rcx,8), %rcx
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %r8d
callq 0x410780
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3cbed7
jmp 0x3cbf11
movq -0x8(%rbp), %rax
movw 0xc6(%rax), %cx
andw $-0x4, %cx
orw $0x0, %cx
movw %cx, 0xc6(%rax)
movq $0x0, -0x38(%rbp)
movslq -0x20(%rbp), %rax
imulq $0x38, %rax, %rdx
leaq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x68(%rax)
movslq -0x1c(%rbp), %rax
imulq $0x38, %rax, %rdx
leaq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x80(%rax)
movslq -0x28(%rbp), %rdx
shlq $0x3, %rdx
leaq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
movslq -0x24(%rbp), %rdx
shlq $0x3, %rdx
leaq -0x48(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x78(%rax)
cmpq $0x0, -0x38(%rbp)
je 0x3cc08b
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3d62a0
movq -0x8(%rbp), %rcx
movq %rax, 0xf8(%rcx)
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x61(%rax)
jne 0x3cc089
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rsi
movslq -0x20(%rbp), %rax
imulq $0x38, %rax, %rdx
leaq -0x48(%rbp), %rdi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rsi
movslq -0x1c(%rbp), %rax
imulq $0x38, %rax, %rdx
leaq -0x48(%rbp), %rdi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rsi
movslq -0x28(%rbp), %rdx
shlq $0x3, %rdx
leaq -0x48(%rbp), %rdi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rsi
movslq -0x24(%rbp), %rdx
shlq $0x3, %rdx
leaq -0x48(%rbp), %rdi
callq 0x410810
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x78(%rax)
jmp 0x3cc08b
movq -0x10(%rbp), %rax
movq 0x130(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xb0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x130(%rax)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x61(%rax)
je 0x3cc0dc
movq -0x8(%rbp), %rax
movw $0x0, 0x20(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x28(%rax)
jmp 0x3cc14a
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq 0x80(%rax), %rdi
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rdx
movl $0x1, %ecx
callq 0x410890
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movl -0x20(%rbp), %esi
movq -0x18(%rbp), %rdx
movl $0x80, %ecx
callq 0x410890
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rdi
movslq -0x24(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x19360
movq -0x8(%rbp), %rdi
callq 0x3c75b0
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)