// File: /workspace/github_c_makefile_star2_O3/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 0x27c8e8
testq %r15, %r15
je 0x27d29a
testl %eax, %eax
je 0x27d29a
testl %r12d, %r12d
js 0x27d2cd
je 0x27d2ca
xorl %eax, %eax
cmpb $0x0, (%r15,%rax)
jne 0x27d28c
cmpb $0x0, 0x1(%r15,%rax)
je 0x27d295
addq $0x2, %rax
cmpl %r12d, %eax
jl 0x27d27d
movl %eax, %r12d
jmp 0x27d2cd
leaq 0x15892a(%rip), %rsi    # 0x3d5bcb
leaq 0x15d19f(%rip), %rdx    # 0x3da447
leaq 0x158782(%rip), %r8     # 0x3d5a31
movl $0x15, %ebp
movl $0x15, %edi
movl $0x1f8c3, %ecx          # imm = 0x1F8C3
xorl %eax, %eax
callq 0x274d08
jmp 0x27d3b7
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x27f95c
testq %rax, %rax
je 0x27d378
movq %rax, %r12
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 0x27d0b1
movl %eax, %ebp
leaq 0x10(%rsp), %rax
movq (%rax), %rsi
testq %rsi, %rsi
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x27d38c
subl %r12d, %esi
movq %r12, %rdi
callq 0x2a94d7
leaq 0x1(%r15), %rcx
testl %eax, %eax
jle 0x27d37c
movb (%rcx), %sil
leaq 0x2(%rcx), %rdx
andb $-0x4, %sil
cmpb $-0x28, %sil
jne 0x27d354
movb 0x2(%rcx), %sil
andb $-0x4, %sil
cmpb $-0x24, %sil
je 0x27d359
movq %rdx, %rcx
jmp 0x27d35d
addq $0x4, %rcx
decl %eax
jne 0x27d335
movl %r15d, %eax
notl %eax
addl %eax, %ecx
movslq %ecx, %rax
addq %r15, %rax
movq %rax, (%r14)
testq %r12, %r12
jne 0x27d38c
jmp 0x27d397
xorl %ebp, %ebp
jmp 0x27d397
movl %r15d, %eax
notl %eax
addl %eax, %ecx
movslq %ecx, %rax
addq %r15, %rax
movq %rax, (%r14)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x282904
cmpl $0xc0a, %ebp            # imm = 0xC0A
je 0x27d3aa
cmpb $0x0, 0x61(%rbx)
jne 0x27d3aa
andl 0x54(%rbx), %ebp
jmp 0x27d3b7
movq %rbx, %rdi
callq 0x28fd56
movl $0x7, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq