// File: /workspace/github_cpp_makefile_star2_O1/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)
jne 0x1520fb
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), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movl %ebp, (%rcx,%rax,4)
testq %rdi, %rdi
je 0x152117
movl $0x0, (%rdi)
movq (%rbx), %rax
testq %rax, %rax
je 0x1522a3
movl 0x68(%rsp), %r8d
movl 0x60(%rsp), %r9d
xorpd %xmm0, %xmm0
movl $0x2, %r10d
movapd 0xdce81(%rip), %xmm4    # 0x22efc0
leaq -0x1(%rax), %rcx
movq %rcx, (%rbx)
movq 0x10(%rbx), %rcx
movl -0x4(%rcx,%rax,4), %eax
cmpb $0x0, (%r15,%rax)
jne 0x152167
movb $0x1, (%r15,%rax)
cmpl %ebp, %eax
je 0x152174
movzbl (%rsi,%rax), %ecx
cmpl %r8d, %ecx
je 0x152174
movq (%rbx), %rax
testq %rax, %rax
jne 0x15213f
jmp 0x1522a7
movl %ebp, 0xc(%rsp)
movq 0x28(%r14), %rcx
movq (%rcx,%rax,8), %rax
testl %eax, %eax
movq %r14, 0x18(%rsp)
je 0x15228c
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 0x15227f
movl -0x14(%r13,%rbp), %r12d
movzbl (%rsi,%r12), %eax
testl %r9d, %eax
je 0x15220a
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 0x15227f
movl -0x10(%r13,%rbp), %eax
addl %eax, (%rdi)
jmp 0x15227f
cmpl %r8d, %eax
jne 0x15227f
cmpb $0x0, (%r15,%r12)
jne 0x15227f
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0x15226d
leaq (%rax,%rax), %rsi
testq %rax, %rax
cmoveq %r10, %rsi
movq %rsi, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x2, %rsi
movsd %xmm0, 0x20(%rsp)
callq 0x2370
movapd 0xdcd77(%rip), %xmm4    # 0x22efc0
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), %rax
movq 0x10(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%rbx)
movl %r12d, (%rcx,%rax,4)
addq $0x30, %rbp
cmpq %rbp, %r14
jne 0x1521b9
movq (%rbx), %rax
testq %rax, %rax
movq 0x18(%rsp), %r14
movl 0xc(%rsp), %ebp
jne 0x15213f
jmp 0x1522a7
xorpd %xmm0, %xmm0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq