// File: /workspace/github_c_makefile_star2_O3/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), %r14d
andl $0x3f, %r14d
movzwl 0x8(%rcx), %r12d
andl $0x3f, %r12d
movabsq $-0x5555555555555556, %rdx # imm = 0xAAAAAAAAAAAAAAAA
movq %rdx, %rsi
movl %r14d, %ecx
shrq %cl, %rsi
movl %r12d, %ecx
shrq %cl, %rdx
orl %esi, %edx
testb $0x1, %dl
je 0x2ea832
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 0x278229
movl %eax, %r15d
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0x278229
testl %eax, %eax
jle 0x2ea894
movabsq $0x1000000010001, %rbp  # imm = 0x1000000010001
btq %r14, %rbp
setb %dl
movl %r12d, %ecx
shrq %cl, %rbp
andb %dl, %bpl
cmpb $0x1, %bpl
movq %r13, (%rsp)
jne 0x2ea8a3
movl %eax, %r12d
movq (%rbx), %rdi
callq 0x278177
movq %rax, %r13
movq 0x8(%rbx), %rdi
callq 0x278177
jmp 0x2ea8e5
movl $0x1, %esi
xorl %r14d, %r14d
xorl %ebx, %ebx
jmp 0x2eaa2a
movabsq $-0x1000000010002, %rdx # imm = 0xFFFEFFFFFFFEFFFE
xorl %esi, %esi
btq %r12, %rdx
setb %cl
btq %r14, %rdx
movq (%rbx), %rdi
jae 0x2ea90c
movb %cl, %sil
testq %rsi, %rsi
je 0x2ea90c
movl %eax, %r12d
movl $0x1, %esi
callq 0x278305
movq %rax, %r13
movq 0x8(%rbx), %rdi
movl $0x1, %esi
callq 0x278305
movq %rax, %rsi
testq %rax, %rax
je 0x2ea907
testl %r15d, %r15d
setne %al
testq %r13, %r13
sete %cl
xorl %r14d, %r14d
testb %cl, %al
jne 0x2ea97d
movl %r12d, %r8d
xorl %ebx, %ebx
jmp 0x2ea96d
xorl %r14d, %r14d
jmp 0x2ea97d
callq 0x278377
movq %rax, %r14
movq %rax, %rdi
movl $0x1, %esi
callq 0x278305
testq %rax, %rax
je 0x2ea97d
movq %rax, %r13
movq %r14, %rdi
movl $0x1, %esi
callq 0x278229
movl %eax, %r15d
movq 0x8(%rbx), %rdi
callq 0x278377
movq %rax, %rbx
movq %rax, %rdi
movl $0x1, %esi
callq 0x278305
testq %rax, %rax
je 0x2ea97f
movq %rbx, %rdi
movl $0x1, %esi
movq %rax, %r12
callq 0x278229
movq %r12, %rsi
movl %eax, %r8d
cmpl %r15d, %r8d
jle 0x2ea98d
xorl %esi, %esi
movq (%rsp), %r13
jmp 0x2eaa2a
xorl %ebx, %ebx
movq (%rsp), %rdi
callq 0x278af1
jmp 0x2eaa44
movq %rbx, 0x8(%rsp)
movq %r14, 0x10(%rsp)
movb (%rsi), %r12b
movslq %r8d, %rax
movq %rax, 0x18(%rsp)
movl $0x1, %r10d
cmpb %r12b, (%r13)
jne 0x2ea9db
movq %r13, %rdi
movq 0x18(%rsp), %rdx
movl %r8d, %ebx
movq %rsi, %r14
movq %r15, 0x20(%rsp)
movl %r10d, %r15d
callq 0x17830
movl %r15d, %r10d
movq 0x20(%rsp), %r15
movq %r14, %rsi
movl %ebx, %r8d
testl %eax, %eax
je 0x2eaa19
incl %r10d
leal 0x1(%r15), %ecx
incq %r13
movq %r13, %rdx
movl %ecx, %eax
movq %rdx, %r13
testb %bpl, %bpl
jne 0x2eaa08
movb (%r13), %dil
andb $-0x40, %dil
leal -0x1(%rax), %ecx
leaq 0x1(%r13), %rdx
negb %dil
jo 0x2ea9e8
jmp 0x2eaa0b
movl %r15d, %ecx
addl $-0x2, %eax
movl %eax, %r15d
cmpl %ecx, %r8d
jl 0x2ea9a8
xorl %r10d, %r10d
movl %r10d, %esi
movq (%rsp), %r13
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %rbx
movq (%r13), %rdi
testb $0x24, 0x9(%rdi)
je 0x2eaa3b
callq 0x2929ee
jmp 0x2eaa44
movq %rsi, (%rdi)
movw $0x4, 0x8(%rdi)
movq %r14, %rdi
callq 0x278453
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x278453