// File: /workspace/github_c_makefile_star2_O3/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 $0x98, %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, %rsi
movq %r15, 0x60(%rsp)
movq %rax, 0x38(%rsp)
movq %rax, 0x10(%r15)
cmpl $0x1, %esi
jb 0xd634
movl (%rsp), %r15d
addl %r15d, %r15d
movl %r15d, (%rsp)
movl %r15d, %r15d
leal -0x3(,%rsi,2), %r13d
leal -0x2(%rsi), %ecx
movq 0x38(%rsp), %rax
leaq 0x40(%rax), %rdx
movq %rdx, 0x48(%rsp)
leaq 0x114(%rax), %rdi
movl $0x1, %eax
movq %rax, 0x40(%rsp)
xorl %r8d, %r8d
movdqa 0x14f32(%rip), %xmm5    # 0x221c0
pcmpeqd %xmm6, %xmm6
movl %ecx, 0x30(%rsp)
movl %ecx, %r9d
xorl %ecx, %ecx
xorl %r14d, %r14d
movl %ebp, 0x34(%rsp)
movq %r12, 0x78(%rsp)
movq %rsi, 0x50(%rsp)
movq %r15, 0x70(%rsp)
movl %r13d, 0x2c(%rsp)
movl %r9d, 0x4(%rsp)
movq %r8, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x8(%r12), %rax
imulq $0x58, %rcx, %rbx
movq 0x8(%rax,%rbx), %rdi
cmpq %r15, %rdi
jae 0xd3ff
leaq 0x1(%rcx), %r11
cmpq %rsi, %r11
movq %rcx, %r10
jae 0xd5fb
movl 0x4(%rsp), %r9d
movl %r9d, %eax
addq $0x4, %rax
andq $-0x4, %rax
movl 0x30(%rsp), %ecx
movq 0x8(%rsp), %r8
subl %r8d, %ecx
addl %r13d, %r14d
imulq %r10, %r14
movd %ecx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shlq $0x6, %r14
andq $-0x80, %r14
movq 0x10(%rsp), %rdi
addq %rdi, %r14
pxor %xmm5, %xmm0
xorl %ecx, %ecx
movq %rcx, %xmm1
pshufd $0x44, %xmm1, %xmm1     # xmm1 = xmm1[0,1,0,1]
movdqa %xmm1, %xmm2
por 0x14e6c(%rip), %xmm2    # 0x221b0
pxor %xmm5, %xmm2
movdqa %xmm2, %xmm3
pcmpgtd %xmm0, %xmm3
pcmpeqd %xmm0, %xmm2
pshufd $0xf5, %xmm2, %xmm4     # xmm4 = xmm2[1,1,3,3]
pand %xmm3, %xmm4
pshufd $0xf5, %xmm3, %xmm2     # xmm2 = xmm3[1,1,3,3]
por %xmm4, %xmm2
movd %xmm2, %edx
notl %edx
testb $0x1, %dl
je 0xd37c
movl $0x0, -0x100(%r14)
pxor %xmm6, %xmm2
pextrw $0x4, %xmm2, %edx
testb $0x1, %dl
je 0xd392
movl $0x0, -0x80(%r14)
por 0x152b6(%rip), %xmm1    # 0x22650
pxor %xmm5, %xmm1
movdqa %xmm1, %xmm2
pcmpgtd %xmm0, %xmm2
pcmpeqd %xmm0, %xmm1
pshufd $0xf5, %xmm1, %xmm3     # xmm3 = xmm1[1,1,3,3]
pand %xmm2, %xmm3
pshufd $0xf5, %xmm2, %xmm1     # xmm1 = xmm2[1,1,3,3]
por %xmm3, %xmm1
pxor %xmm6, %xmm1
pextrw $0x0, %xmm1, %edx
testb $0x1, %dl
je 0xd3d1
movl $0x0, (%r14)
pextrw $0x4, %xmm1, %edx
testb $0x1, %dl
je 0xd3e6
movl $0x0, 0x80(%r14)
addq $0x4, %rcx
addq $0x200, %r14            # imm = 0x200
cmpq %rcx, %rax
jne 0xd32e
jmp 0xd60a
movq %rcx, 0x20(%rsp)
movl (%rsp), %esi
callq 0x4b01
movl %ebp, %ecx
movq %rcx, 0x18(%rsp)
cmpl %ebp, %eax
ja 0xd42e
movq 0x8(%r12), %rax
movq 0x8(%rax,%rbx), %rdi
movl (%rsp), %esi
callq 0x4b01
movq %rax, 0x18(%rsp)
movq 0x20(%rsp), %r10
leaq 0x1(%r10), %r11
movq 0x50(%rsp), %rsi
cmpq %rsi, %r11
movdqa 0x14d79(%rip), %xmm5    # 0x221c0
pcmpeqd %xmm6, %xmm6
jae 0xd5fb
movq %r11, 0x68(%rsp)
addl %r13d, %r14d
imulq %r10, %r14
shlq $0x6, %r14
andq $-0x80, %r14
movq 0x38(%rsp), %rax
leaq (%rax,%r14), %rcx
movq 0x18(%rsp), %rax
leal -0x1(%rax), %edx
movq %rdx, 0x90(%rsp)
movl %eax, %eax
movq %rax, 0x88(%rsp)
addq 0x48(%rsp), %r14
movq 0x40(%rsp), %rdx
movq %rcx, 0x80(%rsp)
movq %rdx, %r13
shlq $0x7, %r13
addq %rcx, %r13
movq 0x8(%r12), %rax
imulq $0x58, %rdx, %rbx
movq 0x8(%rax,%rbx), %rdi
cmpq %r15, %rdi
jae 0xd4c4
movl $0x0, -0x6c(%r13)
jmp 0xd5cc
movq %rdx, 0x58(%rsp)
movl (%rsp), %esi
callq 0x4b01
movl %eax, %ecx
movl %ebp, %eax
cmpl %ebp, %ecx
ja 0xd4eb
movq 0x8(%r12), %rax
movq 0x8(%rax,%rbx), %rdi
movl (%rsp), %esi
callq 0x4b01
movl %eax, %r15d
movq 0x18(%rsp), %rdx
imull %edx, %r15d
movq 0x20(%rsp), %rcx
movl %ecx, -0x80(%r13)
movq 0x58(%rsp), %rcx
movl %ecx, -0x7c(%r13)
movl %edx, -0x78(%r13)
movq 0x90(%rsp), %rcx
addl %eax, %ecx
cmpl %ebp, %ecx
cmovael %ebp, %ecx
movl %eax, -0x74(%r13)
movl %ecx, -0x70(%r13)
movl %r15d, -0x6c(%r13)
movl $0x0, -0x68(%r13)
movb $0x0, -0x64(%r13)
movl %eax, %eax
imulq 0x88(%rsp), %rax
cmpq %r15, %rax
jne 0xd650
movl %ecx, %r12d
movq $-0x4, %rbx
movl $0x8, %esi
movq %r15, %rdi
callq 0x2290
movq %rax, %rbp
movq %rax, (%r14,%rbx,8)
movl $0x8, %esi
movq %r12, %rdi
callq 0x2290
movq %rax, 0x20(%r14,%rbx,8)
testq %rbp, %rbp
je 0xd64b
testq %rax, %rax
je 0xd64b
incq %rbx
jne 0xd553
pxor %xmm0, %xmm0
movdqu %xmm0, -0x10(%r13)
movdqu %xmm0, -0x20(%r13)
movl 0x34(%rsp), %ebp
movq 0x78(%rsp), %r12
movq 0x50(%rsp), %rsi
movq 0x70(%rsp), %r15
movdqa 0x14c05(%rip), %xmm5    # 0x221c0
pcmpeqd %xmm6, %xmm6
movq 0x80(%rsp), %rcx
movq 0x58(%rsp), %rdx
incq %rdx
subq $-0x80, %r14
cmpl %edx, %esi
jne 0xd49a
movl 0x2c(%rsp), %r13d
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movl 0x4(%rsp), %r9d
movq 0x20(%rsp), %r10
movq 0x68(%rsp), %r11
jmp 0xd60a
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %r8
movl 0x4(%rsp), %r9d
movl %r10d, %r14d
notl %r14d
incq 0x40(%rsp)
incl %r8d
movl $0x80, %eax
addq %rax, 0x48(%rsp)
decl %r9d
addq %rax, %rdi
movq %r11, %rcx
cmpq %rsi, %r11
jne 0xd2b6
movq 0x60(%rsp), %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2886
leaq 0x15041(%rip), %rdi     # 0x22698
leaq 0x1504e(%rip), %rsi     # 0x226ac
leaq 0x1504e(%rip), %rcx     # 0x226b3
movl $0xc9, %edx
callq 0x21c0