// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/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. */
  u32 prepFlags,            /* Zero or more SQLITE_PREPARE_* flags */
  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;

#ifdef SQLITE_ENABLE_API_ARMOR
  if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
#endif
  *ppStmt = 0;
  if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
    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, prepFlags, 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %r13
movl %ecx, %ebp
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
xorl %eax, %eax
movq %rax, 0x10(%rsp)
movq %rax, (%r8)
callq 0x2863de
testq %r15, %r15
je 0x286ce7
testl %eax, %eax
je 0x286ce7
testl %r12d, %r12d
js 0x286d1a
je 0x286d17
xorl %eax, %eax
cmpb $0x0, (%r15,%rax)
jne 0x286cd9
cmpb $0x0, 0x1(%r15,%rax)
je 0x286ce2
addq $0x2, %rax
cmpl %r12d, %eax
jl 0x286cca
movl %eax, %r12d
jmp 0x286d1a
leaq 0x158631(%rip), %rsi    # 0x3df31f
leaq 0x15cea7(%rip), %rdx    # 0x3e3b9c
leaq 0x158489(%rip), %r8     # 0x3df185
movl $0x15, %ebp
movl $0x15, %edi
movl $0x1f8c3, %ecx          # imm = 0x1F8C3
xorl %eax, %eax
callq 0x27e637
jmp 0x286df1
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x2894d6
movq %rax, %r12
testq %rax, %rax
je 0x286d55
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
xorl %r8d, %r8d
movq %r13, %r9
callq 0x286af6
movl %eax, %ebp
jmp 0x286d57
xorl %ebp, %ebp
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x286dc1
subl %r12d, %esi
movq %r12, %rdi
callq 0x2b3103
leaq 0x1(%r15), %rdx
testl %eax, %eax
jle 0x286dae
movb (%rdx), %sil
leaq 0x2(%rdx), %rcx
andb $-0x4, %sil
cmpb $-0x28, %sil
jne 0x286da5
movb 0x2(%rdx), %sil
andb $-0x4, %sil
cmpb $-0x24, %sil
jne 0x286da5
addq $0x4, %rdx
movq %rdx, %rcx
movq %rcx, %rdx
decl %eax
jne 0x286d7f
jmp 0x286db1
movq %rdx, %rcx
movl %r15d, %eax
notl %eax
addl %eax, %ecx
movslq %ecx, %rax
addq %r15, %rax
movq %rax, (%r14)
testq %r12, %r12
je 0x286dd1
movq %rbx, %rdi
movq %r12, %rsi
callq 0x28c3e7
cmpl $0xc0a, %ebp            # imm = 0xC0A
je 0x286de4
cmpb $0x0, 0x61(%rbx)
jne 0x286de4
andl 0x54(%rbx), %ebp
jmp 0x286df1
movq %rbx, %rdi
callq 0x299b1a
movl $0x7, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq