// File: /workspace/github_cpp_makefile_star2_O2/karel-brinda[P]ococo/ext/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 && *_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
movl %ecx, %r14d
movq %rdx, %r15
movq %rdi, %rbp
testq %r8, %r8
movq %r8, 0x10(%rsp)
je 0x35c42
movq (%r8), %r12
testq %r12, %r12
je 0x35c42
movslq %r14d, %r13
jmp 0x35de1
movl %esi, 0xc(%rsp)
leal 0x100(%r14), %eax
movslq %eax, %rdi
pushq $0x4
popq %rsi
callq 0x4370
movq %rax, %r12
movslq %r14d, %r13
leaq (%rax,%r13,4), %rax
xorl %ecx, %ecx
cmpq $0x100, %rcx            # imm = 0x100
je 0x35c76
movl %r14d, (%rax,%rcx,4)
incq %rcx
jmp 0x35c64
movslq %r14d, %rbx
decq %rbx
xorl %ecx, %ecx
testl %ebx, %ebx
movl $0x0, %edx
cmovgl %ebx, %edx
movl %ebx, %esi
cmpq %rcx, %rdx
je 0x35c9e
movzbl (%r15,%rcx), %edi
movl %esi, (%rax,%rdi,4)
incq %rcx
decl %esi
jmp 0x35c8a
movq %rbp, 0x20(%rsp)
pushq $0x4
popq %rsi
movq %r13, %rdi
callq 0x4370
movslq %ebx, %rdx
movl %r14d, (%rax,%rdx,4)
leal -0x2(%r14), %esi
movslq %esi, %r8
xorl %edi, %edi
movq %r8, 0x18(%rsp)
xorl %ebp, %ebp
movl %ebx, %r9d
testl %r8d, %r8d
js 0x35d37
movl %r8d, %ecx
subl %r9d, %ecx
jle 0x35ced
movl %ebp, %r10d
notl %r10d
addl %r8d, %r10d
addl %r14d, %r10d
movslq %r10d, %r10
movl (%rax,%r10,4), %r11d
cmpl %ecx, %r11d
jl 0x35d1f
movslq %r9d, %rcx
cmpq %rcx, %r8
cmovlq %r8, %rcx
movq %rcx, %r9
testq %rcx, %rcx
js 0x35d16
movb (%r15,%r9), %r10b
leal (%rdi,%r9), %ecx
incl %ecx
movslq %ecx, %r11
leaq -0x1(%r9), %rcx
cmpb (%r15,%r11), %r10b
je 0x35cf7
movl %esi, %r11d
subl %r9d, %r11d
movl %r8d, %ebp
movl %r8d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %r11d, (%rax,%rcx,4)
decq %r8
decq %rsi
incq %rdi
jmp 0x35cc8
xorl %esi, %esi
testl %r14d, %r14d
movl $0x0, %edi
cmovgl %r14d, %edi
movq 0x20(%rsp), %rbp
cmpq %rsi, %rdi
je 0x35d58
movl %r14d, (%r12,%rsi,4)
incq %rsi
jmp 0x35d4a
xorl %esi, %esi
movq %rdx, %rdi
testq %rdi, %rdi
js 0x35d8c
leal 0x1(%rdi), %ecx
cmpl %ecx, (%rax,%rdi,4)
jne 0x35d87
movq %rdx, %r8
subq %rdi, %r8
movslq %esi, %rsi
cmpq %r8, %rsi
jge 0x35d87
cmpl %r14d, (%r12,%rsi,4)
jne 0x35d82
movl %r8d, (%r12,%rsi,4)
incq %rsi
jmp 0x35d73
decq %rdi
jmp 0x35d5d
movq 0x18(%rsp), %rcx
testq %rcx, %rcx
pushq $-0x1
popq %rdx
cmovnsq %rcx, %rdx
incq %rdx
xorl %ecx, %ecx
movl %ebx, %esi
cmpq %rcx, %rdx
je 0x35dbc
movslq (%rax,%rcx,4), %rdi
movq %rbx, %r8
subq %rdi, %r8
movl %esi, (%r12,%r8,4)
incq %rcx
decl %esi
jmp 0x35da2
movq %rax, %rdi
callq 0x4600
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x35ddd
cmpq $0x0, (%rax)
movl 0xc(%rsp), %esi
jne 0x35de1
movq %r12, (%rax)
jmp 0x35de1
movl 0xc(%rsp), %esi
leaq (%r12,%r13,4), %rax
subl %r14d, %esi
movl %r13d, %ecx
subl %r14d, %ecx
incl %ecx
leaq -0x1(%rbp), %rdx
xorl %r14d, %r14d
cmpl %esi, %r14d
jg 0x35e4a
movslq %r14d, %r8
leaq (%rdx,%r8), %r9
movl %ecx, %edi
movq %r13, %r10
testq %r10, %r10
jle 0x35e35
leaq -0x1(%r10), %r11
movzbl (%r9,%r10), %ebx
decl %edi
cmpb %bl, -0x1(%r15,%r10)
movq %r11, %r10
je 0x35e08
addl (%rax,%rbx,4), %edi
movl (%r12,%r11,4), %r8d
cmpl %r8d, %edi
cmovlel %r8d, %edi
addl %edi, %r14d
jmp 0x35df7
addq %r8, %rbp
movq %rbp, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x10(%rsp)
jne 0x35e5a
movq %r12, %rdi
callq 0x4600
xorl %ebp, %ebp
jmp 0x35e38