// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: clean_srt_integer(ul_resolve_t*, unsigned int, ul2ul_item_t*, ul2ul_idx_t*)
void clean_srt_integer(ul_resolve_t *uidx, uint32_t qid, ul2ul_item_t *o, ul2ul_idx_t *ul2)
{
    uint64_t k, l, i, m; ul2ul_t *p;
    radix_sort_ul2ul_srt(o->a, o->a + o->n);
    for(k = 1, l = m = o->cn = 0; k <= o->n; k++) {
        if(k == o->n || o->a[k].hid != o->a[l].hid) {
            for (i = l, p = &(o->a[l]); i < k; i++) {
                if(((p->is_del) && (!o->a[i].is_del)) || 
                            ((o->a[i].qe - o->a[i].qs + o->a[i].te - o->a[i].ts) > (p->qe - p->qs + p->te - p->ts))) {
                    p = &(o->a[i]);
                }
            }
            if(!(p->is_del)) o->cn++;
            o->a[m++] = *p;
            l = k;
        }
    }
    o->n = m;
    if(o->n == o->cn) return;

    for (k = o->cn = 0; k < o->n; k++) {
        if(o->a[k].is_del) o->a[k].hid |= ((uint32_t)(0x80000000));
        else o->cn++;
    }
    radix_sort_ul2ul_srt(o->a, o->a + o->n);

    for (k = 0; k < o->n; k++) {
        if(o->a[k].hid&((uint32_t)(0x80000000))) {
            o->a[k].hid -= ((uint32_t)(0x80000000));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
imulq $0x28, 0x8(%rax), %rax
addq %rax, %rsi
callq 0x30fc30
movq $0x1, -0x28(%rbp)
movq -0x18(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
ja 0x33a636
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
je 0x33a4f1
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x28(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x30(%rbp), %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
je 0x33a623
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x30(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x33a5d3
movq -0x48(%rbp), %rax
movb 0x24(%rax), %al
shrb $0x6, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x33a545
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movb 0x24(%rax), %al
shrb $0x6, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x33a5ad
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
subl 0x4(%rcx), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
addl 0x10(%rcx), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x28, -0x38(%rbp), %rdx
addq %rdx, %rcx
subl 0xc(%rcx), %eax
movq -0x48(%rbp), %rcx
movl 0x8(%rcx), %ecx
movq -0x48(%rbp), %rdx
subl 0x4(%rdx), %ecx
movq -0x48(%rbp), %rdx
addl 0x10(%rdx), %ecx
movq -0x48(%rbp), %rdx
subl 0xc(%rdx), %ecx
cmpl %ecx, %eax
jbe 0x33a5c0
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x33a5c2
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x33a50c
movq -0x48(%rbp), %rax
movb 0x24(%rax), %al
shrb $0x6, %al
andb $0x1, %al
cmpb $0x0, %al
jne 0x33a5f0
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movq -0x48(%rbp), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x40(%rbp)
imulq $0x28, %rax, %rax
addq %rax, %rdi
movl $0x28, %edx
callq 0x2180
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x33a625
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x33a4a9
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movl 0x1c(%rcx), %ecx
cmpq %rcx, %rax
jne 0x33a65b
jmp 0x33a748
movq -0x18(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x33a6cf
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x28(%rbp), %rcx
addq %rcx, %rax
movb 0x24(%rax), %al
shrb $0x6, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x33a6b2
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x28(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %ecx
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%rax)
jmp 0x33a6bf
movq -0x18(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
jmp 0x33a6c1
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x33a66e
movq -0x18(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
imulq $0x28, 0x8(%rax), %rax
addq %rax, %rsi
callq 0x30fc30
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x33a748
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x28(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x0, %eax
je 0x33a738
movq -0x18(%rbp), %rax
movq (%rax), %rax
imulq $0x28, -0x28(%rbp), %rcx
addq %rcx, %rax
movl (%rax), %ecx
subl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%rax)
jmp 0x33a73a
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x33a6f6
addq $0x50, %rsp
popq %rbp
retq
nop