// File: /workspace/github_c_makefile_star2_O0/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
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 0x3cd2e0
cmpl $0x0, %eax
je 0x3cdecd
cmpq $0x0, -0x18(%rbp)
jne 0x3cdedf
movl $0x1f8c3, %edi          # imm = 0x1F8C3
callq 0x3bf6a0
movl %eax, -0x4(%rbp)
jmp 0x3ce009
cmpl $0x0, -0x1c(%rbp)
jl 0x3cdf53
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 0x3cdf37
movq -0x50(%rbp), %rax
movslq -0x48(%rbp), %rcx
movsbl (%rax,%rcx), %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x56(%rbp)
jne 0x3cdf31
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 0x3cdf40
jmp 0x3cdf4d
jmp 0x3cdf42
movl -0x48(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x48(%rbp)
jmp 0x3cdef4
movl -0x48(%rbp), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movl $0x2, %ecx
callq 0x3d1860
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x3cdf9c
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 0x3cdce0
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3cdfe7
cmpq $0x0, -0x30(%rbp)
je 0x3cdfe7
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
movl %eax, %esi
callq 0x412190
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movl -0x54(%rbp), %esi
callq 0x412250
movq -0x60(%rbp), %rcx
cltq
addq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3c00a0
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
callq 0x3c7380
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)