// File: /workspace/github_cpp_makefile_star2_O2/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
andq $0x0, (%r8)
movl %edi, %ebp
movq 0x70(%rsp), %rdi
cmpq $0x0, 0x8(%r8)
movq %rsi, 0x10(%rsp)
je 0x111e80
movq 0x10(%rbx), %rax
xorl %ecx, %ecx
jmp 0x111ea5
movq $0x2, 0x8(%rbx)
movq 0x10(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0x2370
movq 0x70(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
movl %ebp, (%rax,%rcx,4)
testq %rdi, %rdi
je 0x111eb7
andl $0x0, (%rdi)
movl 0x68(%rsp), %r8d
movl 0x60(%rsp), %r9d
xorpd %xmm0, %xmm0
movapd 0xdb1f3(%rip), %xmm4    # 0x1ed0c0
movq (%rbx), %rax
testq %rax, %rax
je 0x11200f
leaq -0x1(%rax), %rcx
movq %rcx, (%rbx)
movq 0x10(%rbx), %rcx
movl -0x4(%rcx,%rax,4), %eax
cmpb $0x0, (%r15,%rax)
jne 0x111ecd
movb $0x1, (%r15,%rax)
cmpl %ebp, %eax
je 0x111f01
movzbl (%rsi,%rax), %ecx
cmpl %r8d, %ecx
jne 0x111ecd
movl %ebp, 0xc(%rsp)
movq 0x10(%r14), %rcx
movq %r14, 0x18(%rsp)
movq 0x28(%r14), %rdx
movq (%rdx,%rax,8), %rax
movl %eax, %edx
shrq $0x20, %rax
imulq $0x30, %rdx, %r13
imulq $0x30, %rax, %rax
leaq (%rcx,%rax), %r14
addq $0x28, %r14
xorl %ebp, %ebp
cmpq %rbp, %r13
je 0x112001
cmpb $0x0, (%r14,%rbp)
js 0x111ff8
movl -0x14(%r14,%rbp), %r12d
movzbl (%rsi,%r12), %eax
testl %r9d, %eax
je 0x111f87
movsd -0x8(%r14,%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 0x111ff8
movl -0x10(%r14,%rbp), %eax
addl %eax, (%rdi)
jmp 0x111ff8
cmpl %r8d, %eax
jne 0x111ff8
cmpb $0x0, (%r15,%r12)
jne 0x111ff8
movq (%rbx), %rcx
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rcx
jne 0x111fed
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
movsd %xmm0, 0x20(%rsp)
callq 0x2370
movapd 0xdb0f4(%rip), %xmm4    # 0x1ed0c0
movl 0x60(%rsp), %r9d
movsd 0x20(%rsp), %xmm0
movl 0x68(%rsp), %r8d
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
jmp 0x111f2e
movq 0x18(%rsp), %r14
movl 0xc(%rsp), %ebp
jmp 0x111ecd
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq