// File: chhylp123[P]hifiasm/hic.cpp
// Function: get_cluster_weight(H_partition*, hc_links*, unsigned int*, unsigned int)
double get_cluster_weight(H_partition* hap, hc_links* link, uint32_t *h, uint32_t h_n)
{
    int o_d = 0;
    double weight = 0;
    uint32_t j, k, m;
    for (j = 0, weight = 0; j < h_n; j++)
    {
        for (k = 0; k < link->a.a[h[j]].e.n; k++)
        {
            if(link->a.a[h[j]].e.a[k].del) continue;
            for (m = 0; m < h_n; m++)
            {
                if(h[m] == link->a.a[h[j]].e.a[k].uID) break;
            }
            if(m < h_n) continue;

            o_d = get_phase_status(hap, link->a.a[h[j]].e.a[k].uID);
            if(o_d < -1) continue;
            ///if(o_d < -1) fprintf(stderr, "ERROR\n");
            weight += (o_d*link->a.a[h[j]].e.a[k].weight);
        }
    }

    return weight;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x1ee152
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
movl -0x2c(%rbp), %esi
movl (%rdx,%rsi,4), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jae 0x1ee142
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0x2c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movb 0x18(%rax), %al
shrb $0x7, %al
cmpb $0x0, %al
je 0x1ee053
jmp 0x1ee134
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x1ee0a7
movq -0x18(%rbp), %rax
movl -0x34(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq -0x18(%rbp), %rdx
movl -0x2c(%rbp), %esi
movl (%rdx,%rsi,4), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
jne 0x1ee09a
jmp 0x1ee0a7
jmp 0x1ee09c
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1ee05a
movl -0x34(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x1ee0b4
jmp 0x1ee134
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0x2c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %esi
callq 0x2145e0
movl %eax, -0x20(%rbp)
cmpl $-0x1, -0x20(%rbp)
jge 0x1ee0f2
jmp 0x1ee134
cvtsi2sdl -0x20(%rbp), %xmm0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0x2c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm2
movsd -0x28(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1edff8
jmp 0x1ee144
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1edfe5
movsd -0x28(%rbp), %xmm0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)