// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %r9, %rbx
movl %r8d, %ebp
movq %rcx, %r14
movl %edx, %r15d
movq %rsi, %r12
movq %rdi, %r13
movq 0xc0(%rdi), %rcx
testq %rsi, %rsi
movq %rcx, 0x10(%rsp)
je 0x10520b
andq $0x0, 0x38(%r12)
movq 0x18(%rcx), %rdi
leaq 0x38(%rsp), %rax
leaq 0x40(%rsp), %r10
leaq 0x34(%rsp), %rcx
leaq 0x50(%rsp), %r8
leaq 0x48(%rsp), %r9
xorl %esi, %esi
movl %r15d, %edx
pushq %r12
pushq $0x1
pushq %rax
pushq %r10
callq 0xc2ebf
movq 0x30(%rsp), %rcx
addq $0x20, %rsp
testq %rbx, %rbx
je 0x105213
andl $0x0, (%rbx)
xorl %eax, %eax
movl %r15d, (%rsp)
movq %r12, 0x18(%rsp)
movl %eax, %eax
testq %r12, %r12
je 0x10523d
cmpq %rax, 0x38(%r12)
jbe 0x10534c
movq %rax, %rdx
movq 0x48(%r12), %rax
movl (%rax,%rdx,4), %eax
jmp 0x10524c
movq %rax, %rdx
movl %r15d, %eax
testq %rdx, %rdx
jne 0x10534c
movq %rdx, 0x20(%rsp)
movq 0x10(%rcx), %r12
shrl %eax
imulq $0x28, %rax, %rcx
movl 0x10(%r12,%rcx), %eax
testl %eax, %eax
je 0x105332
addq %rcx, %r12
xorl %r15d, %r15d
movl %eax, %eax
cmpq %rax, %r15
jae 0x105332
movq 0x18(%r12), %rax
movq (%rax,%r15,8), %rsi
shrq $0x21, %rsi
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x10(%rsp), %rdx
leaq 0xc(%rsp), %rcx
leaq 0x30(%rsp), %r8
leaq 0x14(%rsp), %r9
pushq $0x0
callq 0xf6ab5
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
addq $0x10, %rsp
movl 0xc(%rsp), %eax
movq 0x28(%rsp), %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x1052f1
testq %r14, %r14
je 0x1052d0
movl (%rcx,%rdx,4), %esi
shrl %esi
movb %bpl, (%r14,%rsi)
testq %rbx, %rbx
je 0x1052ec
movq 0x10(%r13), %rsi
movq 0x10(%rsi), %rsi
movl (%rcx,%rdx,4), %edi
shrl %edi
imulq $0x28, %rdi, %rdi
movl 0x10(%rsi,%rdi), %esi
addl %esi, (%rbx)
incq %rdx
jmp 0x1052bd
testq %r14, %r14
sete %cl
movl 0x8(%rsp), %eax
cmpq %r8, %rax
sete %dl
orb %cl, %dl
jne 0x10530b
shrl %eax
movb %bpl, (%r14,%rax)
testq %r14, %r14
sete %cl
movl 0x4(%rsp), %eax
cmpq %r8, %rax
sete %dl
orb %cl, %dl
jne 0x105325
shrl %eax
movb %bpl, (%r14,%rax)
incq %r15
movl 0x10(%r12), %eax
jmp 0x10526e
movq 0x20(%rsp), %rax
incl %eax
movl (%rsp), %r15d
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %rcx
jmp 0x10521e
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq