// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: set_b_utg_weight_flag(bubble_type*, buf_t*, unsigned int, unsigned char*, unsigned int, unsigned int*)
void set_b_utg_weight_flag(bubble_type* bub, buf_t* b, uint32_t v, uint8_t* vis_flag, uint32_t flag, uint32_t* occ)
{
    ma_ug_t *bub_ug = bub->b_ug;
    long long nodeLen, baseLen, max_stop_nodeLen, max_stop_baseLen;
    ma_utg_t *u = NULL;
    uint32_t convex, k, k_i, k_j, *a, n, beg, sink;
    if(b)
    {
        b->b.n = 0;
        get_unitig(bub_ug->g, NULL, v, &convex, &nodeLen, &baseLen, &max_stop_nodeLen, 
                                                                    &max_stop_baseLen, 1, b);
    }
    
    if(occ) (*occ) = 0;
    for (k = 0; k < (b?b->b.n:1); k++)
    {
        u = &(bub_ug->u.a[b?(b->b.a[k]>>1):(v>>1)]);
        if(u->n == 0) continue;
        for (k_i = 0; k_i < u->n; k_i++)
        {
            get_bubbles(bub, u->a[k_i]>>33, &beg, &sink, &a, &n, NULL);

            for (k_j = 0; k_j < n; k_j++)
            {
                if(vis_flag) vis_flag[a[k_j]>>1] = flag;
                if(occ) (*occ) += bub->ug->u.a[a[k_j]>>1].n;
            }
            if(beg != (uint32_t)-1 && vis_flag) vis_flag[beg>>1] = flag;
            if(sink != (uint32_t)-1 && vis_flag) vis_flag[sink>>1] = flag;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movl %r8d, %ebp
movq %rcx, %r14
movq %rsi, %r12
movq %rdi, %r13
movq 0xc0(%rdi), %rsi
testq %r12, %r12
movl %edx, 0x4(%rsp)
movq %rsi, 0x8(%rsp)
je 0x14d2bd
movq $0x0, 0x38(%r12)
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
leaq 0x18(%rsp), %rax
leaq 0x20(%rsp), %r10
leaq 0x14(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0x28(%rsp), %r9
xorl %esi, %esi
movl 0x4(%rsp), %edx
pushq %r12
pushq $0x1
pushq %rax
pushq %r10
callq 0x1053a7
movq 0x28(%rsp), %rsi
movl 0x24(%rsp), %edx
addq $0x20, %rsp
testq %rbx, %rbx
je 0x14d2c8
movl $0x0, (%rbx)
xorl %eax, %eax
movl %eax, %eax
testq %r12, %r12
je 0x14d2e6
cmpq %rax, 0x38(%r12)
jbe 0x14d3c3
movq 0x48(%r12), %rcx
movl (%rcx,%rax,4), %ecx
jmp 0x14d2f1
movl %edx, %ecx
testq %rax, %rax
jne 0x14d3c3
movq 0x10(%rsi), %rdx
shrl %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0x10(%rdx,%rcx,8)
je 0x14d3b3
leaq (%rdx,%rcx,8), %rcx
xorl %edx, %edx
movq 0x18(%rcx), %rsi
movq (%rsi,%rdx,8), %rsi
movq 0x28(%r13), %r8
movq 0x40(%r13), %rdi
shrq $0x21, %rsi
movl (%rdi,%rsi,4), %r10d
movl 0x4(%rdi,%rsi,4), %r9d
subl %r10d, %r9d
leal 0x1(%r10), %esi
movl (%r8,%r10,4), %edi
movl (%r8,%rsi,4), %esi
addl $-0x2, %r9d
je 0x14d384
leaq (%r8,%r10,4), %r8
addq $0x8, %r8
movl %r9d, %r9d
xorl %r10d, %r10d
testq %r14, %r14
je 0x14d35c
movl (%r8,%r10,4), %r11d
shrl %r11d
movb %bpl, (%r14,%r11)
testq %rbx, %rbx
je 0x14d37c
movq 0x10(%r13), %r11
movq 0x10(%r11), %r11
movl (%r8,%r10,4), %r15d
shrl %r15d
leaq (%r15,%r15,4), %r15
movl 0x10(%r11,%r15,8), %r11d
addl %r11d, (%rbx)
incq %r10
cmpq %r10, %r9
jne 0x14d34c
testq %r14, %r14
je 0x14d394
cmpl $-0x1, %edi
je 0x14d394
shrl %edi
movb %bpl, (%r14,%rdi)
testq %r14, %r14
je 0x14d3a4
cmpl $-0x1, %esi
je 0x14d3a4
shrl %esi
movb %bpl, (%r14,%rsi)
incq %rdx
movl 0x10(%rcx), %esi
cmpq %rsi, %rdx
jb 0x14d30c
incl %eax
movl 0x4(%rsp), %edx
movq 0x8(%rsp), %rsi
jmp 0x14d2ca
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq