// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/gfa_ut.cpp
// Function: renew_ul_vec_t(ul_vec_t*, ma_ug_t*)
void renew_ul_vec_t(ul_vec_t *x, ma_ug_t *ug)
{
    if(x->bb.n <= 0) return;
    int64_t l, k, z, bn = x->bb.n, dd; int64_t qs = x->bb.a[0].qs, qe;
    for (l = 0, k = 1, qs = 0; k <= bn; k++) {
        if(k == bn || x->bb.a[k].pidx == (uint32_t)-1) {
            if(k - l > 0) {
                for (z = k - 1, dd = 0; z >= l; z--) {
                    if(z > l) {
                        assert(x->bb.a[z].pidx == z-1);
                        dd += x->bb.a[z].pdis;
                    } else {
                        assert(x->bb.a[z].pidx == (uint32_t)-1);
                        dd += ug->g->seq[x->bb.a[z].hid].len;
                    }
                    dd -= (int64_t)(ug->g->seq[x->bb.a[z].hid].len - (x->bb.a[z].te - x->bb.a[z].ts));
                }
                if(dd < 0) dd = 0;
                qe = qs + dd; 
                if(k < bn) {
                    dd = qe + (int64_t)(x->bb.a[k].qs) - (int64_t)(x->bb.a[k-1].qe);
                    if(dd < 0) dd = 0;
                }
                for (z = k - 1; z >= l; z--) {
                    qs = qe - (int64_t)(x->bb.a[z].te - x->bb.a[z].ts);
                    if(qs < 0) qs = 0;
                    x->bb.a[z].qs = qs; x->bb.a[z].qe = qe; 
                    if(z > l) {
                        qe += (int64_t)(ug->g->seq[x->bb.a[z].hid].len - (x->bb.a[z].te - x->bb.a[z].ts));
                        qe -= (int64_t)(x->bb.a[z].pdis);
                        if(qe < 0) qe = 0;
                    }
                }

                if(k < bn) qs = dd;
            }
            l = k;
        }
    }
    x->rlen = x->bb.a[bn-1].qe;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x20(%rdi), %rbx
testq %rbx, %rbx
je 0x209838
jle 0x209829
movl $0x1, %r9d
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
xorl %ecx, %ecx
xorl %r11d, %r11d
movq %rdi, 0x10(%rsp)
movq %rbx, 0x8(%rsp)
cmpq %rbx, %r9
je 0x2096aa
movq 0x30(%rdi), %rax
leaq (%r9,%r9,8), %r10
cmpl $-0x1, 0x14(%rax,%r10,4)
jne 0x209815
cmpq %r11, %r9
jle 0x209812
leaq -0x1(%r9), %rbx
movq 0x30(%rdi), %r15
xorl %r14d, %r14d
movq %rbx, %r12
leaq (%r12,%r12,8), %r13
leaq (%r15,%r13,4), %rbp
movl 0x14(%rbp), %eax
cmpq %r11, %r12
jle 0x2096f5
leaq -0x1(%r12), %r10
cmpq %rax, %r10
jne 0x209847
movl (%rbp), %edi
movl 0x18(%rbp), %eax
movq 0x18(%rsi), %rbp
movq 0x20(%rbp), %rbp
movl (%rbp,%rdi,8), %ebp
andl %edx, %ebp
jmp 0x209715
cmpl $-0x1, %eax
jne 0x209866
movq 0x18(%rsi), %rax
movq 0x20(%rax), %rax
movl (%rbp), %edi
movl (%rax,%rdi,8), %ebp
andl %edx, %ebp
leaq -0x1(%r12), %r10
movl %ebp, %eax
movl %eax, %eax
subl 0x10(%r15,%r13,4), %ebp
addl 0xc(%r15,%r13,4), %ebp
addq %rax, %r14
subq %rbp, %r14
cmpq %r11, %r12
movq %r10, %r12
jg 0x2096c1
testq %r14, %r14
movl $0x0, %r12d
cmovleq %r12, %r14
addq %r14, %rcx
cmpq 0x8(%rsp), %r9
movq 0x10(%rsp), %r10
jge 0x20976d
movq 0x30(%r10), %rax
leaq (%r9,%r9,8), %rdi
movl 0x4(%rax,%rdi,4), %r14d
addq %rcx, %r14
leaq (%rbx,%rbx,8), %rdi
movl 0x8(%rax,%rdi,4), %eax
subq %rax, %r14
testq %r14, %r14
cmovleq %r12, %r14
movq 0x30(%r10), %r15
leaq (%rbx,%rbx,8), %rax
movl 0xc(%r15,%rax,4), %ebp
movl 0x10(%r15,%rax,4), %r13d
movl %r13d, %edi
subl %ebp, %edi
movq %rcx, %r10
subq %rdi, %r10
testq %r10, %r10
cmovleq %r12, %r10
movl %r10d, 0x4(%r15,%rax,4)
movl %ecx, 0x8(%r15,%rax,4)
cmpq %r11, %rbx
jle 0x2097f9
movq 0x18(%rsi), %rax
movq 0x20(%rax), %r12
addq %r8, %r15
subl %r13d, %ebp
movl (%r15), %eax
movl (%r12,%rax,8), %eax
andl %edx, %eax
addl %ebp, %eax
movl 0x18(%r15), %edi
subq %rdi, %rcx
addq %rax, %rcx
testq %rcx, %rcx
jg 0x2097ca
xorl %ecx, %ecx
movl -0x18(%r15), %ebp
movl -0x14(%r15), %r13d
movl %r13d, %eax
subl %ebp, %eax
movq %rcx, %r10
subq %rax, %r10
testq %r10, %r10
jg 0x2097e5
xorl %r10d, %r10d
decq %rbx
movl %r10d, -0x20(%r15)
movl %ecx, -0x1c(%r15)
addq $-0x24, %r15
cmpq %r11, %rbx
jg 0x2097ab
movq 0x8(%rsp), %rbx
cmpq %rbx, %r9
cmovlq %r14, %r10
movq %r9, %r11
movq %r10, %rcx
movq 0x10(%rsp), %rdi
jmp 0x209815
movq %r9, %r11
leaq 0x1(%r9), %rax
addq $0x24, %r8
cmpq %rbx, %r9
movq %rax, %r9
jne 0x209691
movq 0x30(%rdi), %rax
leaq (%rbx,%rbx,8), %rcx
movl -0x1c(%rax,%rcx,4), %eax
movl %eax, 0x18(%rdi)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3e225(%rip), %rdi     # 0x247a73
leaq 0x3bdb4(%rip), %rsi     # 0x245609
leaq 0x3e22e(%rip), %rcx     # 0x247a8a
movl $0x1e1d, %edx           # imm = 0x1E1D
callq 0x2110
leaq 0x3e248(%rip), %rdi     # 0x247ab5
leaq 0x3bd95(%rip), %rsi     # 0x245609
leaq 0x3e20f(%rip), %rcx     # 0x247a8a
movl $0x1e20, %edx           # imm = 0x1E20
callq 0x2110