// File: /workspace/github_c_makefile_star2_O3/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
movl %edx, %ebp
testl %edi, %edi
movq %rsi, 0x10(%rsp)
jle 0x2846
movl %edi, %ebx
movl %edi, %edx
xorl %r15d, %r15d
movq %rsi, %rcx
movq %rdx, %rax
cmpl $0x0, (%rcx)
jg 0x2868
addq $0x18, %rcx
decq %rax
jne 0x2833
jmp 0x2c18
je 0x2c15
movl $0x40, %edi
movl $0x200, %esi            # imm = 0x200
movl $0x2, %edx
callq 0x7930
movq %rax, %r14
jmp 0x2ad7
testl %eax, %eax
je 0x2c15
movq %rdx, 0x20(%rsp)
movl $0x40, %edi
movl $0x200, %esi            # imm = 0x200
movl $0x2, %edx
callq 0x7930
movq %rax, %r14
testl %ebx, %ebx
jle 0x2ad7
movl %ebp, 0x1c(%rsp)
movq %r14, 0x28(%rsp)
xorl %r12d, %r12d
leaq 0x1a8c9(%rip), %r15     # 0x1d170
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
xorl %r13d, %r13d
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r14
leaq (%r12,%r12,2), %rax
cmpl $0x0, (%rbx,%rax,8)
je 0x2abc
leaq (%rbx,%rax,8), %rbp
movq 0x10(%rbp), %rdi
callq 0x2040
movl (%rbp), %edi
testl %edi, %edi
jle 0x291f
xorl %eax, %eax
movq 0x8(%rbp), %rcx
movsbq (%rcx,%rax), %rdx
movb (%rdx,%r15), %dl
movb %dl, (%rcx,%rax)
incq %rax
movslq (%rbp), %rdi
cmpq %rdi, %rax
jl 0x28e9
testl %edi, %edi
jle 0x291f
movq 0x8(%rbp), %rsi
xorl %eax, %eax
cmpb $0x5, (%rsi,%rax)
je 0x295c
incq %rax
cmpq %rax, %rdi
jne 0x290f
jmp 0x2923
movq 0x8(%rbp), %rsi
testb $0x1, %dil
jne 0x2985
movl %edi, %eax
sarl %eax
testl %eax, %eax
jle 0x2969
movl %eax, %edx
leal -0x1(%rdi), %r8d
xorl %ecx, %ecx
movsbl (%rsi,%rcx), %r9d
movslq %r8d, %r10
movsbl (%rsi,%r10), %r10d
addl %r9d, %r10d
cmpl $0x5, %r10d
jne 0x296b
incq %rcx
decl %r8d
cmpq %rcx, %rdx
jne 0x2939
jmp 0x296f
movq %rsi, %rdi
callq 0x2040
jmp 0x2abc
xorl %ecx, %ecx
cmpl %eax, %ecx
jne 0x2985
movslq %edi, %rax
leaq -0x1(%rax), %rcx
movl %ecx, (%rbp)
movb $0x0, -0x1(%rsi,%rax)
movl (%rbp), %edi
movq 0x8(%rbp), %rsi
callq 0x4662
movq 0x8(%rbp), %rsi
movslq (%rbp), %rbx
movq %r13, %r14
leaq (%rbx,%r13), %rax
addq $0x2, %rax
cmpq 0x8(%rsp), %rax
jae 0x29af
movq (%rsp), %r15
movq 0x8(%rsp), %r13
jmp 0x29f8
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %r13
shrq $0x10, %r13
orq %rax, %r13
incq %r13
movq (%rsp), %rdi
movq %rsi, %r15
movq %r13, %rsi
callq 0x21c0
movq %r15, %rsi
movq %rax, %r15
incq %rbx
leaq (%r15,%r14), %rdi
movq %rbx, %rdx
callq 0x2170
addq %r14, %rbx
movb $0x0, (%r15,%rbx)
movl (%rbp), %edi
movq 0x8(%rbp), %rsi
callq 0x468c
movq 0x8(%rbp), %rsi
movslq (%rbp), %r14
leaq (%r14,%rbx), %rax
addq $0x2, %rax
cmpq %r13, %rax
jae 0x2a37
movq %r13, 0x8(%rsp)
jmp 0x2a81
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rsi, %r13
movq %rax, %rsi
shrq $0x10, %rsi
orq %rax, %rsi
incq %rsi
movq %r15, %rdi
movq %rsi, 0x8(%rsp)
callq 0x21c0
movq %r13, %rsi
movq %rax, %r15
leaq (%r14,%rbx), %r13
incq %r13
incq %r14
addq %r15, %rbx
movq %rbx, %rdi
movq %r14, %rdx
callq 0x2170
movq %r15, (%rsp)
movb $0x0, (%r15,%r13)
movq 0x8(%rbp), %rdi
callq 0x2040
movq 0x10(%rsp), %rbx
movq 0x20(%rsp), %r14
leaq 0x1a6b4(%rip), %r15     # 0x1d170
incq %r12
cmpq %r14, %r12
jne 0x28c5
movq 0x28(%rsp), %r14
movl 0x1c(%rsp), %ebp
movq (%rsp), %rbx
jmp 0x2adc
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x10(%rsp), %rdi
callq 0x2040
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x7e70
movq %rbx, %rdi
callq 0x2040
movl $0x6, %edi
movl $0x3, %esi
callq 0x8880
movq %rax, %r15
leaq 0x30(%rsp), %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x8a3f
leaq 0x68(%rsp), %rbx
movq %r14, %rbp
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x7dca
movq %rbx, %rdi
callq 0x7de4
testq %rax, %rax
je 0x2bfe
movq %rax, %r12
leaq 0x68(%rsp), %r14
leaq 0x30(%rsp), %r13
movzwl (%r12), %eax
testq %rax, %rax
je 0x2bea
leaq (%rax,%r12), %rbx
addq $0x2, %rbx
addq $0x2, %r12
movzbl (%r12), %eax
testb %al, %al
js 0x2b97
incq %r12
movl %eax, %edx
shrl $0x3, %edx
andb $0x7, %al
movzbl %al, %ecx
movq %r15, %rdi
movq %r13, %rsi
callq 0x8aba
cmpq %rbx, %r12
jb 0x2b6f
jmp 0x2bea
movl %eax, %ecx
andl $-0x20, %ecx
cmpl $0xc0, %ecx
jne 0x2bbc
movl %eax, %ecx
andl $0x18, %ecx
movzbl 0x1(%r12), %edx
andl $0x3f, %edx
leaq (%rdx,%rcx,8), %rdx
addq $0x2, %r12
jmp 0x2b80
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x4, %ecx
movl %eax, %edx
shrl $0x3, %edx
andl $0x1, %edx
incq %r12
xorl $-0x3, %ecx
shlq $0x6, %rdx
movzbl (%r12), %esi
andl $0x3f, %esi
orq %rsi, %rdx
incq %r12
incl %ecx
jne 0x2bd2
jmp 0x2b80
movq %r14, %rdi
callq 0x7de4
movq %rax, %r12
testq %rax, %rax
jne 0x2b55
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x9060
movq %rbp, %rdi
callq 0x79a7
jmp 0x2c18
xorl %r15d, %r15d
movq %r15, %rax
addq $0x448, %rsp            # imm = 0x448
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq