// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap2/esterr.c
// Function: mm_est_err
void mm_est_err(const mm_idx_t *mi, int qlen, int n_regs, mm_reg1_t *regs, const mm128_t *a, int32_t n, const uint64_t *mini_pos)
{
	int i;
	uint64_t sum_k = 0;
	float avg_k;

	if (n == 0) return;
	for (i = 0; i < n; ++i)
		sum_k += mini_pos[i] >> 32 & 0xff;
	avg_k = (float)sum_k / n;

	for (i = 0; i < n_regs; ++i) {
		mm_reg1_t *r = &regs[i];
		int32_t st, en, j, k, n_match, n_tot, l_ref;
		r->div = -1.0f;
		if (r->cnt == 0) continue;
		st = en = get_mini_idx(qlen, r->rev? &a[r->as + r->cnt - 1] : &a[r->as], n, mini_pos);
		if (st < 0) {
			if (mm_verbose >= 2)
				fprintf(stderr, "[WARNING] logic inconsistency in mm_est_err(). Please contact the developer.\n");
			continue;
		}
		l_ref = mi->seq[r->rid].len;
		for (k = 1, j = st + 1, n_match = 1; j < n && k < r->cnt; ++j) {
			int32_t x;
			x = get_for_qpos(qlen, r->rev? &a[r->as + r->cnt - 1 - k] : &a[r->as + k]);
			if (x == (int32_t)mini_pos[j])
				++k, en = j, ++n_match;
		}
		n_tot = en - st + 1;
		if (r->qs > avg_k && r->rs > avg_k) ++n_tot;
		if (qlen - r->qs > avg_k && l_ref - r->re > avg_k) ++n_tot;
		r->div = n_match >= n_tot? 0.0f : (float)(1.0 - pow((double)n_match / n_tot, 1.0 / avg_k));
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x19628
jmp 0x19975
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x19660
movq 0x10(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
andq $0xff, %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1962f
movq -0x30(%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, -0x68(%rbp)
testq %rax, %rax
movss %xmm0, -0x64(%rbp)
js 0x19699
movss -0x68(%rbp), %xmm0
movss %xmm0, -0x64(%rbp)
movss -0x64(%rbp), %xmm0
cvtsi2ssl -0x24(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x34(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x19975
movq -0x18(%rbp), %rax
movslq -0x28(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movss 0x3e4ba(%rip), %xmm0    # 0x57b98
movss %xmm0, 0x44(%rax)
movq -0x40(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x196f2
jmp 0x19967
movl -0xc(%rbp), %eax
movl %eax, -0x6c(%rbp)
movq -0x40(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1972f
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movl 0x28(%rcx), %ecx
movq -0x40(%rbp), %rdx
addl 0x4(%rdx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
jmp 0x19746
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movslq 0x28(%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x6c(%rbp), %edi
movq -0x78(%rbp), %rsi
movl -0x24(%rbp), %edx
movq 0x10(%rbp), %rcx
callq 0x19980
movl %eax, -0x48(%rbp)
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jge 0x1978e
leaq 0x44fa4(%rip), %rax     # 0x5e710
cmpl $0x2, (%rax)
jl 0x19789
movq 0x44880(%rip), %rax     # 0x5dff8
movq (%rax), %rdi
leaq 0x3e41a(%rip), %rsi     # 0x57b9c
movb $0x0, %al
callq 0x2250
jmp 0x19967
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rcx
movslq 0x8(%rcx), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0x5c(%rbp)
movl $0x1, -0x50(%rbp)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl $0x1, -0x54(%rbp)
movl -0x4c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x24(%rbp), %ecx
movb %al, -0x79(%rbp)
jge 0x197df
movl -0x50(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpl 0x4(%rcx), %eax
setl %al
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
testb $0x1, %al
jne 0x197eb
jmp 0x1989a
movl -0xc(%rbp), %eax
movl %eax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movl 0x3c(%rax), %eax
shrl $0xa, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1982e
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movl 0x28(%rcx), %ecx
movq -0x40(%rbp), %rdx
addl 0x4(%rdx), %ecx
subl $0x1, %ecx
subl -0x50(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
jmp 0x1984d
movq -0x20(%rbp), %rax
movq -0x40(%rbp), %rcx
movl 0x28(%rcx), %ecx
addl -0x50(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movl -0x80(%rbp), %edi
movq -0x88(%rbp), %rsi
callq 0x19a20
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq 0x10(%rbp), %rcx
movslq -0x4c(%rbp), %rdx
movq (%rcx,%rdx,8), %rcx
cmpl %ecx, %eax
jne 0x1988a
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x1988c
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x197c2
movl -0x48(%rbp), %eax
subl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movq -0x40(%rbp), %rax
cvtsi2ssl 0x10(%rax), %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x198cd
movq -0x40(%rbp), %rax
cvtsi2ssl 0x18(%rax), %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x198cd
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0xc(%rbp), %eax
movq -0x40(%rbp), %rcx
subl 0x10(%rcx), %eax
cvtsi2ss %eax, %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x198fe
movl -0x5c(%rbp), %eax
movq -0x40(%rbp), %rcx
subl 0x1c(%rcx), %eax
cvtsi2ss %eax, %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x198fe
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x58(%rbp), %eax
jl 0x19913
xorps %xmm0, %xmm0
movss %xmm0, -0x8c(%rbp)
jmp 0x19956
cvtsi2sdl -0x54(%rbp), %xmm0
cvtsi2sdl -0x58(%rbp), %xmm1
divsd %xmm1, %xmm0
movss -0x34(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x3b6de(%rip), %xmm1    # 0x55010
divsd %xmm2, %xmm1
callq 0x2110
movaps %xmm0, %xmm1
movsd 0x3b6ca(%rip), %xmm0    # 0x55010
subsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x8c(%rbp)
movss -0x8c(%rbp), %xmm0
movq -0x40(%rbp), %rax
movss %xmm0, 0x44(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x196b3
addq $0x90, %rsp
popq %rbp
retq
nop