// File: /workspace/github_c_makefile_star2_O0/ukontainer[P]sqlite-bench/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 && nMem<10 ){
    nMem = 10;
  }
  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.
  */
  do {
    x.nNeeded = 0;
    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
    if( x.nNeeded==0 ) break;
    x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);
    x.nFree = x.nNeeded;
  }while( !db->mallocFailed );

  p->pVList = pParse->pVList;
  pParse->pVList =  0;
  p->explain = pParse->explain;
  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 $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
movswl 0x108(%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 0x4117d8
cmpl $0x0, -0x20(%rbp)
jle 0x4117d8
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movslq 0xb8(%rax), %rax
imulq $0x18, %rax, %rax
addq $0x7, %rax
andq $-0x8, %rax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x68(%rax), %rax
movslq -0x2c(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movl 0x40(%rax), %eax
subl -0x2c(%rbp), %eax
andl $-0x8, %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x453b50
movq -0x10(%rbp), %rax
movzbl 0x20(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x41(%rbp)
je 0x411845
movq -0x10(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movzbl %al, %ecx
movq -0x8(%rbp), %rax
movw %cx, %dx
movw 0xc1(%rax), %cx
andw $0x1, %dx
shlw $0x7, %dx
andw $0xff7f, %cx            # imm = 0xFF7F
orw %dx, %cx
movw %cx, 0xc1(%rax)
movq -0x10(%rbp), %rax
movzbl 0x10b(%rax), %eax
cmpl $0x0, %eax
je 0x411892
cmpl $0xa, -0x20(%rbp)
jge 0x411892
movl $0xa, -0x20(%rbp)
movq -0x8(%rbp), %rax
movw 0xc1(%rax), %cx
andw $-0x4, %cx
orw $0x0, %cx
movw %cx, 0xc1(%rax)
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rsi
movslq -0x20(%rbp), %rax
imulq $0x38, %rax, %rax
movl %eax, %edx
leaq -0x40(%rbp), %rdi
callq 0x453d90
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rax
movq 0xa0(%rax), %rsi
movslq -0x1c(%rbp), %rax
imulq $0x38, %rax, %rax
movl %eax, %edx
leaq -0x40(%rbp), %rdi
callq 0x453d90
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rsi
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
movl %eax, %edx
leaq -0x40(%rbp), %rdi
callq 0x453d90
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rsi
movslq -0x24(%rbp), %rax
shlq $0x3, %rax
movl %eax, %edx
leaq -0x40(%rbp), %rdi
callq 0x453d90
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x98(%rax)
cmpl $0x0, -0x34(%rbp)
jne 0x41195f
jmp 0x411996
movq -0x18(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x41b3d0
movq -0x8(%rbp), %rcx
movq %rax, 0xf0(%rcx)
movq %rax, -0x40(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x61(%rax)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x4118ac
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xa8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x120(%rax)
movq -0x10(%rbp), %rax
movzbl 0x10b(%rax), %ecx
movq -0x8(%rbp), %rax
movw %cx, %dx
movw 0xc1(%rax), %cx
andw $0x3, %dx
shlw $0x2, %dx
andw $-0xd, %cx
orw %dx, %cx
movw %cx, 0xc1(%rax)
movq -0x18(%rbp), %rax
cmpb $0x0, 0x61(%rax)
je 0x411a16
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 0x411a87
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 0xa0(%rax), %rdi
movl -0x1c(%rbp), %esi
movq -0x18(%rbp), %rdx
movl $0x1, %ecx
callq 0x453e00
movl -0x20(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
movq 0x70(%rax), %rdi
movl -0x20(%rbp), %esi
movq -0x18(%rbp), %rdx
movl $0x80, %ecx
callq 0x453e00
movq -0x8(%rbp), %rax
movq 0x98(%rax), %rdi
movslq -0x24(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x4010b0
movq -0x8(%rbp), %rdi
callq 0x40cf60
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)