// File: /workspace/github_cpp_makefile_star2_O3/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 %rbx
pushq %rax
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
movd %edi, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
xorl %ecx, %ecx
movdqu %xmm0, (%rax,%rcx,4)
addq $0x4, %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x112da
leal -0x1(%r14), %ebp
cmpl $0x1, %r14d
jle 0x113b0
movl %ebp, %ecx
movq %r15, %rdx
movzbl (%rdx), %esi
movl %ecx, (%rax,%rsi,4)
incq %rdx
decq %rcx
jne 0x112ff
movl $0x4, %esi
callq 0x3530
movslq %ebp, %rcx
movl %r14d, (%rax,%rcx,4)
cmpl $0x2, %r14d
jl 0x113c1
leal -0x2(%r14), %ecx
leal -0x1(%r14), %edx
xorl %r8d, %r8d
movl %ebp, %esi
movslq %esi, %rdi
cmpq %rdi, %rcx
jle 0x1135b
movl %r8d, %r9d
notl %r9d
addl %ecx, %r9d
addl %r14d, %r9d
movslq %r9d, %r9
movl (%rax,%r9,4), %r9d
movl %ecx, %r10d
subl %esi, %r10d
cmpl %r10d, %r9d
jl 0x1139e
cmpl %esi, %ecx
cmovll %ecx, %esi
testl %esi, %esi
js 0x11395
cmpq %rdi, %rcx
cmovlq %rcx, %rdi
movl %edx, %esi
subl %ecx, %esi
movb (%r15,%rdi), %r8b
leal (%rsi,%rdi), %r9d
movslq %r9d, %r9
cmpb (%r15,%r9), %r8b
jne 0x11393
leaq -0x1(%rdi), %r8
testq %rdi, %rdi
movq %r8, %rdi
jg 0x1136f
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
jmp 0x11395
movl %edi, %esi
movl %ecx, %r9d
subl %esi, %r9d
movl %ecx, %r8d
movl %r9d, (%rax,%rcx,4)
leaq -0x1(%rcx), %rdi
testq %rcx, %rcx
movq %rdi, %rcx
jg 0x11335
jmp 0x113c1
movl $0x4, %esi
callq 0x3530
movslq %ebp, %rcx
movl %r14d, (%rax,%rcx,4)
testl %r14d, %r14d
jle 0x1152b
movl %r14d, %ecx
leal 0x3(%r14), %edx
leaq -0x1(%rcx), %rsi
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %edx
shlq $0x4, %rdx
movdqa 0x13f02(%rip), %xmm1    # 0x252f0
movdqa 0x13f0a(%rip), %xmm2    # 0x25300
xorl %esi, %esi
movdqa 0x13f10(%rip), %xmm3    # 0x25310
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x13f10(%rip), %xmm5    # 0x25320
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edi
notl %edi
testb $0x1, %dil
je 0x11449
movl %r14d, (%rbx,%rsi)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edi
testb $0x1, %dil
je 0x1145d
movl %r14d, 0x4(%rbx,%rsi)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edi
testb $0x1, %dil
je 0x1149a
movl %r14d, 0x8(%rbx,%rsi)
pextrw $0x4, %xmm6, %edi
testb $0x1, %dil
je 0x114aa
movl %r14d, 0xc(%rbx,%rsi)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x10, %rsi
cmpq %rsi, %rdx
jne 0x11410
testl %r14d, %r14d
jle 0x1152b
movl %ebp, %edx
xorl %esi, %esi
movq %rdx, %rdi
xorl %r8d, %r8d
movl (%rax,%rdi,4), %r9d
leaq 0x1(%rdi), %r10
cmpq %r9, %r10
jne 0x114fe
movq %rdx, %r9
subq %rdi, %r9
movslq %r8d, %r10
cmpq %r10, %r9
jle 0x114fe
cmpl %r14d, (%rbx,%r10,4)
jne 0x114f3
movl %r9d, (%rbx,%r10,4)
incq %r10
cmpq %r10, %rsi
jne 0x114e9
movl %esi, %r8d
decq %rdi
incq %rsi
cmpq %rcx, %rsi
jne 0x114ce
cmpl $0x1, %r14d
je 0x1152b
movslq %ebp, %rcx
movq %rax, %rsi
movslq (%rsi), %rdi
movq %rcx, %r8
subq %rdi, %r8
movl %edx, (%rbx,%r8,4)
addq $0x4, %rsi
decq %rdx
jne 0x11515
movq %rax, %rdi
callq 0x32c0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq