// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: dfs_weight(unsigned int, unsigned char*, unsigned char*, hc_links*, kvec_t_u32_warp*, kvec_t_u32_warp*, unsigned int, unsigned int, unsigned int*)
double dfs_weight(uint32_t v, uint8_t* vis_flag, uint8_t* is_vis, hc_links* link, 
kvec_t_u32_warp* stack, kvec_t_u32_warp* result, uint32_t e_flag, uint32_t ava_flag,
uint32_t* link_occ)
{
    uint32_t cur, i, next = (uint32_t)-1;
    stack->a.n = 0;
    kv_push(uint32_t, stack->a, v);
    double w = 0;
    if(link_occ) (*link_occ) = 0;
    while (stack->a.n > 0)
    {
        stack->a.n--;
        cur = stack->a.a[stack->a.n];
        if(is_vis[cur]) continue;
        is_vis[cur] = 1;
        if(cur!=v && vis_flag[cur] != ava_flag) continue;
        for (i = 0; i < link->a.a[cur].e.n; i++)
        {
            if(link->a.a[cur].e.a[i].del) continue;
            next = link->a.a[cur].e.a[i].uID;
            ///if(vis_flag[next] == e_flag)
            if(vis_flag[next]&e_flag)
            {
                w += link->a.a[cur].e.a[i].weight;
                if(link_occ) (*link_occ) += link->a.a[cur].e.a[i].occ;
                continue;
            }
            if(is_vis[next]) continue;
            if(vis_flag[next] != ava_flag) continue;
            kv_push(uint32_t, stack->a, next);
        }
    }
    return w;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %rbx
movq %rdx, %r15
movq %rsi, %r12
movl %edi, %ebp
movq 0x60(%rsp), %r8
movq $0x0, (%rbx)
cmpq $0x0, 0x8(%rbx)
je 0x150260
movq 0x10(%rbx), %rax
xorl %edx, %edx
jmp 0x150289
movq $0x2, 0x8(%rbx)
movq 0x10(%rbx), %rdi
movl $0x8, %esi
movq %rcx, %r14
movq %r8, %r13
callq 0x2370
movq %r13, %r8
movq %r14, %rcx
movq %rax, 0x10(%rbx)
movq (%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbx)
movl %ebp, (%rax,%rdx,4)
testq %r8, %r8
je 0x15029f
movl $0x0, (%r8)
testq %rsi, %rsi
je 0x1503e4
movl 0x58(%rsp), %r9d
movl 0x50(%rsp), %r10d
xorpd %xmm0, %xmm0
movl $0x2, %r11d
leaq -0x1(%rsi), %rdx
movq %rdx, (%rbx)
movq 0x10(%rbx), %rax
movl -0x4(%rax,%rsi,4), %eax
cmpb $0x0, (%r15,%rax)
jne 0x1502e8
movb $0x1, (%r15,%rax)
cmpl %ebp, %eax
je 0x1502f5
movzbl (%r12,%rax), %edx
cmpl %r9d, %edx
je 0x1502f5
movq (%rbx), %rdx
movq %rdx, %rsi
testq %rdx, %rdx
jne 0x1502bc
jmp 0x1503e8
movl %ebp, 0x4(%rsp)
movq 0x10(%rcx), %rdi
leaq (%rax,%rax,2), %r13
shlq $0x4, %r13
cmpq $0x0, (%rdi,%r13)
je 0x1503d2
movl $0x1, %r14d
xorl %eax, %eax
movq %rcx, 0x8(%rsp)
movq 0x10(%rdi,%r13), %rdx
leaq (%rax,%rax,4), %rax
cmpb $0x0, 0x18(%rdx,%rax,8)
js 0x1503c2
leaq (%rdx,%rax,8), %rax
movl 0x8(%rax), %ebp
movzbl (%r12,%rbp), %edx
testl %r10d, %edx
je 0x150353
addsd (%rax), %xmm0
testq %r8, %r8
je 0x1503c2
movl 0x20(%rax), %eax
addl %eax, (%r8)
jmp 0x1503c2
cmpl %r9d, %edx
jne 0x1503c2
cmpb $0x0, (%r15,%rbp)
jne 0x1503c2
movq (%rbx), %rdx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rdx
jne 0x1503b8
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
cmoveq %r11, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x2370
movl $0x2, %r11d
movl 0x50(%rsp), %r10d
movl 0x58(%rsp), %r9d
movsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %r8
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rbx)
movq (%rbx), %rdx
movq 0x10(%rcx), %rdi
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbx)
movl %ebp, (%rax,%rdx,4)
movl %r14d, %eax
incl %r14d
cmpq %rax, (%rdi,%r13)
ja 0x15031d
movq (%rbx), %rsi
testq %rsi, %rsi
movl 0x4(%rsp), %ebp
jne 0x1502bc
jmp 0x1503e8
xorpd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq