// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rdi, %rbx
movq (%rdi), %r15
movl 0x1e4(%rsi), %eax
movq %rax, -0x40(%rbp)
movl 0x50(%rsi), %edx
movl 0x1a8(%rsi), %eax
movl 0x54(%rsi), %r13d
movq %rdx, -0x50(%rbp)
addl %edx, %r13d
movl %eax, -0x2c(%rbp)
movl 0x5c(%rsi), %eax
cmpl $0x1, %eax
adcl $0x0, %eax
movq %rax, -0x48(%rbp)
movq %rsi, -0x58(%rbp)
movl 0x64(%rsi), %r14d
imull $0x18, 0x3c(%rdi), %eax
cltq
movq 0x8(%rdi), %r12
addq %rax, %r12
subl %eax, %r14d
andl $-0x8, %r14d
jle 0x13a20
movl %r14d, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0xa270
leaq -0x2c(%rbp), %rsi
movq %rbx, %rdi
callq 0x38742
movq -0x58(%rbp), %rdx
cmpb $0x0, 0x20(%rdx)
je 0x13a44
xorl %eax, %eax
cmpb $0x0, 0x21(%rdx)
setne %al
shll $0x5, %eax
jmp 0x13a46
xorl %eax, %eax
movl 0x8c(%rbx), %ecx
andl $-0x21, %ecx
movzwl %ax, %eax
orl %ecx, %eax
movw %ax, 0x8c(%rbx)
cmpl $0xb, %r13d
pushq $0xa
popq %rcx
cmovgel %r13d, %ecx
cmpb $0x0, 0x1ed(%rdx)
cmovel %r13d, %ecx
andl $0xfff7, %eax           # imm = 0xFFF7
movw %ax, 0x8c(%rbx)
movq %rcx, -0x60(%rbp)
imull $0x38, %ecx, %eax
movl %eax, -0x34(%rbp)
movq -0x40(%rbp), %rax
imull $0x38, %eax, %ecx
movl %ecx, -0x30(%rbp)
movl -0x2c(%rbp), %r8d
shll $0x3, %r8d
leal (,%rax,8), %r13d
movq -0x50(%rbp), %rax
leal (,%rax,8), %r10d
movq -0x48(%rbp), %rax
leal 0x7(%rax), %r11d
andl $-0x8, %r11d
movq %rbx, -0x68(%rbp)
movq 0x10(%rbx), %rax
testq %rax, %rax
jne 0x13adf
movl %r14d, %ecx
movl -0x34(%rbp), %eax
subl %eax, %ecx
jge 0x13ad6
movl %eax, %ecx
xorl %eax, %eax
jmp 0x13ae1
movslq %ecx, %rax
addq %r12, %rax
movl %ecx, %r14d
xorl %ecx, %ecx
movq %rax, 0x10(%rbx)
movq 0x68(%rbx), %rax
testq %rax, %rax
je 0x13af3
movl %r14d, %edx
jmp 0x13b0c
movl %r14d, %edx
movl -0x30(%rbp), %eax
subl %eax, %edx
jge 0x13b06
addl %eax, %ecx
movl %r14d, %edx
xorl %eax, %eax
jmp 0x13b0c
movslq %edx, %rax
addq %r12, %rax
movq %rax, 0x68(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x13b1d
movl %edx, %esi
jmp 0x13b33
movl %edx, %esi
subl %r8d, %esi
jge 0x13b2d
addl %r8d, %ecx
movl %edx, %esi
xorl %edi, %edi
jmp 0x13b33
movslq %esi, %rdi
addq %r12, %rdi
movq %rdi, 0x18(%rbx)
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x13b44
movl %esi, %edx
jmp 0x13b5a
movl %esi, %edx
subl %r13d, %edx
jge 0x13b54
addl %r13d, %ecx
movl %esi, %edx
xorl %edi, %edi
jmp 0x13b5a
movslq %edx, %rdi
addq %r12, %rdi
movq %rdi, 0x70(%rbx)
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x13b6b
movl %edx, %esi
jmp 0x13b81
movl %edx, %esi
subl %r10d, %esi
jge 0x13b7b
addl %r10d, %ecx
movl %edx, %esi
xorl %edi, %edi
jmp 0x13b81
movslq %esi, %rdi
addq %r12, %rdi
movq %rdi, 0x60(%rbx)
movq 0x118(%rbx), %rdx
testq %rdx, %rdx
jne 0x13ba6
subl %r11d, %esi
jge 0x13b9d
addl %r11d, %ecx
xorl %edx, %edx
jmp 0x13ba6
movslq %esi, %rdx
addq %rdx, %r12
movq %r12, %rdx
movq %rdx, 0x118(%rbx)
testl %ecx, %ecx
je 0x13bf8
movslq %ecx, %rsi
movq %r15, %rdi
movl %r8d, %r12d
movl %ecx, -0x38(%rbp)
movq %r15, %r14
movl %r10d, %r15d
movl %r11d, %ebx
callq 0x12153
movl %ebx, %r11d
movq -0x68(%rbp), %rbx
movl %r15d, %r10d
movq %r14, %r15
movl -0x38(%rbp), %r14d
movl %r12d, %r8d
movq %rax, %r12
movq %rax, 0xe8(%rbx)
cmpb $0x0, 0x51(%r15)
je 0x13abd
movq 0x68(%rbx), %rax
movq -0x50(%rbp), %rcx
movl %ecx, 0x40(%rbx)
movq -0x48(%rbp), %rcx
movl %ecx, 0x110(%rbx)
testq %rax, %rax
movq -0x58(%rbp), %r14
je 0x13c3c
movq -0x40(%rbp), %rdx
movw %dx, 0x78(%rbx)
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0x38, %rdx, %rdx
cmpq %rcx, %rdx
je 0x13c3c
movw $0x1, 0x8(%rax,%rcx)
movq %r15, 0x28(%rax,%rcx)
addq $0x38, %rcx
jmp 0x13c25
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x13c81
movl 0x1e8(%r14), %eax
testl %eax, %eax
jle 0x13c81
movw %ax, 0x7a(%rbx)
movq 0x208(%r14), %rsi
movswq %ax, %rdx
shlq $0x3, %rdx
callq 0xa3b0
movq 0x208(%r14), %rdi
movslq 0x1e8(%r14), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0xa270
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x13cbb
leaq -0x38(%rax), %rcx
movq %rcx, 0x10(%rbx)
movq -0x60(%rbp), %rdx
movl %edx, 0x38(%rbx)
xorl %ecx, %ecx
testl %edx, %edx
cmovlel %ecx, %edx
imulq $0x38, %rdx, %rdx
cmpq %rcx, %rdx
je 0x13cbb
movw $0x80, 0x8(%rax,%rcx)
movq %r15, 0x28(%rax,%rcx)
addq $0x38, %rcx
jmp 0x13ca4
movzbl 0x1ed(%r14), %eax
movl 0x8c(%rbx), %ecx
andl $0x3, %eax
andl $-0x4, %ecx
orl %eax, %ecx
movw %cx, 0x8c(%rbx)
movq %rbx, %rdi
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10a2b