// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]yahs/link.c
// Function: inter_link_mat_from_file
inter_link_mat_t *inter_link_mat_from_file(const char *f, cov_norm_t *cov_norm, asm_dict_t *dict, re_cuts_t *re_cuts, uint32_t resolution, uint32_t radius, uint8_t mq)
{
    uint32_t i, j, k, m, n, i0, i1, b0, b1;
    uint64_t p0, p1, pair_n, pair_c, inter_c, radius_c, noise_c;
    int64_t magic_number;
    uint8_t buffer[BUFF_SIZE * 17];
    double l0, l1, c, a, na[4], nc[4];
    inter_link_mat_t *link_mat;
    inter_link_t *link;
    FILE *fp;

    fp = fopen(f, "r");
    if (fp == NULL)
        return 0;

    m = fread(&magic_number, sizeof(int64_t), 1, fp);
    if (m != 1) bin_fread_error();
    if (!is_valid_bin_header(magic_number)) {
        fprintf(stderr, "[E::%s] not a valid BIN file\n", __func__);
        return 0;
    }
    file_seek_skip_sdict(fp);
    m = fread(&pair_n, sizeof(uint64_t), 1, fp);
    if (m != 1) bin_fread_error();

    n = dict->n;
    link_mat = inter_link_mat_init(dict, resolution, radius);
    pair_c = inter_c = radius_c = 0;

    while (pair_c < pair_n) {
        m = fread(buffer, sizeof(uint8_t), BUFF_SIZE * 17, fp);

        for (i = 0; i < m && pair_c < pair_n; i += 17, ++pair_c) {
            if (*(uint8_t *) (buffer + i + 16) < mq)
                continue;
            
            sd_coordinate_conversion(dict, *(uint32_t *) (buffer + i),     *(uint32_t *) (buffer + i + 4),  &i0, &p0, 0);
            sd_coordinate_conversion(dict, *(uint32_t *) (buffer + i + 8), *(uint32_t *) (buffer + i + 12), &i1, &p1, 0);

            if (i0 != i1 && i0 != UINT32_MAX) {
                c = cov_norm->norm[*(uint32_t *) (buffer + i)][*(uint32_t *) (buffer + i + 4) / cov_norm->w] *
                    cov_norm->norm[*(uint32_t *) (buffer + i + 8)][*(uint32_t *) (buffer + i + 12) / cov_norm->w];

                if (i0 > i1) {
                    SWAP(uint32_t, i0, i1);
                    SWAP(uint64_t, p0, p1);
                }

                link = &link_mat->links[(long) (n * 2 - i0 - 3) * i0 / 2 + i1 - 1];

                if (link->n == 0)
                    continue;

                l0 = dict->s[i0].len / 2.;
                l1 = dict->s[i1].len / 2.;
                
                if (p0 >= l0 && p1 < l1) {
                    // i0(-) -> i1(+)
                    b0 = (uint32_t) ((2 * l0 - p0) / resolution);
                    b1 = (uint32_t) ((double) p1 / resolution);
                    if (b0 < link->b0 && b1 < link->b1 && b0 + b1 < radius) {
                        k = (long) (MAX(1, b0) - 1) * link->b1 + b1;
                        // link->link[0][k] += 1.;
                        link->link[0][k] += c;
                        ++radius_c;
                    }
                } else if(p0 >= l0 && p1 >= l1) {
                    // i0(-) -> i1(-)
                    b0 = (uint32_t) ((2 * l0 - p0) / resolution);
                    b1 = (uint32_t) ((2 * l1 - p1) / resolution);
                    if (b0 < link->b0 && b1 < link->b1 && b0 + b1 < radius) {
                        k = (long) (MAX(1, b0) - 1) * link->b1 + b1;
                        // link->link[1][k] += 1.;
                        link->link[1][k] += c;
                        ++radius_c;
                    }
                } else if(p0 < l0 && p1 < l1) {
                    // i0(+) -> i1(+)
                    b0 = (uint32_t) ((double) p0 / resolution);
                    b1 = (uint32_t) ((double) p1 / resolution);
                    if (b0 < link->b0 && b1 < link->b1 && b0 + b1 < radius) {
                        k = (long) (MAX(1, b0) - 1) * link->b1 + b1;
                        // link->link[2][k] += 1.;
                        link->link[2][k] += c;
                        ++radius_c;
                    }
                } else if(p0 < l0 && p1 >= l1) {
                    // i0(+) -> i1(-)
                    b0 = (uint32_t) ((double) p0 / resolution);
                    b1 = (uint32_t) ((2 * l1 - p1) / resolution);
                    if (b0 < link->b0 && b1 < link->b1 && b0 + b1 < radius) {
                        k = (long) (MAX(1, b0) - 1) * link->b1 + b1;
                        // link->link[3][k] += 1.;
                        link->link[3][k] += c;
                        ++radius_c;
                    }
                }

                ++inter_c;
            }
        }
    }

#ifdef DEBUG
    fprintf(stderr, "[DEBUG::%s] %lu read pairs processed, %lu inter links \n", __func__, pair_c, inter_c);
    fprintf(stderr, "[DEBUG::%s] within radius %d: %lu\n", __func__, radius, radius_c);
#endif
    fclose(fp);

    // TODO normalise links by cell size
    inter_link_mat_normalise(link_mat, dict, re_cuts, resolution, radius);

    // calculate noise level
    noise_c = a = 0;
    for (i = 0; i < link_mat->n; ++i) {
        memset(nc, 0, sizeof(nc));
        memset(na, 0, sizeof(na));
        link = &link_mat->links[i];
        for (j = 0; j < link->n; ++j) {
            for (k = 0; k < 4; ++k) {
                if (link->link[k][j] >= 0) {
                    nc[k] += link->link[k][j];
                    na[k] += 1.;
                }
            }
        }
        
        j = 0;
        for (k = 1; k < 4; ++k)
            if (nc[k] < nc[j])
                j = k;
        noise_c += nc[j];
        a += na[j];
    }
    link_mat->noise = a > 0? noise_c / a : 0;
#ifdef DEBUG_NOISE
    fprintf(stderr, "[DEBUG_NOISE::%s] noise links: %lu; area: %.12f; noise estimation: %.12f\n", __func__, noise_c, a, link_mat->noise);
#endif

    return link_mat;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x110d8, %rsp          # imm = 0x110D8
movl %r9d, 0x4(%rsp)
movl %r8d, (%rsp)
movq %rcx, %rbx
movq %rdx, 0x10(%rsp)
movq %rsi, 0x60(%rsp)
leaq 0x1536f(%rip), %rsi     # 0x2240f
callq 0x23e0
testq %rax, %rax
je 0xda60
movq %rax, %r14
leaq 0x80(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x20f0
cmpl $0x1, %eax
je 0xd0d7
xorl %eax, %eax
callq 0x4c81
movq 0x80(%rsp), %rdi
callq 0x4c6e
testl %eax, %eax
je 0xda5b
movq %rbx, 0x40(%rsp)
movq %r14, %rdi
callq 0x15804
leaq 0x88(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x20f0
cmpl $0x1, %eax
je 0xd11f
xorl %eax, %eax
callq 0x4c81
movq 0x10(%rsp), %rdi
movl (%rdi), %ebx
movl (%rsp), %ebp
movl %ebp, %esi
movl 0x4(%rsp), %edx
callq 0xc4bc
movq %rax, 0x68(%rsp)
movq 0x88(%rsp), %r15
movl %ebp, %eax
movq %rax, 0x30(%rsp)
testq %r15, %r15
je 0xd54c
leal -0x3(,%rbx,2), %eax
movl %eax, 0x58(%rsp)
cvtsi2sdq 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
xorl %ebx, %ebx
movq %r14, 0x48(%rsp)
movl $0x1, %esi
movl $0x11000, %edx          # imm = 0x11000
leaq 0xd0(%rsp), %rdi
movq %r14, %rcx
callq 0x20f0
movq %rax, %rbp
testl %ebp, %ebp
je 0xd53e
movl $0x11, %r14d
leal -0x11(%r14), %r13d
movb 0x11110(%rsp), %al
cmpb %al, 0xe0(%rsp,%r13)
jb 0xd529
movl 0xd0(%rsp,%r13), %esi
movl 0xd4(%rsp,%r13), %edx
movq %r14, 0x20(%rsp)
movq %r15, %r12
movq 0x10(%rsp), %r15
movq %r15, %rdi
movq %rsi, 0x38(%rsp)
movl %edx, 0x50(%rsp)
leaq 0x1c(%rsp), %rcx
leaq 0x70(%rsp), %r8
xorl %r9d, %r9d
callq 0x13d50
movl 0xd8(%rsp,%r13), %esi
movl 0xdc(%rsp,%r13), %r13d
movq %r15, %rdi
movq %r12, %r15
movq 0x20(%rsp), %r14
movq %rsi, %r12
movl %r13d, %edx
leaq 0x18(%rsp), %rcx
leaq 0x28(%rsp), %r8
xorl %r9d, %r9d
callq 0x13d50
movl 0x1c(%rsp), %ecx
movl 0x18(%rsp), %esi
cmpl %esi, %ecx
sete %al
cmpl $-0x1, %ecx
sete %dl
orb %al, %dl
jne 0xd529
movq 0x60(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x38(%rsp), %rdx
movq (%rdi,%rdx,8), %r8
movl 0x8(%rax), %r9d
movl 0x50(%rsp), %eax
xorl %edx, %edx
divl %r9d
movsd (%r8,%rax,8), %xmm0
movq (%rdi,%r12,8), %rdi
movl %r13d, %eax
xorl %edx, %edx
divl %r9d
mulsd (%rdi,%rax,8), %xmm0
cmpl %esi, %ecx
jbe 0xd293
movl %esi, 0x1c(%rsp)
movl %ecx, 0x18(%rsp)
movq 0x70(%rsp), %rax
movq 0x28(%rsp), %rcx
movq %rcx, 0x70(%rsp)
movq %rax, 0x28(%rsp)
movl 0x1c(%rsp), %edx
movl 0x58(%rsp), %eax
subl %edx, %eax
imulq %rdx, %rax
movl 0x18(%rsp), %ecx
shlq $0x6, %rax
andq $-0x80, %rax
movq 0x68(%rsp), %rsi
addq 0x10(%rsi), %rax
movq %rcx, %rsi
shlq $0x7, %rsi
cmpl $0x0, -0x6c(%rsi,%rax)
je 0xd529
addq %rsi, %rax
movq 0x10(%rsp), %rsi
movq 0x8(%rsi), %rsi
imulq $0x58, %rdx, %rdx
movsd 0x8(%rsi,%rdx), %xmm1
movsd 0x13eda(%rip), %xmm5    # 0x211c0
unpcklps %xmm5, %xmm1            # xmm1 = xmm1[0],xmm5[0],xmm1[1],xmm5[1]
movapd 0x13edf(%rip), %xmm6    # 0x211d0
subpd %xmm6, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movsd 0x13eef(%rip), %xmm4    # 0x211f8
mulsd %xmm4, %xmm2
imulq $0x58, %rcx, %rcx
movsd 0x8(%rsi,%rcx), %xmm3
unpcklps %xmm5, %xmm3            # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
subpd %xmm6, %xmm3
movapd %xmm3, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
addsd %xmm3, %xmm1
mulsd %xmm4, %xmm1
movsd 0x70(%rsp), %xmm4
unpcklps %xmm5, %xmm4            # xmm4 = xmm4[0],xmm5[0],xmm4[1],xmm5[1]
subpd %xmm6, %xmm4
movapd %xmm4, %xmm3
unpckhpd %xmm4, %xmm3            # xmm3 = xmm3[1],xmm4[1]
addsd %xmm4, %xmm3
ucomisd %xmm2, %xmm3
jae 0xd3ba
ucomisd %xmm3, %xmm2
jbe 0xd529
movsd 0x28(%rsp), %xmm5
unpcklps 0x13e5c(%rip), %xmm5    # xmm5 = xmm5[0],mem[0],xmm5[1],mem[1]
subpd 0x13e64(%rip), %xmm5    # 0x211d0
movapd %xmm5, %xmm4
unpckhpd %xmm5, %xmm4            # xmm4 = xmm4[1],xmm5[1]
addsd %xmm5, %xmm4
ucomisd %xmm4, %xmm1
jbe 0xd4c1
divsd 0x8(%rsp), %xmm3
cvttsd2si %xmm3, %rcx
cmpl %ecx, -0x78(%rax)
jbe 0xd529
divsd 0x8(%rsp), %xmm4
cvttsd2si %xmm4, %rdx
leal (%rdx,%rcx), %esi
cmpl 0x4(%rsp), %esi
jae 0xd529
movl -0x74(%rax), %esi
movq $-0x50, %rdi
jmp 0xd41f
movsd 0x28(%rsp), %xmm5
unpcklps 0x13df9(%rip), %xmm5    # xmm5 = xmm5[0],mem[0],xmm5[1],mem[1]
subpd 0x13e01(%rip), %xmm5    # 0x211d0
movapd %xmm5, %xmm4
unpckhpd %xmm5, %xmm4            # xmm4 = xmm4[1],xmm5[1]
addsd %xmm5, %xmm4
ucomisd %xmm4, %xmm1
jbe 0xd445
addsd %xmm2, %xmm2
subsd %xmm3, %xmm2
divsd 0x8(%rsp), %xmm2
cvttsd2si %xmm2, %rcx
cmpl %ecx, -0x78(%rax)
jbe 0xd529
divsd 0x8(%rsp), %xmm4
cvttsd2si %xmm4, %rdx
leal (%rdx,%rcx), %esi
cmpl 0x4(%rsp), %esi
jae 0xd529
movl -0x74(%rax), %esi
movq $-0x60, %rdi
cmpl %edx, %esi
jbe 0xd529
cmpl $0x1, %ecx
adcl $-0x1, %ecx
imull %esi, %ecx
addl %edx, %ecx
movq (%rax,%rdi), %rax
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
jmp 0xd529
ucomisd %xmm2, %xmm3
jb 0xd34d
movsd 0x28(%rsp), %xmm5
unpcklps 0x13d64(%rip), %xmm5    # xmm5 = xmm5[0],mem[0],xmm5[1],mem[1]
subpd 0x13d6c(%rip), %xmm5    # 0x211d0
movapd %xmm5, %xmm4
unpckhpd %xmm5, %xmm4            # xmm4 = xmm4[1],xmm5[1]
addsd %xmm5, %xmm4
ucomisd %xmm1, %xmm4
jb 0xd34d
addsd %xmm2, %xmm2
subsd %xmm3, %xmm2
divsd 0x8(%rsp), %xmm2
cvttsd2si %xmm2, %rcx
cmpl %ecx, -0x78(%rax)
jbe 0xd529
addsd %xmm1, %xmm1
subsd %xmm4, %xmm1
divsd 0x8(%rsp), %xmm1
cvttsd2si %xmm1, %rdx
leal (%rdx,%rcx), %esi
cmpl 0x4(%rsp), %esi
jae 0xd529
movl -0x74(%rax), %esi
movq $-0x58, %rdi
jmp 0xd41f
ucomisd %xmm3, %xmm2
jbe 0xd529
movsd 0x28(%rsp), %xmm4
unpcklps 0x13cec(%rip), %xmm4    # xmm4 = xmm4[0],mem[0],xmm4[1],mem[1]
subpd 0x13cf4(%rip), %xmm4    # 0x211d0
movapd %xmm4, %xmm2
unpckhpd %xmm4, %xmm2            # xmm2 = xmm2[1],xmm4[1]
addsd %xmm4, %xmm2
ucomisd %xmm1, %xmm2
jb 0xd529
divsd 0x8(%rsp), %xmm3
cvttsd2si %xmm3, %rcx
cmpl %ecx, -0x78(%rax)
jbe 0xd529
addsd %xmm1, %xmm1
subsd %xmm2, %xmm1
divsd 0x8(%rsp), %xmm1
cvttsd2si %xmm1, %rdx
leal (%rdx,%rcx), %esi
cmpl 0x4(%rsp), %esi
jae 0xd529
movl -0x74(%rax), %esi
movq $-0x48, %rdi
jmp 0xd41f
incq %rbx
cmpl %ebp, %r14d
jae 0xd53e
addl $0x11, %r14d
cmpq %r15, %rbx
jb 0xd19b
cmpq %r15, %rbx
movq 0x48(%rsp), %r14
jb 0xd170
movq %r14, %rdi
callq 0x2150
movq 0x10(%rsp), %rdx
movl (%rdx), %ebx
movq 0x40(%rsp), %rdi
movl (%rsp), %esi
callq 0x1d425
movq %rbx, %r11
movq %rax, %rbx
testq %r11, %r11
movq %r11, 0x38(%rsp)
je 0xd893
movl (%rsp), %eax
addl %eax, %eax
movl %eax, (%rsp)
movl %eax, %eax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2sdq 0x30(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leal -0x3(%r11,%r11), %eax
movl $0x1, %ecx
movq %rcx, 0x48(%rsp)
movl $0x20, %ecx
movq %rcx, 0x30(%rsp)
xorl %ecx, %ecx
movabsq $-0x10000000000001, %r13 # imm = 0xFFEFFFFFFFFFFFFF
movl %eax, 0x7c(%rsp)
movl %eax, 0x40(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq %rcx, 0x20(%rsp)
imulq $0x58, %rcx, %r15
movq 0x8(%rax,%r15), %rdi
cmpq 0x50(%rsp), %rdi
jb 0xd873
movl (%rsp), %esi
callq 0x4bf1
movl 0x4(%rsp), %ecx
movl %ecx, %r14d
cmpl %ecx, %eax
ja 0xd616
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax,%r15), %rdi
movl (%rsp), %esi
callq 0x4bf1
movl %eax, %r14d
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movsd 0x8(%rax,%r15), %xmm1
unpcklps 0x13b93(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x13b9b(%rip), %xmm1    # 0x211d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
movsd 0x13baf(%rip), %xmm1    # 0x211f8
mulsd %xmm1, %xmm0
movq 0x20(%rsp), %rax
incq %rax
movq 0x38(%rsp), %r11
cmpq %r11, %rax
movsd 0x13fcb(%rip), %xmm3    # 0x21630
jae 0xd873
movl 0x40(%rsp), %r12d
movq 0x20(%rsp), %rcx
imulq %rcx, %r12
shlq $0x6, %r12
andq $-0x80, %r12
decl %r14d
xorps %xmm1, %xmm1
cvtsi2sd %r14, %xmm1
addq 0x30(%rsp), %r12
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
divsd %xmm2, %xmm0
movapd %xmm3, %xmm8
minsd %xmm0, %xmm8
movl 0x7c(%rsp), %eax
subl %ecx, %eax
imulq %rcx, %rax
shrq %rax
shlq $0x7, %rax
movq %rax, 0x58(%rsp)
movq 0x48(%rsp), %r15
movsd %xmm8, 0x60(%rsp)
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
imulq $0x58, %r15, %rbp
movq 0x8(%rax,%rbp), %rdi
cmpq 0x50(%rsp), %rdi
jb 0xd863
movl (%rsp), %esi
callq 0x4bf1
movl 0x4(%rsp), %edx
movl %edx, %ecx
cmpl %edx, %eax
ja 0xd716
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax,%rbp), %rdi
movl (%rsp), %esi
callq 0x4bf1
movl %eax, %ecx
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
movsd 0x8(%rax,%rbp), %xmm0
unpcklps 0x13a94(%rip), %xmm0    # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x13a9c(%rip), %xmm0    # 0x211d0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0x13ab0(%rip), %xmm4    # 0x211f8
mulsd %xmm4, %xmm1
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rdi
movq 0x58(%rsp), %rax
addq %rdi, %rax
movq %r15, %rdx
shlq $0x7, %rdx
movl -0x6c(%rdx,%rax), %r8d
testq %r8, %r8
movq 0x38(%rsp), %r11
movsd 0x13eb7(%rip), %xmm5    # 0x21630
movsd 0x13eb7(%rip), %xmm6    # 0x21638
movsd 0x13eb7(%rip), %xmm7    # 0x21640
movsd 0x60(%rsp), %xmm8
je 0xd863
leal -0x1(%rcx), %r9d
xorps %xmm0, %xmm0
cvtsi2sd %r9, %xmm0
movsd 0x8(%rsp), %xmm2
mulsd %xmm2, %xmm0
subsd %xmm0, %xmm1
divsd %xmm2, %xmm1
movapd %xmm5, %xmm0
minsd %xmm1, %xmm0
addq %r12, %rdi
xorl %esi, %esi
movl %esi, %eax
xorl %edx, %edx
divl %ecx
movapd %xmm8, %xmm1
cmpl %r14d, %eax
je 0xd7d5
movapd %xmm5, %xmm1
cmpl %r9d, %edx
jne 0xd7de
mulsd %xmm0, %xmm1
movapd %xmm1, %xmm2
cmpltsd %xmm4, %xmm2
movapd %xmm5, %xmm3
testq %rbx, %rbx
je 0xd80c
movq 0x20(%rsp), %r10
movq (%rbx,%r10,8), %r10
movl %eax, %eax
movsd (%r10,%rax,8), %xmm3
movq (%rbx,%r15,8), %rax
movl %edx, %edx
mulsd (%rax,%rdx,8), %xmm3
andnpd %xmm1, %xmm2
movapd %xmm3, %xmm1
cmpltsd %xmm6, %xmm1
andnpd %xmm3, %xmm1
mulsd %xmm2, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm7
jbe 0xd83c
movq (%rdi,%rax,8), %rdx
movq %r13, (%rdx,%rsi,8)
incq %rax
cmpq $0x4, %rax
jne 0xd829
jmp 0xd857
movq (%rdi,%rax,8), %rdx
movsd (%rdx,%rsi,8), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, (%rdx,%rsi,8)
incq %rax
cmpq $0x4, %rax
jne 0xd83c
incq %rsi
cmpq %r8, %rsi
jne 0xd7c1
incq %r15
subq $-0x80, %r12
cmpl %r15d, %r11d
jne 0xd6cf
movq 0x20(%rsp), %rcx
incq %rcx
incq 0x48(%rsp)
subq $-0x80, 0x30(%rsp)
decl 0x40(%rsp)
cmpq %r11, %rcx
jne 0xd5c8
testq %rbx, %rbx
je 0xd8bb
testq %r11, %r11
je 0xd8b3
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
callq 0x2060
incq %r14
cmpq %r14, 0x38(%rsp)
jne 0xd8a0
movq %rbx, %rdi
callq 0x2060
movq 0x68(%rsp), %rax
movl (%rax), %ebx
xorpd %xmm0, %xmm0
xorpd %xmm2, %xmm2
xorpd %xmm1, %xmm1
testq %rbx, %rbx
je 0xda47
movq 0x10(%rax), %rcx
leaq 0x20(%rcx), %rdx
xorl %esi, %esi
xorpd %xmm3, %xmm3
movq 0x138d3(%rip), %xmm4    # 0x211c0
movapd 0x138db(%rip), %xmm5    # 0x211d0
movsd 0x13d4b(%rip), %xmm6    # 0x21648
movsd 0x13d2b(%rip), %xmm7    # 0x21630
xorl %edi, %edi
movapd %xmm3, 0xa0(%rsp)
movapd %xmm3, 0x90(%rsp)
movapd %xmm3, 0xb0(%rsp)
movapd %xmm3, 0xc0(%rsp)
movq %rsi, %r8
shlq $0x7, %r8
movl 0x14(%rcx,%r8), %r8d
testq %r8, %r8
je 0xd991
xorl %r9d, %r9d
xorl %r10d, %r10d
movq (%rdx,%r10,8), %r11
movsd (%r11,%r9,8), %xmm8
ucomisd %xmm2, %xmm8
jb 0xd980
addsd 0x90(%rsp,%r10,8), %xmm8
movsd %xmm8, 0x90(%rsp,%r10,8)
movsd 0xb0(%rsp,%r10,8), %xmm8
addsd %xmm7, %xmm8
movsd %xmm8, 0xb0(%rsp,%r10,8)
incq %r10
cmpq $0x4, %r10
jne 0xd942
incq %r9
cmpq %r8, %r9
jne 0xd93f
xorl %r9d, %r9d
movl $0x1, %r8d
movl %r9d, %r10d
movsd 0x90(%rsp,%r10,8), %xmm8
ucomisd 0x90(%rsp,%r8,8), %xmm8
movl %r8d, %r10d
ja 0xd9b9
movl %r9d, %r10d
incq %r8
movl %r10d, %r9d
cmpq $0x4, %r8
jne 0xd99a
movl %r10d, %r8d
movq %rdi, %xmm8
punpckldq %xmm4, %xmm8    # xmm8 = xmm8[0],xmm4[0],xmm8[1],xmm4[1]
subpd %xmm5, %xmm8
movapd %xmm8, %xmm9
unpckhpd %xmm8, %xmm9            # xmm9 = xmm9[1],xmm8[1]
addsd %xmm8, %xmm9
addsd 0x90(%rsp,%r8,8), %xmm9
cvttsd2si %xmm9, %r9
movq %r9, %r10
subsd %xmm6, %xmm9
cvttsd2si %xmm9, %rdi
sarq $0x3f, %r10
andq %r10, %rdi
addsd 0xb0(%rsp,%r8,8), %xmm1
orq %r9, %rdi
incq %rsi
subq $-0x80, %rdx
cmpq %rbx, %rsi
jne 0xd907
movq %rdi, %xmm3
punpckldq 0x1378d(%rip), %xmm3 # xmm3 = xmm3[0],mem[0],xmm3[1],mem[1]
subpd 0x13795(%rip), %xmm3    # 0x211d0
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addsd %xmm3, %xmm2
divsd %xmm1, %xmm2
cmpltsd %xmm1, %xmm0
andpd %xmm2, %xmm0
movlpd %xmm0, 0x8(%rax)
jmp 0xda62
callq 0x28f5
xorl %eax, %eax
addq $0x110d8, %rsp          # imm = 0x110D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq