// File: chhylp123[P]hifiasm/hic.cpp
// Function: dedup_hits(kvec_pe_hit*, unsigned long)
void dedup_hits(kvec_pe_hit* hits, uint64_t is_dup)
{
    double index_time = yak_realtime();
    uint64_t k, l, m = 0, cur;
    radix_sort_pe_hit_an1(hits->a.a, hits->a.a + hits->a.n);
    for (k = 1, l = 0; k <= hits->a.n; ++k) 
    {   
        if (k == hits->a.n || hits->a.a[k].s != hits->a.a[l].s) 
        {
            if (k - l > 1) radix_sort_pe_hit_an2(hits->a.a + l, hits->a.a + k);
            if(is_dup)
            {
                cur = (uint64_t)-1;
                while (l < k)
                {
                    if(hits->a.a[l].e != cur)
                    {
                        cur = hits->a.a[l].e;
                        hits->a.a[m++] = hits->a.a[l];
                    }
                    l++;
                }
            }
            l = k;
        }
    }
    if(is_dup) hits->a.n = m;
    fprintf(stderr, "[M::%s::%.3f] ==> Dedup\n", __func__, yak_realtime()-index_time);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x1b7ca0
movsd %xmm0, -0x18(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x8(%rbp), %rax
movq (%rax), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x1b8c80
movq $0x1, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
ja 0x1c4914
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
je 0x1c4805
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x28(%rbp), %rdx
shlq $0x5, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
je 0x1c4901
movq -0x20(%rbp), %rax
subq -0x28(%rbp), %rax
cmpq $0x1, %rax
jbe 0x1c483e
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x28(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
callq 0x1b91d0
cmpq $0x0, -0x10(%rbp)
je 0x1c48f9
movq $-0x1, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x1c48f7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
cmpq -0x38(%rbp), %rax
je 0x1c48e6
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x28(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x30(%rbp), %rdx
movq %rdx, %rsi
addq $0x1, %rsi
movq %rsi, -0x30(%rbp)
shlq $0x5, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movq 0x18(%rcx), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x1c4851
jmp 0x1c48f9
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x1c4903
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1c47b5
cmpq $0x0, -0x10(%rbp)
je 0x1c4926
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
movq 0x1ff6b3(%rip), %rax    # 0x3c3fe0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x1b7ca0
movq -0x40(%rbp), %rdi
subsd -0x18(%rbp), %xmm0
leaq 0x1c7763(%rip), %rsi    # 0x38c0ac
leaq 0x1c7775(%rip), %rdx    # 0x38c0c5
movb $0x1, %al
callq 0x22a0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)