// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/link.c
// Function: intra_link_mat_normalise
static void intra_link_mat_normalise(intra_link_mat_t *link_mat, void *dict, re_cuts_t *re_cuts, uint32_t resolution, int use_gap_seq)
{
    intra_link_t *link;
    uint32_t i, j, k, n, b;
    uint64_t len;
    double a, a0, a1, s;
    double **re_dens;

    n = use_gap_seq? ((asm_dict_t *) dict)->n : ((sdict_t *) dict)->n;

    re_dens = use_gap_seq? calc_re_cuts_density1(re_cuts, resolution, dict) : calc_re_cuts_density(re_cuts, resolution);
    
    for (i = 0; i < n; ++i) {
        len = use_gap_seq? ((asm_dict_t *) dict)->s[i].len : ((sdict_t *) dict)->s[i].len;
        if (len < resolution) continue;
        
        link = &link_mat->links[i];
        b = link->n;
        // relative size of the last cell
        a = ((double) len - (double) (b - 1) * resolution) / resolution;

        for (j = 0; j < b; ++j) {
            a0 = j < b-1? 1. : a;
            for (k = j; k < b; ++k) {
                a1 = k < b-1? 1. : a;
                a1 *= a0;
                a1 = a1 < .5? .0 : a1;
                s = re_dens? re_dens[i][j] * re_dens[i][k] : 1.;
                s = s < MIN_RE_DENS? .0 : s;
                s *= a1;
                if (s < FLT_EPSILON)
                    link->link[(long) (b * 2 - k + j - 1) * (k - j) / 2 + k] = -DBL_MAX;
                else
                    link->link[(long) (b * 2 - k + j - 1) * (k - j) / 2 + k] /= s;
            }
        }
    }
    
    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)
cmpl $0x0, -0x20(%rbp)
je 0xe7cf
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
jmp 0xe7d8
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0xe7fa
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x29f50
movq %rax, -0x80(%rbp)
jmp 0xe80a
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x29d40
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0xeb4e
cmpl $0x0, -0x20(%rbp)
je 0xe84a
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0xe866
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl -0x1c(%rbp), %ecx
cmpq %rcx, %rax
jae 0xe882
jmp 0xeb40
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x2c(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x3c(%rbp)
movaps 0x228f7(%rip), %xmm1    # 0x311a0
movq -0x48(%rbp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x228f6(%rip), %xmm1    # 0x311b0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %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, -0x50(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0xeb3e
movl -0x30(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0xe91e
movsd 0x22ce4(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0x90(%rbp)
jmp 0xe92b
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jae 0xeb2e
movl -0x34(%rbp), %eax
movl -0x3c(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0xe969
movsd 0x22c99(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0x98(%rbp)
jmp 0xe976
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x58(%rbp), %xmm0
mulsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd 0x22c66(%rip), %xmm0    # 0x31600
ucomisd -0x60(%rbp), %xmm0
jbe 0xe9ae
xorps %xmm0, %xmm0
movsd %xmm0, -0xa0(%rbp)
jmp 0xe9bb
movsd -0x60(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0xe9ff
movq -0x70(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x30(%rbp), %ecx
movsd (%rax,%rcx,8), %xmm0
movq -0x70(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x34(%rbp), %ecx
mulsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0xa8(%rbp)
jmp 0xea11
movsd 0x22bf1(%rip), %xmm0    # 0x315f8
movsd %xmm0, -0xa8(%rbp)
jmp 0xea11
movsd -0xa8(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x22be2(%rip), %xmm0    # 0x31608
ucomisd -0x68(%rbp), %xmm0
jbe 0xea3a
xorps %xmm0, %xmm0
movsd %xmm0, -0xb0(%rbp)
jmp 0xea47
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xb0(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x60(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x22ba5(%rip), %xmm0    # 0x31610
ucomisd -0x68(%rbp), %xmm0
jbe 0xeac6
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movl -0x3c(%rbp), %eax
shll %eax
subl -0x34(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x34(%rbp), %ecx
subl -0x30(%rbp), %ecx
movl %ecx, %ecx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movl -0x34(%rbp), %edx
addq %rdx, %rcx
movsd 0x22b59(%rip), %xmm0    # 0x31618
movsd %xmm0, (%rax,%rcx,8)
jmp 0xeb1e
movsd -0x68(%rbp), %xmm1
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xc0(%rbp)
movl -0x3c(%rbp), %eax
shll %eax
subl -0x34(%rbp), %eax
addl -0x30(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl -0x34(%rbp), %ecx
subl -0x30(%rbp), %ecx
movl %ecx, %ecx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movl -0x34(%rbp), %edx
addq %rdx, %rcx
movsd (%rax,%rcx,8), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0xeb20
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xe93e
jmp 0xeb30
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xe8f3
jmp 0xeb40
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xe819
cmpq $0x0, -0x70(%rbp)
je 0xeb88
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0xeb7f
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 0xeb5c
movq -0x70(%rbp), %rdi
callq 0x2050
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)