// File: /workspace/github_cpp_makefile_star2_O3/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 0x13df01
movl (%r13), %eax
testq %rax, %rax
je 0xf7bde
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 0xf7bd6
leaq (%rsi,%rdi,8), %rsi
movl 0x10(%rsi), %edi
testl %edi, %edi
je 0xf7bd6
xorl %r8d, %r8d
movq 0x18(%rsi), %r9
movq (%r9,%r8,8), %r9
shrq $0x21, %r9
movq 0x20(%r15), %r10
cmpl $0x0, (%r10,%r9,8)
js 0xf7bcb
movb %bl, (%r14,%r9)
movl 0x10(%rsi), %edi
incq %r8
movl %edi, %r9d
cmpq %r9, %r8
jb 0xf7bad
incq %rdx
cmpq %rax, %rdx
jne 0xf7b8a
movl 0xc(%rsp), %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rcx
je 0xf7c33
shrl %ecx
movq 0x10(%r12), %rdx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0xc(%rdx,%rcx,8)
je 0xf7c33
leaq (%rdx,%rcx,8), %rcx
movl 0x10(%rcx), %edx
testl %edx, %edx
je 0xf7c33
xorl %esi, %esi
movq 0x18(%rcx), %rdi
movq (%rdi,%rsi,8), %rdi
shrq $0x21, %rdi
movq 0x20(%r15), %r8
cmpl $0x0, (%r8,%rdi,8)
js 0xf7c29
movb %bl, (%r14,%rdi)
movl 0x10(%rcx), %edx
incq %rsi
movl %edx, %edi
cmpq %rdi, %rsi
jb 0xf7c0b
movl 0x8(%rsp), %ecx
cmpq %rax, %rcx
je 0xf7c82
shrl %ecx
movq 0x10(%r12), %rax
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xf7c82
leaq (%rax,%rcx,8), %rax
movl 0x10(%rax), %ecx
testl %ecx, %ecx
je 0xf7c82
xorl %edx, %edx
movq 0x18(%rax), %rsi
movq (%rsi,%rdx,8), %rsi
shrq $0x21, %rsi
movq 0x20(%r15), %rdi
cmpl $0x0, (%rdi,%rsi,8)
js 0xf7c78
movb %bl, (%r14,%rsi)
movl 0x10(%rax), %ecx
incq %rdx
movl %ecx, %esi
cmpq %rsi, %rdx
jb 0xf7c5b
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq