// File: /workspace/github_c_makefile_star2_O3/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), %rax
movq %rax, -0x40(%rbp)
movl 0x1e4(%rsi), %eax
movq %rax, -0x38(%rbp)
movl 0x50(%rsi), %edx
movl 0x1a8(%rsi), %eax
movl 0x54(%rsi), %r13d
movq %rdx, -0x60(%rbp)
addl %edx, %r13d
movl %eax, -0x30(%rbp)
movl 0x5c(%rsi), %eax
movq %rsi, -0x68(%rbp)
movl 0x64(%rsi), %r14d
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), %r15
addq %rax, %r15
subl %eax, %r14d
andl $-0x8, %r14d
jle 0x14d30
movl %r14d, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0xa220
movl %r14d, -0x2c(%rbp)
leaq -0x30(%rbp), %rsi
movq %rbx, %rdi
callq 0x3ebe9
movq -0x68(%rbp), %rdx
cmpb $0x0, 0x20(%rdx)
je 0x14d58
xorl %eax, %eax
cmpb $0x0, 0x21(%rdx)
setne %al
shll $0x5, %eax
jmp 0x14d5a
xorl %eax, %eax
movl 0x8c(%rbx), %ecx
andl $-0x21, %ecx
movzwl %ax, %eax
orl %ecx, %eax
movw %ax, 0x8c(%rbx)
cmpl $0xb, %r13d
movl $0xa, %ecx
cmovgel %r13d, %ecx
cmpb $0x0, 0x1ed(%rdx)
cmovel %r13d, %ecx
andl $0xfff7, %eax           # imm = 0xFFF7
movw %ax, 0x8c(%rbx)
movq %rcx, -0x70(%rbp)
imull $0x38, %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x38(%rbp), %rax
imull $0x38, %eax, %ecx
movl %ecx, -0x48(%rbp)
movl -0x30(%rbp), %r8d
shll $0x3, %r8d
leal (,%rax,8), %r10d
movq -0x60(%rbp), %rax
leal (,%rax,8), %r14d
movq -0x58(%rbp), %rax
addl $0x7, %eax
andl $-0x8, %eax
movl %eax, -0x44(%rbp)
movq -0x40(%rbp), %r9
movq %r15, %rax
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
je 0x14de7
xorl %ecx, %ecx
movl -0x2c(%rbp), %edi
jmp 0x14e03
movl -0x2c(%rbp), %edi
movl %edi, %ecx
movl -0x4c(%rbp), %edx
subl %edx, %ecx
jge 0x14df9
movl %edx, %ecx
xorl %edx, %edx
jmp 0x14e03
movslq %ecx, %rdx
addq %rax, %rdx
movl %ecx, %edi
xorl %ecx, %ecx
movq %rdx, 0x10(%rbx)
movq 0x68(%rbx), %r11
testq %r11, %r11
je 0x14e14
movl %edi, %edx
jmp 0x14e2c
movl %edi, %edx
movl -0x48(%rbp), %esi
subl %esi, %edx
jge 0x14e26
addl %esi, %ecx
movl %edi, %edx
xorl %r11d, %r11d
jmp 0x14e2c
movslq %edx, %r11
addq %rax, %r11
movq %r11, 0x68(%rbx)
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x14e3d
movl %edx, %esi
jmp 0x14e53
movl %edx, %esi
subl %r8d, %esi
jge 0x14e4d
addl %r8d, %ecx
movl %edx, %esi
xorl %edi, %edi
jmp 0x14e53
movslq %esi, %rdi
addq %rax, %rdi
movq %rdi, 0x18(%rbx)
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
je 0x14e64
movl %esi, %edx
jmp 0x14e7a
movl %esi, %edx
subl %r10d, %edx
jge 0x14e74
addl %r10d, %ecx
movl %esi, %edx
xorl %edi, %edi
jmp 0x14e7a
movslq %edx, %rdi
addq %rax, %rdi
movq %rdi, 0x70(%rbx)
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x14e8b
movl %edx, %esi
jmp 0x14ea1
movl %edx, %esi
subl %r14d, %esi
jge 0x14e9b
addl %r14d, %ecx
movl %edx, %esi
xorl %edi, %edi
jmp 0x14ea1
movslq %esi, %rdi
addq %rax, %rdi
movq %rdi, 0x60(%rbx)
movq 0x118(%rbx), %rdx
testq %rdx, %rdx
jne 0x14ec7
movl -0x44(%rbp), %edx
subl %edx, %esi
jge 0x14ebe
addl %edx, %ecx
xorl %edx, %edx
jmp 0x14ec7
movslq %esi, %rdx
addq %rdx, %rax
movq %rax, %rdx
movq %rdx, 0x118(%rbx)
testl %ecx, %ecx
je 0x14f21
movl %r10d, %r12d
movl %r8d, %r15d
movl %ecx, -0x2c(%rbp)
movslq %ecx, %r13
movq %r9, %rdi
movq %r13, %rsi
callq 0x145aa
testq %rax, %rax
je 0x14f01
movq %rax, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %rax, %r13
callq 0xa220
movq %r13, %rax
movq %rax, 0xe8(%rbx)
movq -0x40(%rbp), %r9
cmpb $0x0, 0x51(%r9)
movl %r15d, %r8d
movl %r12d, %r10d
je 0x14dd7
movq 0x68(%rbx), %r11
movq -0x60(%rbp), %rcx
movl %ecx, 0x40(%rbx)
movq -0x58(%rbp), %rcx
movl %ecx, 0x110(%rbx)
testq %r11, %r11
je 0x14f60
movq -0x38(%rbp), %rcx
movw %cx, 0x78(%rbx)
testl %ecx, %ecx
jle 0x14f60
imulq $0x38, -0x38(%rbp), %rcx
xorl %edx, %edx
movw $0x1, 0x8(%r11,%rdx)
movq %r9, 0x28(%r11,%rdx)
addq $0x38, %rdx
cmpq %rdx, %rcx
jne 0x14f4a
movq 0x70(%rbx), %rdi
testq %rdi, %rdi
movq -0x68(%rbp), %r14
movq -0x70(%rbp), %r12
je 0x14fb1
movl 0x1e8(%r14), %eax
testl %eax, %eax
jle 0x14fb1
movw %ax, 0x7a(%rbx)
movq 0x208(%r14), %rsi
movswq %ax, %rdx
shlq $0x3, %rdx
callq 0xa320
movq 0x208(%r14), %rdi
movslq 0x1e8(%r14), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0xa220
movq -0x40(%rbp), %r9
movq 0x10(%rbx), %rax
testq %rax, %rax
je 0x14fed
leaq -0x38(%rax), %rcx
movq %rcx, 0x10(%rbx)
movl %r12d, 0x38(%rbx)
testl %r12d, %r12d
jle 0x14fed
incl %r12d
imulq $0x38, %r12, %rcx
addq $-0x38, %rcx
xorl %edx, %edx
movw $0x80, 0x8(%rax,%rdx)
movq %r9, 0x28(%rax,%rdx)
addq $0x38, %rdx
cmpq %rdx, %rcx
jne 0x14fd8
movzbl 0x1ed(%r14), %eax
movl 0x8c(%rbx), %ecx
andl $0x3, %eax
andl $-0x4, %ecx
orl %eax, %ecx
movw %cx, 0x8c(%rbx)
xorl %eax, %eax
movl %eax, 0x84(%rbx)
movw $0xff02, 0x8a(%rbx)     # imm = 0xFF02
movl $0xbdf20da3, 0x44(%rbx) # imm = 0xBDF20DA3
movl %eax, 0x90(%rbx)
movabsq $-0xffffffff, %rcx      # imm = 0xFFFFFFFF00000001
movq %rcx, 0x7c(%rbx)
movl %eax, 0x9c(%rbx)
movq $0x0, 0xc8(%rbx)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq