// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/link.c
// Function: inter_link_mat_normalise
static void inter_link_mat_normalise(inter_link_mat_t *link_mat, asm_dict_t *dict, re_cuts_t *re_cuts, uint32_t resolution, uint32_t radius)
{
    inter_link_t *link;
    uint32_t i, j, k, l, b0, b1, n, p, r2;
    double a0, a1, a;
    double **re_dens, re;

    n = dict->n;
    r2 = resolution * 2;

    re_dens = calc_re_cuts_density2(re_cuts, resolution, dict);

    for (i = 0; i < n; ++i) {
        if (dict->s[i].len < r2) continue;
        
        b0 = MIN(radius, div_ceil(dict->s[i].len, r2));
        // relative size of the last cell
        a0 = MIN(1., (dict->s[i].len / 2. - (double) (b0 - 1) * resolution) / resolution);
        
        for (j = i + 1; j < n; ++j) {
            if (dict->s[j].len < r2) continue;
            
            b1 = MIN(radius, div_ceil(dict->s[j].len, r2));
            // relative size of the last cell
            a1 = MIN(1., (dict->s[j].len / 2. - (double) (b1 - 1) * resolution) / resolution);
            
            link = &link_mat->links[(long) (n * 2 - i - 3) * i / 2 + j - 1];
            p = link->n;
            // calculate relative areas for each cell
            for (l = 0; l < p; ++l) {
                a = 1.;
                if (l / b1 == b0 - 1)
                    a *= a0;
                if (l % b1 == b1 - 1)
                    a *= a1;
                if (a < .5)
                    a = .0;
                re = re_dens? re_dens[i][l / b1] * re_dens[j][l % b1] : 1.;
                a *= re < MIN_RE_DENS? .0 : re;
                if (a < FLT_EPSILON)
                    for (k = 0; k < 4; ++k) link->link[k][l] = -DBL_MAX;
                else
                    for (k = 0; k < 4; ++k) link->link[k][l] /= a;
            }
        }
    }

    if (re_dens) {
        for (i = 0; i < n; ++i)
            free(re_dens[i]);
        free(re_dens);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x1c(%rbp), %eax
shll %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x2a380
movq %rax, -0x70(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0xfdf3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x4c(%rbp), %ecx
cmpq %rcx, %rax
jae 0xf8c9
jmp 0xfde5
movl -0x20(%rbp), %eax
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x4c(%rbp), %esi
callq 0x2aa0
movl %eax, %ecx
movl -0x7c(%rbp), %eax
cmpl %ecx, %eax
jae 0xf8fe
movl -0x20(%rbp), %eax
movl %eax, -0x80(%rbp)
jmp 0xf91f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x4c(%rbp), %esi
callq 0x2aa0
movl %eax, -0x80(%rbp)
movl -0x80(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
movq 0x8(%rax,%rcx), %xmm0
movaps 0x2185f(%rip), %xmm1    # 0x311a0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x21863(%rip), %xmm1    # 0x311b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x21c9c(%rip), %xmm1    # 0x31600
mulsd %xmm1, %xmm0
movl -0x3c(%rbp), %eax
decl %eax
cvtsi2sd %rax, %xmm2
movl -0x1c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd 0x21c6a(%rip), %xmm1    # 0x315f8
ucomisd %xmm1, %xmm0
jbe 0xf9a6
movsd 0x21c5c(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0x88(%rbp)
jmp 0xfa0f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
movq 0x8(%rax,%rcx), %xmm0
movaps 0x217de(%rip), %xmm1    # 0x311a0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x217e2(%rip), %xmm1    # 0x311b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x21c1b(%rip), %xmm1    # 0x31600
mulsd %xmm1, %xmm0
movl -0x3c(%rbp), %eax
decl %eax
cvtsi2sd %rax, %xmm2
movl -0x1c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0xfde3
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x4c(%rbp), %ecx
cmpq %rcx, %rax
jae 0xfa54
jmp 0xfdd5
movl -0x20(%rbp), %eax
movl %eax, -0x8c(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x4c(%rbp), %esi
callq 0x2aa0
movl %eax, %ecx
movl -0x8c(%rbp), %eax
cmpl %ecx, %eax
jae 0xfa92
movl -0x20(%rbp), %eax
movl %eax, -0x90(%rbp)
jmp 0xfab6
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x4c(%rbp), %esi
callq 0x2aa0
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x58, %rcx, %rcx
movq 0x8(%rax,%rcx), %xmm0
movaps 0x216c5(%rip), %xmm1    # 0x311a0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x216c9(%rip), %xmm1    # 0x311b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x21b02(%rip), %xmm1    # 0x31600
mulsd %xmm1, %xmm0
movl -0x40(%rbp), %eax
decl %eax
cvtsi2sd %rax, %xmm2
movl -0x1c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd 0x21ad0(%rip), %xmm1    # 0x315f8
ucomisd %xmm1, %xmm0
jbe 0xfb40
movsd 0x21ac2(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0x98(%rbp)
jmp 0xfba9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x30(%rbp), %ecx
imulq $0x58, %rcx, %rcx
movq 0x8(%rax,%rcx), %xmm0
movaps 0x21644(%rip), %xmm1    # 0x311a0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x21648(%rip), %xmm1    # 0x311b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x21a81(%rip), %xmm1    # 0x31600
mulsd %xmm1, %xmm0
movl -0x40(%rbp), %eax
decl %eax
cvtsi2sd %rax, %xmm2
movl -0x1c(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm2
subsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
movl -0x44(%rbp), %eax
shll %eax
subl -0x2c(%rbp), %eax
subl $0x3, %eax
movl %eax, %eax
movl -0x2c(%rbp), %ecx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0xa0(%rbp), %rax
movl -0x30(%rbp), %edx
addq %rdx, %rcx
subq $0x1, %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x48(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x48(%rbp), %eax
jae 0xfdd3
movsd 0x219d1(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0x68(%rbp)
movl -0x38(%rbp), %eax
xorl %edx, %edx
divl -0x40(%rbp)
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xfc4d
movsd -0x58(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movl -0x38(%rbp), %eax
xorl %edx, %edx
divl -0x40(%rbp)
movl -0x40(%rbp), %eax
subl $0x1, %eax
cmpl %eax, %edx
jne 0xfc6e
movsd -0x60(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x2198a(%rip), %xmm0    # 0x31600
ucomisd -0x68(%rbp), %xmm0
jbe 0xfc85
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xfce8
movq -0x70(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb8(%rbp)
movl -0x38(%rbp), %eax
xorl %edx, %edx
divl -0x40(%rbp)
movl %eax, %ecx
movq -0xb8(%rbp), %rax
movl %ecx, %ecx
movsd (%rax,%rcx,8), %xmm0
movq -0x70(%rbp), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0xb0(%rbp)
movl -0x38(%rbp), %eax
xorl %edx, %edx
divl -0x40(%rbp)
movq -0xb0(%rbp), %rax
movl %edx, %ecx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xa8(%rbp)
jmp 0xfcfa
movsd 0x21908(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0xa8(%rbp)
jmp 0xfcfa
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd 0x218f9(%rip), %xmm0    # 0x31608
ucomisd -0x78(%rbp), %xmm0
jbe 0xfd23
xorps %xmm0, %xmm0
movsd %xmm0, -0xc0(%rbp)
jmp 0xfd30
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0xc0(%rbp)
movsd -0xc0(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x218c6(%rip), %xmm0    # 0x31610
ucomisd -0x68(%rbp), %xmm0
jbe 0xfd87
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jae 0xfd85
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movq 0x20(%rax,%rcx,8), %rax
movl -0x38(%rbp), %ecx
movsd 0x218a3(%rip), %xmm0    # 0x31618
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xfd58
jmp 0xfdc3
movl $0x0, -0x34(%rbp)
cmpl $0x4, -0x34(%rbp)
jae 0xfdc1
movsd -0x68(%rbp), %xmm1
movq -0x28(%rbp), %rax
movl -0x34(%rbp), %ecx
movq 0x20(%rax,%rcx,8), %rax
movl -0x38(%rbp), %ecx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xfd8e
jmp 0xfdc3
jmp 0xfdc5
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0xfc13
jmp 0xfdd5
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xfa25
jmp 0xfde5
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xf89a
cmpq $0x0, -0x70(%rbp)
je 0xfe2d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0xfe24
movq -0x70(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
callq 0x2050
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xfe01
movq -0x70(%rbp), %rdi
callq 0x2050
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)