// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq (%rdx), %rax
movq 0x8(%rdx), %rcx
movzwl 0x8(%rax), %r15d
andl $0x3f, %r15d
movzwl 0x8(%rcx), %r12d
andl $0x3f, %r12d
movabsq $-0x5555555555555556, %rdx # imm = 0xAAAAAAAAAAAAAAAA
movq %rdx, %rsi
movl %r15d, %ecx
shrq %cl, %rsi
movl %r12d, %ecx
shrq %cl, %rdx
orl %esi, %edx
testb $0x1, %dl
je 0x285bbb
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r13
movq %rax, %rdi
callq 0x2243eb
movl %eax, %r14d
movq 0x8(%rbx), %rdi
callq 0x2243eb
testl %eax, %eax
jle 0x285c13
movl %eax, %ebp
movq %r13, 0x18(%rsp)
movabsq $0x1000000010001, %r13  # imm = 0x1000000010001
btq %r15, %r13
setb %al
movl %r12d, %ecx
shrq %cl, %r13
andb %al, %r13b
cmpb $0x1, %r13b
jne 0x285c20
movq (%rbx), %rdi
callq 0x22434b
movq %rax, %r12
movq 0x8(%rbx), %rdi
callq 0x22434b
jmp 0x285c54
pushq $0x1
popq %r15
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0x285d72
movabsq $-0x1000000010002, %rdx # imm = 0xFFFEFFFFFFFEFFFE
xorl %eax, %eax
btq %r12, %rdx
setb %cl
btq %r15, %rdx
movq (%rbx), %rdi
jae 0x285c7f
movb %cl, %al
testq %rax, %rax
je 0x285c7f
callq 0x2243e3
movq %rax, %r12
movq 0x8(%rbx), %rdi
callq 0x2243e3
movq %rax, %rsi
testq %rax, %rax
je 0x285c7b
testl %r14d, %r14d
setne %al
testq %r12, %r12
sete %cl
movq $0x0, 0x10(%rsp)
testb %cl, %al
je 0x285ce8
xorl %ebx, %ebx
xorl %ebp, %ebp
jmp 0x285cd9
xorl %ebp, %ebp
jmp 0x285cd7
callq 0x224530
movq %rax, %rbp
movq %rax, %rdi
callq 0x2243e3
testq %rax, %rax
je 0x285cd7
movq %rax, %r12
movq %rbp, %rdi
callq 0x2243eb
movl %eax, %r14d
movq 0x8(%rbx), %rdi
callq 0x224530
movq %rax, %rbx
movq %rax, %rdi
callq 0x2243e3
testq %rax, %rax
je 0x285cd9
movq %rbp, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movq %rax, %rbx
callq 0x2243eb
movq %rbx, %rsi
movl %eax, %ebp
jmp 0x285cf1
xorl %ebx, %ebx
movq 0x18(%rsp), %rdi
callq 0x224b94
jmp 0x285d7d
movq $0x0, 0x8(%rsp)
movb (%rsi), %dil
movslq %ebp, %rax
movq %rax, 0x20(%rsp)
pushq $0x1
popq %r15
movb %dil, 0x7(%rsp)
cmpl %r14d, %ebp
jg 0x285d60
cmpb %dil, (%r12)
jne 0x285d30
movq %r12, %rdi
movl %ebp, %ebx
movq %rsi, %rbp
movq 0x20(%rsp), %rdx
callq 0x177e0
movb 0x7(%rsp), %dil
movq %rbp, %rsi
movl %ebx, %ebp
testl %eax, %eax
je 0x285d63
incl %r15d
decl %r14d
incq %r12
movq %r12, %rax
movl %r14d, %ecx
movl %ecx, %r14d
movq %rax, %r12
testb %r13b, %r13b
jne 0x285d05
movb (%r12), %dl
andb $-0x40, %dl
leal -0x1(%r14), %ecx
leaq 0x1(%r12), %rax
negb %dl
jo 0x285d3f
jmp 0x285d05
xorl %r15d, %r15d
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %rbp
movq 0x8(%rsp), %rbx
movq %r13, %rdi
movl %r15d, %esi
callq 0x224920
movq %rbp, %rdi
callq 0x2245fd
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2245fd