// File: /workspace/github_cpp_makefile_star2_O1/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), %r8
testq %r8, %r8
je 0x1fe133
jle 0x1fe124
movl $0x1, %r9d
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
xorl %r11d, %r11d
xorl %r10d, %r10d
movq %r8, 0x8(%rsp)
cmpq %r8, %r9
je 0x1fdfc0
movq 0x30(%rdi), %rcx
leaq (%r9,%r9,8), %rbx
cmpl $-0x1, 0x14(%rcx,%rbx,4)
jne 0x1fe110
cmpq %r10, %r9
jle 0x1fe10d
leaq -0x1(%r9), %r8
movq 0x30(%rdi), %r14
movq %r12, 0x10(%rsp)
movq %r9, %rbp
xorl %ebx, %ebx
leaq -0x1(%rbp), %r13
movl 0x14(%r14,%r12), %ecx
cmpq %r10, %r13
jle 0x1fdffd
addq $-0x2, %rbp
cmpq %rcx, %rbp
jne 0x1fe142
movl 0x18(%r14,%r12), %ecx
jmp 0x1fe017
cmpl $-0x1, %ecx
jne 0x1fe161
movq 0x18(%rsi), %rcx
movq 0x20(%rcx), %rcx
movl (%r14,%r12), %ebp
movl (%rcx,%rbp,8), %ecx
andl %edx, %ecx
movl %ecx, %ecx
addq %rcx, %rbx
movq 0x18(%rsi), %rcx
movq 0x20(%rcx), %rcx
movq 0x30(%rdi), %rbp
movl (%rbp,%r12), %r15d
movl (%rcx,%r15,8), %ecx
andl %edx, %ecx
subl 0x10(%rbp,%r12), %ecx
addl 0xc(%rbp,%r12), %ecx
subq %rcx, %rbx
addq $-0x24, %r12
movq %r13, %rbp
cmpq %r10, %r13
jg 0x1fdfdb
testq %rbx, %rbx
movl $0x0, %eax
cmovleq %rax, %rbx
leaq (%rbx,%r11), %r14
cmpq 0x8(%rsp), %r9
jge 0x1fe08a
movq 0x30(%rdi), %rcx
leaq (%r9,%r9,8), %rbx
movl 0x4(%rcx,%rbx,4), %ebx
addq %r14, %rbx
leaq (%r8,%r8,8), %r15
movl 0x8(%rcx,%r15,4), %ecx
subq %rcx, %rbx
testq %rbx, %rbx
movl $0x0, %eax
cmovleq %rax, %rbx
cmpq %r10, %r9
jle 0x1fe0f7
movq 0x30(%rdi), %r15
addq 0x10(%rsp), %r15
movq %r9, %r12
movl 0xc(%r15), %r13d
movl 0x10(%r15), %ebp
movl %ebp, %ecx
subl %r13d, %ecx
movq %r14, %r11
subq %rcx, %r11
testq %r11, %r11
jg 0x1fe0b6
xorl %r11d, %r11d
decq %r12
movl %r11d, 0x4(%r15)
movl %r14d, 0x8(%r15)
cmpq %r10, %r12
jle 0x1fe0ee
movq 0x18(%rsi), %rcx
movq 0x20(%rcx), %rcx
movl (%r15), %eax
movl 0x18(%r15), %r8d
movl (%rcx,%rax,8), %eax
andl %edx, %eax
subl %ebp, %r13d
addl %eax, %r13d
subq %r8, %r14
addq %r13, %r14
testq %r14, %r14
jg 0x1fe0ee
xorl %r14d, %r14d
addq $-0x24, %r15
cmpq %r10, %r12
jg 0x1fe09b
movq 0x8(%rsp), %r8
cmpq %r8, %r9
cmovlq %rbx, %r11
movq %r9, %r10
movq 0x10(%rsp), %r12
jmp 0x1fe110
movq %r9, %r10
leaq 0x1(%r9), %rax
addq $0x24, %r12
cmpq %r8, %r9
movq %rax, %r9
jne 0x1fdfa8
movq 0x30(%rdi), %rax
leaq (%r8,%r8,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 0x3d646(%rip), %rdi     # 0x23b78f
leaq 0x3b1d5(%rip), %rsi     # 0x239325
leaq 0x3d64f(%rip), %rcx     # 0x23b7a6
movl $0x1e1d, %edx           # imm = 0x1E1D
callq 0x2110
leaq 0x3d669(%rip), %rdi     # 0x23b7d1
leaq 0x3b1b6(%rip), %rsi     # 0x239325
leaq 0x3d630(%rip), %rcx     # 0x23b7a6
movl $0x1e20, %edx           # imm = 0x1E20
callq 0x2110