// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi2/profk.c
// Function: fm_extend_to
int fm_extend_to(const rld_t *e, const char *s, int x, int min_ext, int sat_occ, int *occ)
{
	extern unsigned char seq_nt6_table[128];
	int i, k;
	uint64_t l = 0, u = e->mcnt[0];
	*occ = 0;
	if (x + 1 - min_ext < 0) return 0;
	for (i = x, k = 0; i >= 0; --i) {
		int c = (uint8_t)s[i];
		uint64_t l0 = l, u0 = u;
		c = c < 6? c : c < 128? seq_nt6_table[c] : 5;
		l = e->cnt[c] + rld_rank11(e, l, c);
		u = e->cnt[c] + rld_rank11(e, u, c);
		if (l >= u) break; // can't be extended
		++k;
		if (sat_occ > 0) {
			if (k > min_ext && u - l < sat_occ) {
				--k, l = l0, u = u0;
				break;
			}
		} else if (k == min_ext) {
			break;
		}
	}
	if (l < u) *occ = u - l;
	return k;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
subl -0x20(%rbp), %eax
cmpl $0x0, %eax
jge 0x2991c
movl $0x0, -0x4(%rbp)
jmp 0x29a84
movl -0x1c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x29a64
movq -0x18(%rbp), %rax
movslq -0x34(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x4c(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpl $0x6, -0x4c(%rbp)
jge 0x29960
movl -0x4c(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x2998d
cmpl $0x80, -0x4c(%rbp)
jge 0x2997d
movslq -0x4c(%rbp), %rcx
leaq 0x987c(%rip), %rax      # 0x331f0
movzbl (%rax,%rcx), %eax
movl %eax, -0x68(%rbp)
jmp 0x29987
movl $0x5, %eax
movl %eax, -0x68(%rbp)
jmp 0x29987
movl -0x68(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x4c(%rbp), %edx
callq 0x3ee0
movq %rax, %rcx
movq -0x78(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x4c(%rbp), %edx
callq 0x3ee0
movq %rax, %rcx
movq -0x70(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jb 0x29a03
jmp 0x29a64
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x24(%rbp)
jle 0x29a48
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
jle 0x29a46
movq -0x48(%rbp), %rax
subq -0x40(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpq %rcx, %rax
jae 0x29a46
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x29a64
jmp 0x29a54
movl -0x38(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x29a52
jmp 0x29a64
jmp 0x29a54
jmp 0x29a56
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x29929
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x29a7e
movq -0x48(%rbp), %rax
subq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq