// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]yahs/break.c
// Function: detect_break_points_local_joint
bp_t *detect_break_points_local_joint(link_mat_t *link_mat, uint32_t bin_size, double fold_thres, uint32_t flank_size, asm_dict_t *dict, uint32_t *bp_n)
{
    uint32_t i, j, b_n, b_m;
    double mcnt;
    int64_t *link;
    uint32_t s, e, t;
    int8_t a;
    bp_t *bp, *bp1;
    sd_seg_t *segs, seg;
    sd_aseq_t seq;
    
    segs = dict->seg;
    b_n = 0;
    b_m = 16;
    bp = (bp_t *) malloc(b_m * sizeof(bp_t));
    bp1 = 0;
    for (i = 0; i < link_mat->n; ++i) {
        seq = dict->s[i];
        link = link_mat->link[i].link;
        a = 0;
        for (j = 1; j < seq.n; ++j) {
            seg = segs[seq.s + j];
            s = (seg.a - MIN(flank_size, segs[seq.s + j - 1].y)) / bin_size;
            e = (seg.a + MIN(flank_size, seg.y) - 1) / bin_size;
            // s = (MAX(seg.a - MIN(flank_size, segs[seq.s + j - 1].y), 1) - 1) / bin_size;
            // e = (MAX(seg.a + MIN(flank_size, seg.y), 1) - 1) / bin_size;
            t = e - s + 1;
            qsort(link + s, t, sizeof(int64_t), cnt_cmp);
            mcnt = t & 1? (int32_t) link[(e + s) / 2] : ((int32_t) link[(e + s) / 2] + (int32_t) link[(e + s) / 2 + 1]) / 2.;
            mcnt *= fold_thres;
            qsort(link + s, t, sizeof(int64_t), pos_cmp);

            if ((int32_t) link[seg.a / bin_size] < mcnt) {
                if (!a) {
                    if (b_n == b_m) {
                        b_m <<= 1;
                        bp = (bp_t *) realloc(bp, b_m * sizeof(bp_t));
                    }
                    bp1 = bp + b_n;
                    bp1->s = i;
                    bp1->n = 0;
                    bp1->m = 4;
                    bp1->p = (uint64_t *) malloc(bp1->m * sizeof(uint64_t));
                    ++b_n;
                    a = 1;
                }
                add_break_point(bp1, seg.a);
#ifdef DEBUG_LOCAL_BREAK
                fprintf(stderr, "[DEBUG_LOCAL_BREAK::%s] break local joint: %s at %lu (link number %d < %.3f)\n", __func__,
                        seq.name, seg.a, (int32_t) link[seg.a / bin_size], mcnt);
#endif
            }
        }
    }

    *bp_n = b_n;

    return bp;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movsd %xmm0, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x10, -0x40(%rbp)
movl -0x40(%rbp), %eax
imulq $0x18, %rax, %rdi
callq 0x2340
movq %rax, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x565f
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
movl -0x34(%rbp), %eax
imulq $0x58, %rax, %rax
addq %rax, %rsi
leaq -0x100(%rbp), %rdi
movl $0x58, %edx
callq 0x22e0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x34(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x50(%rbp)
movb $0x0, -0x5d(%rbp)
movl $0x1, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0xe8(%rbp), %eax
jae 0x564f
movq -0x78(%rbp), %rsi
movl -0xe4(%rbp), %eax
addl -0x38(%rbp), %eax
movl %eax, %eax
imulq $0x30, %rax, %rax
addq %rax, %rsi
leaq -0xa8(%rbp), %rdi
movl $0x30, %edx
callq 0x22e0
movq -0xa0(%rbp), %rax
movq %rax, -0x108(%rbp)
movl -0x1c(%rbp), %eax
movq -0x78(%rbp), %rcx
movl -0xe4(%rbp), %edx
addl -0x38(%rbp), %edx
subl $0x1, %edx
movl %edx, %edx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x20(%rcx), %eax
jae 0x5403
movl -0x1c(%rbp), %eax
movl %eax, -0x10c(%rbp)
jmp 0x5425
movq -0x78(%rbp), %rax
movl -0xe4(%rbp), %ecx
addl -0x38(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x20(%rax), %eax
movl %eax, -0x10c(%rbp)
movq -0x108(%rbp), %rax
movl -0x10c(%rbp), %ecx
movl %ecx, %ecx
subq %rcx, %rax
movl -0xc(%rbp), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x54(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x118(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x88(%rbp), %eax
jae 0x5466
movl -0x1c(%rbp), %eax
movl %eax, -0x11c(%rbp)
jmp 0x5472
movl -0x88(%rbp), %eax
movl %eax, -0x11c(%rbp)
movq -0x118(%rbp), %rax
movl -0x11c(%rbp), %ecx
movl %ecx, %ecx
addq %rcx, %rax
subq $0x1, %rax
movl -0xc(%rbp), %ecx
xorl %edx, %edx
divq %rcx
movl %eax, -0x58(%rbp)
movl -0x58(%rbp), %eax
subl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x5c(%rbp), %eax
movl %eax, %esi
movl $0x8, %edx
leaq -0x21e(%rip), %rcx      # 0x52a0
callq 0x20e0
movl -0x5c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x54ee
movq -0x50(%rbp), %rax
movl -0x58(%rbp), %ecx
addl -0x54(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x128(%rbp)
jmp 0x552f
movq -0x50(%rbp), %rax
movl -0x58(%rbp), %ecx
addl -0x54(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq -0x50(%rbp), %rcx
movl -0x58(%rbp), %edx
addl -0x54(%rbp), %edx
shrl %edx
addl $0x1, %edx
movl %edx, %edx
movq (%rcx,%rdx,8), %rcx
addl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0x2bc9d(%rip), %xmm1    # 0x311c0
divsd %xmm1, %xmm0
movsd %xmm0, -0x128(%rbp)
movsd -0x128(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x18(%rbp), %xmm0
mulsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x50(%rbp), %rdi
movl -0x54(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
movl -0x5c(%rbp), %eax
movl %eax, %esi
movl $0x8, %edx
leaq -0x30a(%rip), %rcx      # 0x5260
callq 0x20e0
movq -0x50(%rbp), %rax
movq %rax, -0x130(%rbp)
movq -0xa0(%rbp), %rax
movl -0xc(%rbp), %ecx
xorl %edx, %edx
divq %rcx
movq %rax, %rcx
movq -0x130(%rbp), %rax
movq (%rax,%rcx,8), %rax
cvtsi2sd %eax, %xmm1
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x563f
cmpb $0x0, -0x5d(%rbp)
jne 0x562f
movl -0x3c(%rbp), %eax
cmpl -0x40(%rbp), %eax
jne 0x55d4
movl -0x40(%rbp), %eax
shll %eax
movl %eax, -0x40(%rbp)
movq -0x68(%rbp), %rdi
movl -0x40(%rbp), %eax
imulq $0x18, %rax, %rsi
callq 0x23a0
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movl -0x3c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movl -0x34(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x70(%rbp), %rax
movl $0x0, (%rax)
movq -0x70(%rbp), %rax
movl $0x4, 0x4(%rax)
movq -0x70(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2340
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x10(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movb $0x1, -0x5d(%rbp)
movq -0x70(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x5680
jmp 0x5641
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5393
jmp 0x5651
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x533b
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x68(%rbp), %rax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
nopw %cs:(%rax,%rax)