// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/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 nOnce;                     /* Number of OP_Once instructions */
  int n;                         /* Loop counter */
  int nFree;                     /* Available free space */
  u8 *zCsr;                      /* Memory available for allocation */
  int nByte;                     /* How much extra memory is needed */

  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;
  nOnce = pParse->nOnce;
  if( nOnce==0 ) nOnce = 1; /* Ensure at least one byte in p->aOnceFlag[] */
  
  /* For each cursor required, also allocate a memory cell. Memory
  ** cells (nMem+1-nCursor)..nMem, inclusive, will never be used by
  ** the vdbe program. Instead they are used to allocate space for
  ** VdbeCursor/BtCursor structures. The blob of memory associated with 
  ** cursor 0 is stored in memory cell nMem. Memory cell (nMem-1)
  ** stores the blob of memory associated with cursor 1, etc.
  **
  ** See also: allocateCursor().
  */
  nMem += nCursor;

  /* zCsr will initially point to nFree bytes of unused space at the
  ** end of the opcode array, p->aOp.  The computation of nFree is
  ** conservative - it might be smaller than the true number of free
  ** bytes, but never larger.  nFree must be a multiple of 8 - it is
  ** rounded down if is not.
  */
  n = ROUND8(sizeof(Op)*p->nOp);              /* Bytes of opcode space used */
  zCsr = &((u8*)p->aOp)[n];                   /* Unused opcode space */
  assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
  nFree = ROUNDDOWN8(pParse->szOpAlloc - n);  /* Bytes of unused space */
  assert( nFree>=0 );
  if( nFree>0 ){
    memset(zCsr, 0, nFree);
    assert( EIGHT_BYTE_ALIGNMENT(&zCsr[nFree]) );
  }

  resolveP2Values(p, &nArg);
  p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);
  if( pParse->explain && nMem<10 ){
    nMem = 10;
  }
  p->expired = 0;

  /* Memory for registers, parameters, cursor, etc, is allocated in two
  ** passes.  On the first pass, we try to reuse unused space 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 rest using a fresh allocation.  
  **
  ** This two-pass approach that reuses as much memory as possible from
  ** the leftover space at the end of the opcode array can significantly
  ** reduce the amount of memory held by a prepared statement.
  */
  do {
    nByte = 0;
    p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), zCsr, &nFree, &nByte);
    p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), zCsr, &nFree, &nByte);
    p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), zCsr, &nFree, &nByte);
    p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), zCsr, &nFree, &nByte);
    p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),
                          zCsr, &nFree, &nByte);
    p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, zCsr, &nFree, &nByte);
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
    p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), zCsr, &nFree, &nByte);
#endif
    if( nByte ){
      p->pFree = sqlite3DbMallocZero(db, nByte);
    }
    zCsr = p->pFree;
    nFree = nByte;
  }while( nByte && !db->mallocFailed );

  p->nCursor = nCursor;
  p->nOnceFlag = nOnce;
  if( p->aVar ){
    p->nVar = (ynVar)nVar;
    for(n=0; n<nVar; n++){
      p->aVar[n].flags = MEM_Null;
      p->aVar[n].db = db;
    }
  }
  if( p->azVar && pParse->nzVar>0 ){
    p->nzVar = pParse->nzVar;
    memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0]));
    memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0]));
  }
  if( p->aMem ){
    p->aMem--;                      /* aMem[] goes from 1..nMem */
    p->nMem = nMem;                 /*       not from 0..nMem-1 */
    for(n=1; n<=nMem; n++){
      p->aMem[n].flags = MEM_Undefined;
      p->aMem[n].db = db;
    }
  }
  p->explain = pParse->explain;
  sqlite3VdbeRewind(p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x1e4(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x54(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0x1a8(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x18040
movl $0x1, -0x2c(%rbp)
movl -0x24(%rbp), %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movslq 0x3c(%rax), %rax
imulq $0x18, %rax, %rax
addq $0x7, %rax
andq $-0x8, %rax
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x30(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x64(%rax), %eax
subl -0x30(%rbp), %eax
andl $-0x8, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x18098
movq -0x40(%rbp), %rdi
movslq -0x34(%rbp), %rdx
xorl %esi, %esi
callq 0xb2b0
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x56f00
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x45(%rbp)
je 0x180c8
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x45(%rbp)
movb -0x45(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movzbl %al, %ecx
movq -0x8(%rbp), %rax
movw %cx, %dx
movw 0x8c(%rax), %cx
andw $0x1, %dx
shlw $0x5, %dx
andw $-0x21, %cx
orw %dx, %cx
movw %cx, 0x8c(%rax)
movq -0x10(%rbp), %rax
movzbl 0x1ed(%rax), %eax
cmpl $0x0, %eax
je 0x18114
cmpl $0xa, -0x20(%rbp)
jge 0x18114
movl $0xa, -0x20(%rbp)
movq -0x8(%rbp), %rax
movw 0x8c(%rax), %cx
andw $-0x9, %cx
orw $0x0, %cx
movw %cx, 0x8c(%rax)
movl $0x0, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x20(%rbp), %rax
imulq $0x38, %rax, %rax
movl %eax, %esi
movq -0x40(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x57150
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rdi
movslq -0x1c(%rbp), %rax
imulq $0x38, %rax, %rax
movl %eax, %esi
movq -0x40(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x57150
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
movl %eax, %esi
movq -0x40(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x57150
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdi
movslq -0x1c(%rbp), %rax
shlq $0x3, %rax
movl %eax, %esi
movq -0x40(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x57150
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rax
movq 0x60(%rax), %rdi
movslq -0x24(%rbp), %rax
shlq $0x3, %rax
movl %eax, %esi
movq -0x40(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x57150
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x8(%rbp), %rax
movq 0x118(%rax), %rdi
movl -0x2c(%rbp), %esi
movq -0x40(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq 0x57150
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x118(%rax)
cmpl $0x0, -0x44(%rbp)
je 0x18269
movq -0x18(%rbp), %rdi
movslq -0x44(%rbp), %rsi
callq 0x15b80
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xe8(%rax)
movq -0x8(%rbp), %rax
movq 0xe8(%rax), %rax
movq %rax, -0x40(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x34(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x44(%rbp)
movb %al, -0x46(%rbp)
je 0x18299
movq -0x18(%rbp), %rax
cmpb $0x0, 0x51(%rax)
setne %al
xorb $-0x1, %al
movb %al, -0x46(%rbp)
movb -0x46(%rbp), %al
testb $0x1, %al
jne 0x1812e
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x40(%rax)
movl -0x2c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x110(%rax)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x68(%rax)
je 0x18324
movl -0x1c(%rbp), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x78(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x18322
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movw $0x1, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movslq -0x30(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x28(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x182db
jmp 0x18324
movq -0x8(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x18397
movq -0x10(%rbp), %rax
cmpl $0x0, 0x1e8(%rax)
jle 0x18397
movq -0x10(%rbp), %rax
movl 0x1e8(%rax), %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x7a(%rax)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x208(%rax), %rsi
movq -0x8(%rbp), %rax
movswq 0x7a(%rax), %rdx
shlq $0x3, %rdx
callq 0xb420
movq -0x10(%rbp), %rax
movq 0x208(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0x1e8(%rax), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0xb2b0
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1840c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
addq $-0x38, %rcx
movq %rcx, 0x10(%rax)
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x1840a
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x30(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movw $0x80, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x30(%rbp), %rdx
imulq $0x38, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x28(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x183c3
jmp 0x1840c
movq -0x10(%rbp), %rax
movzbl 0x1ed(%rax), %ecx
movq -0x8(%rbp), %rax
movw %cx, %dx
movw 0x8c(%rax), %cx
andw $0x3, %dx
andw $-0x4, %cx
orw %dx, %cx
movw %cx, 0x8c(%rax)
movq -0x8(%rbp), %rdi
callq 0x13e20
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)