// File: /workspace/github_c_makefile_star2_O2/lh3[P]fermi-lite/misc.c
// Function: fml_fmi_gen
struct rld_t *fml_fmi_gen(int n, bseq1_t *seq, int is_mt)
{
	mrope_t *mr;
	kstring_t str = {0,0,0};
	mritr_t itr;
	rlditr_t di;
	const uint8_t *block;
	rld_t *e = 0;
	int k;

	for (k = 0; k < n; ++k)
		if (seq[k].l_seq > 0)
			break;
	if (k == n) return 0;

	mr = mr_init(ROPE_DEF_MAX_NODES, ROPE_DEF_BLOCK_LEN, MR_SO_RCLO);
	for (k = 0; k < n; ++k) {
		int i;
		bseq1_t *s = &seq[k];
		if (s->l_seq == 0) continue;
		free(s->qual);
		for (i = 0; i < s->l_seq; ++i)
			s->seq[i] = seq_nt6_table[(int)s->seq[i]];
		for (i = 0; i < s->l_seq; ++i)
			if (s->seq[i] == 5) break;
		if (i < s->l_seq) {
			free(s->seq);
			continue;
		}
		if (is_rev_same(s->l_seq, s->seq))
			--s->l_seq, s->seq[s->l_seq] = 0;
		seq_reverse(s->l_seq, (uint8_t*)s->seq);
		kputsn(s->seq, s->l_seq + 1, &str);
		seq_revcomp6(s->l_seq, (uint8_t*)s->seq);
		kputsn(s->seq, s->l_seq + 1, &str);
		free(s->seq);
	}
	free(seq);
	mr_insert_multi(mr, str.l, (uint8_t*)str.s, is_mt);
	free(str.s);

	e = rld_init(6, 3);
	rld_itr_init(e, &di, 0);
	mr_itr_first(mr, &itr, 1);
	while ((block = mr_itr_next_block(&itr)) != 0) {
		const uint8_t *q = block + 2, *end = block + 2 + *rle_nptr(block);
		while (q < end) {
			int c = 0;
			int64_t l;
			rle_dec1(q, c, l);
			rld_enc(e, &di, l, c);
		}
	}
	rld_enc_finish(e, &di);

	mr_destroy(mr);
	return e;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x448, %rsp            # imm = 0x448
movq %rsi, %r15
andq $0x0, 0x20(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
testl %edi, %edi
movl $0x0, %eax
cmovgl %edi, %eax
movl %eax, %r13d
cmpq %rcx, %r13
je 0x277c
cmpl $0x0, (%rsi)
jg 0x277a
incq %rcx
addq $0x18, %rsi
jmp 0x2767
movl %ecx, %eax
xorl %r14d, %r14d
cmpl %edi, %eax
je 0x29d8
movl %edx, 0x4(%rsp)
pushq $0x40
popq %rdi
pushq $0x2
popq %rdx
movl $0x200, %esi            # imm = 0x200
callq 0x6514
movq %rax, 0x8(%rsp)
leaq 0x189c9(%rip), %rbx     # 0x1b170
leaq 0x10(%rsp), %r12
cmpq %r13, %r14
je 0x28c1
imulq $0x18, %r14, %rbp
cmpl $0x0, (%r15,%rbp)
je 0x28b9
addq %r15, %rbp
movq 0x10(%rbp), %rdi
callq 0x2040
xorl %ecx, %ecx
movl (%rbp), %edi
movslq %edi, %rax
cmpq %rax, %rcx
jge 0x27f1
movq 0x8(%rbp), %rax
movsbq (%rax,%rcx), %rdx
movb (%rdx,%rbx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
jmp 0x27d2
testl %edi, %edi
movl $0x0, %ecx
cmovgl %edi, %ecx
movq 0x8(%rbp), %rsi
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x2818
cmpb $0x5, (%rsi,%rdx)
leaq 0x1(%rdx), %rdx
jne 0x2801
movq %rsi, %rdi
jmp 0x28b4
testb $0x1, %dil
jne 0x287d
movl %edi, %ecx
sarl %ecx
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
leal -0x1(%rdi), %r9d
pushq $-0x1
popq %r8
xorl %r10d, %r10d
cmpq %r10, %rdx
je 0x285d
movsbl (%rsi,%r10), %r11d
movslq %r9d, %r9
movsbl (%rsi,%r9), %r12d
addl %r11d, %r12d
incq %r10
incl %r8d
decl %r9d
cmpl $0x5, %r12d
je 0x2837
jmp 0x2860
movl %edx, %r8d
cmpl %ecx, %r8d
jne 0x2878
leaq -0x1(%rax), %rcx
movl %ecx, (%rbp)
movb $0x0, -0x1(%rsi,%rax)
movl (%rbp), %edi
movq 0x8(%rbp), %rsi
leaq 0x10(%rsp), %r12
callq 0x3796
movq 0x8(%rbp), %rdi
movl (%rbp), %esi
incl %esi
movq %r12, %rdx
callq 0x29ed
movl (%rbp), %edi
movq 0x8(%rbp), %rsi
callq 0x37be
movq 0x8(%rbp), %rdi
movl (%rbp), %esi
incl %esi
movq %r12, %rdx
callq 0x29ed
movq 0x8(%rbp), %rdi
callq 0x2040
incq %r14
jmp 0x27ac
movq %r15, %rdi
callq 0x2040
movq 0x10(%rsp), %rsi
movq 0x20(%rsp), %r14
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rdx
movl 0x4(%rsp), %ecx
callq 0x6a04
movq %r14, %rdi
callq 0x2040
pushq $0x6
popq %rdi
pushq $0x3
popq %rsi
callq 0x736c
movq %rax, %r14
leaq 0x30(%rsp), %r15
movq %rax, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x74dd
leaq 0x68(%rsp), %r12
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x696b
movq %r12, %rdi
callq 0x6982
testq %rax, %rax
je 0x29c1
movq %rax, %r13
movzwl (%rax), %eax
leaq (%rax,%r13), %rbx
addq $0x2, %rbx
addq $0x2, %r13
cmpq %rbx, %r13
jae 0x2922
movzbl (%r13), %eax
testb %al, %al
js 0x296d
incq %r13
movl %eax, %edx
shrl $0x3, %edx
andb $0x7, %al
movzbl %al, %ecx
movq %r14, %rdi
movq %r15, %rsi
callq 0x7555
jmp 0x2945
movl %eax, %ecx
andl $-0x20, %ecx
cmpl $0xc0, %ecx
jne 0x2991
movl %eax, %ecx
andl $0x18, %ecx
movzbl 0x1(%r13), %edx
andl $0x3f, %edx
leaq (%rdx,%rcx,8), %rdx
addq $0x2, %r13
jmp 0x295b
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x4, %ecx
movl %eax, %edx
shrl $0x3, %edx
andl $0x1, %edx
incq %r13
xorl $-0x3, %ecx
testl %ecx, %ecx
je 0x295b
shlq $0x6, %rdx
movzbl (%r13), %esi
andl $0x3f, %esi
orq %rsi, %rdx
incq %r13
incl %ecx
jmp 0x29a7
leaq 0x30(%rsp), %rsi
movq %r14, %rdi
callq 0x7932
movq 0x8(%rsp), %rdi
callq 0x6585
movq %r14, %rax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq