// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: kt_u_trans_t_symm(kv_u_trans_t*, ma_ug_t*)
void kt_u_trans_t_symm(kv_u_trans_t *ta, ma_ug_t *ug)
{
    u_trans_t *a = NULL, *r_a = NULL, *p = NULL;
    uint32_t k, n, r_n, st, i, m;
    double w0, w1;
    kvec_t(u_trans_t) e0; kv_init(e0);
    kvec_t(u_trans_t) e1; kv_init(e1);
    for (k = 0; k < ta->idx.n; k++)
    {
        a = u_trans_a(*ta, k);
        n = u_trans_n(*ta, k);
        for (st = 0, i = 1; i <= n; ++i)
        {
            if (i == n || a[i].tn != a[st].tn)
            {
                get_u_trans_spec(ta, a[st].tn, a[st].qn, &r_a, &r_n);
                if(i == st + 1 && r_n == 0) {///should be always here
                    st = i;
                    continue;
                } 

                e0.n = e1.n = 0;
                for (m = st; m < i; m++) {
                    if(a[m].del) continue;
                    if(a[m].rev) {
                        kv_push(u_trans_t, e1, a[m]);
                    } else {
                        kv_push(u_trans_t, e0, a[m]);
                    }
                }
                
                for (m = 0; m < r_n; m++) {
                    if(r_a[m].del) continue;
                    if(r_a[m].rev) {
                        kv_pushp(u_trans_t, e1, &p);
                    } else {
                        kv_pushp(u_trans_t, e0, &p);
                    }
                    (*p) = r_a[m];
                    p->qn = r_a[m].tn; p->qs = r_a[m].ts; p->qe = r_a[m].te;
                    p->tn = r_a[m].qn; p->ts = r_a[m].qs; p->te = r_a[m].qe;
                }
                

                if(e0.n + e1.n > 1) {
                    ///must be here
                    for (m = st; m < i; m++) a[m].del = 1;
                    for (m = 0; m < r_n; m++) r_a[m].del = 1;

                    w0 = merge_u_trans(e0.a, e0.n, ug);
                    w1 = merge_u_trans(e1.a, e1.n, ug);
                    if(w0 >= w1)
                    {
                        for (m = 0; m < e0.n; m++)
                        {
                            kv_push(u_trans_t, *ta, e0.a[m]);
                        }
                    }
                    else
                    {
                        for (m = 0; m < e1.n; m++)
                        {
                            kv_push(u_trans_t, *ta, e1.a[m]);
                        }
                    }
                }
                st = i;
            }
        }

    }
    kv_destroy(e0);
    kv_destroy(e1);
    for (i = m = 0; i < ta->n; ++i)
    {
        if(ta->a[i].del) continue;
        ta->a[m] = ta->a[i];
        m++;
    }
    ta->n = m;
    n = ta->n;
    for (i = 0; i < n; ++i)
    {
        if(ta->a[i].del) continue;
        kv_pushp(u_trans_t, *ta, &p);
        (*p) = ta->a[i];
        p->qn = ta->a[i].tn; p->qs = ta->a[i].ts; p->qe = ta->a[i].te;
        p->tn = ta->a[i].qn; p->ts = ta->a[i].qs; p->te = ta->a[i].qe;
    }
    kt_u_trans_t_idx(ta, ug->g->n_seq);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, 0x60(%rsp)
movq %rdi, %rbx
movq $0x0, 0x28(%rsp)
xorl %r14d, %r14d
cmpq $0x0, 0x18(%rdi)
je 0xcb492
leaq 0x28(%rsp), %r15
xorl %esi, %esi
xorl %r8d, %r8d
movq $0x0, 0x38(%rsp)
movq $0x0, 0x30(%rsp)
movq %rbx, 0x68(%rsp)
movq 0x28(%rbx), %rax
movq (%rax,%r14,8), %r13
testl %r13d, %r13d
je 0xcb483
movq 0x10(%rbx), %rax
movq %r13, %rcx
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
leaq (%rax,%rcx), %rbp
addq %rcx, %rax
addq $0x28, %rax
movq %rax, 0x80(%rsp)
movq $0x0, 0x10(%rsp)
movl $0x1, %eax
movq %rbp, 0x58(%rsp)
movq %r14, 0x48(%rsp)
movq %r13, 0x40(%rsp)
movl %eax, %edx
movl 0x10(%rsp), %edi
movl %eax, 0xc(%rsp)
cmpl %r13d, %eax
je 0xcaf31
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
movl 0x14(%rbp,%rax), %eax
leaq (%rdi,%rdi,2), %rcx
shlq $0x4, %rcx
cmpl 0x14(%rbp,%rcx), %eax
jne 0xcaf31
movl 0xc(%rsp), %eax
jmp 0xcb452
movq %rdx, 0x78(%rsp)
movq %rsi, 0x18(%rsp)
movq %r8, 0x50(%rsp)
movq %rdi, 0x70(%rsp)
leaq (%rdi,%rdi,2), %rax
shlq $0x4, %rax
movl 0x8(%rbp,%rax), %edx
movl 0x14(%rbp,%rax), %esi
movq %rbx, %rdi
movq %r15, %rcx
leaq 0x24(%rsp), %r8
callq 0xca79c
movq 0x10(%rsp), %rax
incl %eax
movl 0xc(%rsp), %ecx
cmpl %eax, %ecx
movl %ecx, %eax
jne 0xcaf93
cmpl $0x0, 0x24(%rsp)
jne 0xcaf93
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
movq 0x50(%rsp), %r8
movq 0x18(%rsp), %rsi
jmp 0xcb452
cmpl %eax, 0x10(%rsp)
jae 0xcb0b8
movq 0x70(%rsp), %rax
leaq (%rax,%rax,2), %r13
shlq $0x4, %r13
addq %rbp, %r13
movq 0x78(%rsp), %rbp
subq %rax, %rbp
xorl %r12d, %r12d
xorl %r9d, %r9d
movq 0x50(%rsp), %r8
movq 0x30(%rsp), %r14
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %r15
movb 0x28(%r13), %al
testb %al, %al
js 0xcb0a9
cmpb $0x40, %al
jae 0xcb039
cmpq %r15, %r9
jne 0xcb029
leaq (%r15,%r15), %rbx
testq %r15, %r15
movl $0x2, %eax
cmoveq %rax, %rbx
movq %rbx, %rax
shlq $0x4, %rax
movq %rsi, 0x18(%rsp)
leaq (%rax,%rax,2), %rsi
movq %r14, %rdi
movq %r8, %r14
movq %r12, %r15
movq %r9, %r12
callq 0x2370
movq %r12, %r9
movq %r15, %r12
movq 0x18(%rsp), %rsi
movq %r14, %r8
movq %rax, %r14
movq %rbx, %r15
leaq (%r9,%r9,2), %rax
incq %r9
shlq $0x4, %rax
addq %r14, %rax
jmp 0xcb08b
cmpq %rsi, %r12
jne 0xcb07d
leaq (%rsi,%rsi), %rbx
testq %rsi, %rsi
movl $0x2, %eax
cmoveq %rax, %rbx
movq %rbx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq %r8, %rdi
movq %r15, 0x38(%rsp)
movq %r14, %r15
movq %r9, %r14
callq 0x2370
movq %r14, %r9
movq %r15, %r14
movq 0x38(%rsp), %r15
movq %rax, %r8
movq %rbx, %rsi
leaq (%r12,%r12,2), %rax
incq %r12
shlq $0x4, %rax
addq %r8, %rax
movupd (%r13), %xmm0
movupd 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups %xmm2, 0x20(%rax)
movupd %xmm1, 0x10(%rax)
movupd %xmm0, (%rax)
addq $0x30, %r13
decq %rbp
jne 0xcafcf
jmp 0xcb0d2
xorl %r9d, %r9d
xorl %r12d, %r12d
movq 0x50(%rsp), %r8
movq 0x30(%rsp), %r14
movq 0x18(%rsp), %rsi
movq 0x38(%rsp), %r15
cmpl $0x0, 0x24(%rsp)
je 0xcb20b
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x28(%rsp), %rax
movb 0x28(%rax,%r13), %al
testb %al, %al
js 0xcb1f7
cmpb $0x40, %al
jae 0xcb152
cmpq %r15, %r9
jne 0xcb142
leaq (%r15,%r15), %rbx
testq %r15, %r15
movl $0x2, %eax
cmoveq %rax, %rbx
movq %rbx, %rax
shlq $0x4, %rax
movq %rsi, 0x18(%rsp)
leaq (%rax,%rax,2), %rsi
movq %r14, %rdi
movq %r8, %r14
movq %r12, %r15
movq %r9, %r12
callq 0x2370
movq %r12, %r9
movq %r15, %r12
movq 0x18(%rsp), %rsi
movq %r14, %r8
movq %rax, %r14
movq %rbx, %r15
leaq (%r9,%r9,2), %rax
incq %r9
shlq $0x4, %rax
addq %r14, %rax
jmp 0xcb1a4
cmpq %rsi, %r12
jne 0xcb196
leaq (%rsi,%rsi), %rbx
testq %rsi, %rsi
movl $0x2, %eax
cmoveq %rax, %rbx
movq %rbx, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rsi
movq %r8, %rdi
movq %r15, 0x38(%rsp)
movq %r14, %r15
movq %r9, %r14
callq 0x2370
movq %r14, %r9
movq %r15, %r14
movq 0x38(%rsp), %r15
movq %rax, %r8
movq %rbx, %rsi
leaq (%r12,%r12,2), %rax
incq %r12
shlq $0x4, %rax
addq %r8, %rax
movq 0x28(%rsp), %rcx
movupd (%rcx,%r13), %xmm0
movupd 0x10(%rcx,%r13), %xmm1
movups 0x20(%rcx,%r13), %xmm2
movups %xmm2, 0x20(%rax)
movupd %xmm1, 0x10(%rax)
movupd %xmm0, (%rax)
movl 0x14(%rcx,%r13), %edx
movl %edx, 0x8(%rax)
movl 0xc(%rcx,%r13), %edx
movl %edx, (%rax)
movl 0x10(%rcx,%r13), %edx
movl %edx, 0x4(%rax)
movl 0x8(%rcx,%r13), %edx
movl %edx, 0x14(%rax)
movl (%rcx,%r13), %edx
movl %edx, 0xc(%rax)
movl 0x4(%rcx,%r13), %ecx
movl %ecx, 0x10(%rax)
incq %rbp
movl 0x24(%rsp), %eax
addq $0x30, %r13
cmpq %rax, %rbp
jb 0xcb0e2
leaq (%r12,%r9), %rax
cmpq $0x2, %rax
movq %r14, 0x30(%rsp)
movq %r15, 0x38(%rsp)
jb 0xcb36a
movq 0x10(%rsp), %rax
cmpl 0xc(%rsp), %eax
movq 0x68(%rsp), %rbx
movq 0x58(%rsp), %rbp
movq 0x78(%rsp), %rcx
jae 0xcb261
movq 0x70(%rsp), %rdx
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
addq 0x80(%rsp), %rax
subq %rdx, %rcx
orb $-0x80, (%rax)
addq $0x30, %rax
decq %rcx
jne 0xcb255
movq %r12, %r14
movq %rsi, 0x18(%rsp)
movq %r8, %r13
cmpl $0x0, 0x24(%rsp)
je 0xcb293
movl $0x28, %eax
xorl %ecx, %ecx
movq 0x28(%rsp), %rdx
orb $-0x80, (%rdx,%rax)
incq %rcx
movl 0x24(%rsp), %edx
addq $0x30, %rax
cmpq %rdx, %rcx
jb 0xcb27a
movq 0x30(%rsp), %rdi
movl %r9d, %esi
movq 0x60(%rsp), %r12
movq %r12, %rdx
movq %r9, 0x50(%rsp)
callq 0xca846
movsd %xmm0, 0x10(%rsp)
movq %r13, %rdi
movl %r14d, %esi
movq %r12, %rdx
callq 0xca846
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jae 0xcb389
testq %r14, %r14
je 0xcb45f
movl $0x1, %ebp
xorl %r15d, %r15d
movq %r13, %r8
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0xcb31a
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %r13, %r8
movq %rax, 0x10(%rbx)
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movupd (%r8,%rax), %xmm0
movupd 0x10(%r8,%rax), %xmm1
movups 0x20(%r8,%rax), %xmm2
movups %xmm2, 0x20(%rdx,%rcx)
movupd %xmm1, 0x10(%rdx,%rcx)
movupd %xmm0, (%rdx,%rcx)
movl %ebp, %r15d
incl %ebp
cmpq %r15, %r14
ja 0xcb2e5
jmp 0xcb42e
movl 0xc(%rsp), %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
movq 0x68(%rsp), %rbx
movq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
jmp 0xcb448
movq 0x50(%rsp), %r9
testq %r9, %r9
je 0xcb45f
movl $0x1, %ebp
xorl %r14d, %r14d
movq %r13, %r8
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0xcb3dd
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %r9, %r12
callq 0x2370
movq %r12, %r9
movq %r13, %r8
movq %rax, 0x10(%rbx)
leaq (%r14,%r14,2), %rax
shlq $0x4, %rax
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movq 0x30(%rsp), %rsi
movupd (%rsi,%rax), %xmm0
movupd 0x10(%rsi,%rax), %xmm1
movups 0x20(%rsi,%rax), %xmm2
movups %xmm2, 0x20(%rdx,%rcx)
movupd %xmm1, 0x10(%rdx,%rcx)
movupd %xmm0, (%rdx,%rcx)
movl %ebp, %r14d
incl %ebp
cmpq %r14, %r9
ja 0xcb3a2
movl 0xc(%rsp), %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
movq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
movq 0x18(%rsp), %rsi
movq 0x40(%rsp), %r13
movq 0x58(%rsp), %rbp
incl %eax
cmpl %r13d, %eax
jbe 0xcaeff
jmp 0xcb483
movl 0xc(%rsp), %eax
movl %eax, %ecx
movq %rcx, 0x10(%rsp)
movq 0x48(%rsp), %r14
leaq 0x28(%rsp), %r15
movq %r13, %r8
movq 0x18(%rsp), %rsi
movq 0x40(%rsp), %r13
jmp 0xcb452
incl %r14d
cmpq %r14, 0x18(%rbx)
ja 0xcaeab
jmp 0xcb49e
movq $0x0, 0x30(%rsp)
xorl %r8d, %r8d
movq %r8, %r14
movq 0x30(%rsp), %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2220
cmpq $0x0, (%rbx)
je 0xcb50c
xorl %edx, %edx
movl $0x1, %ecx
xorl %eax, %eax
movq 0x10(%rbx), %rsi
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
cmpb $0x0, 0x28(%rsi,%rdx)
js 0xcb501
addq %rsi, %rdx
movl %eax, %edi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
movupd (%rdx), %xmm0
movupd 0x10(%rdx), %xmm1
movups 0x20(%rdx), %xmm2
movups %xmm2, 0x20(%rsi,%rdi)
movupd %xmm1, 0x10(%rsi,%rdi)
movupd %xmm0, (%rsi,%rdi)
incl %eax
movl %ecx, %edx
incl %ecx
cmpq %rdx, (%rbx)
ja 0xcb4c2
jmp 0xcb50e
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, (%rbx)
testl %eax, %eax
je 0xcb5e3
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %r14
xorl %r15d, %r15d
movl $0x2, %r12d
movq 0x10(%rbx), %rdi
cmpb $0x0, 0x28(%rdi,%r15)
js 0xcb5d6
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0xcb565
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %r12, %rcx
movq %rcx, 0x8(%rbx)
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
movupd (%rcx,%r15), %xmm0
movupd 0x10(%rcx,%r15), %xmm1
movups 0x20(%rcx,%r15), %xmm2
movups %xmm2, 0x20(%rcx,%rax)
movupd %xmm1, 0x10(%rcx,%rax)
movupd %xmm0, (%rcx,%rax)
movq 0x10(%rbx), %rdx
movl 0x14(%rdx,%r15), %esi
movl %esi, 0x8(%rcx,%rax)
movl 0xc(%rdx,%r15), %esi
movl %esi, (%rcx,%rax)
movl 0x10(%rdx,%r15), %esi
movl %esi, 0x4(%rcx,%rax)
movl 0x8(%rdx,%r15), %esi
movl %esi, 0x14(%rcx,%rax)
movl (%rdx,%r15), %esi
movl %esi, 0xc(%rcx,%rax)
movl 0x4(%rdx,%r15), %edx
movl %edx, 0x10(%rcx,%rax)
addq $0x30, %r15
cmpq %r15, %r14
jne 0xcb52c
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rax
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl 0x14(%rax), %esi
movq %rbx, %rdi
callq 0xc405a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq