// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3WhereEnd
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
  Parse *pParse = pWInfo->pParse;
  Vdbe *v = pParse->pVdbe;
  int i;
  WhereLevel *pLevel;
  WhereLoop *pLoop;
  SrcList *pTabList = pWInfo->pTabList;
  sqlite3 *db = pParse->db;

  /* Generate loop termination code.
  */
  VdbeModuleComment((v, "End WHERE-core"));
  sqlite3ExprCacheClear(pParse);
  for(i=pWInfo->nLevel-1; i>=0; i--){
    int addr;
    pLevel = &pWInfo->a[i];
    pLoop = pLevel->pWLoop;
    sqlite3VdbeResolveLabel(v, pLevel->addrCont);
    if( pLevel->op!=OP_Noop ){
      sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3);
      sqlite3VdbeChangeP5(v, pLevel->p5);
      VdbeCoverage(v);
      VdbeCoverageIf(v, pLevel->op==OP_Next);
      VdbeCoverageIf(v, pLevel->op==OP_Prev);
      VdbeCoverageIf(v, pLevel->op==OP_VNext);
    }
    if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){
      struct InLoop *pIn;
      int j;
      sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
      for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
        sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
        sqlite3VdbeAddOp2(v, pIn->eEndLoopOp, pIn->iCur, pIn->addrInTop);
        VdbeCoverage(v);
        VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
        VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
        sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
      }
    }
    sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
    if( pLevel->addrSkip ){
      sqlite3VdbeGoto(v, pLevel->addrSkip);
      VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
      sqlite3VdbeJumpHere(v, pLevel->addrSkip);
      sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
    }
#ifndef SQLITE_LIKE_DOESNT_MATCH_BLOBS
    if( pLevel->addrLikeRep ){
      int op;
      if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){
        op = OP_DecrJumpZero;
      }else{
        op = OP_JumpZeroIncr;
      }
      sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep);
      VdbeCoverage(v);
    }
#endif
    if( pLevel->iLeftJoin ){
      addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
      assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
           || (pLoop->wsFlags & WHERE_INDEXED)!=0 );
      if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 ){
        sqlite3VdbeAddOp1(v, OP_NullRow, pTabList->a[i].iCursor);
      }
      if( pLoop->wsFlags & WHERE_INDEXED ){
        sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
      }
      if( pLevel->op==OP_Return ){
        sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
      }else{
        sqlite3VdbeGoto(v, pLevel->addrFirst);
      }
      sqlite3VdbeJumpHere(v, addr);
    }
    VdbeModuleComment((v, "End WHERE-loop%d: %s", i,
                     pWInfo->pTabList->a[pLevel->iFrom].pTab->zName));
  }

  /* The "break" point is here, just past the end of the outer loop.
  ** Set it.
  */
  sqlite3VdbeResolveLabel(v, pWInfo->iBreak);

  assert( pWInfo->nLevel<=pTabList->nSrc );
  for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){
    int k, last;
    VdbeOp *pOp;
    Index *pIdx = 0;
    struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
    Table *pTab = pTabItem->pTab;
    assert( pTab!=0 );
    pLoop = pLevel->pWLoop;

    /* For a co-routine, change all OP_Column references to the table of
    ** the co-routine into OP_Copy of result contained in a register.
    ** OP_Rowid becomes OP_Null.
    */
    if( pTabItem->fg.viaCoroutine && !db->mallocFailed ){
      translateColumnToCopy(v, pLevel->addrBody, pLevel->iTabCur,
                            pTabItem->regResult, 0);
      continue;
    }

    /* Close all of the cursors that were opened by sqlite3WhereBegin.
    ** Except, do not close cursors that will be reused by the OR optimization
    ** (WHERE_OMIT_OPEN_CLOSE).  And do not close the OP_OpenWrite cursors
    ** created for the ONEPASS optimization.
    */
    if( (pTab->tabFlags & TF_Ephemeral)==0
     && pTab->pSelect==0
     && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0
    ){
      int ws = pLoop->wsFlags;
      if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
        sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
      }
      if( (ws & WHERE_INDEXED)!=0
       && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 
       && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1]
      ){
        sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
      }
    }

    /* If this scan uses an index, make VDBE code substitutions to read data
    ** from the index instead of from the table where possible.  In some cases
    ** this optimization prevents the table from ever being read, which can
    ** yield a significant performance boost.
    ** 
    ** Calls to the code generator in between sqlite3WhereBegin and
    ** sqlite3WhereEnd will have created code that references the table
    ** directly.  This loop scans all that code looking for opcodes
    ** that reference the table and converts them into opcodes that
    ** reference the index.
    */
    if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){
      pIdx = pLoop->u.btree.pIndex;
    }else if( pLoop->wsFlags & WHERE_MULTI_OR ){
      pIdx = pLevel->u.pCovidx;
    }
    if( pIdx
     && (pWInfo->eOnePass==ONEPASS_OFF || !HasRowid(pIdx->pTable))
     && !db->mallocFailed
    ){
      last = sqlite3VdbeCurrentAddr(v);
      k = pLevel->addrBody;
      pOp = sqlite3VdbeGetOp(v, k);
      for(; k<last; k++, pOp++){
        if( pOp->p1!=pLevel->iTabCur ) continue;
        if( pOp->opcode==OP_Column ){
          int x = pOp->p2;
          assert( pIdx->pTable==pTab );
          if( !HasRowid(pTab) ){
            Index *pPk = sqlite3PrimaryKeyIndex(pTab);
            x = pPk->aiColumn[x];
            assert( x>=0 );
          }
          x = sqlite3ColumnOfIndex(pIdx, x);
          if( x>=0 ){
            pOp->p2 = x;
            pOp->p1 = pLevel->iIdxCur;
          }
          assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 );
        }else if( pOp->opcode==OP_Rowid ){
          pOp->p1 = pLevel->iIdxCur;
          pOp->opcode = OP_IdxRowid;
        }
      }
    }
  }

  /* Final cleanup
  */
  pParse->nQueryLoop = pWInfo->savedNQueryLoop;
  whereInfoFree(db, pWInfo);
  return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7ff50
movq -0x8(%rbp), %rax
movzbl 0x39(%rax), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x7faa5
movq -0x8(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movslq -0x1c(%rbp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x18(%rax), %esi
callq 0x6e780
movq -0x28(%rbp), %rax
movzbl 0x2d(%rax), %eax
cmpl $0xa1, %eax
je 0x7f87b
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movzbl 0x2d(%rax), %esi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %edx
movq -0x28(%rbp), %rax
movl 0x34(%rax), %ecx
movq -0x28(%rbp), %rax
movzbl 0x2e(%rax), %r8d
callq 0x56c10
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movzbl 0x2f(%rax), %esi
callq 0x17b70
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x7f937
movq -0x28(%rbp), %rax
cmpl $0x0, 0x38(%rax)
jle 0x7f937
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x10(%rax), %esi
callq 0x6e780
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x54(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
cmpl $0x0, -0x54(%rbp)
jle 0x7f935
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0x4(%rax), %esi
addl $0x1, %esi
callq 0x6be30
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movzbl 0x8(%rax), %esi
movq -0x50(%rbp), %rax
movl (%rax), %edx
movq -0x50(%rbp), %rax
movl 0x4(%rax), %ecx
callq 0x6c310
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rax
movl 0x4(%rax), %esi
subl $0x1, %esi
callq 0x6be30
movl -0x54(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x50(%rbp), %rax
addq $-0xc, %rax
movq %rax, -0x50(%rbp)
jmp 0x7f8d4
jmp 0x7f937
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0xc(%rax), %esi
callq 0x6e780
movq -0x28(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x7f984
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x14(%rax), %esi
callq 0x6c1b0
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x14(%rax), %esi
callq 0x6be30
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x14(%rax), %esi
subl $0x2, %esi
callq 0x6be30
movq -0x28(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0x7f9d1
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x28(%rax), %esi
subl $0x1, %esi
callq 0x56e10
cmpl $0x0, 0x4(%rax)
je 0x7f9b0
movl $0x8e, -0x58(%rbp)
jmp 0x7f9b7
movl $0x8f, -0x58(%rbp)
movq -0x18(%rbp), %rdi
movl -0x58(%rbp), %esi
movq -0x28(%rbp), %rax
movl 0x24(%rax), %edx
movq -0x28(%rbp), %rax
movl 0x28(%rax), %ecx
callq 0x6c310
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x7fa95
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl (%rax), %edx
movl $0x8b, %esi
callq 0x6e570
movl %eax, -0x44(%rbp)
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x7fa28
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rax
addq $0x8, %rax
movslq -0x1c(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movl 0x44(%rax), %edx
movl $0x6a, %esi
callq 0x6e570
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x7fa4e
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %edx
movl $0x6a, %esi
callq 0x6e570
movq -0x28(%rbp), %rax
movzbl 0x2d(%rax), %eax
cmpl $0x10, %eax
jne 0x7fa79
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x30(%rax), %edx
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %ecx
movl $0xf, %esi
callq 0x6c310
jmp 0x7fa89
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x6c1b0
movq -0x18(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x6be30
jmp 0x7fa97
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x7f7f4
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x44(%rax), %esi
callq 0x6e780
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rax
addq $0x340, %rax            # imm = 0x340
movq %rax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movzbl 0x39(%rcx), %ecx
cmpl %ecx, %eax
jge 0x7fdcf
movq $0x0, -0x70(%rbp)
movq -0x38(%rbp), %rax
addq $0x8, %rax
movq -0x28(%rbp), %rcx
movzbl 0x2c(%rcx), %ecx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x78(%rbp), %rax
movb 0x3d(%rax), %al
shrb $0x4, %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x7fb5c
movq -0x40(%rbp), %rax
cmpb $0x0, 0x51(%rax)
jne 0x7fb5c
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x20(%rax), %esi
movq -0x28(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x78(%rbp), %rax
movl 0x38(%rax), %ecx
xorl %r8d, %r8d
callq 0x8dda0
jmp 0x7fdb5
movq -0x80(%rbp), %rax
movzbl 0x46(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x7fc17
movq -0x80(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x7fc17
movq -0x8(%rbp), %rax
movzwl 0x32(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x7fc17
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x84(%rbp)
movq -0x8(%rbp), %rax
movzbl 0x36(%rax), %eax
cmpl $0x0, %eax
jne 0x7fbd0
movl -0x84(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x7fbd0
movq -0x18(%rbp), %rdi
movq -0x78(%rbp), %rax
movl 0x44(%rax), %edx
movl $0x3e, %esi
callq 0x6e570
movl -0x84(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x7fc15
movl -0x84(%rbp), %eax
andl $0x4100, %eax           # imm = 0x4100
cmpl $0x0, %eax
jne 0x7fc15
movq -0x28(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x50(%rcx), %eax
je 0x7fc15
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rax
movl 0x8(%rax), %edx
movl $0x3e, %esi
callq 0x6e570
jmp 0x7fc17
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x240, %eax            # imm = 0x240
cmpl $0x0, %eax
je 0x7fc36
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x7fc55
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x7fc53
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x7fc55
cmpq $0x0, -0x70(%rbp)
je 0x7fdb3
movq -0x8(%rbp), %rax
movzbl 0x36(%rax), %eax
cmpl $0x0, %eax
je 0x7fc85
movq -0x70(%rbp), %rax
movq 0x18(%rax), %rax
movzbl 0x46(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x7fdb3
movq -0x40(%rbp), %rax
cmpb $0x0, 0x51(%rax)
jne 0x7fdb3
movq -0x18(%rbp), %rdi
callq 0x6c2b0
movl %eax, -0x60(%rbp)
movq -0x28(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x56e10
movq %rax, -0x68(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x60(%rbp), %eax
jge 0x7fdb1
movq -0x68(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x4(%rcx), %eax
je 0x7fcda
jmp 0x7fd97
movq -0x68(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x30, %eax
jne 0x7fd72
movq -0x68(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x88(%rbp)
movq -0x80(%rbp), %rax
movzbl 0x46(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x7fd33
movq -0x80(%rbp), %rdi
callq 0x52e70
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x88(%rbp), %rcx
movswl (%rax,%rcx,2), %eax
movl %eax, -0x88(%rbp)
movq -0x70(%rbp), %rdi
movl -0x88(%rbp), %eax
movswl %ax, %esi
callq 0x70180
cwtl
movl %eax, -0x88(%rbp)
cmpl $0x0, -0x88(%rbp)
jl 0x7fd70
movl -0x88(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x4(%rax)
jmp 0x7fd95
movq -0x68(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x69, %eax
jne 0x7fd93
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x68(%rbp), %rax
movb $0x72, (%rax)
jmp 0x7fd95
jmp 0x7fd97
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x68(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x68(%rbp)
jmp 0x7fcb9
jmp 0x7fdb3
jmp 0x7fdb5
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x28(%rbp)
jmp 0x7faca
movq -0x8(%rbp), %rax
movl 0x48(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1d4(%rax)
movq -0x40(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x86d40
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)