// File: /workspace/github_c_makefile_star2_O1/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 0x174a7
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %ecx, %r14d
movq %rdx, %rbx
movl %esi, %r15d
leaq 0x48(%rdx), %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq (%rsi), %r9
testq %r9, %r9
je 0x1727b
movl 0x8(%r9), %r9d
cmpl %ecx, %r9d
jle 0x17274
movl %r8d, %eax
movl %ecx, %edx
movl %r9d, %ecx
jmp 0x1727b
cmpl %edx, %r9d
cmovgl %r9d, %edx
incq %r8
addq $0x50, %rsi
cmpq %r8, %r15
jne 0x17259
testl %eax, %eax
js 0x1749d
testl %ecx, %ecx
js 0x1749d
testl %edx, %edx
js 0x1749d
movl %eax, %eax
leaq (%rax,%rax,4), %rax
shlq $0x4, %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 0x1749d
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %ecx, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
ja 0x1749d
addq %rbx, %rax
movq %rax, %rdi
callq 0x171b8
movsd 0x12d2e(%rip), %xmm1    # 0x2a028
subsd %xmm0, %xmm1
movsd 0x1627a(%rip), %xmm2    # 0x2d580
maxsd %xmm1, %xmm2
movsd 0x14d8e(%rip), %xmm3    # 0x2c0a0
xorps %xmm0, %xmm0
cvtsi2sd %r14d, %xmm0
divsd %xmm2, %xmm3
movapd %xmm3, %xmm1
xorps %xmm2, %xmm2
cvtsi2sd %ebp, %xmm2
mulsd %xmm0, %xmm1
movapd %xmm0, %xmm4
divsd %xmm2, %xmm4
cmpltsd %xmm2, %xmm1
andpd %xmm1, %xmm4
andnpd %xmm3, %xmm1
orpd %xmm4, %xmm1
movapd 0x16082(%rip), %xmm2    # 0x2d3d0
xorpd %xmm1, %xmm2
xorl %eax, %eax
movl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movsd 0x12cbf(%rip), %xmm3    # 0x2a020
movss 0x16053(%rip), %xmm4    # 0x2d3bc
movss 0x1604f(%rip), %xmm5    # 0x2d3c0
movss 0x1604b(%rip), %xmm6    # 0x2d3c4
xorl %edx, %edx
leaq (%rdx,%rdx,4), %rdi
shlq $0x4, %rdi
movq 0x48(%rbx,%rdi), %rsi
testq %rsi, %rsi
je 0x17491
movl 0x18(%rsi), %r9d
testq %r9, %r9
je 0x1743a
xorl %r10d, %r10d
xorpd %xmm7, %xmm7
xorl %r8d, %r8d
movl 0x1c(%rsi,%r10,4), %r11d
movl %r11d, %ebp
andl $0xf, %ebp
decl %ebp
cmpl $0x1, %ebp
ja 0x1742c
shrl $0x4, %r11d
leal 0x1(%r11), %ebp
xorps %xmm8, %xmm8
cvtsi2ss %ebp, %xmm8
movd %xmm8, %ebp
movl %ebp, %r14d
shrl $0x17, %r14d
addl $-0x80, %r14d
xorps %xmm8, %xmm8
cvtsi2ss %r14, %xmm8
andl $0x7fffff, %ebp         # imm = 0x7FFFFF
orl $0x3f800000, %ebp       # imm = 0x3F800000
movd %ebp, %xmm9
movdqa %xmm9, %xmm10
mulss %xmm4, %xmm10
addss %xmm5, %xmm10
mulss %xmm9, %xmm10
addss %xmm6, %xmm10
addss %xmm8, %xmm10
xorps %xmm8, %xmm8
cvtss2sd %xmm10, %xmm8
addsd %xmm1, %xmm8
addsd %xmm8, %xmm7
addl %r8d, %r11d
movl %r11d, %r8d
incq %r10
cmpq %r10, %r9
jne 0x173a8
jmp 0x17441
xorl %r8d, %r8d
xorpd %xmm7, %xmm7
addq %rbx, %rdi
movl 0x14(%rsi), %r9d
andl %ecx, %r9d
movl 0x2c(%rdi), %r10d
addl 0x30(%rdi), %r9d
addl %r10d, %r8d
subl %r8d, %r9d
xorps %xmm8, %xmm8
cvtsi2sd %r10d, %xmm8
xorps %xmm9, %xmm9
cvtsi2sd %r9d, %xmm9
mulsd %xmm2, %xmm9
addsd %xmm8, %xmm9
subsd %xmm7, %xmm9
mulsd %xmm0, %xmm9
addsd %xmm3, %xmm9
cvttsd2si %xmm9, %edi
testl %edi, %edi
cmovlel %eax, %edi
movl %edi, 0x8(%rsi)
incq %rdx
cmpq %r15, %rdx
jne 0x1737b
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq