// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3Prepare16
static int sqlite3Prepare16(
  sqlite3 *db,              /* Database handle. */ 
  const void *zSql,         /* UTF-16 encoded SQL statement. */
  int nBytes,               /* Length of zSql in bytes. */
  int saveSqlFlag,          /* True to save SQL text into the sqlite3_stmt */
  sqlite3_stmt **ppStmt,    /* OUT: A pointer to the prepared statement */
  const void **pzTail       /* OUT: End of parsed string */
){
  /* This function currently works by first transforming the UTF-16
  ** encoded string to UTF-8, then invoking sqlite3_prepare(). The
  ** tricky bit is figuring out the pointer to return in *pzTail.
  */
  char *zSql8;
  const char *zTail8 = 0;
  int rc = SQLITE_OK;

  assert( ppStmt );
  *ppStmt = 0;
  if( !sqlite3SafetyCheckOk(db) ){
    return SQLITE_MISUSE_BKPT;
  }
  if( nBytes>=0 ){
    int sz;
    const char *z = (const char*)zSql;
    for(sz=0; sz<nBytes && (z[sz]!=0 || z[sz+1]!=0); sz += 2){}
    nBytes = sz;
  }
  sqlite3_mutex_enter(db->mutex);
  zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
  if( zSql8 ){
    rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
  }

  if( zTail8 && pzTail ){
    /* If sqlite3_prepare returns a tail pointer, we calculate the
    ** equivalent pointer into the UTF-16 string by counting the unicode
    ** characters between zSql8 and zTail8, and then returning a pointer
    ** the same number of characters into the UTF-16 string.
    */
    int chars_parsed = sqlite3Utf8CharLen(zSql8, (int)(zTail8-zSql8));
    *pzTail = (u8 *)zSql + sqlite3Utf16ByteLen(zSql, chars_parsed);
  }
  sqlite3DbFree(db, zSql8); 
  rc = sqlite3ApiExit(db, rc);
  sqlite3_mutex_leave(db->mutex);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x10(%rbp), %rdi
callq 0x15390
cmpl $0x0, %eax
jne 0x158e8
movl $0x17881, %edi          # imm = 0x17881
callq 0x9420
movl %eax, -0x4(%rbp)
jmp 0x15a12
cmpl $0x0, -0x1c(%rbp)
jl 0x1595c
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %ecx
xorl %eax, %eax
cmpl -0x1c(%rbp), %ecx
movb %al, -0x55(%rbp)
jge 0x15940
movq -0x50(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x56(%rbp)
jne 0x1593a
movq -0x50(%rbp), %rax
movl -0x48(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x56(%rbp)
movb -0x56(%rbp), %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %al
testb $0x1, %al
jne 0x15949
jmp 0x15956
jmp 0x1594b
movl -0x48(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x48(%rbp)
jmp 0x158fd
movl -0x48(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl $0x2, %ecx
callq 0x18c70
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x159a5
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x20(%rbp), %ecx
movq -0x28(%rbp), %r9
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %r8d
leaq -0x40(%rbp), %rax
movq %rax, (%rsp)
callq 0x15780
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x159f0
cmpq $0x0, -0x30(%rbp)
je 0x159f0
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
callq 0x4c140
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x4c200
movq -0x60(%rbp), %rcx
cltq
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x9cd0
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0xfe10
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)