// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/kstring.c
// Function: kmemmem
void *kmemmem(const void *_str, int n, const void *_pat, int m, int **_prep)
{
	int i, j, *prep = 0, *bmGs, *bmBc;
	const ubyte_t *str, *pat;
	str = (const ubyte_t*)_str; pat = (const ubyte_t*)_pat;
	prep = (_prep == 0 || *_prep == 0)? ksBM_prep(pat, m) : *_prep;
    if (!prep) return NULL;
	if (_prep && *_prep == 0) *_prep = prep;
	bmGs = prep; bmBc = prep + m;
	j = 0;
	while (j <= n - m) {
		for (i = m - 1; i >= 0 && pat[i] == str[i+j]; --i);
		if (i >= 0) {
			int max = bmBc[str[i+j]] - m + 1 + i;
			if (max < bmGs[i]) max = bmGs[i];
			j += max;
		} else return (void*)(str + j);
	}
	if (_prep == 0) free(prep);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %rbp
movl %ecx, %r14d
movq %rdx, %r15
movq %rdi, %rbx
testq %r8, %r8
je 0x91ed
movq (%rbp), %r12
testq %r12, %r12
je 0x91ed
movslq %r14d, %r10
leaq (%r12,%r10,4), %rax
movq %rax, 0x8(%rsp)
subl %r14d, %esi
movl %r10d, %ecx
subl %r14d, %ecx
incl %ecx
movq %rbx, %rax
leaq -0x1(%rbx), %rdx
xorl %r13d, %r13d
cmpl %esi, %r13d
jg 0x93bf
movslq %r13d, %r8
leaq (%rdx,%r8), %r9
movl %ecx, %edi
movq %r10, %rbx
testq %r10, %r10
jle 0x922a
leaq -0x1(%r10), %r11
movzbl (%r9,%r10), %r14d
decl %edi
cmpb %r14b, -0x1(%r15,%r10)
movq %r11, %r10
je 0x91b7
movq 0x8(%rsp), %r8
addl (%r8,%r14,4), %edi
movl (%r12,%r11,4), %r8d
cmpl %r8d, %edi
cmovlel %r8d, %edi
addl %edi, %r13d
movq %rbx, %r10
jmp 0x91a2
movl %esi, 0x8(%rsp)
leal 0x100(%r14), %eax
movslq %eax, %rdi
pushq $0x4
popq %rsi
callq 0x4300
testq %rax, %rax
je 0x93cc
movq %rax, %r12
movslq %r14d, %rdi
leaq (%rax,%rdi,4), %rax
xorl %ecx, %ecx
cmpq $0x100, %rcx            # imm = 0x100
je 0x9232
movl %r14d, (%rax,%rcx,4)
incq %rcx
jmp 0x9218
addq %r8, %rax
jmp 0x93ce
movq %rbp, 0x20(%rsp)
movslq %r14d, %rbp
decq %rbp
xorl %ecx, %ecx
testl %ebp, %ebp
movl $0x0, %edx
cmovgl %ebp, %edx
movl %ebp, %esi
cmpq %rcx, %rdx
je 0x9260
movzbl (%r15,%rcx), %r8d
movl %esi, (%rax,%r8,4)
incq %rcx
decl %esi
jmp 0x924b
pushq $0x4
popq %rsi
movq %rdi, 0x10(%rsp)
callq 0x4300
testq %rax, %rax
je 0x93c4
movq %rbx, 0x18(%rsp)
movslq %ebp, %rdx
movl %r14d, (%rax,%rdx,4)
leal -0x2(%r14), %esi
movslq %esi, %r8
xorl %edi, %edi
movq %r8, %r13
xorl %ebx, %ebx
movl %ebp, %r9d
testl %r8d, %r8d
js 0x9302
movl %r8d, %ecx
subl %r9d, %ecx
jle 0x92b8
movl %ebx, %r10d
notl %r10d
addl %r8d, %r10d
addl %r14d, %r10d
movslq %r10d, %r10
movl (%rax,%r10,4), %r11d
cmpl %ecx, %r11d
jl 0x92ea
movslq %r9d, %rcx
cmpq %rcx, %r8
cmovlq %r8, %rcx
movq %rcx, %r9
testq %rcx, %rcx
js 0x92e1
movb (%r15,%r9), %r10b
leal (%rdi,%r9), %ecx
incl %ecx
movslq %ecx, %r11
leaq -0x1(%r9), %rcx
cmpb (%r15,%r11), %r10b
je 0x92c2
movl %esi, %r11d
subl %r9d, %r11d
movl %r8d, %ebx
movl %r8d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %r11d, (%rax,%rcx,4)
decq %r8
decq %rsi
incq %rdi
jmp 0x9293
xorl %esi, %esi
testl %r14d, %r14d
movl $0x0, %edi
cmovgl %r14d, %edi
movq 0x18(%rsp), %rbx
cmpq %rsi, %rdi
je 0x9323
movl %r14d, (%r12,%rsi,4)
incq %rsi
jmp 0x9315
xorl %esi, %esi
movq %rdx, %rdi
testq %rdi, %rdi
js 0x9357
leal 0x1(%rdi), %ecx
cmpl %ecx, (%rax,%rdi,4)
jne 0x9352
movq %rdx, %r8
subq %rdi, %r8
movslq %esi, %rsi
cmpq %r8, %rsi
jge 0x9352
cmpl %r14d, (%r12,%rsi,4)
jne 0x934d
movl %r8d, (%r12,%rsi,4)
incq %rsi
jmp 0x933e
decq %rdi
jmp 0x9328
testq %r13, %r13
pushq $-0x1
popq %rdx
cmovnsq %r13, %rdx
incq %rdx
xorl %ecx, %ecx
movl %ebp, %esi
cmpq %rcx, %rdx
je 0x9382
movslq (%rax,%rcx,4), %rdi
movq %rbp, %r8
subq %rdi, %r8
movl %esi, (%r12,%r8,4)
incq %rcx
decl %esi
jmp 0x9368
movq %rax, %rdi
callq 0x45c0
movq 0x20(%rsp), %rbp
testq %rbp, %rbp
je 0x93b1
cmpq $0x0, (%rbp)
movl 0x8(%rsp), %esi
movq 0x10(%rsp), %r10
jne 0x9184
movq %r12, (%rbp)
jmp 0x9184
movl 0x8(%rsp), %esi
movq 0x10(%rsp), %r10
jmp 0x9184
testq %rbp, %rbp
jne 0x93cc
movq %r12, %rdi
callq 0x45c0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq