// File: /workspace/github_cpp_makefile_star2_O1/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), %rdi
movq $0x0, (%r8)
cmpq $0x0, 0x8(%r8)
jne 0x149d1f
movq $0x2, 0x8(%rbx)
movq %rdi, %r13
movq 0x10(%rbx), %rdi
movl $0x8, %esi
movq %rcx, %r14
callq 0x2370
movq %r13, %rdi
movq %r14, %rcx
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movl %ebp, (%rsi,%rax,4)
testq %rdi, %rdi
je 0x149d3b
movl $0x0, (%rdi)
movq (%rbx), %rax
testq %rax, %rax
je 0x149e7f
movl 0x58(%rsp), %r8d
movl 0x50(%rsp), %r9d
xorpd %xmm0, %xmm0
movl $0x2, %r10d
leaq -0x1(%rax), %rdx
movq %rdx, (%rbx)
movq 0x10(%rbx), %rdx
movl -0x4(%rdx,%rax,4), %edx
cmpb $0x0, (%r15,%rdx)
jne 0x149d84
movb $0x1, (%r15,%rdx)
cmpl %ebp, %edx
je 0x149d91
movzbl (%r12,%rdx), %eax
cmpl %r8d, %eax
je 0x149d91
movq (%rbx), %rax
testq %rax, %rax
jne 0x149d5b
jmp 0x149e83
movl %ebp, 0x4(%rsp)
movq 0x10(%rcx), %rax
leaq (%rdx,%rdx,2), %r13
shlq $0x4, %r13
cmpq $0x0, (%rax,%r13)
je 0x149e6d
movl $0x1, %ebp
xorl %edx, %edx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax,%r13), %rax
leaq (%rdx,%rdx,4), %rdx
cmpb $0x0, 0x18(%rax,%rdx,8)
js 0x149e5b
leaq (%rax,%rdx,8), %rax
movl 0x8(%rax), %r14d
movzbl (%r12,%r14), %edx
testl %r9d, %edx
je 0x149dee
addsd (%rax), %xmm0
testq %rdi, %rdi
je 0x149e5b
movl 0x20(%rax), %eax
addl %eax, (%rdi)
jmp 0x149e5b
cmpl %r8d, %edx
jne 0x149e5b
cmpb $0x0, (%r15,%r14)
jne 0x149e5b
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0x149e49
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r10, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x2, %rsi
movsd %xmm0, 0x10(%rsp)
callq 0x2370
movl $0x2, %r10d
movl 0x50(%rsp), %r9d
movl 0x58(%rsp), %r8d
movsd 0x10(%rsp), %xmm0
movq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rcx
movq %rax, 0x10(%rbx)
movq (%rbx), %rax
movq 0x10(%rbx), %rsi
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movl %r14d, (%rsi,%rax,4)
movl %ebp, %edx
movq 0x10(%rcx), %rax
incl %ebp
cmpq %rdx, (%rax,%r13)
ja 0x149db8
movq (%rbx), %rax
testq %rax, %rax
movl 0x4(%rsp), %ebp
jne 0x149d5b
jmp 0x149e83
xorpd %xmm0, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq