// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: set_rtg_flag_by_bubble(bubble_type*, ma_ug_t*, asg_t*, unsigned int, unsigned char*, unsigned int)
void set_rtg_flag_by_bubble(bubble_type* bub, ma_ug_t* ug, asg_t *r_g, uint32_t v, uint8_t* vis_flag, 
uint32_t flag)
{
    uint32_t beg, sink, *a = NULL, n, i, k, uId, rId;
    ma_utg_t* nsu = NULL;
    get_bubbles(bub, v, &beg, &sink, &a, &n, NULL);
    for (i = 0; i < n; i++)
    {
        uId = a[i]>>1;

        nsu = &(ug->u.a[uId]);
        if(nsu->m > 0)
        {
            for (k = 0; k < nsu->n; k++)
            {
                rId = nsu->a[k]>>33;
                if(r_g->seq[rId].del) continue;
                vis_flag[rId] = flag;
            }
        }
    } 

    if(beg != (uint32_t)-1)
    {
        uId = beg>>1;

        nsu = &(ug->u.a[uId]);
        if(nsu->m > 0)
        {
            for (k = 0; k < nsu->n; k++)
            {
                rId = nsu->a[k]>>33;
                if(r_g->seq[rId].del) continue;
                vis_flag[rId] = flag;
            }
        }
    }
    
    if(sink != (uint32_t)-1)
    {
        uId = sink>>1;

        nsu = &(ug->u.a[uId]);
        if(nsu->m > 0)
        {
            for (k = 0; k < nsu->n; k++)
            {
                rId = nsu->a[k]>>33;
                if(r_g->seq[rId].del) continue;
                vis_flag[rId] = flag;
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %r9d, %ebx
movq %r8, %r14
movq %rdx, %r15
movq %rsi, %r12
xorl %eax, %eax
leaq 0x10(%rsp), %r8
movq %rax, (%r8)
movl %ecx, %esi
movq %rax, (%rsp)
leaq 0xc(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0x1c(%rsp), %r13
movq %r13, %r9
callq 0x13812e
movl (%r13), %eax
testq %rax, %rax
je 0xf4e85
movq 0x10(%rsp), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %edi
shrl %edi
movq 0x10(%r12), %rsi
leaq (%rdi,%rdi,4), %rdi
cmpl $0x0, 0xc(%rsi,%rdi,8)
je 0xf4e7d
leaq (%rsi,%rdi,8), %rsi
cmpl $0x0, 0x10(%rsi)
je 0xf4e7d
xorl %edi, %edi
movq 0x18(%rsi), %r8
movq (%r8,%rdi,8), %r8
shrq $0x21, %r8
movq 0x20(%r15), %r9
cmpl $0x0, (%r9,%r8,8)
js 0xf4e71
movb %bl, (%r14,%r8)
incq %rdi
movl 0x10(%rsi), %r8d
cmpq %r8, %rdi
jb 0xf4e56
incq %rdx
cmpq %rax, %rdx
jne 0xf4e35
movl 0xc(%rsp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rcx
je 0xf4ed6
shrl %ecx
movq 0x10(%r12), %rdx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0xc(%rdx,%rcx,8)
je 0xf4ed6
leaq (%rdx,%rcx,8), %rcx
cmpl $0x0, 0x10(%rcx)
je 0xf4ed6
xorl %edx, %edx
movq 0x18(%rcx), %rsi
movq (%rsi,%rdx,8), %rsi
shrq $0x21, %rsi
movq 0x20(%r15), %rdi
cmpl $0x0, (%rdi,%rsi,8)
js 0xf4ecb
movb %bl, (%r14,%rsi)
incq %rdx
movl 0x10(%rcx), %esi
cmpq %rsi, %rdx
jb 0xf4eb1
movl 0x8(%rsp), %ecx
cmpq %rax, %rcx
je 0xf4f22
shrl %ecx
movq 0x10(%r12), %rax
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xf4f22
leaq (%rax,%rcx,8), %rax
cmpl $0x0, 0x10(%rax)
je 0xf4f22
xorl %ecx, %ecx
movq 0x18(%rax), %rdx
movq (%rdx,%rcx,8), %rdx
shrq $0x21, %rdx
movq 0x20(%r15), %rsi
cmpl $0x0, (%rsi,%rdx,8)
js 0xf4f17
movb %bl, (%r14,%rdx)
incq %rcx
movl 0x10(%rax), %edx
cmpq %rdx, %rcx
jb 0xf4efd
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq