// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3VdbeExpandSql
SQLITE_PRIVATE char *sqlite3VdbeExpandSql(
  Vdbe *p,                 /* The prepared statement being evaluated */
  const char *zRawSql      /* Raw text of the SQL statement */
){
  sqlite3 *db;             /* The database connection */
  int idx = 0;             /* Index of a host parameter */
  int nextIndex = 1;       /* Index of next ? host parameter */
  int n;                   /* Length of a token prefix */
  int nToken;              /* Length of the parameter token */
  int i;                   /* Loop counter */
  Mem *pVar;               /* Value of a host parameter */
  StrAccum out;            /* Accumulate the output here */
  char zBase[100];         /* Initial working space */

  db = p->db;
  sqlite3StrAccumInit(&out, zBase, sizeof(zBase), 
                      db->aLimit[SQLITE_LIMIT_LENGTH]);
  out.db = db;
  if( db->nVdbeExec>1 ){
    while( *zRawSql ){
      const char *zStart = zRawSql;
      while( *(zRawSql++)!='\n' && *zRawSql );
      sqlite3StrAccumAppend(&out, "-- ", 3);
      sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
    }
  }else{
    while( zRawSql[0] ){
      n = findNextHostParameter(zRawSql, &nToken);
      assert( n>0 );
      sqlite3StrAccumAppend(&out, zRawSql, n);
      zRawSql += n;
      assert( zRawSql[0] || nToken==0 );
      if( nToken==0 ) break;
      if( zRawSql[0]=='?' ){
        if( nToken>1 ){
          assert( sqlite3Isdigit(zRawSql[1]) );
          sqlite3GetInt32(&zRawSql[1], &idx);
        }else{
          idx = nextIndex;
        }
      }else{
        assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' );
        testcase( zRawSql[0]==':' );
        testcase( zRawSql[0]=='$' );
        testcase( zRawSql[0]=='@' );
        idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);
        assert( idx>0 );
      }
      zRawSql += nToken;
      nextIndex = idx + 1;
      assert( idx>0 && idx<=p->nVar );
      pVar = &p->aVar[idx-1];
      if( pVar->flags & MEM_Null ){
        sqlite3StrAccumAppend(&out, "NULL", 4);
      }else if( pVar->flags & MEM_Int ){
        sqlite3XPrintf(&out, "%lld", pVar->u.i);
      }else if( pVar->flags & MEM_Real ){
        sqlite3XPrintf(&out, "%!.15g", pVar->r);
      }else if( pVar->flags & MEM_Str ){
        int nOut;  /* Number of bytes of the string text to include in output */
#ifndef SQLITE_OMIT_UTF16
        u8 enc = ENC(db);
        Mem utf8;
        if( enc!=SQLITE_UTF8 ){
          memset(&utf8, 0, sizeof(utf8));
          utf8.db = db;
          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
          sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8);
          pVar = &utf8;
        }
#endif
        nOut = pVar->n;
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut>SQLITE_TRACE_SIZE_LIMIT ){
          nOut = SQLITE_TRACE_SIZE_LIMIT;
          while( nOut<pVar->n && (pVar->z[nOut]&0xc0)==0x80 ){ nOut++; }
        }
#endif    
        sqlite3XPrintf(&out, "'%.*q'", nOut, pVar->z);
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut<pVar->n ) sqlite3XPrintf(&out, "/*+%d bytes*/", pVar->n-nOut);
#endif
#ifndef SQLITE_OMIT_UTF16
        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);
#endif
      }else if( pVar->flags & MEM_Zero ){
        sqlite3XPrintf(&out, "zeroblob(%d)", pVar->u.nZero);
      }else{
        int nOut;  /* Number of bytes of the blob to include in output */
        assert( pVar->flags & MEM_Blob );
        sqlite3StrAccumAppend(&out, "x'", 2);
        nOut = pVar->n;
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut>SQLITE_TRACE_SIZE_LIMIT ) nOut = SQLITE_TRACE_SIZE_LIMIT;
#endif
        for(i=0; i<nOut; i++){
          sqlite3XPrintf(&out, "%02x", pVar->z[i]&0xff);
        }
        sqlite3StrAccumAppend(&out, "'", 1);
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut<pVar->n ) sqlite3XPrintf(&out, "/*+%d bytes*/", pVar->n-nOut);
#endif
      }
    }
  }
  return sqlite3StrAccumFinish(&out);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r13
movl $0x0, -0x30(%rbp)
movq (%rdi), %rdx
movl 0x68(%rdx), %eax
leaq -0x120(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movq %rcx, -0x48(%rbp)
movabsq $0x6400000000, %rcx     # imm = 0x6400000000
movq %rcx, -0x40(%rbp)
movl %eax, -0x38(%rbp)
movw $0x1, -0x34(%rbp)
movq %rdx, -0x58(%rbp)
cmpl $0x1, 0xa8(%rdx)
movb (%rsi), %al
jle 0x3048c
testb %al, %al
je 0x3071a
leaq 0x4a52d(%rip), %r14     # 0x7a96c
leaq -0x58(%rbp), %r15
movl $0x1, %ecx
movq %rcx, %r12
cmpb $0xa, %al
je 0x3045d
movb (%r13,%r12), %al
leaq 0x1(%r12), %rcx
testb %al, %al
jne 0x30448
movq %r15, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq 0x172f3
movq %r15, %rdi
movq %r13, %rsi
movl %r12d, %edx
callq 0x172f3
movb (%r13,%r12), %al
addq %r12, %r13
testb %al, %al
jne 0x30443
jmp 0x3071a
movq %rdx, -0x78(%rbp)
movq %rdi, -0x60(%rbp)
testb %al, %al
je 0x3071a
movl $0x1, -0x2c(%rbp)
leaq -0xb0(%rbp), %r15
movq %r13, %rbx
xorl %r14d, %r14d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x35fcf
movl %eax, %r12d
cmpl $0x85, -0xb0(%rbp)
je 0x304df
addl %r12d, %r14d
movslq %r12d, %rax
cmpb $0x0, (%rbx,%rax)
leaq (%rbx,%rax), %rbx
jne 0x304b0
jmp 0x3070b
leaq -0x58(%rbp), %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x172f3
testl %r12d, %r12d
je 0x3071a
movslq %r14d, %rax
addq %rax, %r13
cmpb $0x3f, (%r13)
jne 0x30521
cmpl $0x2, %r12d
movq -0x60(%rbp), %rbx
jl 0x3053b
leaq 0x1(%r13), %rdi
leaq -0x30(%rbp), %rsi
callq 0x33f5b
movl -0x30(%rbp), %r14d
jmp 0x30543
movq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movl %r12d, %edx
callq 0x10dee
movl %eax, %r14d
movl %eax, -0x30(%rbp)
jmp 0x30543
movl -0x2c(%rbp), %r14d
movl %r14d, -0x30(%rbp)
movq 0x78(%rbx), %rbx
movslq %r14d, %rax
imulq $0x38, %rax, %rcx
movzwl -0x14(%rbx,%rcx), %eax
testb $0x1, %al
jne 0x305f9
addq %rcx, %rbx
testb $0x4, %al
jne 0x30610
testb $0x8, %al
jne 0x30628
testb $0x2, %al
jne 0x3065c
btl $0xe, %eax
jb 0x3068a
movl %r14d, -0x2c(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x4b044(%rip), %rsi     # 0x7b5d3
movl $0x2, %edx
callq 0x172f3
movslq -0x18(%rbx), %rcx
testq %rcx, %rcx
leaq 0x4a3dd(%rip), %rsi     # 0x7a984
jle 0x305de
xorl %r14d, %r14d
movq %rbx, -0x70(%rbp)
movq %rcx, -0x68(%rbp)
movq -0x30(%rbx), %rax
movzbl (%rax,%r14), %edx
leaq -0x58(%rbp), %rdi
movq %rsi, %rbx
xorl %eax, %eax
callq 0x35f4d
movq %rbx, %rsi
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %rbx
incq %r14
cmpq %r14, %rcx
jne 0x305b4
leaq -0x58(%rbp), %rdi
leaq 0x4ddaa(%rip), %rsi     # 0x7e393
movl $0x1, %edx
callq 0x172f3
movl -0x2c(%rbp), %r14d
jmp 0x3063f
leaq -0x58(%rbp), %rdi
leaq 0x4be6b(%rip), %rsi     # 0x7c46f
movl $0x4, %edx
callq 0x172f3
jmp 0x3063f
movq -0x20(%rbx), %rdx
leaq -0x58(%rbp), %rdi
leaq 0x4a3cb(%rip), %rsi     # 0x7a9ea
xorl %eax, %eax
callq 0x35f4d
jmp 0x3063f
movsd -0x28(%rbx), %xmm0
leaq -0x58(%rbp), %rdi
leaq 0x492aa(%rip), %rsi     # 0x798e2
movb $0x1, %al
callq 0x35f4d
movslq %r12d, %rax
addq %rax, %r13
incl %r14d
movl %r14d, -0x2c(%rbp)
cmpb $0x0, (%r13)
jne 0x304aa
jmp 0x3071a
movq -0x78(%rbp), %rcx
movq 0x20(%rcx), %rax
movq 0x18(%rax), %rax
movb 0x71(%rax), %al
cmpb $0x1, %al
jne 0x306a1
movl -0x18(%rbx), %edx
movq -0x30(%rbx), %rcx
leaq -0x58(%rbp), %rdi
leaq 0x4a2ef(%rip), %rsi     # 0x7a970
xorl %eax, %eax
callq 0x35f4d
jmp 0x3063f
movl -0x20(%rbx), %edx
leaq -0x58(%rbp), %rdi
leaq 0x4a2df(%rip), %rsi     # 0x7a977
xorl %eax, %eax
callq 0x35f4d
jmp 0x3063f
leaq -0xa8(%rbp), %rdx
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdx)
movups %xmm0, 0x10(%rdx)
movups %xmm0, (%rdx)
movq %rcx, -0xb0(%rbp)
movq -0x30(%rbx), %rsi
movl -0x18(%rbx), %edx
movzbl %al, %ecx
movq %r15, %rdi
xorl %r8d, %r8d
callq 0xf0d7
movq %r15, %rdi
movl $0x1, %esi
callq 0x24930
movl -0x90(%rbp), %edx
movq -0xa8(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq 0x4a279(%rip), %rsi     # 0x7a970
xorl %eax, %eax
callq 0x35f4d
movq %r15, %rdi
callq 0xecfd
jmp 0x3063f
leaq -0x58(%rbp), %rdi
movq %r13, %rsi
movl %r14d, %edx
callq 0x172f3
leaq -0x58(%rbp), %rdi
callq 0xb7d6
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq