// File: /workspace/github_cpp_makefile_star2_O2/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, 0x10(%rsp)
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r13
movq 0x10(%rdi), %r15
movq 0x8(%rsi), %r12
cmpq %r15, 0x8(%rdx)
jae 0x3210f
leaq -0x1(%r15), %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 %rax, 0x10(%r14)
xorl %ecx, %ecx
testq %r15, %r15
cmovleq %rcx, %r15
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
xorl %esi, %esi
movq %r15, 0x8(%rsp)
movq %r13, 0x18(%rsp)
movq %rcx, (%r14)
cmpq %r15, %rsi
je 0x3221b
movq (%r13), %rax
imulq $0xa8, %rsi, %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
movq %rsi, 0x20(%rsp)
orq %rsi, (%rdx,%rcx,8)
movq (%rbx), %r13
movq %rax, %r15
shlq $0x4, %r15
leaq (%r15,%r13), %rdi
movl (%r13,%r15), %ecx
andl %r9d, %ecx
cmpq %rax, %r12
movq %rax, %rbp
cmovgq %r12, %rbp
movq %rdi, %rsi
movq %rax, %rdx
cmpq %r12, %rdx
jge 0x321ad
movl (%rsi), %r8d
andl %r9d, %r8d
cmpl %ecx, %r8d
jne 0x321aa
cmpl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
je 0x321aa
incq %rdx
addq $0x10, %rsi
jmp 0x32188
movq %rdx, %rbp
subq %rax, %rbp
movl $0x1388, %r9d           # imm = 0x1388
movq %rbp, %rsi
movq %rdi, %rdx
movq 0x10(%rsp), %rcx
pushq $0x32
popq %r8
pushq $0x10
pushq $0x200                  # imm = 0x200
callq 0x1751e
addq $0x10, %rsp
movq %rax, %rcx
shlq $0x4, %rcx
addq %r15, %rcx
addq %rcx, %r13
movq 0x8(%rsp), %r15
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movq 0x20(%rsp), %rsi
cmpq %rbp, %rax
jge 0x32208
orl $0x7fffffff, (%r13)     # imm = 0x7FFFFFFF
incq %rax
addq $0x10, %r13
jmp 0x321f2
incq %rsi
movq (%r14), %rcx
incq %rcx
movq 0x18(%rsp), %r13
jmp 0x3212a
movq 0x10(%r14), %rdi
leaq (%rdi,%rcx,8), %rsi
callq 0x1905d
xorl %eax, %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl $0x80000000, %edx       # imm = 0x80000000
xorl %esi, %esi
cmpq %r15, %rsi
je 0x322d9
movq (%r13), %r10
movq 0x10(%r14), %rdi
movl (%rdi,%rsi,8), %edi
imulq $0xa8, %rdi, %r15
movslq 0x24(%r10,%r15), %rdi
movq (%rbx), %r11
movq %rdi, %r8
shlq $0x4, %r8
movl (%r11,%r8), %r9d
andl %ecx, %r9d
movl %eax, 0x24(%r10,%r15)
movq %rax, %r10
shlq $0x4, %r10
cmpq %r12, %rdi
jge 0x322cc
movl (%r11,%r8), %ebp
andl %ecx, %ebp
cmpl %r9d, %ebp
jne 0x322cc
cmpl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
je 0x322cc
leaq (%r11,%r8), %r15
movups (%r15), %xmm0
movups %xmm0, (%r11,%r10)
movq 0x10(%r14), %r11
movq (%rbx), %r15
movl (%r11,%rsi,8), %r11d
andl %ecx, %r11d
movl (%r15,%r10), %ebp
andl %edx, %ebp
orl %r11d, %ebp
movl %ebp, (%r15,%r10)
movq (%rbx), %r11
andl $0x0, 0xc(%r11,%r10)
incq %rax
incq %rdi
addq $0x10, %r8
addq $0x10, %r10
jmp 0x32273
incq %rsi
movq 0x8(%rsp), %r15
jmp 0x32236
movq %rax, 0x8(%rbx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq