// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Correct.cpp
// Function: count_k_hits_filter(overlap_region_alloc*, Candidates_list*, asg64_v*, Chain_Data*)
void count_k_hits_filter(overlap_region_alloc* ol, Candidates_list *cl, asg64_v* ii, Chain_Data *dp)
{
    int64_t k, on = ol->length, m = 0, i, cn = cl->length, scn; k_mer_hit *ca;
    overlap_region *z; uint64_t pid; 
    kv_resize(uint64_t, *ii, ol->length);
    for (k = 0, ii->n = 0; k < on; k++, ii->n++) {
        z = &(ol->list[k]);  
        ii->a[ii->n] = z->shared_seed;
        ii->a[ii->n] <<= 32; ii->a[ii->n] |= k;
        i = z->shared_seed; pid = cl->list[i].readID;
        for (; i < cn && cl->list[i].readID == pid && cl->list[i].readID != ((uint32_t)(0x7fffffff)); i++);
        scn = i - z->shared_seed; ca = cl->list+z->shared_seed;
        i = lchain_refine(ca, scn, ca, dp, 50, 5000, 512, 16); 
        for (; i < scn; i++) ca[i].readID = ((uint32_t)(0x7fffffff));
    }
    radix_sort_bc64(ii->a, ii->a+ii->n); 

    for (k = m = 0; k < on; k++) {
        z = &(ol->list[(uint32_t)ii->a[k]]); i = z->shared_seed; 
        pid = cl->list[i].readID; z->shared_seed = m;
        for (; i < cn && cl->list[i].readID == pid && cl->list[i].readID != ((uint32_t)(0x7fffffff)); i++) {
            cl->list[m] = cl->list[i]; 
            cl->list[m].readID = (uint32_t)ii->a[k]; 
            cl->list[m].cnt = 0;
            m++;
        }
    }
    cl->length = cn = m; 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r12
movq 0x10(%rdi), %r13
movq 0x8(%rsi), %r8
cmpq %r13, 0x8(%rdx)
movq %r8, 0x8(%rsp)
jae 0x62c0a
leaq -0x1(%r13), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x8(%r14)
movq 0x10(%r14), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x8(%rsp), %r8
movq %rax, 0x10(%r14)
movq $0x0, (%r14)
testq %r13, %r13
jle 0x62d15
xorl %r15d, %r15d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movq %r12, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movq (%r12), %rax
imulq $0xa8, %r15, %rdx
movslq 0x24(%rax,%rdx), %rax
movq 0x10(%r14), %rdx
movq %rax, (%rdx,%rcx,8)
movq (%r14), %rcx
shlq $0x20, (%rdx,%rcx,8)
movq (%r14), %rcx
orq %r15, (%rdx,%rcx,8)
movq (%rbx), %rbp
movq %rax, %r12
shlq $0x4, %r12
leaq (%r12,%rbp), %rdi
movq %rax, %r13
cmpq %rax, %r8
jle 0x62c9a
movl (%rbp,%r12), %ecx
andl %r9d, %ecx
movq %rdi, %rdx
movq %rax, %r13
movl (%rdx), %esi
andl %r9d, %esi
cmpl %ecx, %esi
jne 0x62c9a
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x62c9a
incq %r13
addq $0x10, %rdx
cmpq %r13, %r8
jne 0x62c7a
movq %r8, %r13
subq %rax, %r13
movl $0x32, %r8d
movl $0x1388, %r9d           # imm = 0x1388
movq %r13, %rsi
movq %rdi, %rdx
movq 0x20(%rsp), %rcx
pushq $0x10
pushq $0x200                  # imm = 0x200
callq 0x441c0
addq $0x10, %rsp
cmpq %r13, %rax
jge 0x62ce9
movq %rax, %rcx
shlq $0x4, %rcx
addq %r12, %rbp
addq %rcx, %rbp
orl $0x7fffffff, (%rbp)     # imm = 0x7FFFFFFF
incq %rax
addq $0x10, %rbp
cmpq %r13, %rax
jl 0x62cd6
incq %r15
movq (%r14), %rcx
incq %rcx
movq %rcx, (%r14)
movq 0x10(%rsp), %r13
cmpq %r13, %r15
movq 0x18(%rsp), %r12
movq 0x8(%rsp), %r8
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
jne 0x62c2f
jmp 0x62d17
xorl %ecx, %ecx
movq 0x10(%r14), %rdi
leaq (%rdi,%rcx,8), %rsi
callq 0x45d47
testq %r13, %r13
jle 0x62de1
xorl %ecx, %ecx
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl $0x80000000, %esi       # imm = 0x80000000
xorl %eax, %eax
movq (%r12), %r9
movq 0x10(%r14), %rdi
movl (%rdi,%rcx,8), %edi
imulq $0xa8, %rdi, %r10
movslq 0x24(%r9,%r10), %r11
movq (%rbx), %r8
movq %r11, %rdi
shlq $0x4, %rdi
movl (%r8,%rdi), %r8d
andl %edx, %r8d
movl %eax, 0x24(%r9,%r10)
movq 0x8(%rsp), %r9
subq %r11, %r9
jle 0x62dd3
movq %rax, %r10
shlq $0x4, %r10
movq (%rbx), %r11
movl (%r11,%rdi), %ebp
andl %edx, %ebp
cmpl %r8d, %ebp
jne 0x62dd3
cmpl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x62dd3
leaq (%r11,%rdi), %r15
movups (%r15), %xmm0
movups %xmm0, (%r11,%r10)
movq 0x10(%r14), %r11
movq (%rbx), %r15
movl (%r11,%rcx,8), %r11d
andl %edx, %r11d
movl (%r15,%r10), %ebp
andl %esi, %ebp
orl %r11d, %ebp
movl %ebp, (%r15,%r10)
movq (%rbx), %r11
movl $0x0, 0xc(%r11,%r10)
incq %rax
addq $0x10, %r10
addq $0x10, %rdi
decq %r9
jne 0x62d79
incq %rcx
cmpq %r13, %rcx
jne 0x62d3b
jmp 0x62de3
xorl %eax, %eax
movq %rax, 0x8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq