// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/bfc.c
// Function: fml_correct_core
float fml_correct_core(const fml_opt_t *opt, int flt_uniq, int n, bseq1_t *seq)
{
	bfc_ch_t *ch;
	int i, mode;
	uint64_t hist[256], hist_high[64], tot_len = 0, sum_k = 0, tot_k = 0;
	ec_step_t es;
	bfc_opt_t bfc_opt;
	float kcov;

	// initialize BFC options
	bfc_opt_init(&bfc_opt);
	bfc_opt.n_threads = opt->n_threads; // copy from FML options
	bfc_opt.k = flt_uniq? opt->min_asm_ovlp : opt->ec_k;
	for (i = 0; i < n; ++i) tot_len += seq[i].l_seq; // compute total length
	bfc_opt.l_pre = tot_len - 8 < 20? tot_len - 8 : 20;

	memset(&es, 0, sizeof(ec_step_t));
	es.opt = &bfc_opt, es.n_seqs = n, es.seqs = seq, es.flt_uniq = flt_uniq;

	es.ch = ch = fml_count(n, seq, bfc_opt.k, bfc_opt.q, bfc_opt.l_pre, bfc_opt.n_threads);
	mode = bfc_ch_hist(ch, hist, hist_high);
	for (i = opt->min_cnt; i < 256; ++i)
		sum_k += hist[i], tot_k += i * hist[i];
	kcov = (float)tot_k / sum_k;
	bfc_opt.min_cov = (int)(BFC_EC_MIN_COV_COEF * kcov + .499);
	bfc_opt.min_cov = bfc_opt.min_cov < opt->max_cnt? bfc_opt.min_cov : opt->max_cnt;
	bfc_opt.min_cov = bfc_opt.min_cov > opt->min_cnt? bfc_opt.min_cov : opt->min_cnt;

	es.e = calloc(es.opt->n_threads, sizeof(void*));
	for (i = 0; i < es.opt->n_threads; ++i)
		es.e[i] = ec1buf_init(es.opt, ch), es.e[i]->mode = mode;
	kt_for(es.opt->n_threads, worker_ec, &es, es.n_seqs);
	for (i = 0; i < es.opt->n_threads; ++i)
		ec1buf_destroy(es.e[i]);
	free(es.e);
	bfc_ch_destroy(ch);
	return kcov;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xae0, %rsp            # imm = 0xAE0
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq $0x0, -0xa38(%rbp)
movq $0x0, -0xa40(%rbp)
movq $0x0, -0xa48(%rbp)
leaq -0xab0(%rbp), %rdi
callq 0x4e30
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0xab0(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x88d7
movq -0x8(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0xab8(%rbp)
jmp 0x88e4
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0xab8(%rbp)
movl -0xab8(%rbp), %eax
movl %eax, -0xaa8(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x892a
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movslq (%rax), %rax
addq -0xa38(%rbp), %rax
movq %rax, -0xa38(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x88f7
movq -0xa38(%rbp), %rax
subq $0x8, %rax
cmpq $0x14, %rax
jae 0x894f
movq -0xa38(%rbp), %rax
subq $0x8, %rax
movq %rax, -0xac0(%rbp)
jmp 0x895d
movl $0x14, %eax
movq %rax, -0xac0(%rbp)
jmp 0x895d
movq -0xac0(%rbp), %rax
movl %eax, -0xaa4(%rbp)
leaq -0xa78(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x2110
leaq -0xab0(%rbp), %rax
movq %rax, -0xa78(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0xa58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa50(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0xa54(%rbp)
movl -0x10(%rbp), %edi
movq -0x18(%rbp), %rsi
movl -0xaa8(%rbp), %edx
movl -0xaac(%rbp), %ecx
movl -0xaa4(%rbp), %r8d
movl -0xab0(%rbp), %r9d
callq 0x4f00
movq %rax, -0x20(%rbp)
movq %rax, -0xa70(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x830(%rbp), %rsi
leaq -0xa30(%rbp), %rdx
callq 0x21cf0
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0x8a4a
movslq -0x24(%rbp), %rax
movq -0x830(%rbp,%rax,8), %rax
addq -0xa40(%rbp), %rax
movq %rax, -0xa40(%rbp)
movslq -0x24(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq -0x830(%rbp,%rcx,8), %rax
addq -0xa48(%rbp), %rax
movq %rax, -0xa48(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x89fd
movq -0xa48(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xac8(%rbp)
testq %rax, %rax
movss %xmm0, -0xac4(%rbp)
js 0x8a92
movss -0xac8(%rbp), %xmm0
movss %xmm0, -0xac4(%rbp)
movss -0xac4(%rbp), %xmm0
movss %xmm0, -0xad4(%rbp)
movq -0xa40(%rbp), %rax
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0xad0(%rbp)
testq %rax, %rax
movss %xmm0, -0xacc(%rbp)
js 0x8aea
movss -0xad0(%rbp), %xmm0
movss %xmm0, -0xacc(%rbp)
movss -0xad4(%rbp), %xmm0
movss -0xacc(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0xab4(%rbp)
movss -0xab4(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x1c80e(%rip), %xmm1    # 0x25328
mulsd %xmm1, %xmm0
movsd 0x1c7fa(%rip), %xmm1    # 0x25320
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xaa0(%rbp)
movl -0xaa0(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x8b51
movl -0xaa0(%rbp), %eax
movl %eax, -0xad8(%rbp)
jmp 0x8b5e
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0xad8(%rbp)
movl -0xad8(%rbp), %eax
movl %eax, -0xaa0(%rbp)
movl -0xaa0(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jle 0x8b87
movl -0xaa0(%rbp), %eax
movl %eax, -0xadc(%rbp)
jmp 0x8b94
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0xadc(%rbp)
movl -0xadc(%rbp), %eax
movl %eax, -0xaa0(%rbp)
movq -0xa78(%rbp), %rax
movslq (%rax), %rdi
movl $0x8, %esi
callq 0x2140
movq %rax, -0xa68(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0xa78(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x8c15
movq -0xa78(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x8ca0
movq %rax, %rdx
movq -0xa68(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x28(%rbp), %ecx
movq -0xa68(%rbp), %rax
movslq -0x24(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %ecx, 0xa0(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8bc2
movq -0xa78(%rbp), %rax
movl (%rax), %edi
movslq -0xa58(%rbp), %rcx
leaq 0xc4(%rip), %rsi        # 0x8cf0
leaq -0xa78(%rbp), %rdx
callq 0x20e50
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
movq -0xa78(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x8c6c
movq -0xa68(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x8f20
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x8c3f
movq -0xa68(%rbp), %rdi
callq 0x2040
movq -0x20(%rbp), %rdi
callq 0x212a0
movss -0xab4(%rbp), %xmm0
addq $0xae0, %rsp            # imm = 0xAE0
popq %rbp
retq
nopw %cs:(%rax,%rax)