// File: chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: deduplicate_edge(kvec_asg_arc_t_offset*)
void deduplicate_edge(kvec_asg_arc_t_offset* u_buffer)
{
    if(u_buffer->a.n == 0) return;
    long long i = u_buffer->a.n - 1, k, i_off;
    uint32_t v = u_buffer->a.a[i].x.ul>>33, m;

    for (; i >= 0; i--) {
        if((u_buffer->a.a[i].x.ul>>33) != v) break;
    }

    i = i + 1;
    for (m = i; i < (long long)u_buffer->a.n; i++)
    {
        if(u_buffer->a.a[i].x.del) continue;

        i_off = Cal_Off(u_buffer->a.a[i].Off);

        for (k = i + 1; k < (long long)u_buffer->a.n; k++)
        {
            if(u_buffer->a.a[k].x.del) continue;
            if(u_buffer->a.a[i].x.el != u_buffer->a.a[k].x.el) continue;
            if(i_off != Cal_Off(u_buffer->a.a[k].Off)) continue;
            u_buffer->a.a[k].x.del = 1;
            u_buffer->a.a[i].weight += u_buffer->a.a[k].weight;
        }
        u_buffer->a.a[m] = u_buffer->a.a[i];
        m++;
    }

    u_buffer->a.n = m;
    ///fprintf(stderr, "u_buffer->a.n: %u, i: %lld\n", u_buffer->a.n, i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x1702cb
jmp 0x170504
movq -0x8(%rbp), %rax
movq (%rax), %rax
subq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x21, %rax
movl %eax, -0x24(%rbp)
cmpq $0x0, -0x10(%rbp)
jl 0x17032c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x21, %rax
movl -0x24(%rbp), %ecx
cmpq %rcx, %rax
je 0x17031c
jmp 0x17032c
jmp 0x17031e
movq -0x10(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x1702f4
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x1704f8
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x170370
jmp 0x1704e7
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
shrq $0x20, %rax
movl %eax, %eax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, -0x10(%rbp), %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
movl %ecx, %ecx
subq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jge 0x1704b2
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1703e4
jmp 0x1704a1
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x10(%rbp), %rcx
addq %rcx, %rax
movzbl 0x12(%rax), %eax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, -0x18(%rbp), %rdx
addq %rdx, %rcx
movzbl 0x12(%rcx), %ecx
cmpl %ecx, %eax
je 0x170415
jmp 0x1704a1
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, -0x18(%rbp), %rdx
addq %rdx, %rcx
movq 0x18(%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
movq -0x8(%rbp), %rdx
movq 0x10(%rdx), %rdx
imulq $0x28, -0x18(%rbp), %rsi
addq %rsi, %rdx
movq 0x18(%rdx), %rdx
movl %edx, %edx
subq %rdx, %rcx
cmpq %rcx, %rax
je 0x170453
jmp 0x1704a1
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x18(%rbp), %rcx
addq %rcx, %rax
movq 0x20(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x10(%rbp), %rdx
addq %rdx, %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x1703b3
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rsi
imulq $0x28, -0x10(%rbp), %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
movl -0x28(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x17033f
movl -0x28(%rbp), %eax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movq %rcx, (%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)