// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Overlaps.cpp
// Function: kt_u_trans_t_simple_symm(kv_u_trans_t*, unsigned int, unsigned int)
void kt_u_trans_t_simple_symm(kv_u_trans_t *ta, uint32_t un, uint32_t symm_add)
{
    u_trans_t *a = NULL, *r_a = NULL, *p = NULL;
    uint32_t k, n, m;
    n = ta->n;
    for (k = 0; k < n; k++)
    {
        if(ta->a[k].del || ta->a[k].qn > ta->a[k].tn) continue;
        get_u_trans_spec(ta, ta->a[k].tn, ta->a[k].qn, &r_a, NULL);
        a = &(ta->a[k]); 
        if(!r_a || r_a->del)
        {
            if(symm_add) kv_pushp(u_trans_t, *ta, &r_a);
            else
            {
                a->del = 1; 
                continue;
            }
        }
        else
        {
            if(r_a->nw > a->nw) 
            {
                p = a;
                a = r_a;
                r_a = p;
            }
        }
        (*r_a) = (*a);
        r_a->qn = a->tn; r_a->qs = a->ts; r_a->qe = a->te;
        r_a->tn = a->qn; r_a->ts = a->qs; r_a->te = a->qe;
    }
    
    for (k = m = 0; k < ta->n; ++k)
    {
        if(ta->a[k].del) continue;
        ta->a[m] = ta->a[k];
        m++;
    }
    ta->n = m;
    kt_u_trans_t_idx(ta, un);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq $0x0, 0x8(%rsp)
movq (%rdi), %rcx
testl %ecx, %ecx
je 0xcc9d2
movl %edx, %ebp
movl %esi, 0x14(%rsp)
movl %ecx, %eax
shlq $0x4, %rax
leaq (%rax,%rax,2), %r13
xorl %ebx, %ebx
movq 0x10(%r14), %r12
cmpb $0x0, 0x28(%r12,%rbx)
js 0xcc9be
movl 0x8(%r12,%rbx), %edx
movl 0x14(%r12,%rbx), %esi
cmpl %esi, %edx
ja 0xcc9be
leaq (%r12,%rbx), %r15
movq %r14, %rdi
leaq 0x8(%rsp), %rcx
xorl %r8d, %r8d
callq 0xcba40
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
je 0xcc92b
cmpb $0x0, 0x28(%rcx)
js 0xcc92b
movsd 0x20(%rcx), %xmm0
ucomisd 0x20(%r12,%rbx), %xmm0
jbe 0xcc986
movq %r15, 0x8(%rsp)
movq %r15, %rax
movq %rcx, %r15
jmp 0xcc989
testl %ebp, %ebp
je 0xcc97f
movq (%r14), %rax
cmpq 0x8(%r14), %rax
jne 0xcc966
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%r14)
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %r12, %rdi
callq 0x2370
movq %rax, %r12
movq %rax, 0x10(%r14)
movq (%r14), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r14)
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
addq %r12, %rax
movq %rax, 0x8(%rsp)
jmp 0xcc989
orb $-0x80, 0x28(%r15)
jmp 0xcc9be
movq %rcx, %rax
movups (%r15), %xmm0
movups 0x10(%r15), %xmm1
movups 0x20(%r15), %xmm2
movups %xmm2, 0x20(%rax)
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
movl 0x14(%r15), %ecx
movl %ecx, 0x8(%rax)
movq 0xc(%r15), %rcx
movq %rcx, (%rax)
movl 0x8(%r15), %ecx
movl %ecx, 0x14(%rax)
movq (%r15), %rcx
movq %rcx, 0xc(%rax)
addq $0x30, %rbx
cmpq %rbx, %r13
jne 0xcc8ca
movq (%r14), %rcx
movl 0x14(%rsp), %esi
xorl %eax, %eax
testq %rcx, %rcx
je 0xcca2f
movl $0x1, %edx
xorl %r8d, %r8d
movq 0x10(%r14), %rdi
leaq (%r8,%r8,2), %r8
shlq $0x4, %r8
cmpb $0x0, 0x28(%rdi,%r8)
js 0xcca23
addq %rdi, %r8
movl %eax, %ecx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movups (%r8), %xmm0
movups 0x10(%r8), %xmm1
movups 0x20(%r8), %xmm2
movups %xmm2, 0x20(%rdi,%rcx)
movups %xmm1, 0x10(%rdi,%rcx)
movups %xmm0, (%rdi,%rcx)
incl %eax
movq (%r14), %rcx
movl %edx, %r8d
incl %edx
cmpq %r8, %rcx
ja 0xcc9e1
movl %eax, %eax
movq %rax, (%r14)
movq %r14, %rdi
callq 0xc4edd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq