// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: explainOneScan
static void explainOneScan(
  Parse *pParse,                  /* Parse context */
  SrcList *pTabList,              /* Table list this loop refers to */
  WhereLevel *pLevel,             /* Scan to write OP_Explain opcode for */
  int iLevel,                     /* Value for "level" column of output */
  int iFrom,                      /* Value for "from" column of output */
  u16 wctrlFlags                  /* Flags passed to sqlite3WhereBegin() */
){
  if( pParse->explain==2 ){
    struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
    Vdbe *v = pParse->pVdbe;      /* VM being constructed */
    sqlite3 *db = pParse->db;     /* Database handle */
    char *zMsg;                   /* Text to add to EQP output */
    int iId = pParse->iSelectId;  /* Select id (left-most output column) */
    int isSearch;                 /* True for a SEARCH. False for SCAN. */
    WhereLoop *pLoop;             /* The controlling WhereLoop object */
    u32 flags;                    /* Flags that describe this loop */

    pLoop = pLevel->pWLoop;
    flags = pLoop->wsFlags;
    if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return;

    isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
            || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
            || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));

    zMsg = sqlite3MPrintf(db, "%s", isSearch?"SEARCH":"SCAN");
    if( pItem->pSelect ){
      zMsg = sqlite3MAppendf(db, zMsg, "%s SUBQUERY %d", zMsg,pItem->iSelectId);
    }else{
      zMsg = sqlite3MAppendf(db, zMsg, "%s TABLE %s", zMsg, pItem->zName);
    }

    if( pItem->zAlias ){
      zMsg = sqlite3MAppendf(db, zMsg, "%s AS %s", zMsg, pItem->zAlias);
    }
    if( (flags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0
     && ALWAYS(pLoop->u.btree.pIndex!=0)
    ){
      char *zWhere = explainIndexRange(db, pLoop, pItem->pTab);
      zMsg = sqlite3MAppendf(db, zMsg,
               ((flags & WHERE_AUTO_INDEX) ? 
                   "%s USING AUTOMATIC %sINDEX%.0s%s" :
                   "%s USING %sINDEX %s%s"), 
               zMsg, ((flags & WHERE_IDX_ONLY) ? "COVERING " : ""),
               pLoop->u.btree.pIndex->zName, zWhere);
      sqlite3DbFree(db, zWhere);
    }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
      zMsg = sqlite3MAppendf(db, zMsg, "%s USING INTEGER PRIMARY KEY", zMsg);

      if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
        zMsg = sqlite3MAppendf(db, zMsg, "%s (rowid=?)", zMsg);
      }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){
        zMsg = sqlite3MAppendf(db, zMsg, "%s (rowid>? AND rowid<?)", zMsg);
      }else if( flags&WHERE_BTM_LIMIT ){
        zMsg = sqlite3MAppendf(db, zMsg, "%s (rowid>?)", zMsg);
      }else if( ALWAYS(flags&WHERE_TOP_LIMIT) ){
        zMsg = sqlite3MAppendf(db, zMsg, "%s (rowid<?)", zMsg);
      }
    }
#ifndef SQLITE_OMIT_VIRTUALTABLE
    else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
      zMsg = sqlite3MAppendf(db, zMsg, "%s VIRTUAL TABLE INDEX %d:%s", zMsg,
                  pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr);
    }
#endif
    zMsg = sqlite3MAppendf(db, zMsg, "%s", zMsg);
    sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg, P4_DYNAMIC);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
cmpb $0x2, 0x200(%rdi)
jne 0x57640
movq 0x40(%rdx), %r10
movl 0x28(%r10), %r13d
btl $0xd, %r13d
jb 0x57640
movzwl %r9w, %eax
testb $0x40, %al
jne 0x57640
movl %ecx, %r12d
movzbl 0x20(%rdx), %ecx
imulq $0x68, %rcx, %rcx
leaq (%rsi,%rcx), %r14
addq $0x8, %r14
movq (%rdi), %rcx
movq %rcx, -0x30(%rbp)
movl %r13d, %ecx
leaq 0x2457a(%rip), %rdx     # 0x7bb3e
andl $0x30, %ecx
movl %ecx, -0x38(%rbp)
movl %r8d, %ebx
jne 0x575f1
btl $0xa, %r13d
jb 0x575dd
cmpl $0x0, 0x18(%r10)
jg 0x575f1
testb $0x3, %al
leaq 0x2455f(%rip), %rax     # 0x7bb45
leaq 0x24551(%rip), %rdx     # 0x7bb3e
cmoveq %rax, %rdx
movq %r10, -0x40(%rbp)
movq 0x10(%rdi), %rax
movq %rax, -0x70(%rbp)
movl 0x210(%rdi), %eax
movl %eax, -0x5c(%rbp)
leaq 0x220cc(%rip), %rsi     # 0x796d9
movq -0x30(%rbp), %r15
movq %r15, %rdi
xorl %eax, %eax
callq 0x11900
cmpq $0x0, 0x28(%r14)
je 0x5764f
movzbl 0x3a(%r14), %r8d
leaq 0x24064(%rip), %rdx     # 0x7b692
movq %r15, %rdi
movq %rax, %rsi
movq %rax, %rcx
xorl %eax, %eax
callq 0x33fcf
jmp 0x5766a
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r14), %r8
leaq 0x244f0(%rip), %rdx     # 0x7bb4a
movq %r15, %rdi
movq %rax, %rsi
movq %rax, %rcx
xorl %eax, %eax
callq 0x33fcf
movq %rax, %rsi
movq 0x18(%r14), %r8
testq %r8, %r8
movl %ebx, %r15d
je 0x57691
leaq 0x244d6(%rip), %rdx     # 0x7bb56
movq -0x30(%rbp), %rdi
movq %rsi, %rcx
xorl %eax, %eax
callq 0x33fcf
movq %rax, %rsi
movq -0x40(%rbp), %rdx
testl $0x500, %r13d           # imm = 0x500
je 0x57712
btl $0x8, %r13d
setae %al
testb $0xf, %r13b
sete %cl
orb %al, %cl
je 0x576e1
btl $0xa, %r13d
movq -0x30(%rbp), %r14
jae 0x5796d
movl 0x18(%rdx), %r8d
movq 0x20(%rdx), %r9
leaq 0x2452e(%rip), %rdx     # 0x7bbfd
movq %r14, %rdi
movq %rsi, %rcx
xorl %eax, %eax
callq 0x33fcf
jmp 0x5796a
leaq 0x244b8(%rip), %rdx     # 0x7bba0
movq -0x30(%rbp), %r14
movq %r14, %rdi
movq %rsi, %rcx
xorl %eax, %eax
callq 0x33fcf
movq %rax, %rsi
testb $0x5, %r13b
je 0x577ef
leaq 0x244b0(%rip), %rdx     # 0x7bbbd
jmp 0x5795d
movq 0x20(%rdx), %rbx
testq %rbx, %rbx
je 0x5769e
movl %r12d, -0x58(%rbp)
movq 0x20(%r14), %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movl 0x18(%rdx), %r12d
movq 0x8(%rbx), %rax
movq %rax, -0x50(%rbp)
testq %r12, %r12
jne 0x57746
testb $0x30, 0x28(%rdx)
je 0x579be
movq %rsi, -0x68(%rbp)
xorps %xmm0, %xmm0
leaq -0x98(%rbp), %rdi
movups %xmm0, 0x8(%rdi)
movq $0x0, 0x18(%rdi)
movl $0x3b9aca00, 0x20(%rdi) # imm = 0x3B9ACA00
movw $0x1, 0x24(%rdi)
movq -0x30(%rbp), %r14
movq %r14, (%rdi)
leaq 0x267a6(%rip), %rsi     # 0x7df21
movl $0x2, %edx
callq 0x172f3
testl %r12d, %r12d
movl %r15d, -0x44(%rbp)
jle 0x57801
movl %r13d, -0x54(%rbp)
xorl %r15d, %r15d
leaq 0x264e0(%rip), %r13     # 0x7dc7c
leaq -0x98(%rbp), %r14
movzwl 0x54(%rbx), %eax
leaq 0x227c6(%rip), %rdx     # 0x79f74
cmpq %rax, %r15
je 0x577cb
movq -0x50(%rbp), %rax
movslq (%rax,%r15,4), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq -0x38(%rbp), %rcx
movq (%rcx,%rax), %rdx
movq %r14, %rdi
movl %r15d, %esi
movq %r13, %rcx
callq 0x5b183
incq %r15
cmpq %r15, %r12
jne 0x577a3
movl -0x44(%rbp), %r15d
movq -0x30(%rbp), %r14
movl -0x54(%rbp), %r13d
jmp 0x57804
cmpl $0x30, -0x38(%rbp)
jne 0x57824
leaq 0x243ce(%rip), %rdx     # 0x7bbca
jmp 0x5795d
xorl %r12d, %r12d
movq -0x40(%rbp), %rax
movl 0x28(%rax), %eax
movl %r12d, %esi
testb $0x20, %al
je 0x57888
movzwl 0x54(%rbx), %eax
cmpl %eax, %r12d
jne 0x57844
leaq 0x22752(%rip), %rdx     # 0x79f74
jmp 0x5785f
testb $0x20, %r13b
jne 0x57956
testb $0x10, %r13b
je 0x5796d
leaq 0x243b1(%rip), %rdx     # 0x7bbf0
jmp 0x5795d
movl %r12d, %eax
movq -0x50(%rbp), %rcx
movslq (%rcx,%rax,4), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq -0x38(%rbp), %rcx
movq (%rcx,%rax), %rdx
leal 0x1(%r12), %r15d
leaq 0x243af(%rip), %rcx     # 0x7bc1a
leaq -0x98(%rbp), %rdi
movl %r12d, %esi
callq 0x5b183
movl %r15d, %esi
movq -0x40(%rbp), %rax
movl 0x28(%rax), %eax
movl -0x44(%rbp), %r15d
testb $0x10, %al
je 0x578cc
movzwl 0x54(%rbx), %eax
cmpl %eax, %r12d
jne 0x5789e
leaq 0x226d8(%rip), %rdx     # 0x79f74
jmp 0x578b9
movl %r12d, %eax
movq -0x50(%rbp), %rcx
movslq (%rcx,%rax,4), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq -0x38(%rbp), %rcx
movq (%rcx,%rax), %rdx
leaq 0x2435c(%rip), %rcx     # 0x7bc1c
leaq -0x98(%rbp), %rdi
callq 0x5b183
leaq 0x23a82(%rip), %rsi     # 0x7b355
leaq -0x98(%rbp), %rbx
movq %rbx, %rdi
movl $0x1, %edx
callq 0x172f3
movq %rbx, %rdi
callq 0xb7d6
movq %rax, %r12
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rbx
movq -0x68(%rbp), %rsi
btl $0xe, %r13d
leaq 0x24276(%rip), %rax     # 0x7bb80
leaq 0x2424e(%rip), %rdx     # 0x7bb5f
cmovaeq %rax, %rdx
testb $0x40, %r13b
leaq 0x26a90(%rip), %rax     # 0x7e3b0
leaq 0x2426f(%rip), %r8      # 0x7bb96
cmoveq %rax, %r8
movq (%rbx), %r9
movq %r12, (%rsp)
movq %r14, %rdi
movq %rsi, %rcx
xorl %eax, %eax
callq 0x33fcf
movq %rax, %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0x9ca4
movq %rbx, %rsi
movl -0x58(%rbp), %r12d
jmp 0x5796d
leaq 0x24286(%rip), %rdx     # 0x7bbe3
movq %r14, %rdi
movq %rsi, %rcx
xorl %eax, %eax
callq 0x33fcf
movq %rax, %rsi
leaq 0x21d65(%rip), %rdx     # 0x796d9
movq %r14, %rdi
movq %rsi, %rcx
xorl %eax, %eax
callq 0x33fcf
movq %rax, %rbx
movq -0x70(%rbp), %r14
movq %r14, %rdi
movl $0x96, %esi
movl -0x5c(%rbp), %edx
movl %r12d, %ecx
movl %r15d, %r8d
callq 0x45f15
movq %r14, %rdi
movl %eax, %esi
movq %rbx, %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11a9f
xorl %r12d, %r12d
movq -0x30(%rbp), %r14
jmp 0x578fe