// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeList
SQLITE_PRIVATE int sqlite3VdbeList(
  Vdbe *p                   /* The VDBE */
){
  int nRow;                            /* Stop when row count reaches this */
  int nSub = 0;                        /* Number of sub-vdbes seen so far */
  SubProgram **apSub = 0;              /* Array of sub-vdbes */
  Mem *pSub = 0;                       /* Memory cell hold array of subprogs */
  sqlite3 *db = p->db;                 /* The database connection */
  int i;                               /* Loop counter */
  int rc = SQLITE_OK;                  /* Return code */
  Mem *pMem = &p->aMem[1];             /* First Mem of result set */

  assert( p->explain );
  assert( p->magic==VDBE_MAGIC_RUN );
  assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );

  /* Even though this opcode does not use dynamic strings for
  ** the result, result columns may become dynamic if the user calls
  ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.
  */
  releaseMemArray(pMem, 8);
  p->pResultSet = 0;

  if( p->rc==SQLITE_NOMEM ){
    /* This happens if a malloc() inside a call to sqlite3_column_text() or
    ** sqlite3_column_text16() failed.  */
    db->mallocFailed = 1;
    return SQLITE_ERROR;
  }

  /* When the number of output rows reaches nRow, that means the
  ** listing has finished and sqlite3_step() should return SQLITE_DONE.
  ** nRow is the sum of the number of rows in the main program, plus
  ** the sum of the number of rows in all trigger subprograms encountered
  ** so far.  The nRow value will increase as new trigger subprograms are
  ** encountered, but p->pc will eventually catch up to nRow.
  */
  nRow = p->nOp;
  if( p->explain==1 ){
    /* The first 8 memory cells are used for the result set.  So we will
    ** commandeer the 9th cell to use as storage for an array of pointers
    ** to trigger subprograms.  The VDBE is guaranteed to have at least 9
    ** cells.  */
    assert( p->nMem>9 );
    pSub = &p->aMem[9];
    if( pSub->flags&MEM_Blob ){
      /* On the first call to sqlite3_step(), pSub will hold a NULL.  It is
      ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */
      nSub = pSub->n/sizeof(Vdbe*);
      apSub = (SubProgram **)pSub->z;
    }
    for(i=0; i<nSub; i++){
      nRow += apSub[i]->nOp;
    }
  }

  do{
    i = p->pc++;
  }while( i<nRow && p->explain==2 && p->aOp[i].opcode!=OP_Explain );
  if( i>=nRow ){
    p->rc = SQLITE_OK;
    rc = SQLITE_DONE;
  }else if( db->u1.isInterrupted ){
    p->rc = SQLITE_INTERRUPT;
    rc = SQLITE_ERROR;
    sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc));
  }else{
    char *z;
    Op *pOp;
    if( i<p->nOp ){
      /* The output line number is small enough that we are still in the
      ** main program. */
      pOp = &p->aOp[i];
    }else{
      /* We are currently listing subprograms.  Figure out which one and
      ** pick up the appropriate opcode. */
      int j;
      i -= p->nOp;
      for(j=0; i>=apSub[j]->nOp; j++){
        i -= apSub[j]->nOp;
      }
      pOp = &apSub[j]->aOp[i];
    }
    if( p->explain==1 ){
      pMem->flags = MEM_Int;
      pMem->type = SQLITE_INTEGER;
      pMem->u.i = i;                                /* Program counter */
      pMem++;
  
      pMem->flags = MEM_Static|MEM_Str|MEM_Term;
      pMem->z = (char*)sqlite3OpcodeName(pOp->opcode);  /* Opcode */
      assert( pMem->z!=0 );
      pMem->n = sqlite3Strlen30(pMem->z);
      pMem->type = SQLITE_TEXT;
      pMem->enc = SQLITE_UTF8;
      pMem++;

      /* When an OP_Program opcode is encounter (the only opcode that has
      ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
      ** kept in p->aMem[9].z to hold the new program - assuming this subprogram
      ** has not already been seen.
      */
      if( pOp->p4type==P4_SUBPROGRAM ){
        int nByte = (nSub+1)*sizeof(SubProgram*);
        int j;
        for(j=0; j<nSub; j++){
          if( apSub[j]==pOp->p4.pProgram ) break;
        }
        if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
          apSub = (SubProgram **)pSub->z;
          apSub[nSub++] = pOp->p4.pProgram;
          pSub->flags |= MEM_Blob;
          pSub->n = nSub*sizeof(SubProgram*);
        }
      }
    }

    pMem->flags = MEM_Int;
    pMem->u.i = pOp->p1;                          /* P1 */
    pMem->type = SQLITE_INTEGER;
    pMem++;

    pMem->flags = MEM_Int;
    pMem->u.i = pOp->p2;                          /* P2 */
    pMem->type = SQLITE_INTEGER;
    pMem++;

    pMem->flags = MEM_Int;
    pMem->u.i = pOp->p3;                          /* P3 */
    pMem->type = SQLITE_INTEGER;
    pMem++;

    if( sqlite3VdbeMemGrow(pMem, 32, 0) ){            /* P4 */
      assert( p->db->mallocFailed );
      return SQLITE_ERROR;
    }
    pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
    z = displayP4(pOp, pMem->z, 32);
    if( z!=pMem->z ){
      sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0);
    }else{
      assert( pMem->z!=0 );
      pMem->n = sqlite3Strlen30(pMem->z);
      pMem->enc = SQLITE_UTF8;
    }
    pMem->type = SQLITE_TEXT;
    pMem++;

    if( p->explain==1 ){
      if( sqlite3VdbeMemGrow(pMem, 4, 0) ){
        assert( p->db->mallocFailed );
        return SQLITE_ERROR;
      }
      pMem->flags = MEM_Dyn|MEM_Str|MEM_Term;
      pMem->n = 2;
      sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5);   /* P5 */
      pMem->type = SQLITE_TEXT;
      pMem->enc = SQLITE_UTF8;
      pMem++;
  
#ifdef SQLITE_DEBUG
      if( pOp->zComment ){
        pMem->flags = MEM_Str|MEM_Term;
        pMem->z = pOp->zComment;
        pMem->n = sqlite3Strlen30(pMem->z);
        pMem->enc = SQLITE_UTF8;
        pMem->type = SQLITE_TEXT;
      }else
#endif
      {
        pMem->flags = MEM_Null;                       /* Comment */
        pMem->type = SQLITE_NULL;
      }
    }

    p->nResColumn = 8 - 4*(p->explain-1);
    p->pResultSet = &p->aMem[1];
    p->rc = SQLITE_OK;
    rc = SQLITE_ROW;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl $0x8, %esi
callq 0x2e430
movq -0x10(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
cmpl $0x7, 0x94(%rax)
jne 0x32210
movq -0x30(%rbp), %rax
movb $0x1, 0x50(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x327ac
movq -0x10(%rbp), %rax
movl 0x34(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
andw $0x3, %ax
movzwl %ax, %eax
cmpl $0x1, %eax
jne 0x3229f
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
addq $0x1f8, %rax            # imm = 0x1F8
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x3226e
movq -0x28(%rbp), %rax
movslq 0x20(%rax), %rax
shrq $0x3, %rax
movl %eax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x3229d
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %eax
addl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x32275
jmp 0x3229f
jmp 0x322a1
movq -0x10(%rbp), %rcx
movl 0x90(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x90(%rcx)
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x5d(%rbp)
jge 0x32303
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
andw $0x3, %ax
movzwl %ax, %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
movb %al, -0x5d(%rbp)
jne 0x32303
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
cmpl $0x96, %eax
setne %al
movb %al, -0x5d(%rbp)
movb -0x5d(%rbp), %al
testb $0x1, %al
jne 0x322a1
movl -0x34(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x3232c
movq -0x10(%rbp), %rax
movl $0x0, 0x94(%rax)
movl $0x65, -0x38(%rbp)
jmp 0x327a6
movq -0x30(%rbp), %rax
movl 0x148(%rax), %eax
cmpl $0x0, %eax
je 0x32391
movq -0x10(%rbp), %rax
movl $0x9, 0x94(%rax)
movl $0x1, -0x38(%rbp)
movq -0x10(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movl 0x94(%rax), %edi
callq 0x11060
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq %rax, %rcx
leaq 0x7be4b(%rip), %rdx     # 0xae1d0
movb $0x0, %al
callq 0x30360
jmp 0x327a4
movl -0x34(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x34(%rcx), %eax
jge 0x323b6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
jmp 0x32420
movq -0x10(%rbp), %rax
movl 0x34(%rax), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x34(%rbp), %eax
movq -0x20(%rbp), %rcx
movslq -0x54(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x8(%rcx), %eax
jl 0x32402
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x323cc
movq -0x20(%rbp), %rax
movslq -0x54(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
andw $0x3, %ax
movzwl %ax, %eax
cmpl $0x1, %eax
jne 0x32582
movq -0x40(%rbp), %rax
movw $0x4, 0x24(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x26(%rax)
movslq -0x34(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movw $0xa02, 0x24(%rax)      # imm = 0xA02
movq -0x50(%rbp), %rax
movzbl (%rax), %edi
callq 0x3a7d0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x92f0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x40(%rbp), %rax
movb $0x3, 0x26(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x27(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $-0x12, %eax
jne 0x32580
movl -0x18(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movl %eax, -0x58(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x3250c
movq -0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x324ff
jmp 0x3250c
jmp 0x32501
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x324df
movl -0x5c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0x3257e
movq -0x28(%rbp), %rdi
movl -0x58(%rbp), %esi
cmpl $0x0, -0x18(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %edx
callq 0x11940
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3257e
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x20(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rax
movzwl 0x24(%rax), %ecx
orl $0x10, %ecx
movw %cx, 0x24(%rax)
movslq -0x18(%rbp), %rax
shlq $0x3, %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x20(%rax)
jmp 0x32580
jmp 0x32582
movq -0x40(%rbp), %rax
movw $0x4, 0x24(%rax)
movq -0x50(%rbp), %rax
movslq 0x4(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x26(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movw $0x4, 0x24(%rax)
movq -0x50(%rbp), %rax
movslq 0x8(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x26(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movw $0x4, 0x24(%rax)
movq -0x50(%rbp), %rax
movslq 0xc(%rax), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x26(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movl $0x20, %esi
xorl %edx, %edx
callq 0x11940
cmpl $0x0, %eax
je 0x3262d
movl $0x1, -0x4(%rbp)
jmp 0x327ac
movq -0x40(%rbp), %rax
movw $0x602, 0x24(%rax)      # imm = 0x602
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movl $0x20, %edx
callq 0x3a7f0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x3267d
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x10900
jmp 0x3269b
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x92f0
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x27(%rax)
movq -0x40(%rbp), %rax
movb $0x3, 0x26(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
andw $0x3, %ax
movzwl %ax, %eax
cmpl $0x1, %eax
jne 0x32751
movq -0x40(%rbp), %rdi
movl $0x4, %esi
xorl %edx, %edx
callq 0x11940
cmpl $0x0, %eax
je 0x326eb
movl $0x1, -0x4(%rbp)
jmp 0x327ac
movq -0x40(%rbp), %rax
movw $0x602, 0x24(%rax)      # imm = 0x602
movq -0x40(%rbp), %rax
movl $0x2, 0x20(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x50(%rbp), %rax
movzbl 0x3(%rax), %ecx
movl $0x3, %edi
leaq 0x7bcec(%rip), %rdx     # 0xae408
movb $0x0, %al
callq 0xc540
movq -0x40(%rbp), %rax
movb $0x3, 0x26(%rax)
movq -0x40(%rbp), %rax
movb $0x1, 0x27(%rax)
movq -0x40(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movw $0x1, 0x24(%rax)
movq -0x40(%rbp), %rax
movb $0x5, 0x26(%rax)
movq -0x10(%rbp), %rax
movw 0x9a(%rax), %ax
andw $0x3, %ax
movzwl %ax, %ecx
subl $0x1, %ecx
shll $0x2, %ecx
movl $0x8, %eax
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rcx
addq $0x38, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x94(%rax)
movl $0x64, -0x38(%rbp)
jmp 0x327a6
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)