// File: /workspace/github_cpp_makefile_star2_O3/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, 0x10(%rsp)
movq 0x10(%rdi), %r13
movq 0x8(%rsi), %r8
cmpq %r13, 0x8(%rdx)
movq %r8, 0x8(%rsp)
jae 0x62728
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 0x62901
xorl %r12d, %r12d
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %ecx, %ecx
movq %r13, 0x18(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rax
imulq $0xa8, %r12, %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 %r12, (%rdx,%rcx,8)
movq (%rbx), %rbp
movq %rax, %r15
shlq $0x4, %r15
leaq (%r15,%rbp), %rdi
movq %rax, %r13
cmpq %rax, %r8
jle 0x627b7
movl (%rbp,%r15), %ecx
andl %r9d, %ecx
movq %rdi, %rdx
movq %rax, %r13
movl (%rdx), %esi
andl %r9d, %esi
cmpl %ecx, %esi
jne 0x627b7
cmpl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
je 0x627b7
incq %r13
addq $0x10, %rdx
cmpq %r13, %r8
jne 0x62797
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 0x438d5
addq $0x10, %rsp
cmpq %r13, %rax
jge 0x62806
movq %rax, %rcx
shlq $0x4, %rcx
addq %r15, %rbp
addq %rcx, %rbp
orl $0x7fffffff, (%rbp)     # imm = 0x7FFFFFFF
incq %rax
addq $0x10, %rbp
cmpq %r13, %rax
jl 0x627f3
incq %r12
movq (%r14), %rcx
incq %rcx
movq %rcx, (%r14)
movq 0x18(%rsp), %r13
cmpq %r13, %r12
movq 0x8(%rsp), %r8
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
jne 0x62748
movq 0x10(%r14), %rdi
leaq (%rdi,%rcx,8), %rsi
callq 0x45373
testq %r13, %r13
jle 0x6290d
movq (%rbx), %rdi
xorl %eax, %eax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl $0x80000000, %esi       # imm = 0x80000000
xorl %ecx, %ecx
movq 0x10(%rsp), %r8
movq (%r8), %r10
movq 0x10(%r14), %r8
movl (%r8,%rax,8), %r8d
imulq $0xa8, %r8, %r11
movslq 0x24(%r10,%r11), %r15
movq %r15, %r8
shlq $0x4, %r8
movl (%rdi,%r8), %r9d
andl %edx, %r9d
movl %ecx, 0x24(%r10,%r11)
movq 0x8(%rsp), %r11
movq %r11, %r10
subq %r15, %r10
jle 0x628f3
addq %rcx, %r11
subq %r15, %r11
movq %rcx, %r15
shlq $0x4, %r15
movl (%rdi,%r8), %ebp
andl %edx, %ebp
cmpl %r9d, %ebp
jne 0x628f3
cmpl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x628f3
leaq (%rdi,%r8), %r12
movups (%r12), %xmm0
movups %xmm0, (%rdi,%r15)
movq 0x10(%r14), %rdi
movq (%rbx), %r12
movl (%rdi,%rax,8), %edi
andl %edx, %edi
movl (%r12,%r15), %ebp
andl %esi, %ebp
orl %edi, %ebp
movl %ebp, (%r12,%r15)
movq (%rbx), %rdi
movl $0x0, 0xc(%rdi,%r15)
incq %rcx
addq $0x10, %r15
addq $0x10, %r8
decq %r10
jne 0x6289b
movq %r11, %rcx
incq %rax
cmpq %r13, %rax
jne 0x62852
jmp 0x6290f
movq 0x10(%r14), %rdi
movq %rdi, %rsi
callq 0x45373
xorl %ecx, %ecx
movq %rcx, 0x8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq