// File: 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
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x38(%rbp)
movq $0x0, -0x60(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1e060e
movq -0x10(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %esi
leaq -0x64(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x48(%rbp), %r9
leaq -0x50(%rbp), %r11
leaq -0x58(%rbp), %r10
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl $0x1, 0x10(%rsp)
movq %rax, 0x18(%rsp)
callq 0x166c30
cmpq $0x0, -0x30(%rbp)
je 0x1e061f
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1e0648
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x98(%rbp)
jmp 0x1e0656
movl $0x1, %eax
movq %rax, -0x98(%rbp)
jmp 0x1e0656
movq -0x90(%rbp), %rax
movq -0x98(%rbp), %rcx
cmpq %rcx, %rax
jae 0x1e07f5
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1e069b
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movl -0x68(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
movl %eax, -0xa4(%rbp)
jmp 0x1e06a6
movl -0x14(%rbp), %eax
shrl %eax
movl %eax, -0xa4(%rbp)
movq -0xa0(%rbp), %rax
movl -0xa4(%rbp), %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1e06cf
jmp 0x1e07e7
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x60(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x1e07e5
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x6c(%rbp), %ecx
movq (%rax,%rcx,8), %rsi
shrq $0x21, %rsi
leaq -0x80(%rbp), %rdx
leaq -0x84(%rbp), %rcx
leaq -0x78(%rbp), %r8
leaq -0x7c(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x1c4b20
movl $0x0, -0x70(%rbp)
movl -0x70(%rbp), %eax
cmpl -0x7c(%rbp), %eax
jae 0x1e078f
cmpq $0x0, -0x20(%rbp)
je 0x1e074f
movl -0x24(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movq -0x78(%rbp), %rcx
movl -0x70(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
shrl %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
cmpq $0x0, -0x30(%rbp)
je 0x1e0782
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movq -0x78(%rbp), %rcx
movl -0x70(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x1e0784
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x1e0726
cmpl $-0x1, -0x80(%rbp)
je 0x1e07af
cmpq $0x0, -0x20(%rbp)
je 0x1e07af
movl -0x24(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x80(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
cmpl $-0x1, -0x84(%rbp)
je 0x1e07d5
cmpq $0x0, -0x20(%rbp)
je 0x1e07d5
movl -0x24(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movl -0x84(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movb %dl, (%rax,%rcx)
jmp 0x1e07d7
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1e06d6
jmp 0x1e07e7
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x1e0626
addq $0xd0, %rsp
popq %rbp
retq
nop