// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]yahs/link.c
// Function: inter_link_mat_init
inter_link_mat_t *inter_link_mat_init(asm_dict_t *dict, uint32_t resolution, uint32_t radius)
{
    inter_link_mat_t *link_mat;
    inter_link_t *link;
    uint32_t i, j, k, b0, b1, n, m, p, r2;

    n = dict->n;
    m = (long) n * (n - 1) / 2;
    r2 = resolution * 2;
    link_mat = (inter_link_mat_t *) malloc(sizeof(inter_link_mat_t));
    link_mat->n = m;
    link_mat->r = radius;
    link_mat->links = (inter_link_t *) malloc(m * sizeof(inter_link_t));
    
    for (i = 0; i < n; ++i) {
        if (dict->s[i].len < r2) {
            for (j = i + 1; j < n; ++j)
                link_mat->links[(long) (n * 2 - i - 3) * i / 2 + j - 1].n = 0;
            continue;
        }
        
        b0 = MIN(radius, div_ceil(dict->s[i].len, r2));
        for (j = i + 1; j < n; ++j) {
            link = &link_mat->links[(long) (n * 2 - i - 3) * i / 2 + j - 1];
            if (dict->s[j].len < r2) {
                link->n = 0;
                continue;
            }
            
            b1 = MIN(radius, div_ceil(dict->s[j].len, r2));
            p = b0 * b1; 
            link->c0 = i;
            link->c1 = j;
            link->b0 = b0;
            link->b1 = b1;
            link->r = MIN(radius, (uint32_t) (b0 + b1 - 1));
            link->n = p;
            link->n0 = 0;
            link->linkt = 0;
            assert(p == (long) b0 * b1);
            for (k = 0; k < 4; ++k) {
                link->link[k] = (double *) calloc(p, sizeof(double));
                link->linkb[k] = (double *) calloc(link->r, sizeof(double));
                if (!link->link[k] || !link->linkb[k]) {
                    fprintf(stderr, "[E::%s] memory allocation failure\n", __func__);
                    exit(EXIT_FAILURE);
                }
            }

            memset(link->norms, 0, sizeof(link->norms));
        }
    }

    return link_mat;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %r13
movl (%rdi), %eax
movq %rax, 0x10(%rsp)
leal -0x1(%rax), %ebx
imulq %rax, %rbx
movq %rbx, %r14
shrq %r14
addl %r15d, %r15d
pushq $0x18
popq %rdi
callq 0x2330
movq %rax, %r12
movl %r14d, (%rax)
movl %ebp, 0x4(%rax)
shlq $0x6, %rbx
movabsq $0x7fffffff80, %rdi     # imm = 0x7FFFFFFF80
andq %rbx, %rdi
callq 0x2330
movq 0x10(%rsp), %rcx
movq %r12, 0x40(%rsp)
movq %rax, 0x10(%r12)
leal -0x3(,%rcx,2), %edx
leaq -0x40(%rax), %rsi
movq %rsi, 0x48(%rsp)
movq %rax, 0x50(%rsp)
addq $0x14, %rax
movq %rax, 0x30(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x8(%rsp)
xorl %esi, %esi
movl %edx, 0x24(%rsp)
movl %ebp, 0x2c(%rsp)
movq %r15, 0x60(%rsp)
movq %r13, 0x58(%rsp)
cmpq %rcx, %rsi
je 0x97f2
movl %edx, 0x28(%rsp)
movl %edx, %r14d
imulq %rsi, %r14
shlq $0x6, %r14
andq $-0x80, %r14
movq 0x8(%r13), %rax
movq %rsi, 0x18(%rsp)
imulq $0x58, %rsi, %rbx
movq 0x8(%rax,%rbx), %rdi
cmpq %r15, %rdi
jae 0x9638
addq 0x30(%rsp), %r14
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x97d4
andl $0x0, (%r14)
incq %rax
subq $-0x80, %r14
jmp 0x9622
movl %r15d, %esi
callq 0x28ff
movl %ebp, %r12d
cmpl %ebp, %eax
ja 0x965b
movq 0x8(%r13), %rax
movq 0x8(%rax,%rbx), %rdi
movl %r15d, %esi
callq 0x28ff
movl %eax, %r12d
movl 0x8(%rsp), %ebx
shlq $0x7, %rbx
addq 0x48(%rsp), %rbx
addq %r14, %rbx
movl 0x24(%rsp), %eax
movl %eax, %edx
movq 0x18(%rsp), %rax
subl %eax, %edx
imulq %rax, %rdx
shlq $0x6, %rdx
andq $-0x80, %rdx
addq 0x50(%rsp), %rdx
leal -0x1(%r12), %ecx
movq %rcx, 0x80(%rsp)
movl %r12d, %ecx
movq %rcx, 0x78(%rsp)
movl %eax, %esi
movq 0x10(%rsp), %rcx
movq %r12, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
incl %esi
cmpl %ecx, %esi
jae 0x97d4
movl %esi, %r8d
imulq $0x58, %r8, %r14
shlq $0x7, %r8
addq %rdx, %r8
movq 0x8(%r13), %rax
movq 0x8(%rax,%r14), %rdi
cmpq %r15, %rdi
jae 0x96df
andl $0x0, -0x6c(%r8)
jmp 0x97cb
movq %r8, 0x38(%rsp)
movl %esi, 0x4(%rsp)
movl %r15d, %esi
callq 0x28ff
movl %eax, %ecx
movl %ebp, %eax
cmpl %ebp, %ecx
ja 0x9709
movq 0x8(%r13), %rax
movq 0x8(%rax,%r14), %rdi
movl %r15d, %esi
callq 0x28ff
movl %eax, %r13d
imull %r12d, %r13d
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %rdx
movl %ecx, -0x80(%rdx)
movl 0x4(%rsp), %ecx
movl %ecx, -0x7c(%rdx)
movl %r12d, -0x78(%rdx)
movl %eax, -0x74(%rdx)
movq 0x80(%rsp), %rcx
addl %eax, %ecx
cmpl %ebp, %ecx
cmovael %ebp, %ecx
movl %ecx, -0x70(%rdx)
movl %r13d, -0x6c(%rdx)
andl $0x0, -0x68(%rdx)
movb $0x0, -0x64(%rdx)
movl %eax, %eax
imulq 0x78(%rsp), %rax
cmpq %r13, %rax
jne 0x9830
movl %ecx, %r15d
xorl %ebp, %ebp
cmpq $0x4, %rbp
je 0x979f
movq %r13, %rdi
pushq $0x8
popq %r12
movq %r12, %rsi
callq 0x2290
movq %rax, %r14
movq %rax, -0x20(%rbx,%rbp,8)
movq %r15, %rdi
movq %r12, %rsi
callq 0x2290
movq 0x38(%rsp), %rdx
movq %rax, (%rbx,%rbp,8)
testq %r14, %r14
je 0x9809
incq %rbp
testq %rax, %rax
jne 0x975f
jmp 0x9809
xorps %xmm0, %xmm0
movups %xmm0, -0x10(%rdx)
movups %xmm0, -0x20(%rdx)
movl 0x2c(%rsp), %ebp
movq 0x60(%rsp), %r15
movq 0x58(%rsp), %r13
movq 0x10(%rsp), %rcx
movq 0x70(%rsp), %r12
movq 0x68(%rsp), %rdx
movl 0x4(%rsp), %esi
subq $-0x80, %rbx
jmp 0x96af
movq 0x18(%rsp), %rsi
incq %rsi
movl 0x28(%rsp), %edx
decl %edx
incq 0x8(%rsp)
subq $-0x80, 0x30(%rsp)
jmp 0x95e5
movq 0x40(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1e7e8(%rip), %rax     # 0x27ff8
movq (%rax), %rdi
leaq 0x14e99(%rip), %rsi     # 0x1e6b3
leaq 0x14eb5(%rip), %rdx     # 0x1e6d6
xorl %eax, %eax
callq 0x22c0
pushq $0x1
popq %rdi
callq 0x24b0
leaq 0x14e19(%rip), %rdi     # 0x1e650
leaq 0x14e26(%rip), %rsi     # 0x1e664
leaq 0x14e26(%rip), %rcx     # 0x1e66b
movl $0xc9, %edx
callq 0x21c0