// File: /workspace/github_cpp_makefile_star2_O1/statgen[P]statgen/lib/samtools-0.1.7a-hybrid/kstring.c
// Function: ksBM_prep
int *ksBM_prep(const uint8_t *pat, int m)
{
	int i, *suff, *prep, *bmGs, *bmBc;
	prep = calloc(m + 256, 1);
	bmGs = prep; bmBc = prep + m;
	{ // preBmBc()
		for (i = 0; i < 256; ++i) bmBc[i] = m;
		for (i = 0; i < m - 1; ++i) bmBc[pat[i]] = m - i - 1;
	}
	suff = calloc(m, sizeof(int));
	{ // suffixes()
		int f = 0, g;
		suff[m - 1] = m;
		g = m - 1;
		for (i = m - 2; i >= 0; --i) {
			if (i > g && suff[i + m - 1 - f] < i - g)
				suff[i] = suff[i + m - 1 - f];
			else {
				if (i < g) g = i;
				f = i;
				while (g >= 0 && pat[g] == pat[g + m - 1 - f]) --g;
				suff[i] = f - g;
			}
		}
	}
	{ // preBmGs()
		int j = 0;
		for (i = 0; i < m; ++i) bmGs[i] = m;
		for (i = m - 1; i >= 0; --i)
			if (suff[i] == i + 1)
				for (; j < m - 1 - i; ++j)
					if (bmGs[j] == m)
						bmGs[j] = m - 1 - i;
		for (i = 0; i <= m - 2; ++i)
			bmGs[m - 1 - suff[i]] = m - 1 - i;
	}
	free(suff);
	return prep;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r14d
movq %rdi, %r15
leal 0x100(%r14), %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x3530
movq %rax, %rbx
movslq %r14d, %rdi
leaq (%rax,%rdi,4), %rax
xorl %ecx, %ecx
movl %r14d, (%rax,%rcx,4)
incq %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x10d56
leal -0x1(%r14), %ebp
movl %ebp, %r12d
cmpl $0x2, %r14d
jl 0x10d87
movq %r15, %rcx
movq %r12, %rdx
movzbl (%rcx), %esi
movl %edx, (%rax,%rsi,4)
incq %rcx
decq %rdx
jne 0x10d79
movl $0x4, %esi
callq 0x3530
movslq %ebp, %rcx
movl %r14d, (%rax,%rcx,4)
cmpl $0x2, %r14d
jl 0x10e37
leal -0x2(%r14), %esi
movslq %esi, %rdx
xorl %r8d, %r8d
movl $0x1, %edi
movslq %ebp, %r9
cmpq %r9, %rsi
jle 0x10ddd
movl %r8d, %r10d
notl %r10d
addl %esi, %r10d
addl %r14d, %r10d
movslq %r10d, %r10
movl (%rax,%r10,4), %r10d
movl %esi, %r11d
subl %ebp, %r11d
cmpl %r11d, %r10d
jge 0x10ddd
movl %r10d, (%rax,%rsi,4)
jmp 0x10e21
cmpl %ebp, %esi
cmovll %esi, %ebp
testl %ebp, %ebp
js 0x10e14
cmpq %r9, %rdx
cmovlq %rdx, %r9
movb (%r15,%r9), %r8b
leal (%rdi,%r9), %r10d
movslq %r10d, %r10
cmpb (%r15,%r10), %r8b
jne 0x10e11
leaq -0x1(%r9), %r8
testq %r9, %r9
movq %r8, %r9
jg 0x10ded
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x10e14
movl %r9d, %ebp
movl %esi, %r8d
subl %ebp, %r8d
movl %r8d, (%rax,%rsi,4)
movl %esi, %r8d
leaq -0x1(%rsi), %r9
decq %rdx
incq %rdi
testq %rsi, %rsi
movq %r9, %rsi
jg 0x10db1
movl %r14d, %edx
testl %r14d, %r14d
jle 0x10e4d
xorl %esi, %esi
movl %r14d, (%rbx,%rsi,4)
incq %rsi
cmpq %rsi, %rdx
jne 0x10e41
testl %r14d, %r14d
jle 0x10e95
xorl %esi, %esi
movq %r12, %rdi
xorl %r8d, %r8d
movl (%rax,%rdi,4), %r9d
leaq 0x1(%rdi), %r10
cmpq %r9, %r10
jne 0x10e8a
movq %r12, %r10
subq %rdi, %r10
movslq %r8d, %r9
cmpq %r9, %r10
jle 0x10e8a
cmpl %r14d, (%rbx,%r9,4)
jne 0x10e7f
movl %r10d, (%rbx,%r9,4)
incq %r9
cmpq %r9, %rsi
jne 0x10e75
movl %r9d, %r8d
decq %rdi
incq %rsi
cmpq %rdx, %rsi
jne 0x10e5a
cmpl $0x2, %r14d
jl 0x10eb4
movq %rax, %rdx
movslq (%rdx), %rsi
movq %rcx, %rdi
subq %rsi, %rdi
movl %r12d, (%rbx,%rdi,4)
addq $0x4, %rdx
decq %r12
jne 0x10e9e
movq %rax, %rdi
callq 0x32c0
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq