// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movl %ecx, %r13d
movl %edx, %r12d
movq %rsi, %r15
andq $0x0, 0x8(%rsp)
movq %rdi, %rbx
andq $0x0, (%r8)
callq 0x228052
testq %r15, %r15
je 0x22878b
testl %eax, %eax
je 0x22878b
testl %r12d, %r12d
js 0x2287a3
movl %r12d, %eax
xorl %r12d, %r12d
cmpq %rax, %r12
jae 0x2287a3
cmpb $0x0, (%r15,%r12)
jne 0x228785
cmpb $0x0, 0x1(%r15,%r12)
je 0x2287a3
addq $0x2, %r12
jmp 0x228771
movl $0x1f8c3, %edi          # imm = 0x1F8C3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21ec3c
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
callq 0x22a9b2
movq %rax, %r12
testq %rax, %rax
je 0x228842
leaq 0x8(%rsp), %rax
movq %rax, (%rsp)
movl %r13d, %ecx
movq %r14, %r13
xorl %r14d, %r14d
pushq $-0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
movq %rbp, %r9
callq 0x228600
movl %eax, %ebp
leaq 0x8(%rsp), %rax
movq (%rax), %rsi
testq %rsi, %rsi
sete %al
movq %r13, 0x10(%rsp)
testq %r13, %r13
sete %cl
orb %al, %cl
jne 0x22885b
subl %r12d, %esi
movq %r12, %rdi
callq 0x24e3fa
leaq 0x1(%r15), %rcx
testl %eax, %eax
cmovgl %eax, %r14d
subl $0x1, %r14d
jb 0x228846
movb (%rcx), %dl
leaq 0x2(%rcx), %rax
andb $-0x4, %dl
cmpb $-0x28, %dl
jne 0x22883d
movb 0x2(%rcx), %dl
andb $-0x4, %dl
cmpb $-0x24, %dl
jne 0x22883d
addq $0x4, %rcx
movq %rcx, %rax
movq %rax, %rcx
jmp 0x228817
xorl %ebp, %ebp
jmp 0x22885b
movl %r15d, %eax
notl %eax
addl %eax, %ecx
movslq %ecx, %rax
addq %r15, %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x21f26b
movq %rbx, %rdi
movl %ebp, %esi
callq 0x22417d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq