// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq (%rdi), %rax
movq %rax, -0x70(%rbp)
movl 0x1e4(%rsi), %eax
movq %rax, -0x40(%rbp)
movl 0x50(%rsi), %edx
movl 0x1a8(%rsi), %eax
movl 0x54(%rsi), %r13d
movq %rdx, -0x60(%rbp)
addl %edx, %r13d
movl %eax, -0x2c(%rbp)
movl 0x5c(%rsi), %eax
movq %rsi, -0x68(%rbp)
movl 0x64(%rsi), %ebx
cmpl $0x1, %eax
adcl $0x0, %eax
movq %rax, -0x58(%rbp)
movl 0x3c(%rdi), %eax
shll $0x3, %eax
leal (%rax,%rax,2), %eax
cltq
movq 0x8(%rdi), %r12
addq %rax, %r12
subl %eax, %ebx
andl $-0x8, %ebx
movq %rdi, -0x38(%rbp)
jle 0x14ca4
movl %ebx, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0xa210
movq -0x38(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3fbe8
movq -0x68(%rbp), %rdx
cmpb $0x0, 0x20(%rdx)
je 0x14cc5
xorl %eax, %eax
cmpb $0x0, 0x21(%rdx)
setne %al
shll $0x5, %eax
jmp 0x14cc7
xorl %eax, %eax
movq -0x38(%rbp), %r10
movl 0x8c(%r10), %ecx
andl $-0x21, %ecx
movzwl %ax, %eax
orl %ecx, %eax
movw %ax, 0x8c(%r10)
cmpl $0xb, %r13d
movl $0xa, %ecx
cmovgel %r13d, %ecx
cmpb $0x0, 0x1ed(%rdx)
cmovel %r13d, %ecx
andl $0xfff7, %eax           # imm = 0xFFF7
movw %ax, 0x8c(%r10)
movq %rcx, -0x78(%rbp)
imull $0x38, %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x40(%rbp), %rax
imull $0x38, %eax, %r15d
movl -0x2c(%rbp), %r14d
shll $0x3, %r14d
leal (,%rax,8), %r9d
movq -0x60(%rbp), %rax
leal (,%rax,8), %r11d
movq -0x58(%rbp), %rax
addl $0x7, %eax
andl $-0x8, %eax
movl %eax, -0x44(%rbp)
movq -0x70(%rbp), %r13
movl %r11d, -0x50(%rbp)
movl %r9d, -0x4c(%rbp)
movq 0x10(%r10), %rcx
testq %rcx, %rcx
jne 0x14d6e
movl %ebx, %eax
movl -0x48(%rbp), %ecx
subl %ecx, %eax
jge 0x14d66
movl %ecx, %eax
xorl %ecx, %ecx
jmp 0x14d70
movslq %eax, %rcx
addq %r12, %rcx
movl %eax, %ebx
xorl %eax, %eax
movq %rcx, 0x10(%r10)
movq 0x68(%r10), %rdx
testq %rdx, %rdx
je 0x14d81
movl %ebx, %ecx
jmp 0x14d97
movl %ebx, %ecx
subl %r15d, %ecx
jge 0x14d91
addl %r15d, %eax
movl %ebx, %ecx
xorl %edx, %edx
jmp 0x14d97
movslq %ecx, %rdx
addq %r12, %rdx
movq %rdx, 0x68(%r10)
movq 0x18(%r10), %rsi
testq %rsi, %rsi
je 0x14da8
movl %ecx, %edx
jmp 0x14dbe
movl %ecx, %edx
subl %r14d, %edx
jge 0x14db8
addl %r14d, %eax
movl %ecx, %edx
xorl %esi, %esi
jmp 0x14dbe
movslq %edx, %rsi
addq %r12, %rsi
movq %rsi, 0x18(%r10)
movq 0x70(%r10), %rsi
testq %rsi, %rsi
je 0x14dcf
movl %edx, %ecx
jmp 0x14de5
movl %edx, %ecx
subl %r9d, %ecx
jge 0x14ddf
addl %r9d, %eax
movl %edx, %ecx
xorl %esi, %esi
jmp 0x14de5
movslq %ecx, %rsi
addq %r12, %rsi
movq %rsi, 0x70(%r10)
movq 0x60(%r10), %rsi
testq %rsi, %rsi
je 0x14df6
movl %ecx, %edx
jmp 0x14e0c
movl %ecx, %edx
subl %r11d, %edx
jge 0x14e06
addl %r11d, %eax
movl %ecx, %edx
xorl %esi, %esi
jmp 0x14e0c
movslq %edx, %rsi
addq %r12, %rsi
movq %rsi, 0x60(%r10)
movq 0x118(%r10), %rcx
testq %rcx, %rcx
jne 0x14e32
movl -0x44(%rbp), %ecx
subl %ecx, %edx
jge 0x14e29
addl %ecx, %eax
xorl %ecx, %ecx
jmp 0x14e32
movslq %edx, %rcx
addq %rcx, %r12
movq %r12, %rcx
movq %rcx, 0x118(%r10)
testl %eax, %eax
je 0x14e8f
movl %eax, %ebx
movslq %eax, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x144ee
movq %rax, %r13
testq %rax, %rax
je 0x14e62
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0xa210
movq -0x38(%rbp), %r10
movq %r13, 0xe8(%r10)
testl %ebx, %ebx
movq -0x70(%rbp), %r13
movl -0x4c(%rbp), %r9d
movl -0x50(%rbp), %r11d
je 0x14e8f
movq 0xe8(%r10), %r12
cmpb $0x0, 0x51(%r13)
je 0x14d4e
movq -0x60(%rbp), %rax
movl %eax, 0x40(%r10)
movq -0x58(%rbp), %rax
movl %eax, 0x110(%r10)
movq 0x68(%r10), %rax
testq %rax, %rax
je 0x14ed4
movq -0x40(%rbp), %rcx
movw %cx, 0x78(%r10)
testl %ecx, %ecx
jle 0x14ed4
imulq $0x38, -0x40(%rbp), %rcx
xorl %edx, %edx
movw $0x1, 0x8(%rax,%rdx)
movq %r13, 0x28(%rax,%rdx)
addq $0x38, %rdx
cmpq %rdx, %rcx
jne 0x14ebf
movq 0x70(%r10), %rdi
testq %rdi, %rdi
movq -0x68(%rbp), %r14
movq -0x78(%rbp), %r12
je 0x14f26
movl 0x1e8(%r14), %eax
testl %eax, %eax
jle 0x14f26
movw %ax, 0x7a(%r10)
movq 0x208(%r14), %rsi
movswq %ax, %rdx
shlq $0x3, %rdx
callq 0xa310
movq 0x208(%r14), %rdi
movslq 0x1e8(%r14), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0xa210
movq -0x38(%rbp), %r10
movq 0x10(%r10), %rax
testq %rax, %rax
je 0x14f62
leaq -0x38(%rax), %rcx
movq %rcx, 0x10(%r10)
movl %r12d, 0x38(%r10)
testl %r12d, %r12d
jle 0x14f62
incl %r12d
imulq $0x38, %r12, %rcx
addq $-0x38, %rcx
xorl %edx, %edx
movw $0x80, 0x8(%rax,%rdx)
movq %r13, 0x28(%rax,%rdx)
addq $0x38, %rdx
cmpq %rdx, %rcx
jne 0x14f4d
movzbl 0x1ed(%r14), %eax
movl 0x8c(%r10), %ecx
andl $0x3, %eax
andl $-0x4, %ecx
orl %eax, %ecx
movw %cx, 0x8c(%r10)
movl $0xbdf20da3, 0x44(%r10) # imm = 0xBDF20DA3
xorl %eax, %eax
movl %eax, 0x84(%r10)
movw $0xff02, 0x8a(%r10)     # imm = 0xFF02
movl %eax, 0x90(%r10)
movabsq $-0xffffffff, %rcx      # imm = 0xFFFFFFFF00000001
movq %rcx, 0x7c(%r10)
movl %eax, 0x9c(%r10)
movq $0x0, 0xc8(%r10)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq