// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa80, %rsp            # imm = 0xA80
movl %edx, %eax
movq %rdi, %r14
movaps 0x10730(%rip), %xmm0    # 0x17450
movaps %xmm0, 0x40(%rsp)
movaps 0x10734(%rip), %xmm0    # 0x17460
movaps %xmm0, 0x50(%rsp)
movaps 0x10738(%rip), %xmm0    # 0x17470
movaps %xmm0, 0x60(%rsp)
movabsq $0x640000000f, %rdx     # imm = 0x640000000F
movq %rdx, 0x70(%rsp)
movl (%rdi), %r9d
leaq 0x10(%rdi), %rdx
addq $0x4, %rdi
testl %esi, %esi
cmoveq %rdi, %rdx
movl %r9d, 0x40(%rsp)
movl (%rdx), %edx
movl %edx, 0x48(%rsp)
testl %eax, %eax
jle 0x6d91
movl %eax, %edi
shlq $0x3, %rdi
leaq (%rdi,%rdi,2), %r8
xorl %r10d, %r10d
xorl %edi, %edi
movslq (%rcx,%r10), %r11
addq %r11, %rdi
addq $0x18, %r10
cmpq %r10, %r8
jne 0x6d7b
addq $-0x8, %rdi
jmp 0x6d98
movq $-0x8, %rdi
cmpq $0x14, %rdi
movl $0x14, %r8d
cmovbq %rdi, %r8
leaq 0x40(%rsp), %rdi
movl %r8d, 0xc(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq %rdi, 0x10(%rsp)
movl %eax, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movl %esi, 0x34(%rsp)
movl %eax, %edi
movq %rcx, %rsi
movl $0x14, %ecx
callq 0x44fb
movq %rax, %rbx
movq %rax, 0x18(%rsp)
leaq 0x280(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movq %rax, %rdi
callq 0x1475c
movl %eax, %ebp
movslq 0x8(%r14), %rax
cmpq $0xff, %rax
jg 0x6e40
xorl %edx, %edx
movq %rax, %rsi
xorl %ecx, %ecx
movq 0x280(%rsp,%rsi,8), %rdi
addq %rdi, %rcx
imulq %rsi, %rdi
addq %rdi, %rdx
incq %rsi
cmpl $0x100, %esi            # imm = 0x100
jne 0x6e17
testq %rdx, %rdx
js 0x6e4a
cvtsi2ss %rdx, %xmm1
jmp 0x6e5f
movss 0x10660(%rip), %xmm1    # 0x174a8
jmp 0x6e8a
movq %rdx, %rsi
shrq %rsi
andl $0x1, %edx
orq %rsi, %rdx
cvtsi2ss %rdx, %xmm1
addss %xmm1, %xmm1
testq %rcx, %rcx
js 0x6e6e
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
jmp 0x6e86
movq %rcx, %rdx
shrq %rdx
andl $0x1, %ecx
orq %rdx, %rcx
xorps %xmm0, %xmm0
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
divss %xmm0, %xmm1
movss %xmm1, 0xc(%rsp)
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
mulsd 0x10511(%rip), %xmm0    # 0x173b0
addsd 0x10501(%rip), %xmm0    # 0x173a8
cvttsd2si %xmm0, %ecx
movl %ecx, 0x50(%rsp)
movl 0xc(%r14), %edx
cmpl %ecx, %edx
cmovll %edx, %ecx
cmpl %eax, %ecx
cmovlel %eax, %ecx
movl %ecx, 0x50(%rsp)
movq 0x10(%rsp), %r15
movslq (%r15), %r14
movl $0x8, %esi
movq %r14, %rdi
callq 0x2130
movq %rax, 0x20(%rsp)
testq %r14, %r14
jle 0x6f21
xorl %r12d, %r12d
movl $0x1, %edi
movl $0xb0, %esi
callq 0x2130
movq %r15, (%rax)
movq %rbx, 0x8(%rax)
movq 0x20(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x20(%rsp), %rax
movq (%rax,%r12,8), %rax
movl %ebp, 0xa0(%rax)
incq %r12
movq 0x10(%rsp), %r15
movslq (%r15), %r14
cmpq %r14, %r12
jl 0x6ee3
leaq 0x10(%rsp), %r15
movslq 0x20(%r15), %rcx
leaq 0x9b(%rip), %rsi        # 0x6fcc
movl %r14d, %edi
movq %r15, %rdx
callq 0x13f60
movq (%r15), %rax
cmpl $0x0, (%rax)
jle 0x6fa4
xorl %r15d, %r15d
movq 0x20(%rsp), %rax
movq (%rax,%r15,8), %r14
movq 0x20(%r14), %rdi
callq 0x2040
movq 0x38(%r14), %rdi
callq 0x2040
movq 0x50(%r14), %rdi
callq 0x2040
movq 0x68(%r14), %rdi
callq 0x2040
movq 0x80(%r14), %rdi
callq 0x2040
movq 0x98(%r14), %rdi
callq 0x2040
movq %r14, %rdi
callq 0x2040
incq %r15
movq 0x10(%rsp), %rax
movslq (%rax), %rax
cmpq %rax, %r15
jl 0x6f47
movq 0x20(%rsp), %rdi
callq 0x2040
movq %rbx, %rdi
callq 0x14208
movss 0xc(%rsp), %xmm0
addq $0xa80, %rsp            # imm = 0xA80
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq