// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, (%r8)
movl %edi, %ebp
movq 0x60(%rsp), %r8
cmpq $0x0, 0x8(%rbx)
movq %rcx, 0x8(%rsp)
je 0x107f37
movq 0x10(%rbx), %rax
xorl %esi, %esi
jmp 0x107f5c
movq $0x2, 0x8(%rbx)
movq 0x10(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0x2370
movq 0x60(%rsp), %r8
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rbx)
movq (%rbx), %rsi
leaq 0x1(%rsi), %rdx
movq %rdx, (%rbx)
movl %ebp, (%rax,%rsi,4)
testq %r8, %r8
je 0x107f6f
andl $0x0, (%r8)
movl 0x58(%rsp), %esi
movl 0x50(%rsp), %r9d
xorpd %xmm0, %xmm0
movq (%rbx), %rax
testq %rax, %rax
je 0x10807d
leaq -0x1(%rax), %rdx
movq %rdx, (%rbx)
movq 0x10(%rbx), %rdx
movl -0x4(%rdx,%rax,4), %eax
cmpb $0x0, (%r15,%rax)
jne 0x107f7c
movb $0x1, (%r15,%rax)
cmpl %ebp, %eax
je 0x107fb0
movzbl (%r12,%rax), %edx
cmpl %esi, %edx
jne 0x107f7c
movl %ebp, 0x4(%rsp)
xorl %r13d, %r13d
imulq $0x30, %rax, %rbp
movl %r13d, %r13d
movq 0x10(%rcx), %rdx
leaq (%rdx,%rbp), %rax
cmpq %r13, (%rdx,%rbp)
jbe 0x108074
movq 0x10(%rax), %rax
imulq $0x28, %r13, %rdx
cmpb $0x0, 0x18(%rax,%rdx)
js 0x10806c
addq %rdx, %rax
movl 0x8(%rax), %r14d
movzbl (%r12,%r14), %edx
testl %r9d, %edx
je 0x108005
addsd (%rax), %xmm0
testq %r8, %r8
je 0x10806c
movl 0x20(%rax), %eax
addl %eax, (%r8)
jmp 0x10806c
cmpl %esi, %edx
jne 0x10806c
cmpb $0x0, (%r15,%r14)
jne 0x10806c
movq (%rbx), %rdi
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rdi
jne 0x108061
leaq (%rdi,%rdi), %rsi
testq %rdi, %rdi
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
movsd %xmm0, 0x10(%rsp)
callq 0x2370
movl 0x50(%rsp), %r9d
movsd 0x10(%rsp), %xmm0
movl 0x58(%rsp), %esi
movq 0x60(%rsp), %r8
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rbx)
movq (%rbx), %rdi
leaq 0x1(%rdi), %rdx
movq %rdx, (%rbx)
movl %r14d, (%rax,%rdi,4)
incl %r13d
jmp 0x107fbb
movl 0x4(%rsp), %ebp
jmp 0x107f7c
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq