// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: instrFunc
static void instrFunc(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
  const unsigned char *zHaystack;
  const unsigned char *zNeedle;
  int nHaystack;
  int nNeedle;
  int typeHaystack, typeNeedle;
  int N = 1;
  int isText;
  unsigned char firstChar;
  sqlite3_value *pC1 = 0;
  sqlite3_value *pC2 = 0;

  UNUSED_PARAMETER(argc);
  typeHaystack = sqlite3_value_type(argv[0]);
  typeNeedle = sqlite3_value_type(argv[1]);
  if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return;
  nHaystack = sqlite3_value_bytes(argv[0]);
  nNeedle = sqlite3_value_bytes(argv[1]);
  if( nNeedle>0 ){
    if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){
      zHaystack = sqlite3_value_blob(argv[0]);
      zNeedle = sqlite3_value_blob(argv[1]);
      isText = 0;
    }else if( typeHaystack!=SQLITE_BLOB && typeNeedle!=SQLITE_BLOB ){
      zHaystack = sqlite3_value_text(argv[0]);
      zNeedle = sqlite3_value_text(argv[1]);
      isText = 1;
    }else{
      pC1 = sqlite3_value_dup(argv[0]);
      zHaystack = sqlite3_value_text(pC1);
      if( zHaystack==0 ) goto endInstrOOM;
      nHaystack = sqlite3_value_bytes(pC1);
      pC2 = sqlite3_value_dup(argv[1]);
      zNeedle = sqlite3_value_text(pC2);
      if( zNeedle==0 ) goto endInstrOOM;
      nNeedle = sqlite3_value_bytes(pC2);
      isText = 1;
    }
    if( zNeedle==0 || (nHaystack && zHaystack==0) ) goto endInstrOOM;
    firstChar = zNeedle[0];
    while( nNeedle<=nHaystack
       && (zHaystack[0]!=firstChar || memcmp(zHaystack, zNeedle, nNeedle)!=0)
    ){
      N++;
      do{
        nHaystack--;
        zHaystack++;
      }while( isText && (zHaystack[0]&0xc0)==0x80 );
    }
    if( nNeedle>nHaystack ) N = 0;
  }
  sqlite3_result_int(context, N);
endInstr:
  sqlite3_value_free(pC1);
  sqlite3_value_free(pC2);
  return;
endInstrOOM:
  sqlite3_result_error_nomem(context);
  goto endInstr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
movzwl 0x8(%rax), %r12d
andl $0x3f, %r12d
movzwl 0x8(%rcx), %ebx
andl $0x3f, %ebx
movabsq $-0x5555555555555556, %rdx # imm = 0xAAAAAAAAAAAAAAAA
movq %rdx, %rsi
movl %r12d, %ecx
shrq %cl, %rsi
movl %ebx, %ecx
shrq %cl, %rdx
orl %esi, %edx
testb $0x1, %dl
je 0x2f3b0e
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r13
movq %rax, %rdi
movl $0x1, %esi
callq 0x281bba
movl %eax, %r15d
movq 0x8(%r14), %rdi
movl $0x1, %esi
callq 0x281bba
testl %eax, %eax
jle 0x2f3b6f
movabsq $0x1000000010001, %rbp  # imm = 0x1000000010001
btq %r12, %rbp
setb %dl
movl %ebx, %ecx
shrq %cl, %rbp
andb %dl, %bpl
cmpb $0x1, %bpl
movq %r13, 0x8(%rsp)
jne 0x2f3b91
movq (%r14), %rdi
movl %eax, %ebx
callq 0x281b13
movq %rax, %r13
movq 0x8(%r14), %rdi
callq 0x281b13
jmp 0x2f3bd2
movl $0x1, %esi
xorl %ebx, %ebx
xorl %r12d, %r12d
movq (%r13), %rdi
testb $0x24, 0x9(%rdi)
je 0x2f3c0f
callq 0x29c706
jmp 0x2f3d41
movabsq $-0x1000000010002, %rdx # imm = 0xFFFEFFFFFFFEFFFE
xorl %esi, %esi
btq %rbx, %rdx
setb %cl
btq %r12, %rdx
movq (%r14), %rdi
jae 0x2f3c1d
movb %cl, %sil
testq %rsi, %rsi
je 0x2f3c1d
movl $0x1, %esi
movl %eax, %ebx
callq 0x281c96
movq %rax, %r13
movq 0x8(%r14), %rdi
movl $0x1, %esi
callq 0x281c96
movl %ebx, %r8d
movq %rax, %r14
xorl %ebx, %ebx
xorl %r12d, %r12d
testq %r14, %r14
je 0x2f3d37
testl %r15d, %r15d
setne %al
testq %r13, %r13
sete %cl
testb %cl, %al
jne 0x2f3d37
cmpl %r15d, %r8d
jle 0x2f3c88
xorl %esi, %esi
movq 0x8(%rsp), %r13
jmp 0x2f3b79
movq %rsi, (%rdi)
movw $0x4, 0x8(%rdi)
jmp 0x2f3d41
callq 0x281d08
movq %rax, %rbx
movq %rax, %rdi
movl $0x1, %esi
callq 0x281c96
testq %rax, %rax
je 0x2f3d34
movq %rax, %r13
movq %rbx, %rdi
movl $0x1, %esi
callq 0x281bba
movl %eax, %r15d
movq 0x8(%r14), %rdi
callq 0x281d08
movq %rax, %r12
movq %rax, %rdi
movl $0x1, %esi
callq 0x281c96
testq %rax, %rax
je 0x2f3d37
movq %rax, %r14
movq %r12, %rdi
movl $0x1, %esi
callq 0x281bba
movl %eax, %r8d
jmp 0x2f3bdd
movq %r12, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movb (%r14), %dil
movslq %r8d, %rax
movq %rax, 0x20(%rsp)
movl $0x1, %r9d
movb %dil, 0x7(%rsp)
cmpb %dil, (%r13)
jne 0x2f3cdf
movq %r13, %rdi
movq %r14, %rsi
movq 0x20(%rsp), %rdx
movq %r14, %rbx
movl %r8d, %r14d
movq %r15, %r12
movl %r9d, %r15d
callq 0x17830
movl %r15d, %r9d
movq %r12, %r15
movb 0x7(%rsp), %dil
movl %r14d, %r8d
movq %rbx, %r14
testl %eax, %eax
je 0x2f3d1d
incl %r9d
leal 0x1(%r15), %ecx
incq %r13
movq %r13, %rdx
movl %ecx, %eax
movq %rdx, %r13
testb %bpl, %bpl
jne 0x2f3d0c
movb (%r13), %sil
andb $-0x40, %sil
leal -0x1(%rax), %ecx
leaq 0x1(%r13), %rdx
negb %sil
jo 0x2f3cec
jmp 0x2f3d0f
movl %r15d, %ecx
addl $-0x2, %eax
movl %eax, %r15d
cmpl %ecx, %r8d
jl 0x2f3ca8
xorl %r9d, %r9d
movl %r9d, %esi
movq 0x8(%rsp), %r13
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r12
jmp 0x2f3b79
xorl %r12d, %r12d
movq 0x8(%rsp), %rdi
callq 0x282490
movq %rbx, %rdi
callq 0x281de6
movq %r12, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x281de6