// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3VdbeNextOpcode
SQLITE_PRIVATE int sqlite3VdbeNextOpcode(
  Vdbe *p,         /* The statement being explained */
  Mem *pSub,       /* Storage for keeping track of subprogram nesting */
  int eMode,       /* 0: normal.  1: EQP.  2:  TablesUsed */
  int *piPc,       /* IN/OUT: Current rowid.  Overwritten with next rowid */
  int *piAddr,     /* OUT: Write index into (*paOp)[] here */
  Op **paOp        /* OUT: Write the opcode array here */
){
  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 */
  int i;                               /* Next instruction address */
  int rc = SQLITE_OK;                  /* Result code */
  Op *aOp = 0;                         /* Opcode array */
  int iPc;                             /* Rowid.  Copy of value in *piPc */

  /* 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( pSub!=0 ){
    if( pSub->flags&MEM_Blob ){
      /* pSub is initiallly 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;
    }
  }
  iPc = *piPc;
  while(1){  /* Loop exits via break */
    i = iPc++;
    if( i>=nRow ){
      p->rc = SQLITE_OK;
      rc = SQLITE_DONE;
      break;
    }
    if( i<p->nOp ){
      /* The rowid is small enough that we are still in the
      ** main program. */
      aOp = p->aOp;
    }else{
      /* We are currently listing subprograms.  Figure out which one and
      ** pick up the appropriate opcode. */
      int j;
      i -= p->nOp;
      assert( apSub!=0 );
      assert( nSub>0 );
      for(j=0; i>=apSub[j]->nOp; j++){
        i -= apSub[j]->nOp;
        assert( i<apSub[j]->nOp || j+1<nSub );
      }
      aOp = apSub[j]->aOp;
    }

    /* 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( pSub!=0 && aOp[i].p4type==P4_SUBPROGRAM ){
      int nByte = (nSub+1)*sizeof(SubProgram*);
      int j;
      for(j=0; j<nSub; j++){
        if( apSub[j]==aOp[i].p4.pProgram ) break;
      }
      if( j==nSub ){
        p->rc = sqlite3VdbeMemGrow(pSub, nByte, nSub!=0);
        if( p->rc!=SQLITE_OK ){
          rc = SQLITE_ERROR;
          break;
        }
        apSub = (SubProgram **)pSub->z;
        apSub[nSub++] = aOp[i].p4.pProgram;
        MemSetTypeFlag(pSub, MEM_Blob);
        pSub->n = nSub*sizeof(SubProgram*);
        nRow += aOp[i].p4.pProgram->nOp;
      }
    }
    if( eMode==0 ) break;
#ifdef SQLITE_ENABLE_BYTECODE_VTAB
    if( eMode==2 ){
      Op *pOp = aOp + i;
      if( pOp->opcode==OP_OpenRead ) break;
      if( pOp->opcode==OP_OpenWrite && (pOp->p5 & OPFLAG_P2ISREG)==0 ) break;
      if( pOp->opcode==OP_ReopenIdx ) break;
    }else
#endif
    {
      assert( eMode==1 );
      if( aOp[i].opcode==OP_Explain ) break;
      if( aOp[i].opcode==OP_Init && iPc>1 ) break;
    }
  }
  *piPc = iPc;
  *piAddr = i;
  *paOp = aOp;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x8(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x34(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3f931d
movq -0x10(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x3f92ec
movq -0x10(%rbp), %rax
movslq 0xc(%rax), %rax
shrq $0x3, %rax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x3f931b
movq -0x40(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x3f92f3
jmp 0x3f931d
movq -0x20(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x54(%rbp)
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x34(%rbp), %eax
jl 0x3f9353
movq -0x8(%rbp), %rax
movl $0x0, 0x38(%rax)
movl $0x65, -0x48(%rbp)
jmp 0x3f9553
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x90(%rcx), %eax
jge 0x3f9373
movq -0x8(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x3f93d5
movq -0x8(%rbp), %rax
movl 0x90(%rax), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x58(%rbp)
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x58(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl 0x8(%rcx), %eax
jl 0x3f93c2
movq -0x40(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %ecx
movl -0x44(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x3f938c
movq -0x40(%rbp), %rax
movslq -0x58(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x3f950c
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movsbl 0x1(%rax), %eax
cmpl $-0x4, %eax
jne 0x3f950c
movl -0x38(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x3, %rax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x3f944a
movq -0x40(%rbp), %rax
movslq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
movslq -0x44(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x10(%rcx), %rax
jne 0x3f943d
jmp 0x3f944a
jmp 0x3f943f
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x3f9412
movl -0x60(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0x3f950a
movq -0x10(%rbp), %rdi
movl -0x5c(%rbp), %esi
cmpl $0x0, -0x38(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %edx
callq 0x3ee060
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x38(%rax)
je 0x3f948d
movl $0x1, -0x48(%rbp)
jmp 0x3f9553
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movq -0x40(%rbp), %rax
movl -0x38(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x38(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movzwl 0x8(%rax), %eax
andl $0xffff3e40, %eax       # imm = 0xFFFF3E40
orl $0x10, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x8(%rax)
movslq -0x38(%rbp), %rax
shlq $0x3, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl 0x8(%rax), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x3f950c
cmpl $0x0, -0x14(%rbp)
jne 0x3f9514
jmp 0x3f9553
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
cmpl $0xae, %eax
jne 0x3f952f
jmp 0x3f9553
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
cmpl $0x3e, %eax
jne 0x3f954e
cmpl $0x1, -0x54(%rbp)
jle 0x3f954e
jmp 0x3f9553
jmp 0x3f9326
movl -0x54(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x44(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl -0x48(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)