// File: karel-brinda[P]ococo/ext/htslib/kstring.c
// Function: ksBM_prep
static int *ksBM_prep(const ubyte_t *pat, int m)
{
	int i, *suff, *prep, *bmGs, *bmBc;
	prep = (int*)calloc(m + 256, sizeof(int));
	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 = (int*)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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0xc(%rbp), %eax
addl $0x100, %eax            # imm = 0x100
movslq %eax, %rdi
movl $0x4, %esi
callq 0x4370
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movslq -0xc(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x100, -0x10(%rbp)     # imm = 0x100
jge 0x62a3c
movl -0xc(%rbp), %edx
movq -0x30(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x62a1a
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x62a77
movl -0xc(%rbp), %edx
subl -0x10(%rbp), %edx
subl $0x1, %edx
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
movslq -0x10(%rbp), %rsi
movzbl (%rcx,%rsi), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x62a43
movslq -0xc(%rbp), %rdi
movl $0x4, %esi
callq 0x4370
movq %rax, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
movl -0xc(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0xc(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0x62b89
movl -0x10(%rbp), %eax
cmpl -0x38(%rbp), %eax
jle 0x62b0a
movq -0x18(%rbp), %rax
movl -0x10(%rbp), %ecx
addl -0xc(%rbp), %ecx
subl $0x1, %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl -0x10(%rbp), %ecx
subl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jge 0x62b0a
movq -0x18(%rbp), %rax
movl -0x10(%rbp), %ecx
addl -0xc(%rbp), %ecx
subl $0x1, %ecx
subl -0x34(%rbp), %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x62b79
movl -0x10(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x62b18
movl -0x10(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x34(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x3d(%rbp)
jl 0x62b54
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x8(%rbp), %rcx
movl -0x38(%rbp), %edx
addl -0xc(%rbp), %edx
subl $0x1, %edx
subl -0x34(%rbp), %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x62b5d
jmp 0x62b68
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x62b1e
movl -0x34(%rbp), %edx
subl -0x38(%rbp), %edx
movq -0x18(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x62b7b
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x62ab5
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x62bb8
movl -0xc(%rbp), %edx
movq -0x28(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x62b97
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0x62c2e
movq -0x18(%rbp), %rax
movslq -0x10(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x62c21
jmp 0x62bde
movl -0x3c(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
subl -0x10(%rbp), %ecx
cmpl %ecx, %eax
jge 0x62c1f
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0xc(%rbp), %eax
jne 0x62c12
movl -0xc(%rbp), %edx
subl $0x1, %edx
subl -0x10(%rbp), %edx
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x62c14
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x62bde
jmp 0x62c21
jmp 0x62c23
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x62bc1
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl -0xc(%rbp), %ecx
subl $0x2, %ecx
cmpl %ecx, %eax
jg 0x62c71
movl -0xc(%rbp), %edx
subl $0x1, %edx
subl -0x10(%rbp), %edx
movq -0x28(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x1, %ecx
movq -0x18(%rbp), %rsi
movslq -0x10(%rbp), %rdi
subl (%rsi,%rdi,4), %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x62c35
movq -0x18(%rbp), %rdi
callq 0x46a0
movq -0x20(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)