// File: /workspace/github_c_makefile_star2_O0/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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x1, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
leaq -0xd0(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x68(%rax), %ecx
leaq -0x60(%rbp), %rdi
movl $0x64, %edx
callq 0xa720
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, 0xa8(%rax)
jle 0x401ca
jmp 0x40133
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x401c5
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x11d(%rbp)
je 0x4017d
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x11d(%rbp)
movb -0x11d(%rbp), %al
testb $0x1, %al
jne 0x40189
jmp 0x4018b
jmp 0x4014b
leaq -0x60(%rbp), %rdi
leaq 0x6f2d2(%rip), %rsi     # 0xaf468
movl $0x3, %edx
callq 0x1bb70
movq -0xd8(%rbp), %rsi
movq -0x10(%rbp), %rax
movq -0xd8(%rbp), %rcx
subq %rcx, %rax
movl %eax, %edx
leaq -0x60(%rbp), %rdi
callq 0x1bb70
jmp 0x40133
jmp 0x404ac
jmp 0x401cc
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x404aa
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x499c0
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rsi
movl -0x24(%rbp), %edx
leaq -0x60(%rbp), %rdi
callq 0x1bb70
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x40215
jmp 0x404aa
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3f, %eax
jne 0x40242
cmpl $0x1, -0x28(%rbp)
jle 0x4023a
movq -0x10(%rbp), %rdi
addq $0x1, %rdi
leaq -0x1c(%rbp), %rsi
callq 0x466d0
jmp 0x40240
movl -0x20(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x40255
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x28(%rbp), %edx
callq 0x12960
movl %eax, -0x1c(%rbp)
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x78(%rax), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x402b5
leaq -0x60(%rbp), %rdi
leaq 0x70cc5(%rip), %rsi     # 0xb0f6b
movl $0x4, %edx
callq 0x1bb70
jmp 0x404a5
movq -0x38(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x402e4
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdx
leaq -0x60(%rbp), %rdi
leaq 0x6f20e(%rip), %rsi     # 0xaf4e6
movb $0x0, %al
callq 0x49a40
jmp 0x404a3
movq -0x38(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x40314
movq -0x38(%rbp), %rax
movsd 0x10(%rax), %xmm0
leaq -0x60(%rbp), %rdi
leaq 0x6e0d1(%rip), %rsi     # 0xae3d9
movb $0x1, %al
callq 0x49a40
jmp 0x404a1
movq -0x38(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x403f4
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rax
movb 0x71(%rax), %al
movb %al, -0xdd(%rbp)
movzbl -0xdd(%rbp), %eax
cmpl $0x1, %eax
je 0x403aa
leaq -0x118(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
movq -0x18(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x38(%rbp), %rax
movl 0x20(%rax), %edx
leaq -0x118(%rbp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movzbl -0xdd(%rbp), %ecx
callq 0x10900
leaq -0x118(%rbp), %rdi
movl $0x1, %esi
callq 0x312a0
leaq -0x118(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rcx
leaq -0x60(%rbp), %rdi
leaq 0x6f09c(%rip), %rsi     # 0xaf46c
movb $0x0, %al
callq 0x49a40
movzbl -0xdd(%rbp), %eax
cmpl $0x1, %eax
je 0x403ef
leaq -0x118(%rbp), %rdi
callq 0x10190
jmp 0x4049f
movq -0x38(%rbp), %rax
movzwl 0x24(%rax), %eax
andl $0x4000, %eax           # imm = 0x4000
cmpl $0x0, %eax
je 0x40421
movq -0x38(%rbp), %rax
movl 0x18(%rax), %edx
leaq -0x60(%rbp), %rdi
leaq 0x6f05b(%rip), %rsi     # 0xaf473
movb $0x0, %al
callq 0x49a40
jmp 0x4049d
leaq -0x60(%rbp), %rdi
leaq 0x6fca3(%rip), %rsi     # 0xb00cf
movl $0x2, %edx
callq 0x1bb70
movq -0x38(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x11c(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x11c(%rbp), %eax
jge 0x40488
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x2c(%rbp), %rcx
movsbl (%rax,%rcx), %edx
andl $0xff, %edx
leaq -0x60(%rbp), %rdi
leaq 0x6f00a(%rip), %rsi     # 0xaf480
movb $0x0, %al
callq 0x49a40
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4044a
leaq -0x60(%rbp), %rdi
leaq 0x72953(%rip), %rsi     # 0xb2de6
movl $0x1, %edx
callq 0x1bb70
jmp 0x4049f
jmp 0x404a1
jmp 0x404a3
jmp 0x404a5
jmp 0x401cc
jmp 0x404ac
leaq -0x60(%rbp), %rdi
callq 0xc310
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nop