// File: /workspace/github_c_makefile_star2_O1/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, %r14
movl $0x0, -0x2c(%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 0x2fbb9
testb %al, %al
je 0x2fe2f
leaq 0x4ae01(%rip), %rbx     # 0x7a96c
leaq -0x58(%rbp), %r15
movl $0x1, %eax
movq %rax, %r12
cmpb $0xa, -0x1(%r14,%rax)
je 0x2fb8b
leaq 0x1(%r12), %rax
cmpb $0x0, (%r14,%r12)
jne 0x2fb74
movq %r15, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq 0x172ee
movq %r15, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x172ee
cmpb $0x0, (%r14,%r12)
leaq (%r14,%r12), %r14
jne 0x2fb6f
jmp 0x2fe2f
movq %rdx, -0x70(%rbp)
movq %rdi, -0x60(%rbp)
testb %al, %al
je 0x2fe2f
movl $0x1, %r15d
movq %r14, %rbx
xorl %r12d, %r12d
movq %rbx, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3590c
movl %eax, %r13d
cmpl $0x85, -0xb0(%rbp)
je 0x2fc06
addl %r13d, %r12d
movslq %r13d, %rax
cmpb $0x0, (%rbx,%rax)
leaq (%rbx,%rax), %rbx
jne 0x2fbd5
xorl %r13d, %r13d
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x172ee
testl %r13d, %r13d
je 0x2fe2f
movslq %r12d, %rax
addq %rax, %r14
cmpb $0x3f, (%r14)
jne 0x2fc43
cmpl $0x2, %r13d
movq -0x60(%rbp), %rbx
jl 0x2fc5a
leaq 0x1(%r14), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x33854
jmp 0x2fc5e
movq -0x60(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x10cd8
movl %eax, -0x2c(%rbp)
jmp 0x2fc5e
movl %r15d, -0x2c(%rbp)
movslq -0x2c(%rbp), %r15
movq 0x78(%rbx), %rbx
imulq $0x38, %r15, %rcx
movzwl -0x14(%rbx,%rcx), %eax
testb $0x1, %al
jne 0x2fd10
addq %rcx, %rbx
testb $0x4, %al
jne 0x2fd27
testb $0x8, %al
jne 0x2fd3f
testb $0x2, %al
jne 0x2fd6e
btl $0xe, %eax
jb 0x2fd9c
movq %r15, -0x68(%rbp)
leaq -0x58(%rbp), %rdi
leaq 0x4b928(%rip), %rsi     # 0x7b5d3
movl $0x2, %edx
callq 0x172ee
movslq -0x18(%rbx), %r15
testq %r15, %r15
leaq 0x4acc1(%rip), %rax     # 0x7a984
jle 0x2fcf5
movq %rbx, %rdx
movq %rax, %rbx
xorl %r12d, %r12d
movq %rdx, -0x78(%rbp)
movq -0x30(%rdx), %rax
movzbl (%rax,%r12), %edx
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3588a
movq -0x78(%rbp), %rdx
incq %r12
cmpq %r12, %r15
jne 0x2fcd2
leaq -0x58(%rbp), %rdi
leaq 0x4e643(%rip), %rsi     # 0x7e343
movl $0x1, %edx
callq 0x172ee
movq -0x68(%rbp), %r15
jmp 0x2fd56
leaq -0x58(%rbp), %rdi
leaq 0x4c754(%rip), %rsi     # 0x7c46f
movl $0x4, %edx
callq 0x172ee
jmp 0x2fd56
movq -0x20(%rbx), %rdx
leaq -0x58(%rbp), %rdi
leaq 0x4acb4(%rip), %rsi     # 0x7a9ea
xorl %eax, %eax
callq 0x3588a
jmp 0x2fd56
movsd -0x28(%rbx), %xmm0
leaq -0x58(%rbp), %rdi
leaq 0x49b93(%rip), %rsi     # 0x798e2
movb $0x1, %al
callq 0x3588a
movslq %r13d, %rax
addq %rax, %r14
incl %r15d
cmpb $0x0, (%r14)
jne 0x2fbcf
jmp 0x2fe2f
movq -0x70(%rbp), %rcx
movq 0x20(%rcx), %rax
movq 0x18(%rax), %rax
movb 0x71(%rax), %al
cmpb $0x1, %al
jne 0x2fdb3
movl -0x18(%rbx), %edx
movq -0x30(%rbx), %rcx
leaq -0x58(%rbp), %rdi
leaq 0x4abdd(%rip), %rsi     # 0x7a970
xorl %eax, %eax
callq 0x3588a
jmp 0x2fd56
movl -0x20(%rbx), %edx
leaq -0x58(%rbp), %rdi
leaq 0x4abcd(%rip), %rsi     # 0x7a977
xorl %eax, %eax
callq 0x3588a
jmp 0x2fd56
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movq $0x0, -0x80(%rbp)
movq %rcx, -0xb0(%rbp)
movq -0x30(%rbx), %rsi
movl -0x18(%rbx), %edx
movzbl %al, %ecx
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0xeff4
movq %rbx, %rdi
movl $0x1, %esi
callq 0x24e59
movl -0x90(%rbp), %edx
movq -0xa8(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq 0x4ab55(%rip), %rsi     # 0x7a970
xorl %eax, %eax
callq 0x3588a
movq %rbx, %rdi
callq 0xec23
jmp 0x2fd56
leaq -0x58(%rbp), %rdi
callq 0xb6e7
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq