// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: dfs_weight_hic(unsigned int, unsigned char*, unsigned char*, kv_u_trans_t*, kvec_t_u32_warp*, kvec_t_u32_warp*, unsigned int, unsigned int, unsigned int*)
double dfs_weight_hic(uint32_t v, uint8_t* vis_flag, uint8_t* is_vis, kv_u_trans_t *ta, 
kvec_t_u32_warp* stack, kvec_t_u32_warp* result, uint32_t e_flag, uint32_t ava_flag, uint32_t* link_occ)
{
    u_trans_t *e = NULL;
    uint32_t cur, i, next = (uint32_t)-1, e_n;
    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;
        e = u_trans_a(*ta, cur); e_n = u_trans_n(*ta, cur);
        for (i = 0; i < e_n; i++)
        {
            if(e[i].del) continue;
            next = e[i].tn;
            if(vis_flag[next]&e_flag)
            {
                w += (e[i].nw >= 0? e[i].nw : -e[i].nw);
                if(link_occ) (*link_occ) += e[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 $0x28, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movl %edi, %ebp
movq 0x70(%rsp), %rdi
movq $0x0, (%r8)
cmpq $0x0, 0x8(%r8)
je 0x158880
movq 0x10(%rbx), %rax
xorl %edx, %edx
jmp 0x1588a9
movq $0x2, 0x8(%rbx)
movq %rdi, %r13
movq 0x10(%rbx), %rdi
movq %rsi, %r12
movl $0x8, %esi
callq 0x2370
movq %r13, %rdi
movq %r12, %rsi
movq %rax, 0x10(%rbx)
movq (%rbx), %rdx
leaq 0x1(%rdx), %rcx
movq %rcx, (%rbx)
movl %ebp, (%rax,%rdx,4)
testq %rdi, %rdi
je 0x1588be
movl $0x0, (%rdi)
testq %rcx, %rcx
je 0x158a49
movl 0x68(%rsp), %r8d
movl 0x60(%rsp), %r9d
xorpd %xmm0, %xmm0
movl $0x2, %r10d
movapd 0xe28ed(%rip), %xmm4    # 0x23b1d0
leaq -0x1(%rcx), %rdx
movq %rdx, (%rbx)
movq 0x10(%rbx), %rax
movl -0x4(%rax,%rcx,4), %eax
cmpb $0x0, (%r15,%rax)
jne 0x15890e
movb $0x1, (%r15,%rax)
cmpl %ebp, %eax
je 0x15891b
movzbl (%rsi,%rax), %ecx
cmpl %r8d, %ecx
je 0x15891b
movq (%rbx), %rdx
movq %rdx, %rcx
testq %rdx, %rdx
jne 0x1588e3
jmp 0x158a4d
movl %ebp, 0xc(%rsp)
movq 0x28(%r14), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
movq %r14, 0x18(%rsp)
je 0x158a32
movq 0x10(%r14), %rcx
movq %rax, %rdx
shrq $0x20, %rdx
movl %eax, %eax
leaq (%rdx,%rdx,2), %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %r13
addq $0x28, %r13
shlq $0x4, %rax
leaq (%rax,%rax,2), %r14
xorl %ebp, %ebp
movq %rsi, 0x10(%rsp)
cmpb $0x0, (%r13,%rbp)
js 0x158a25
movl -0x14(%r13,%rbp), %r12d
movzbl (%rsi,%r12), %eax
testl %r9d, %eax
je 0x1589b1
movsd -0x8(%r13,%rbp), %xmm3
movapd %xmm3, %xmm1
xorpd %xmm4, %xmm1
movapd %xmm1, %xmm2
cmpnlesd %xmm3, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm3, %xmm2
orpd %xmm1, %xmm2
addsd %xmm2, %xmm0
testq %rdi, %rdi
je 0x158a25
movl -0x10(%r13,%rbp), %eax
addl %eax, (%rdi)
jmp 0x158a25
cmpl %r8d, %eax
jne 0x158a25
cmpb $0x0, (%r15,%r12)
jne 0x158a25
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x158a1a
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
cmoveq %r10, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
movsd %xmm0, 0x20(%rsp)
callq 0x2370
movapd 0xe27dd(%rip), %xmm4    # 0x23b1d0
movl $0x2, %r10d
movl 0x60(%rsp), %r9d
movl 0x68(%rsp), %r8d
movsd 0x20(%rsp), %xmm0
movq 0x70(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movl %r12d, (%rax,%rcx,4)
addq $0x30, %rbp
cmpq %rbp, %r14
jne 0x158960
movq (%rbx), %rcx
testq %rcx, %rcx
movq 0x18(%rsp), %r14
movl 0xc(%rsp), %ebp
jne 0x1588e3
jmp 0x158a4d
xorpd %xmm0, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq