// File: /workspace/github_c_makefile_star2_O1/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 0x5762f
movl %r8d, %r12d
movq 0x40(%rdx), %r8
movl 0x28(%r8), %r14d
btl $0xd, %r14d
jb 0x5762f
movzwl %r9w, %eax
testb $0x40, %al
jne 0x5762f
movl %ecx, %r13d
movzbl 0x20(%rdx), %ecx
imulq $0x68, %rcx, %rcx
leaq (%rsi,%rcx), %r15
addq $0x8, %r15
movq (%rdi), %rcx
movq %rcx, -0x30(%rbp)
movl %r14d, %ecx
leaq 0x24588(%rip), %rdx     # 0x7bb3e
andl $0x30, %ecx
movl %ecx, -0x38(%rbp)
jne 0x575e0
btl $0xa, %r14d
jb 0x575cc
cmpl $0x0, 0x18(%r8)
jg 0x575e0
testb $0x3, %al
leaq 0x24570(%rip), %rax     # 0x7bb45
leaq 0x24562(%rip), %rdx     # 0x7bb3e
cmoveq %rax, %rdx
movq %r8, -0x40(%rbp)
movq 0x10(%rdi), %rax
movq %rax, -0x68(%rbp)
movl 0x210(%rdi), %eax
movl %eax, -0x58(%rbp)
leaq 0x220dd(%rip), %rsi     # 0x796d9
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x117e2
cmpq $0x0, 0x28(%r15)
je 0x5763e
movzbl 0x3a(%r15), %r8d
leaq 0x24075(%rip), %rdx     # 0x7b692
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rcx
xorl %eax, %eax
callq 0x338d2
jmp 0x57659
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r15), %r8
leaq 0x24501(%rip), %rdx     # 0x7bb4a
movq %rbx, %rdi
movq %rax, %rsi
movq %rax, %rcx
xorl %eax, %eax
callq 0x338d2
movq %rax, %rbx
movq 0x18(%r15), %r8
testq %r8, %r8
je 0x57680
leaq 0x244ea(%rip), %rdx     # 0x7bb56
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x338d2
movq %rax, %rbx
movq -0x40(%rbp), %rsi
testl $0x500, %r14d           # imm = 0x500
je 0x57707
btl $0x8, %r14d
setae %al
testb $0xf, %r14b
sete %cl
orb %al, %cl
je 0x576d3
btl $0xa, %r14d
movq -0x30(%rbp), %r15
jae 0x5795c
movl 0x18(%rsi), %r8d
movq 0x20(%rsi), %r9
leaq 0x2453f(%rip), %rdx     # 0x7bbfd
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x338d2
jmp 0x57959
leaq 0x244c6(%rip), %rdx     # 0x7bba0
movq -0x30(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x338d2
movq %rax, %rbx
testb $0x5, %r14b
je 0x577d4
leaq 0x244bb(%rip), %rdx     # 0x7bbbd
jmp 0x57949
movq 0x20(%rsi), %rcx
testq %rcx, %rcx
je 0x5768d
movl %r13d, -0x44(%rbp)
movq 0x20(%r15), %rax
movl 0x18(%rsi), %r13d
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq 0x8(%rcx), %rax
movq %rax, -0x50(%rbp)
testq %r13, %r13
movl %r12d, -0x54(%rbp)
jne 0x57743
testb $0x30, 0x28(%rsi)
je 0x579b0
movq %rcx, %r15
xorps %xmm0, %xmm0
leaq -0x90(%rbp), %rdi
movaps %xmm0, (%rdi)
movaps %xmm0, 0x10(%rdi)
movl $0x3b9aca00, 0x20(%rdi) # imm = 0x3B9ACA00
movw $0x1, 0x24(%rdi)
movq -0x30(%rbp), %r12
movq %r12, (%rdi)
leaq 0x2675f(%rip), %rsi     # 0x7ded1
movl $0x2, %edx
callq 0x172ee
testl %r13d, %r13d
movq %rbx, -0x60(%rbp)
jle 0x577e6
xorl %r12d, %r12d
leaq -0x90(%rbp), %rbx
movzwl 0x54(%r15), %eax
leaq 0x227d9(%rip), %rdx     # 0x79f74
cmpq %rax, %r12
je 0x577b8
movq -0x50(%rbp), %rax
movslq (%rax,%r12,4), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movq -0x38(%rbp), %rcx
movq (%rcx,%rax), %rdx
movq %rbx, %rdi
movl %r12d, %esi
leaq 0x26467(%rip), %rcx     # 0x7dc2c
callq 0x5b1e7
incq %r12
cmpq %r12, %r13
jne 0x5778f
jmp 0x577e9
cmpl $0x30, -0x38(%rbp)
jne 0x5780f
leaq 0x243e9(%rip), %rdx     # 0x7bbca
jmp 0x57949
xorl %r12d, %r12d
movq %r15, %rcx
movq -0x40(%rbp), %rax
testb $0x20, 0x28(%rax)
movl %r12d, %ebx
movl -0x44(%rbp), %r13d
je 0x5786c
movzwl 0x54(%rcx), %eax
cmpl %eax, %r12d
jne 0x5782f
leaq 0x22767(%rip), %rdx     # 0x79f74
jmp 0x5784a
testb $0x20, %r14b
jne 0x57942
testb $0x10, %r14b
je 0x5795c
leaq 0x243c6(%rip), %rdx     # 0x7bbf0
jmp 0x57949
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), %ebx
leaq 0x243c4(%rip), %rcx     # 0x7bc1a
leaq -0x90(%rbp), %rdi
movl %r12d, %esi
callq 0x5b1e7
movq -0x40(%rbp), %rax
movq %r15, %rcx
testb $0x10, 0x28(%rax)
movq -0x30(%rbp), %r15
je 0x578b8
movzwl 0x54(%rcx), %eax
cmpl %eax, %r12d
jne 0x57888
leaq 0x226ee(%rip), %rdx     # 0x79f74
jmp 0x578a3
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 0x24372(%rip), %rcx     # 0x7bc1c
leaq -0x90(%rbp), %rdi
movl %ebx, %esi
callq 0x5b1e7
leaq 0x23a96(%rip), %rsi     # 0x7b355
leaq -0x90(%rbp), %rbx
movq %rbx, %rdi
movl $0x1, %edx
callq 0x172ee
movq %rbx, %rdi
callq 0xb6e7
movq %rax, %r12
movq -0x60(%rbp), %rbx
movq -0x40(%rbp), %rsi
btl $0xe, %r14d
leaq 0x2428e(%rip), %rax     # 0x7bb80
leaq 0x24266(%rip), %rdx     # 0x7bb5f
cmovaeq %rax, %rdx
testb $0x40, %r14b
leaq 0x26a58(%rip), %rax     # 0x7e360
leaq 0x24287(%rip), %r8      # 0x7bb96
cmoveq %rax, %r8
movq 0x20(%rsi), %rax
movq (%rax), %r9
movq %r12, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x338d2
movq %rax, %rbx
movq %r15, %rdi
movq %r12, %rsi
callq 0x9c3a
movl -0x54(%rbp), %r12d
jmp 0x5795c
leaq 0x2429a(%rip), %rdx     # 0x7bbe3
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x338d2
movq %rax, %rbx
leaq 0x21d76(%rip), %rdx     # 0x796d9
movq %r15, %rdi
movq %rbx, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x338d2
movq %rax, %rbx
movq -0x68(%rbp), %r14
movq %r14, %rdi
movl $0x96, %esi
movl -0x58(%rbp), %edx
movl %r13d, %ecx
movl %r12d, %r8d
callq 0x45b9e
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 0x11975
xorl %r12d, %r12d
movl -0x44(%rbp), %r13d
movq -0x30(%rbp), %r15
jmp 0x578e6