// File: 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 %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdx
leaq -0x34(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x44(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x1c4b20
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x154c86
movq -0x40(%rbp), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x50(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jbe 0x154c76
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x154c74
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x154c5a
jmp 0x154c69
movl -0x2c(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x154c20
jmp 0x154c76
jmp 0x154c78
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x154bde
cmpl $-0x1, -0x30(%rbp)
je 0x154d17
movl -0x30(%rbp), %eax
shrl %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x50(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jbe 0x154d15
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x154d13
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x154cf9
jmp 0x154d08
movl -0x2c(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x154cbf
jmp 0x154d15
jmp 0x154d17
cmpl $-0x1, -0x34(%rbp)
je 0x154da8
movl -0x34(%rbp), %eax
shrl %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x50(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jbe 0x154da6
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x154da4
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x154d8a
jmp 0x154d99
movl -0x2c(%rbp), %eax
movb %al, %dl
movq -0x28(%rbp), %rax
movl -0x54(%rbp), %ecx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x154d50
jmp 0x154da6
jmp 0x154da8
addq $0x70, %rsp
popq %rbp
retq
nop