// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/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 */
#ifndef SQLITE_OMIT_UTF16
  Mem utf8;                /* Used to convert UTF16 into UTF8 for display */
#endif
  char zBase[100];         /* Initial working space */

  db = p->db;
  sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase),
                      db->aLimit[SQLITE_LIMIT_LENGTH]);
  if( db->nVdbeExec>1 ){
    while( *zRawSql ){
      const char *zStart = zRawSql;
      while( *(zRawSql++)!='\n' && *zRawSql );
      sqlite3_str_append(&out, "-- ", 3);
      assert( (zRawSql - zStart) > 0 );
      sqlite3_str_append(&out, zStart, (int)(zRawSql-zStart));
    }
  }else if( p->nVar==0 ){
    sqlite3_str_append(&out, zRawSql, sqlite3Strlen30(zRawSql));
  }else{
    while( zRawSql[0] ){
      n = findNextHostParameter(zRawSql, &nToken);
      assert( n>0 );
      sqlite3_str_append(&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]=='@' || zRawSql[0]=='#' );
        testcase( 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 ){
        sqlite3_str_append(&out, "NULL", 4);
      }else if( pVar->flags & (MEM_Int|MEM_IntReal) ){
        sqlite3_str_appendf(&out, "%lld", pVar->u.i);
      }else if( pVar->flags & MEM_Real ){
        sqlite3_str_appendf(&out, "%!.15g", pVar->u.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);
        if( enc!=SQLITE_UTF8 ){
          memset(&utf8, 0, sizeof(utf8));
          utf8.db = db;
          sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC);
          if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){
            out.accError = SQLITE_NOMEM;
            out.nAlloc = 0;
          }
          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
        sqlite3_str_appendf(&out, "'%.*q'", nOut, pVar->z);
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut<pVar->n ){
          sqlite3_str_appendf(&out, "/*+%d bytes*/", pVar->n-nOut);
        }
#endif
#ifndef SQLITE_OMIT_UTF16
        if( enc!=SQLITE_UTF8 ) sqlite3VdbeMemRelease(&utf8);
#endif
      }else if( pVar->flags & MEM_Zero ){
        sqlite3_str_appendf(&out, "zeroblob(%d)", pVar->u.nZero);
      }else{
        int nOut;  /* Number of bytes of the blob to include in output */
        assert( pVar->flags & MEM_Blob );
        sqlite3_str_append(&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++){
          sqlite3_str_appendf(&out, "%02x", pVar->z[i]&0xff);
        }
        sqlite3_str_append(&out, "'", 1);
#ifdef SQLITE_TRACE_SIZE_LIMIT
        if( nOut<pVar->n ){
          sqlite3_str_appendf(&out, "/*+%d bytes*/", pVar->n-nOut);
        }
#endif
      }
    }
  }
  if( out.accError ) sqlite3_str_reset(&out);
  return sqlite3StrAccumFinish(&out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
andl $0x0, 0x4(%rsp)
movq (%rdi), %rdx
movl 0x7c(%rdx), %eax
leaq 0x80(%rsp), %rcx
movq %rcx, 0x10(%rsp)
andq $0x0, 0x8(%rsp)
movl $0x64, 0x18(%rsp)
movl %eax, 0x1c(%rsp)
andl $0x0, 0x20(%rsp)
andw $0x0, 0x24(%rsp)
movq %rsi, %r14
cmpl $0x2, 0xcc(%rdx)
jl 0x2262b6
pushq $0x1
popq %r13
leaq 0x150f82(%rip), %rbx    # 0x3771ee
leaq 0x8(%rsp), %r15
pushq $0x3
popq %rbp
movb (%r14), %al
testb %al, %al
je 0x226542
movq %r13, %rcx
movq %rcx, %r12
cmpb $0xa, %al
je 0x226296
movb (%r14,%r12), %al
leaq 0x1(%r12), %rcx
testb %al, %al
jne 0x226282
movq %r15, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x220f53
movq %r15, %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x220f53
addq %r12, %r14
jmp 0x226274
cmpw $0x0, 0x20(%rdi)
je 0x22652b
movq %rdx, 0x38(%rsp)
movq %rdi, 0x30(%rsp)
pushq $0x1
popq %rbp
leaq 0x2c(%rsp), %r12
cmpb $0x0, (%r14)
je 0x226542
xorl %r13d, %r13d
movb $0x1, %al
xorl %r15d, %r15d
movq %r14, %rbx
testb %al, %al
je 0x226312
movq %rbx, %rdi
movq %r12, %rsi
callq 0x24cef0
cmpl $0x99, 0x2c(%rsp)
je 0x22630f
addl %eax, %r15d
movslq %eax, %rcx
movb (%rbx,%rcx), %al
addq %rcx, %rbx
jmp 0x2262e8
movl %eax, %r13d
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x220f53
testl %r13d, %r13d
je 0x226542
movslq %r15d, %rax
addq %rax, %r14
cmpb $0x3f, (%r14)
jne 0x226356
cmpl $0x2, %r13d
movq 0x30(%rsp), %rbx
jl 0x226371
leaq 0x1(%r14), %rdi
leaq 0x4(%rsp), %rsi
callq 0x24b4cc
movl 0x4(%rsp), %ebp
jmp 0x226375
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x226061
movl %eax, %ebp
movl %eax, 0x4(%rsp)
jmp 0x226375
movl %ebp, 0x4(%rsp)
movslq %r13d, %rax
addq %rax, %r14
movq 0x80(%rbx), %rbx
movslq %ebp, %rax
incl %ebp
imulq $0x38, %rax, %rcx
movzwl -0x30(%rbx,%rcx), %eax
testb $0x1, %al
jne 0x2263b7
addq %rcx, %rbx
testb $0x24, %al
je 0x2263d0
movq -0x38(%rbx), %rdx
leaq 0x8(%rsp), %rdi
leaq 0x150ea9(%rip), %rsi    # 0x377254
xorl %eax, %eax
callq 0x221594
jmp 0x2262d3
leaq 0x8(%rsp), %rdi
leaq 0x14046b(%rip), %rsi    # 0x36682e
pushq $0x4
popq %rdx
callq 0x220f53
jmp 0x2262d3
testb $0x8, %al
jne 0x226433
testb $0x2, %al
jne 0x226450
btl $0xe, %eax
jb 0x22647b
leaq 0x8(%rsp), %rdi
leaq 0x15240f(%rip), %rsi    # 0x3787fd
pushq $0x2
popq %rdx
callq 0x220f53
movl -0x2c(%rbx), %r15d
testl %r15d, %r15d
movl $0x0, %eax
cmovlel %eax, %r15d
xorl %r13d, %r13d
cmpq %r13, %r15
je 0x226496
movq -0x28(%rbx), %rax
movzbl (%rax,%r13), %edx
leaq 0x8(%rsp), %rdi
leaq 0xe5f4a(%rip), %rsi     # 0x30c371
xorl %eax, %eax
callq 0x221594
incq %r13
jmp 0x226409
movsd -0x38(%rbx), %xmm0
leaq 0x8(%rsp), %rdi
leaq 0x14fda5(%rip), %rsi    # 0x3761e9
movb $0x1, %al
callq 0x221594
jmp 0x2262d3
movq 0x38(%rsp), %rcx
movb 0x5e(%rcx), %al
cmpb $0x1, %al
jne 0x2264af
movl -0x2c(%rbx), %edx
movq -0x28(%rbx), %rcx
leaq 0x8(%rsp), %rdi
leaq 0x150d83(%rip), %rsi    # 0x3771f2
xorl %eax, %eax
callq 0x221594
jmp 0x2262d3
movl -0x38(%rbx), %edx
leaq 0x8(%rsp), %rdi
leaq 0x150d6f(%rip), %rsi    # 0x3771f9
xorl %eax, %eax
callq 0x221594
jmp 0x2262d3
leaq 0x8(%rsp), %rdi
leaq 0xecbaa(%rip), %rsi     # 0x31304c
pushq $0x1
popq %rdx
callq 0x220f53
jmp 0x2262d3
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x70(%rsp)
movaps %xmm0, 0x40(%rsp)
movq %rcx, 0x68(%rsp)
movq -0x28(%rbx), %rsi
movl -0x2c(%rbx), %edx
movzbl %al, %ecx
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
xorl %r8d, %r8d
callq 0x2246e6
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0x23a21d
cmpl $0x7, %eax
jne 0x226500
movb $0x7, 0x24(%rsp)
andl $0x0, 0x18(%rsp)
movl 0x4c(%rsp), %edx
movq 0x50(%rsp), %rcx
leaq 0x8(%rsp), %rdi
leaq 0x150cdd(%rip), %rsi    # 0x3771f2
xorl %eax, %eax
callq 0x221594
leaq 0x40(%rsp), %rdi
callq 0x224336
jmp 0x2262d3
movq %r14, %rdi
callq 0x2211ac
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x220f53
cmpb $0x0, 0x24(%rsp)
je 0x226553
leaq 0x8(%rsp), %rdi
callq 0x22125c
leaq 0x8(%rsp), %rdi
callq 0x221200
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq