// File: /workspace/github_c_makefile_star2_O0/lh3[P]minimap/sdust.c
// Function: find_perfect
static void find_perfect(perf_intv_v *P, const kdq_t(int) *w, int T, int start, int L, int rv, const int *cv)
{
	int c[SD_WTOT], r = rv, i, max_r = 0, max_l = 0;
	memcpy(c, cv, SD_WTOT * sizeof(int));
	for (i = (long)kdq_size(w) - L - 1; i >= 0; --i) {
		int j, t = kdq_at(w, i), new_r, new_l;
		r += c[t]++;
		new_r = r, new_l = kdq_size(w) - i - 1;
		if (new_r * 10 > T * new_l) {
			for (j = 0; j < P->n && P->a[j].start >= i + start; ++j) { // find insertion position
				perf_intv_t *p = &P->a[j];
				if (max_r == 0 || p->r * max_l > max_r * p->l)
					max_r = p->r, max_l = p->l;
			}
			if (max_r == 0 || new_r * max_l >= max_r * new_l) { // then insert
				max_r = new_r, max_l = new_l;
				if (P->n == P->m) kv_resize(perf_intv_t, *P, P->n + 1);
				memmove(&P->a[j+1], &P->a[j], (P->n - j) * sizeof(perf_intv_t)); // make room
				++P->n;
				P->a[j].start = i + start, P->a[j].finish = kdq_size(w) + (SD_WLEN - 1) + start;
				P->a[j].r = new_r, P->a[j].l = new_l;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x124(%rbp)
movl $0x0, -0x12c(%rbp)
movl $0x0, -0x130(%rbp)
leaq -0x120(%rbp), %rdi
movq 0x10(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x2190
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x1c(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x128(%rbp)
cmpl $0x0, -0x128(%rbp)
jl 0xb1fc
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rdx
movabsq $0x3ffffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFFF
andq (%rdx), %rcx
movslq -0x128(%rbp), %rdx
addq %rdx, %rcx
movq -0x10(%rbp), %rdx
andq 0x10(%rdx), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x138(%rbp)
movslq -0x138(%rbp), %rcx
movl -0x120(%rbp,%rcx,4), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x120(%rbp,%rcx,4)
addl -0x124(%rbp), %eax
movl %eax, -0x124(%rbp)
movl -0x124(%rbp), %eax
movl %eax, -0x13c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x128(%rbp), %rcx
subq %rcx, %rax
subq $0x1, %rax
movl %eax, -0x140(%rbp)
imull $0xa, -0x13c(%rbp), %eax
movl -0x14(%rbp), %ecx
imull -0x140(%rbp), %ecx
cmpl %ecx, %eax
jle 0xb1e6
movl $0x0, -0x134(%rbp)
movslq -0x134(%rbp), %rcx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpq (%rdx), %rcx
movb %al, -0x149(%rbp)
jae 0xaf26
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x134(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl -0x128(%rbp), %ecx
addl -0x18(%rbp), %ecx
cmpl %ecx, %eax
setge %al
movb %al, -0x149(%rbp)
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0xaf35
jmp 0xafb7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x134(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x148(%rbp)
cmpl $0x0, -0x12c(%rbp)
je 0xaf81
movq -0x148(%rbp), %rax
movl 0x8(%rax), %eax
imull -0x130(%rbp), %eax
movl -0x12c(%rbp), %ecx
movq -0x148(%rbp), %rdx
imull 0xc(%rdx), %ecx
cmpl %ecx, %eax
jle 0xafa1
movq -0x148(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x12c(%rbp)
movq -0x148(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x130(%rbp)
jmp 0xafa3
movl -0x134(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x134(%rbp)
jmp 0xaee2
cmpl $0x0, -0x12c(%rbp)
je 0xafe2
movl -0x13c(%rbp), %eax
imull -0x130(%rbp), %eax
movl -0x12c(%rbp), %ecx
imull -0x140(%rbp), %ecx
cmpl %ecx, %eax
jl 0xb1e4
movl -0x13c(%rbp), %eax
movl %eax, -0x12c(%rbp)
movl -0x140(%rbp), %eax
movl %eax, -0x130(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0xb0ff
jmp 0xb011
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jae 0xb0fb
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
shrq %rcx
movq -0x8(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x2, %rcx
movq -0x8(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x4, %rcx
movq -0x8(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x8, %rcx
movq -0x8(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x10, %rcx
movq -0x8(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x4, %rsi
callq 0x2200
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0xb0fd
jmp 0xb0ff
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x134(%rbp), %eax
addl $0x1, %eax
cltq
shlq $0x4, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x134(%rbp), %rax
shlq $0x4, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
movslq -0x134(%rbp), %rax
subq %rax, %rdx
shlq $0x4, %rdx
callq 0x2220
movq -0x8(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl -0x128(%rbp), %ecx
addl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x134(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x2, %rax
movslq -0x18(%rbp), %rcx
addq %rcx, %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x134(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movl -0x13c(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x134(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movl -0x140(%rbp), %ecx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x134(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movl %ecx, 0xc(%rax)
jmp 0xb1e6
jmp 0xb1e8
movl -0x128(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x128(%rbp)
jmp 0xae30
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)