// File: /workspace/github_c_makefile_star2_O1/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, (%rsp)
movq %rdi, %r12
movl (%rdi), %r13d
leal -0x1(%r13), %ebx
imulq %r13, %rbx
movq %rbx, %r14
shrq %r14
movl $0x18, %edi
callq 0x2330
movq %rax, %r15
movl %r14d, (%rax)
movl %ebp, 0x4(%rax)
shlq $0x6, %rbx
movabsq $0x7fffffff80, %rdi     # imm = 0x7FFFFFFF80
andq %rbx, %rdi
callq 0x2330
movq %r13, %rcx
movq %r15, 0x60(%rsp)
movq %rax, 0x30(%rsp)
movq %rax, 0x10(%r15)
cmpl $0x1, %ecx
jb 0xc7b9
movl (%rsp), %r15d
addl %r15d, %r15d
movl %r15d, (%rsp)
movl %r15d, %r15d
leal -0x3(,%rcx,2), %edx
movq 0x30(%rsp), %rax
leaq 0x40(%rax), %rsi
movq %rsi, 0x48(%rsp)
addq $0x14, %rax
movq %rax, 0x40(%rsp)
leal -0x1(%rcx), %eax
movl %eax, 0x4(%rsp)
xorl %r14d, %r14d
movl $0x1, %eax
movq %rax, 0x38(%rsp)
movl %edx, 0x24(%rsp)
movl %edx, %esi
xorl %r8d, %r8d
movl %ebp, 0x2c(%rsp)
movq %r12, 0x70(%rsp)
movq %rcx, 0x50(%rsp)
movq %r15, 0x68(%rsp)
movl %esi, %r13d
imulq %r14, %r13
shlq $0x6, %r13
andq $-0x80, %r13
movq 0x8(%r12), %rax
imulq $0x58, %r14, %rbx
movq 0x8(%rax,%rbx), %rdi
cmpq %r15, %rdi
movl %esi, 0x28(%rsp)
movq %r14, 0x18(%rsp)
jae 0xc5db
leaq 0x1(%r14), %rax
cmpq %rcx, %rax
jae 0xc781
addq 0x40(%rsp), %r13
movl 0x4(%rsp), %eax
movl $0x0, (%r13)
subq $-0x80, %r13
decl %eax
jne 0xc5c6
jmp 0xc781
movq %r8, 0x10(%rsp)
movl (%rsp), %esi
callq 0x4bf1
movl %ebp, %ecx
movq %rcx, 0x8(%rsp)
cmpl %ebp, %eax
ja 0xc60a
movq 0x8(%r12), %rax
movq 0x8(%rax,%rbx), %rdi
movl (%rsp), %esi
callq 0x4bf1
movq %rax, 0x8(%rsp)
leaq 0x1(%r14), %rax
movq 0x50(%rsp), %rcx
cmpq %rcx, %rax
movq 0x10(%rsp), %rdx
jae 0xc781
addq 0x48(%rsp), %r13
addl 0x24(%rsp), %edx
imulq 0x18(%rsp), %rdx
shlq $0x6, %rdx
andq $-0x80, %rdx
addq 0x30(%rsp), %rdx
movq 0x8(%rsp), %rax
leal -0x1(%rax), %esi
movq %rsi, 0x80(%rsp)
movl %eax, %eax
movq %rax, 0x78(%rsp)
movq 0x38(%rsp), %rsi
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
shlq $0x7, %rbx
addq %rdx, %rbx
movq 0x8(%r12), %rax
imulq $0x58, %rsi, %r14
movq 0x8(%rax,%r14), %rdi
cmpq %r15, %rdi
jae 0xc687
movl $0x0, -0x6c(%rbx)
jmp 0xc772
movq %rsi, 0x58(%rsp)
movl (%rsp), %esi
callq 0x4bf1
movl %eax, %ecx
movl %ebp, %eax
cmpl %ebp, %ecx
ja 0xc6ae
movq 0x8(%r12), %rax
movq 0x8(%rax,%r14), %rdi
movl (%rsp), %esi
callq 0x4bf1
movl %eax, %r15d
movq 0x8(%rsp), %rdx
imull %edx, %r15d
movq 0x18(%rsp), %rcx
movl %ecx, -0x80(%rbx)
movq 0x58(%rsp), %rcx
movl %ecx, -0x7c(%rbx)
movl %edx, -0x78(%rbx)
movq 0x80(%rsp), %rcx
addl %eax, %ecx
cmpl %ebp, %ecx
cmovael %ebp, %ecx
movl %eax, -0x74(%rbx)
movl %ecx, -0x70(%rbx)
movl %r15d, -0x6c(%rbx)
movl $0x0, -0x68(%rbx)
movb $0x0, -0x64(%rbx)
movl %eax, %eax
imulq 0x78(%rsp), %rax
cmpq %r15, %rax
jne 0xc7d5
movl %ecx, %r12d
movq $-0x4, %r14
movl $0x8, %esi
movq %r15, %rdi
callq 0x2290
movq %rax, %rbp
movq %rax, (%r13,%r14,8)
movl $0x8, %esi
movq %r12, %rdi
callq 0x2290
movq %rax, 0x20(%r13,%r14,8)
testq %rbp, %rbp
je 0xc7d0
testq %rax, %rax
je 0xc7d0
incq %r14
jne 0xc70c
xorps %xmm0, %xmm0
movups %xmm0, -0x10(%rbx)
movups %xmm0, -0x20(%rbx)
movl 0x2c(%rsp), %ebp
movq 0x70(%rsp), %r12
movq 0x50(%rsp), %rcx
movq 0x68(%rsp), %r15
movq 0x10(%rsp), %rdx
movq 0x58(%rsp), %rsi
incq %rsi
subq $-0x80, %r13
cmpl %esi, %ecx
jne 0xc65e
movq 0x18(%rsp), %rax
movl %eax, %r8d
incq %rax
notl %r8d
incq 0x38(%rsp)
movl $0x80, %edx
addq %rdx, 0x48(%rsp)
movl 0x28(%rsp), %esi
decl %esi
addq %rdx, 0x40(%rsp)
decl 0x4(%rsp)
movq %rax, %r14
cmpq %rcx, %rax
jne 0xc585
movq 0x60(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2886
leaq 0x14e84(%rip), %rdi     # 0x21660
leaq 0x14e91(%rip), %rsi     # 0x21674
leaq 0x14e91(%rip), %rcx     # 0x2167b
movl $0xc9, %edx
callq 0x21c0