// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movl %eax, -0x3c(%rbp)
movl -0xc(%rbp), %eax
shll %eax
movl %eax, -0x44(%rbp)
movl $0x18, %edi
callq 0x2340
movq %rax, -0x18(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x10(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x3c(%rbp), %eax
movl %eax, %edi
shlq $0x7, %rdi
callq 0x2340
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0xde2e
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x44(%rbp), %ecx
cmpq %rcx, %rax
jae 0xdb64
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0xdb5f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x38(%rbp), %eax
shll %eax
subl -0x24(%rbp), %eax
subl $0x3, %eax
movl %eax, %eax
movl -0x24(%rbp), %ecx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x50(%rbp), %rax
movl -0x28(%rbp), %edx
addq %rdx, %rcx
subq $0x1, %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movl $0x0, 0x14(%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xdb03
jmp 0xde20
movl -0x10(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x44(%rbp), %esi
callq 0x2aa0
movl %eax, %ecx
movl -0x54(%rbp), %eax
cmpl %ecx, %eax
jae 0xdb99
movl -0x10(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0xdbba
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x24(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x44(%rbp), %esi
callq 0x2aa0
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x38(%rbp), %eax
jae 0xde1e
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x38(%rbp), %eax
shll %eax
subl -0x24(%rbp), %eax
subl $0x3, %eax
movl %eax, %eax
movl -0x24(%rbp), %ecx
imulq %rcx, %rax
movl $0x2, %ecx
cqto
idivq %rcx
movq %rax, %rcx
movq -0x60(%rbp), %rax
movl -0x28(%rbp), %edx
addq %rdx, %rcx
subq $0x1, %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x28(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x44(%rbp), %ecx
cmpq %rcx, %rax
jae 0xdc49
movq -0x20(%rbp), %rax
movl $0x0, 0x14(%rax)
jmp 0xde10
movl -0x10(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x28(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x44(%rbp), %esi
callq 0x2aa0
movl %eax, %ecx
movl -0x64(%rbp), %eax
cmpl %ecx, %eax
jae 0xdc7e
movl -0x10(%rbp), %eax
movl %eax, -0x68(%rbp)
jmp 0xdc9f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x28(%rbp), %ecx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
movl -0x44(%rbp), %esi
callq 0x2aa0
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
imull -0x34(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x24(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x28(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x30(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x10(%rbp), %eax
movl -0x30(%rbp), %ecx
addl -0x34(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0xdcee
movl -0x10(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0xdcfa
movl -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x10(%rax)
movl -0x40(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x20(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x1c(%rax)
movl -0x40(%rbp), %eax
movl -0x30(%rbp), %ecx
movl -0x34(%rbp), %edx
imulq %rdx, %rcx
cmpq %rcx, %rax
jne 0xdd35
jmp 0xdd54
leaq 0x238fc(%rip), %rdi     # 0x31638
leaq 0x23909(%rip), %rsi     # 0x3164c
movl $0xc9, %edx
leaq 0x23904(%rip), %rcx     # 0x31653
callq 0x21c0
movl $0x0, -0x2c(%rbp)
cmpl $0x4, -0x2c(%rbp)
jae 0xddfc
movl -0x40(%rbp), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x2290
movq %rax, %rdx
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq %rdx, 0x20(%rax,%rcx,8)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x2290
movq %rax, %rdx
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq %rdx, 0x40(%rax,%rcx,8)
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
cmpq $0x0, 0x20(%rax,%rcx,8)
je 0xddc3
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
cmpq $0x0, 0x40(%rax,%rcx,8)
jne 0xddec
movq 0x2b22e(%rip), %rax     # 0x38ff8
movq (%rax), %rdi
leaq 0x238c7(%rip), %rsi     # 0x3169b
leaq 0x238e3(%rip), %rdx     # 0x316be
movb $0x0, %al
callq 0x22c0
movl $0x1, %edi
callq 0x24c0
jmp 0xddee
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0xdd5b
movq -0x20(%rbp), %rdi
addq $0x60, %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x21f0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xdbc9
jmp 0xde20
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xdad0
movq -0x18(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)