// File: /workspace/github_c_makefile_star2_O2/lh3[P]minimap2/align.c
// Function: mm_update_dp_max
void mm_update_dp_max(int qlen, int n_regs, mm_reg1_t *regs, float frac, int a, int b)
{
	int32_t max = -1, max2 = -1, i, max_i = -1;
	double div, b2;
	if (n_regs < 2) return;
	for (i = 0; i < n_regs; ++i) {
		mm_reg1_t *r = &regs[i];
		if (r->p == 0) continue;
		if (r->p->dp_max > max) max2 = max, max = r->p->dp_max, max_i = i;
		else if (r->p->dp_max > max2) max2 = r->p->dp_max;
	}
	if (max_i < 0 || max < 0 || max2 < 0) return;
	if (regs[max_i].qe - regs[max_i].qs < (double)qlen * frac) return;
	if (max2 < (double)max * frac) return;
	div = 1. - mm_event_identity(&regs[max_i]);
	if (div < 0.02) div = 0.02;
	b2 = 0.5 / div; // max value: 25
	if (b2 * a < b) b2 = (double)a / b;
	for (i = 0; i < n_regs; ++i) {
		mm_reg1_t *r = &regs[i];
		if (r->p == 0) continue;
		r->p->dp_max = mm_recal_max_dp(r, b2, a);
		if (r->p->dp_max < 0) r->p->dp_max = 0;
	}
}

// Assembly:
cmpl $0x2, %esi
jl 0x15001
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, %rbx
movl %esi, %r15d
leaq 0x48(%rdx), %rsi
pushq $-0x1
popq %rax
xorl %r8d, %r8d
movl %eax, %ecx
movl %eax, %edx
cmpq %r8, %r15
je 0x14fb1
movq (%rsi), %r9
testq %r9, %r9
je 0x14fa2
movl 0x8(%r9), %r9d
cmpl %edx, %r9d
jle 0x14f9b
movl %r8d, %eax
movl %edx, %ecx
jmp 0x14fa5
cmpl %ecx, %r9d
cmovgl %r9d, %ecx
movl %edx, %r9d
incq %r8
addq $0x50, %rsi
movl %r9d, %edx
jmp 0x14f7e
testl %eax, %eax
js 0x14ff3
testl %edx, %edx
js 0x14ff3
testl %ecx, %ecx
js 0x14ff3
movl %eax, %eax
imulq $0x50, %rax, %rax
movl 0x14(%rbx,%rax), %esi
subl 0x10(%rbx,%rax), %esi
cvtsi2sd %esi, %xmm1
cvtsi2sd %edi, %xmm2
cvtss2sd %xmm0, %xmm0
mulsd %xmm0, %xmm2
ucomisd %xmm1, %xmm2
ja 0x14ff3
cvtsi2sd %ecx, %xmm1
cvtsi2sd %edx, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x15002
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rbx, %rax
movq %rax, %rdi
callq 0x14ee6
movsd 0x10ffb(%rip), %xmm1    # 0x26010
subsd %xmm0, %xmm1
movsd 0x1457f(%rip), %xmm0    # 0x295a0
maxsd %xmm1, %xmm0
movsd 0x1308b(%rip), %xmm1    # 0x280b8
divsd %xmm0, %xmm1
cvtsi2sd %r14d, %xmm2
movapd %xmm1, %xmm3
mulsd %xmm2, %xmm3
cvtsi2sd %ebp, %xmm0
movsd %xmm2, 0x8(%rsp)
divsd %xmm0, %xmm2
cmpltsd %xmm0, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm1, %xmm3
orpd %xmm2, %xmm3
movapd 0x1438b(%rip), %xmm0    # 0x293f0
movapd %xmm3, 0x40(%rsp)
xorpd %xmm3, %xmm0
movapd %xmm0, 0x30(%rsp)
xorl %eax, %eax
movq %rbx, 0x18(%rsp)
movq %r15, 0x10(%rsp)
cmpq %r15, %rax
je 0x14ff3
imulq $0x50, %rax, %r14
movq 0x48(%rbx,%r14), %r13
testq %r13, %r13
je 0x1515a
movq %rax, 0x20(%rsp)
addq %rbx, %r14
movl 0x18(%r13), %ebx
xorpd %xmm2, %xmm2
xorl %r12d, %r12d
xorl %ebp, %ebp
cmpq %r12, %rbx
je 0x150fe
movl 0x1c(%r13,%r12,4), %r15d
movl %r15d, %eax
andl $0xf, %eax
decl %eax
cmpl $0x1, %eax
ja 0x150f9
shrl $0x4, %r15d
leal 0x1(%r15), %eax
cvtsi2ss %eax, %xmm0
movsd %xmm2, 0x28(%rsp)
callq 0x17fb2
movsd 0x28(%rsp), %xmm2
cvtss2sd %xmm0, %xmm0
addsd 0x40(%rsp), %xmm0
addsd %xmm0, %xmm2
addl %ebp, %r15d
movl %r15d, %ebp
incq %r12
jmp 0x150b1
movl 0x14(%r13), %eax
movl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
andl %ecx, %eax
movl 0x2c(%r14), %ecx
addl 0x30(%r14), %eax
addl %ecx, %ebp
subl %ebp, %eax
cvtsi2sd %ecx, %xmm0
cvtsi2sd %eax, %xmm1
mulsd 0x30(%rsp), %xmm1
addsd %xmm0, %xmm1
subsd %xmm2, %xmm1
mulsd 0x8(%rsp), %xmm1
addsd 0x10edf(%rip), %xmm1    # 0x26018
cvttsd2si %xmm1, %eax
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
movl %eax, 0x8(%r13)
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rax
incq %rax
jmp 0x15081