// File: /workspace/github_c_makefile_star2_O0/c-zhou[P]oatk/path.c
// Function: find_seeds_in_pure_graph
static uint32_t find_seeds_in_pure_graph(clust_t *clusts, uint32_t n_clust, clust_dp_t *comp_dps, uint32_t nv, OG_TYPE_t og_t, double min_mean, 
        double max_mean, double fold_thresh, uint32_t min_size, uint32_t max_size, double *_c_mean, OG_TYPE_t *og_seeds, int verbose)
{
    uint32_t i, j, c, v, seed, n_seeds, l_seeds, *seed_clust, *gseq_clust;
    uint64_t *gene_clust;
    double c_mean, min_mean1, max_mean1;

    // count number of best genes in each coverage cluster
    MYCALLOC(gseq_clust, n_clust);
    MYCALLOC(gene_clust, n_clust);
    for (i = 0; i < n_clust; ++i) {
        for (j = 0; j < clusts[i].n_dps; ++j) {
            v = clusts[i].dps[j];
            gene_clust[i] += comp_dps[v].gene_num[og_t];
            if (comp_dps[v].gene_num[og_t] > 0)
                gseq_clust[i] += comp_dps[v].size;
        }
        gene_clust[i] <<= 32;
        gene_clust[i] |= i;
        // a simple rule to decide if
        // all sequences in a cluster should be added together
        if (gseq_clust[i] > 0.5 * clusts[i].size)
            gseq_clust[i] = clusts[i].size;
    }
    // sort clusters by number of best genes in descending order
    qsort(gene_clust, n_clust, sizeof(uint64_t), u64_cmpfunc_r);
    
    // collect seeds in each cluster
    MYCALLOC(seed_clust, n_clust);
    min_mean1 = max_mean1 = 0;
    n_seeds = l_seeds = 0;
    for (i = 0; i < n_clust; ++i) {
        if ((gene_clust[i] >> 32) == 0)
            // no gene
            break;
        c = (uint32_t) gene_clust[i]; // cluster index
        if (clusts[c].og_type != og_t)
            // not the right organelle type
            continue;
        c_mean = clusts[c].mean;
        if (c_mean < min_mean && c_mean > max_mean)
            // coverage not in range
            continue;
        if (l_seeds + gseq_clust[c] > max_size)
            // too much sequence
            continue;
        seed = 0;
        if (n_seeds == 0) {
            // major cluster
            // mean coverage not set yet
            min_mean1 = c_mean;
            max_mean1 = c_mean;
            seed = 1;
        } else {
            // secondary clusters
            if (gseq_clust[c] >= min_size) {
                // this is a large cluster
                // make it a seed only when
                // the fold difference is within the range
                if (c_mean >= min_mean1 && c_mean <= max_mean1) {
                    // mean coverage is within the old range
                    seed = 1;
                } else if (fabs(log(min_mean1/c_mean)) <= fold_thresh &&
                        fabs(log(max_mean1/c_mean)) <= fold_thresh) {
                    // mean coverage is within the new range
                    // update coverage
                    if (c_mean < min_mean1)
                        min_mean1 = c_mean;
                    if (c_mean > max_mean1)
                        max_mean1 = c_mean;
                    seed = 1;
                }
            } else {
                // this is a small cluster
                // make it a seed
                // but do not change the coverage
                seed = 1;
            }
        }
        if (seed) {
            seed_clust[c] = 1;
            n_seeds += 1;
            l_seeds += gseq_clust[c];
        }
    }
    
    MYBZERO(og_seeds, nv);
    // process clusters
    int all_seq;
    for (i = 0; i < n_clust; ++i) {
        if (!seed_clust[i])
            continue;
        // not always to add all sequences
        all_seq = clusts[i].size == gseq_clust[i];
        for (j = 0; j < clusts[i].n_dps; ++j)
            if (all_seq || 
                    comp_dps[clusts[i].dps[j]].gene_num[og_t] > 0)
                og_seeds[clusts[i].dps[j]] = og_t;
    }

    // process each unclassified individual sequence
    uint32_t ext_l, ext_n;
    OG_TYPE_t og_t1, *og_seeds1;
    og_t1 = OG_UNCLASSIFIED;
    if (og_t == OG_MITO)
        og_t1 = OG_PLTD;
    else if (og_t == OG_PLTD)
        og_t1 = OG_MITO;
    MYCALLOC(og_seeds1, nv);
    ext_l = ext_n = 0;
    for (i = 0; i < nv; ++i) {
        c_mean = comp_dps[i].val;
        if (!og_seeds[i] && 
                (og_t1 == OG_UNCLASSIFIED || 
                 comp_dps[i].gene_num[og_t1] == 0 ||
                 comp_dps[i].gene_num[og_t] > 0) &&
                c_mean >= min_mean &&
                c_mean <= max_mean &&
                fabs(log(min_mean1/c_mean)) <= fold_thresh) {
            ext_l += comp_dps[i].size;
            ext_n += 1;
            og_seeds1[i] = og_t;
        }
    }
    // only add extra sequences if total size within threshold
    if (l_seeds + ext_l <= max_size) {
        for (i = 0; i < nv; ++i)
            if (og_seeds1[i])
                og_seeds[i] = og_seeds1[i];
        n_seeds += ext_n;
        l_seeds += ext_l;
    }

    free(gseq_clust);
    free(gene_clust);
    free(seed_clust);
    free(og_seeds1);
    
    if (verbose > 2)
        fprintf(stderr, "[M::%s] [%s] - seeds number: %u; seeds length: %u; seeds coverage: %.3f - %.3f\n", 
                __func__, OG_TYPES[og_t], n_seeds, l_seeds, min_mean1, max_mean1);

    if (_c_mean)
        *_c_mean = min_mean1;
    
    return l_seeds;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movsd %xmm1, -0x30(%rbp)
movsd %xmm2, -0x38(%rbp)
movl %r9d, -0x3c(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2240
movq %rax, -0x68(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %edi
movl $0x8, %esi
callq 0x2240
movq %rax, -0x70(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x11a44
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
movl -0x40(%rbp), %edx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jae 0x119be
movq -0x8(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl -0x44(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x4c(%rbp)
movq -0x18(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x20(%rbp), %ecx
movslq 0x18(%rax,%rcx,4), %rdx
movq -0x70(%rbp), %rax
movl -0x40(%rbp), %ecx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x20(%rbp), %ecx
cmpl $0x0, 0x18(%rax,%rcx,4)
jle 0x119ae
movq -0x18(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
movq -0x68(%rbp), %rax
movl -0x40(%rbp), %ecx
addl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x119b0
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1191e
movq -0x70(%rbp), %rax
movl -0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
movl %eax, %ecx
movq -0x70(%rbp), %rax
movq (%rax,%rcx,8), %rdx
orq %rcx, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x68(%rbp), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cvtsi2sd %rax, %xmm0
movq -0x8(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cvtsi2sdl 0x10(%rax), %xmm2
movsd 0x11aa9(%rip), %xmm1    # 0x234b8
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x11a34
movq -0x8(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %edx
movq -0x68(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x11a36
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1190b
movq -0x70(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, %esi
movl $0x8, %edx
leaq -0x33b9(%rip), %rcx     # 0xe6a0
callq 0x20c0
movl -0xc(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2240
movq %rax, -0x60(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x88(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
movl $0x0, -0x58(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x11c80
movq -0x70(%rbp), %rax
movl -0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
cmpq $0x0, %rax
jne 0x11abf
jmp 0x11c80
movq -0x70(%rbp), %rax
movl -0x40(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl -0x48(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x40(%rax), %eax
cmpl -0x20(%rbp), %eax
je 0x11ae8
jmp 0x11c72
movq -0x8(%rbp), %rax
movl -0x48(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movsd 0x18(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x78(%rbp), %xmm1
movsd -0x28(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x11b21
movsd -0x78(%rbp), %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x11b21
jmp 0x11c72
movl -0x58(%rbp), %eax
movq -0x68(%rbp), %rcx
movl -0x48(%rbp), %edx
addl (%rcx,%rdx,4), %eax
cmpl 0x10(%rbp), %eax
jbe 0x11b38
jmp 0x11c72
movl $0x0, -0x50(%rbp)
cmpl $0x0, -0x54(%rbp)
jne 0x11b68
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x11c43
movq -0x68(%rbp), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x3c(%rbp), %eax
jb 0x11c3a
movsd -0x78(%rbp), %xmm0
ucomisd -0x80(%rbp), %xmm0
jb 0x11ba6
movsd -0x78(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11ba6
movl $0x1, -0x50(%rbp)
jmp 0x11c38
movsd -0x80(%rbp), %xmm0
divsd -0x78(%rbp), %xmm0
callq 0x2200
movaps %xmm0, %xmm1
movaps 0x119a1(%rip), %xmm0    # 0x23560
pand %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11c36
movsd -0x88(%rbp), %xmm0
divsd -0x78(%rbp), %xmm0
callq 0x2200
movaps %xmm0, %xmm1
movaps 0x11976(%rip), %xmm0    # 0x23560
pand %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11c36
movsd -0x78(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x11c13
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x78(%rbp), %xmm0
ucomisd -0x88(%rbp), %xmm0
jbe 0x11c2f
movsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl $0x1, -0x50(%rbp)
jmp 0x11c38
jmp 0x11c41
movl $0x1, -0x50(%rbp)
jmp 0x11c43
cmpl $0x0, -0x50(%rbp)
je 0x11c70
movq -0x60(%rbp), %rax
movl -0x48(%rbp), %ecx
movl $0x1, (%rax,%rcx,4)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x68(%rbp), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,4), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
jmp 0x11c72
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x11a99
movq 0x20(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x21c0
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x11d76
movq -0x60(%rbp), %rax
movl -0x40(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jne 0x11cb9
jmp 0x11d68
movq -0x8(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x68(%rbp), %rcx
movl -0x40(%rbp), %edx
cmpl (%rcx,%rdx,4), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x8c(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
movl -0x40(%rbp), %edx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jae 0x11d66
cmpl $0x0, -0x8c(%rbp)
jne 0x11d36
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl -0x40(%rbp), %edx
imulq $0x48, %rdx, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movl -0x44(%rbp), %edx
movslq (%rcx,%rdx,4), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x20(%rbp), %ecx
cmpl $0x0, 0x18(%rax,%rcx,4)
jle 0x11d59
movl -0x20(%rbp), %edx
movq 0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movl -0x40(%rbp), %esi
imulq $0x48, %rsi, %rsi
addq %rsi, %rcx
movq 0x8(%rcx), %rcx
movl -0x44(%rbp), %esi
movslq (%rcx,%rsi,4), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x11d5b
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x11ce9
jmp 0x11d68
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x11c9b
movl $0x0, -0x98(%rbp)
cmpl $0x1, -0x20(%rbp)
jne 0x11d92
movl $0x2, -0x98(%rbp)
jmp 0x11da4
cmpl $0x2, -0x20(%rbp)
jne 0x11da2
movl $0x1, -0x98(%rbp)
jmp 0x11da4
movl -0x1c(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2240
movq %rax, -0xa0(%rbp)
movl $0x0, -0x94(%rbp)
movl $0x0, -0x90(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x11eda
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
movq 0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jne 0x11eca
cmpl $0x0, -0x98(%rbp)
je 0x11e4a
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x98(%rbp), %ecx
cmpl $0x0, 0x18(%rax,%rcx,4)
je 0x11e4a
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl -0x20(%rbp), %ecx
cmpl $0x0, 0x18(%rax,%rcx,4)
jle 0x11eca
movsd -0x78(%rbp), %xmm0
ucomisd -0x28(%rbp), %xmm0
jb 0x11eca
movsd -0x78(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11eca
movsd -0x80(%rbp), %xmm0
divsd -0x78(%rbp), %xmm0
callq 0x2200
movaps %xmm0, %xmm1
movaps 0x116e1(%rip), %xmm0    # 0x23560
pand %xmm0, %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0x11eca
movq -0x18(%rbp), %rax
movl -0x40(%rbp), %ecx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x90(%rbp), %eax
movl %eax, -0x90(%rbp)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
movl -0x20(%rbp), %edx
movq -0xa0(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x11ecc
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x11dd5
movl -0x58(%rbp), %eax
addl -0x90(%rbp), %eax
cmpl 0x10(%rbp), %eax
ja 0x11f43
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x11f2b
movq -0xa0(%rbp), %rax
movl -0x40(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
je 0x11f1e
movq -0xa0(%rbp), %rax
movl -0x40(%rbp), %ecx
movl (%rax,%rcx,4), %edx
movq 0x20(%rbp), %rax
movl -0x40(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x11f20
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x11eef
movl -0x94(%rbp), %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x90(%rbp), %eax
addl -0x58(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x68(%rbp), %rdi
callq 0x2060
movq -0x70(%rbp), %rdi
callq 0x2060
movq -0x60(%rbp), %rdi
callq 0x2060
movq -0xa0(%rbp), %rdi
callq 0x2060
cmpl $0x2, 0x28(%rbp)
jle 0x11fb4
movq 0x18081(%rip), %rax     # 0x29ff8
movq (%rax), %rdi
movl -0x20(%rbp), %eax
movl %eax, %ecx
leaq 0x17bea(%rip), %rax     # 0x29b70
movq (%rax,%rcx,8), %rcx
movl -0x54(%rbp), %r8d
movl -0x58(%rbp), %r9d
movsd -0x80(%rbp), %xmm0
movsd -0x88(%rbp), %xmm1
leaq 0x12563(%rip), %rsi     # 0x24509
leaq 0x125ac(%rip), %rdx     # 0x24559
movb $0x2, %al
callq 0x2290
cmpq $0x0, 0x18(%rbp)
je 0x11fc8
movsd -0x80(%rbp), %xmm0
movq 0x18(%rbp), %rax
movsd %xmm0, (%rax)
movl -0x58(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)