// File: chhylp123[P]hifiasm/hic.cpp
// Function: get_total_weight(H_partition*, G_partition*)
double get_total_weight(H_partition* h, G_partition* g_p)
{
    uint32_t i, k, uID;
    hc_links* link = h->link;
    int o_d = 0, o_f = 0;
    double w, t_w;
    for (i = 0, t_w = 0; i < h->n; i++)
    {
        if(g_p->index[i] == (uint32_t)-1) continue;
        o_f = g_p->a[g_p->index[i]>>1].status[g_p->index[i]&1];
        for (k = 0; k < link->a.a[i].e.n; k++)
        {
            if(link->a.a[i].e.a[k].del) continue;
            uID = link->a.a[i].e.a[k].uID;
            w = link->a.a[i].e.a[k].weight;
            if(g_p->index[uID] == (uint32_t)-1) continue;
            o_d = g_p->a[g_p->index[uID]>>1].status[g_p->index[uID]&1];
            t_w += (o_f*o_d*w);
        }
    }

    return t_w;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x14(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1f1a27
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x14(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1f18bb
jmp 0x1f1a19
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x14(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x14(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
movl 0x24(%rax,%rcx,4), %eax
movl %eax, -0x30(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x14(%rbp), %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jae 0x1f1a17
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movb 0x18(%rax), %al
shrb $0x7, %al
cmpb $0x0, %al
je 0x1f194a
jmp 0x1f1a09
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x14(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rax
movl -0x18(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x1c(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
jne 0x1f19ac
jmp 0x1f1a09
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x1c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl -0x1c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
andl $0x1, %ecx
movl %ecx, %ecx
movl 0x24(%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
imull -0x2c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd -0x38(%rbp), %xmm2
movsd -0x40(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x1f18fd
jmp 0x1f1a19
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1f1895
movsd -0x40(%rbp), %xmm0
popq %rbp
retq
nop