// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: update_ug_by_trans(asg_t*, kv_u_trans_t*)
void update_ug_by_trans(asg_t *sg, kv_u_trans_t *ta)
{
    u_trans_t *a = NULL, *p = NULL;
    uint32_t i, k, st, occ, n, m;
    uint32_t qn, tn, qs, qe, ts, te, rev;
    asg_arc_t t, *e = NULL;
    long long r_qs, r_qe, r_ts, r_te;
    int r;

    for (k = occ = 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)
            {
                for (m = st, p = &(a[st]); m < i; m++)
                {
                    if(a[m].nw > p->nw) p = &(a[m]);
                }

                if(p->f == RC_2)///dis-connected
                {
                    rev = p->rev;
                    qn = p->qn; 
                    qs = p->qs; 
                    qe = p->qe - 1;
                    if(rev)
                    {
                        tn = p->tn;
                        ts = sg->seq[tn].len - (p->te - 1) - 1;
                        te = sg->seq[tn].len - p->ts - 1;
                    }
                    else
                    {
                        tn = p->tn; 
                        ts = p->ts; 
                        te = p->te - 1;
                    }

                    classify_hap_overlap(qs, qe, sg->seq[qn].len, ts, te, sg->seq[tn].len, 
                                                                            &r_qs, &r_qe, &r_ts, &r_te);
                    
                    qs = r_qs; qe = r_qe + 1;
                    if(rev)
                    {
                        ts = sg->seq[tn].len - r_te - 1;
                        te = sg->seq[tn].len - r_ts - 1 + 1;
                    }
                    else
                    {
                        ts = r_ts; te = r_te + 1;
                    }

                    r = get_trans_ug_arch(qn, qs, qe, sg->seq[qn].len, 
                                        tn, ts, te, sg->seq[tn].len, rev, &t);
                    if(r >= 0)
                    {
                        e = asg_arc_pushp(sg);
                        *e = t;
                        occ++;
                    }
                }
                st = i;
            }
        }
    }

    if(occ > 0)
    {
        free(sg->idx);
        sg->idx = 0;
        sg->is_srt = 0;
        asg_cleanup(sg);
    }
    asg_arc_del_trans(sg, asm_opt.gap_fuzz);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
cmpq $0x0, 0x18(%rsi)
je 0x13d803
xorl %ecx, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl $0x0, 0x4(%rsp)
movq %rsi, 0x20(%rsp)
movq 0x28(%rsi), %rax
movq %rcx, 0x28(%rsp)
movq (%rax,%rcx,8), %r9
testl %r9d, %r9d
je 0x13d7c9
movq %r9, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %rbp
shlq $0x4, %rbp
addq 0x10(%rsi), %rbp
xorl %eax, %eax
movl $0x1, %r14d
movq %r9, 0x8(%rsp)
movl %r14d, %ecx
movl %eax, %esi
cmpl %r9d, %r14d
je 0x13d5db
leaq (%rcx,%rcx,2), %rdx
shlq $0x4, %rdx
movl 0x14(%rbp,%rdx), %edx
leaq (%rsi,%rsi,2), %rdi
shlq $0x4, %rdi
cmpl 0x14(%rbp,%rdi), %edx
je 0x13d7bd
leaq (%rsi,%rsi,2), %rdx
shlq $0x4, %rdx
addq %rbp, %rdx
cmpl %r14d, %eax
jae 0x13d619
leaq (%rsi,%rsi,2), %rdi
shlq $0x4, %rdi
addq %rbp, %rdi
subq %rsi, %rcx
movsd 0x20(%rdi), %xmm0
ucomisd 0x20(%rdx), %xmm0
movq %rdi, %rax
ja 0x13d60b
movq %rdx, %rax
addq $0x30, %rdi
movq %rax, %rdx
decq %rcx
jne 0x13d5f9
jmp 0x13d61c
movq %rdx, %rax
movzbl 0x28(%rax), %r13d
movl %r13d, %ecx
andb $0x3f, %cl
cmpb $0x2, %cl
jne 0x13d654
shrl $0x6, %r13d
movl 0x14(%rax), %r15d
andl $0x1, %r13d
je 0x13d65c
movq 0x20(%rbx), %rcx
movl (%rcx,%r15,8), %ecx
andl %r8d, %ecx
movl 0xc(%rax), %r8d
notl %r8d
addl %ecx, %r8d
subl 0x10(%rax), %ecx
jmp 0x13d666
movl %r14d, %eax
jmp 0x13d7bd
movl 0xc(%rax), %ecx
movl 0x10(%rax), %r8d
decl %r8d
movl 0x8(%rax), %r12d
movl (%rax), %edi
movl 0x4(%rax), %eax
decl %eax
movl %eax, %esi
movq 0x20(%rbx), %rax
movl (%rax,%r12,8), %edx
movl $0x7fffffff, %r10d      # imm = 0x7FFFFFFF
andq %r10, %rdx
movl %ecx, %ecx
movl %r8d, %r8d
movl (%rax,%r15,8), %r9d
andq %r10, %r9
leaq 0x10(%rsp), %rax
pushq %rax
leaq 0x20(%rsp), %rax
pushq %rax
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x50(%rsp), %rax
pushq %rax
callq 0x105f44
addq $0x20, %rsp
testb %r13b, %r13b
je 0x13d6d8
movq 0x20(%rbx), %rax
movl (%rax,%r15,8), %eax
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %eax
movl 0x10(%rsp), %r9d
notl %r9d
addl %eax, %r9d
subl 0x18(%rsp), %eax
jmp 0x13d6e9
movl 0x18(%rsp), %r9d
movl 0x10(%rsp), %eax
incl %eax
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movl 0x30(%rsp), %edx
incl %edx
movl 0x38(%rsp), %esi
movq 0x20(%rbx), %rdi
movl (%rdi,%r12,8), %ecx
andl %r8d, %ecx
movl (%rdi,%r15,8), %r10d
andl %r8d, %r10d
movl %r12d, %edi
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl %r15d, %r8d
leaq 0x40(%rsp), %r11
pushq %r11
pushq %r13
pushq %r10
pushq %rax
callq 0x13d427
addq $0x20, %rsp
testl %eax, %eax
js 0x13d7af
movl 0x4(%rbx), %ecx
andl %r12d, %ecx
movl (%rbx), %eax
cmpl %eax, %ecx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
jne 0x13d76a
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%rbx)
movq 0x8(%rbx), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq %rax, 0x8(%rbx)
movq 0x8(%rbx), %rax
movl 0x4(%rbx), %ecx
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leal 0x1(%rcx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %esi, %ecx
movl %ecx, 0x4(%rbx)
leaq (%rdx,%rdx,2), %rcx
movq 0x50(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movupd 0x40(%rsp), %xmm0
movupd %xmm0, (%rax,%rcx,8)
incl 0x4(%rsp)
movl %r14d, %eax
jmp 0x13d7b8
movl %r14d, %eax
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
movq 0x8(%rsp), %r9
incl %r14d
cmpl %r9d, %r14d
jbe 0x13d5b3
movq 0x28(%rsp), %rcx
incl %ecx
movq 0x20(%rsp), %rsi
cmpq %rcx, 0x18(%rsi)
ja 0x13d57d
cmpl $0x0, 0x4(%rsp)
je 0x13d803
movq 0x28(%rbx), %rdi
callq 0x2220
movq $0x0, 0x28(%rbx)
andb $0x7f, 0x7(%rbx)
movq %rbx, %rdi
callq 0xa02fa
leaq 0x14cf4e(%rip), %rax    # 0x28a758
movl 0x110(%rax), %esi
movq %rbx, %rdi
callq 0xa8c8f
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq