// File: /workspace/github_c_makefile_star2_O1/c-zhou[P]oatk/path.c
// Function: asg_annotation
og_component_v *asg_annotation(hmm_annot_db_t *annot_db, asg_t *asg, int no_trn, int no_rrn, double max_eval,
        int n_core, int min_len, int min_score, int fix_og, int verbose)
{
    uint32_t i, j, k, n, m, v, nv, gid, imax, smax, score, n_seg, n_gene, m_gene, n_clust;
    uint32_t l_seeds[4], n_seeds[4], *comp_v;
    uint64_t *gene_score;
    double *a_s, *annot_score, *seg_score, g_n[4], c_means[4];
    OG_TYPE_t og_t, **og_seeds;
    og_component_t *component_s, *component_g;
    og_component_v *sequence_og, *subgraph_og, *component_v;
    clust_dp_t *comp_dps;
    clust_t *clusts;

    n_gene = annot_db->n;
    n_seg = asg->n_seg;

    if (n_gene == 0) return 0;
    
    m_gene = annot_db->n_gene;

    seg_score = get_sequence_annot_score(annot_db, asg, no_trn, no_rrn, max_eval, 0, verbose);
    sequence_og = annot_sequence_og_type(annot_db, asg, no_trn, no_rrn, max_eval, n_core, min_len, min_score, 0, verbose);
    subgraph_og = annot_subgraph_og_type(annot_db, asg, no_trn, no_rrn, max_eval, n_core, min_len, min_score, 0, verbose);

    MYCALLOC(annot_score, m_gene * 4);
    // collect best annotation score for each gene across the entire graph
    for (i = 0; i < n_seg; ++i) {
        component_s = &sequence_og->a[i];
        gene_score = component_s->g;
        for (j = 0; j < component_s->ng; ++j) {
            gid = gene_score[j] >> 34;
            og_t = (gene_score[j] >> 32) & 0x3;
            score = (uint32_t) gene_score[j];
            
            gid += m_gene * og_t;
            if (annot_score[gid] < (double) score)
                annot_score[gid] = score;
        }
    }

    // check if each subgraph is a mito-pltd mixture
    // separate organelle genomes for mixtures
    double g_diff = 0.85; // relaxation for gene socres
    MYCALLOC(component_v, 1);
    for (i = 0; i < subgraph_og->n; ++i) {
        component_g = &subgraph_og->a[i];
        comp_v = component_g->v;
        nv = component_g->nv;

        MYMALLOC(comp_dps, nv);
        for (j = 0; j < nv; ++j) {
            comp_dps[j].index = j;
            comp_dps[j].val = component_g->asmg->vtx[comp_v[j]].cov;
            comp_dps[j].size = component_g->asmg->vtx[comp_v[j]].len;
            comp_dps[j].clust = -1;
            comp_dps[j].og_type = OG_UNCLASSIFIED;
            MYBZERO(comp_dps[j].gene_num, 4);
        }

        // count genes with best annotation scores
        for (j = 0; j < nv; ++j) {
            component_s = &sequence_og->a[comp_v[j]];
            gene_score = component_s->g;
            // count genes with best annotation scores
            n = 0;
            for (k = 0; k < component_s->ng; ++k) {
                og_t = (gene_score[k] >> 32) & 0x3;
                gid = gene_score[k] >> 34;
                score = (uint32_t) gene_score[k];
                a_s = &annot_score[m_gene * og_t];
                if (score >= min_score &&
                        (double) score >= a_s[gid] * g_diff)
                    // the number of best genes
                    ++comp_dps[j].gene_num[og_t];
            }
        }
        
        // do clustering by sequence overage
        n_clust = dbscan_cluster(comp_dps, nv, DBSCAN_EPS, CLUSTV_EPS);
        clusts = make_cluster(comp_dps, nv, n_clust, min_len);

        // organelle type classification for each coverage cluster
        MYBZERO(l_seeds, 4);
        MYBZERO(n_seeds, 4);
        for (j = 0; j < n_clust; ++j) {
            a_s = clusts[j].og_score;
            MYBZERO(a_s, 4);
            MYBZERO(g_n, 4);
            for (m = 0, n = clusts[j].n_dps; m < n; ++m) {
                v = clusts[j].dps[m];
                for (k = 0; k < 4; ++k) {
                    a_s[k] += seg_score[comp_v[v] * 4 + k];
                    g_n[k] += comp_dps[v].gene_num[k];
                }
            }
            imax = max2(a_s, 4, &smax);
            og_t = a_s[imax] == a_s[smax]? OG_UNCLASSIFIED : imax;
            if (og_t == OG_PLTD && 
                    smax == OG_MITO &&
                    g_n[OG_MITO] > 0 &&
                    (a_s[OG_PLTD] < a_s[OG_MITO] * PLTD_TO_MITO_FST[0] ||
                     (a_s[OG_PLTD] < a_s[OG_MITO] * PLTD_TO_MITO_FST[1] && 
                      clusts[j].size > COMMON_MAX_PLTD_SIZE))) {
                // fix OG_TYPE
                og_t = OG_MITO;
                if (verbose > 2)
                    fprintf(stderr, "[M::%s] OG_TYPE changed from PLTD to MITO: CLUST=%d [M=%.3f N=%d L=%d] [MITO=%.3f PLTD=%.3f MINI=%.3f]\n",
                            __func__, j, clusts[j].mean, clusts[j].n_dps, clusts[j].size, a_s[OG_MITO], a_s[OG_PLTD], a_s[OG_MINI]);
            }
            for (m = 0, n = clusts[j].n_dps; m < n; ++m) {
                v = clusts[j].dps[m];
                if (comp_dps[v].gene_num[og_t] > 0) {
                    l_seeds[og_t] += component_g->asmg->vtx[comp_v[v]].len;
                    n_seeds[og_t] += 1;
                }
            }
            clusts[j].og_type = og_t;
        }

        if (verbose > 2) {
            fprintf(stderr, "[M::%s] subgraph sequence coverage clustering [CLUST=%d]:\n", __func__, n_clust);
            for (j = 0; j < n_clust; ++j) {
                a_s = clusts[j].og_score;
                fprintf(stderr, "[M::%s] CLUST=%d OG=%s [M=%.3f N=%d L=%d] [MITO=%.3f PLTD=%.3f MINI=%.3f]\n", 
                        __func__, j, OG_TYPES[clusts[j].og_type], clusts[j].mean, clusts[j].n_dps, clusts[j].size, 
                        a_s[OG_MITO], a_s[OG_PLTD], a_s[OG_MINI]);
            }
            fprintf(stderr, "[M::%s] subgraph sequence [NV=%d]:\n", __func__, nv);
            qsort(comp_dps, nv, sizeof(clust_dp_t), dpVal_cmpfunc);
            for (j = 0; j < nv; ++j) {
                v = comp_dps[j].index;
                og_t = sequence_og->a[comp_v[v]].type;
                fprintf(stderr, "[M::%s] %s [%s #MG=%d #PG=%d] COV=%.3f LEN=%d CLUST=%d\n", __func__,
                        asg->seg[comp_v[v]].name, OG_TYPES[og_t], comp_dps[j].gene_num[OG_MITO], comp_dps[j].gene_num[OG_PLTD], 
                        comp_dps[j].val, comp_dps[j].size, comp_dps[j].clust);
            }
            qsort(comp_dps, nv, sizeof(clust_dp_t), dpIdx_cmpfunc);
            fprintf(stderr, "[M::%s] subgraph organelle initial classification:\n", __func__);
            for (j = 0; j < 4; ++j)
                fprintf(stderr, "[M::%s] %s: SEED=%u SIZE=%u\n", __func__, OG_TYPES[j], n_seeds[j], l_seeds[j]);
        }

        if (l_seeds[OG_MITO] > 0 && l_seeds[OG_PLTD] > 0) {
            if (l_seeds[OG_MITO] > min_len && l_seeds[OG_PLTD] < min_len) {
                l_seeds[OG_PLTD] = 0;
                n_seeds[OG_PLTD] = 0;
            } else if (l_seeds[OG_MITO] < min_len && l_seeds[OG_PLTD] > min_len) {
                l_seeds[OG_MITO] = 0;
                n_seeds[OG_MITO] = 0;
            }
        }

        MYMALLOC(og_seeds, 4);
        MYCALLOC(og_seeds[0], nv * 4);
        for (j = 1; j < 4; ++j)
            og_seeds[j] = og_seeds[j-1] + nv;
        MYBZERO(c_means, 4);
        if (l_seeds[OG_MITO] > 0 && l_seeds[OG_PLTD] > 0) {
            // is a organelle mixture
            if (verbose > 2)
                fprintf(stderr, "[M::%s] processing subgraph as a organelle mixture\n", __func__);
            double min_mito, max_mito, min_pltd, max_pltd;
            min_mito = min_pltd = 0;
            max_mito = max_pltd = DBL_MAX;
            // TODO implement this subroutine to determine boundary of MITO and PLTD coverage
            find_coverage_bound_in_mixture_graph(clusts, n_clust, comp_dps, nv, COMMON_MAX_MITO_SIZE, COMMON_MAX_PLTD_SIZE, 
                    LOG4_5, &min_mito, &max_mito, &min_pltd, &max_pltd, verbose);
            l_seeds[OG_MITO] = find_seeds_in_pure_graph(clusts, n_clust, comp_dps, nv, OG_MITO, min_mito, max_mito, LOG4_5, 
                    min_len, COMMON_MAX_MITO_SIZE, &c_means[OG_MITO], og_seeds[OG_MITO], verbose);
            l_seeds[OG_PLTD] = find_seeds_in_pure_graph(clusts, n_clust, comp_dps, nv, OG_PLTD, min_pltd, max_pltd, LOG4_5, 
                    min_len, COMMON_MAX_PLTD_SIZE, &c_means[OG_PLTD], og_seeds[OG_PLTD], verbose);
        } else if (l_seeds[OG_MITO] > 0) {
            // pure mito
            if (verbose > 2)
                fprintf(stderr, "[M::%s] processing subgraph as a pure MITO\n", __func__);
            l_seeds[OG_MITO] = find_seeds_in_pure_graph(clusts, n_clust, comp_dps, nv, OG_MITO, 0, DBL_MAX, LOG4_5, 
                    min_len, COMMON_MAX_MITO_SIZE, &c_means[OG_MITO], og_seeds[OG_MITO], verbose);
        } else if (l_seeds[OG_PLTD] > 0) {
            // pure pltd
            // similar to mito
            // but also consider genome size
            if (verbose > 2)
                fprintf(stderr, "[M::%s] processing subgraph as a pure PLTD\n", __func__);
            l_seeds[OG_PLTD] = find_seeds_in_pure_graph(clusts, n_clust, comp_dps, nv, OG_PLTD, 0, DBL_MAX, LOG4_5, 
                    min_len, COMMON_MAX_PLTD_SIZE, &c_means[OG_PLTD], og_seeds[OG_PLTD], verbose);
        } else if (l_seeds[OG_MINI] > 0) {
            // is minicircle
            if (verbose > 2)
                fprintf(stderr, "[M::%s] processing subgraph as a MINICIRCLE\n", __func__);
            l_seeds[OG_MINI] = find_seeds_in_pure_graph(clusts, n_clust, comp_dps, nv, OG_MINI, 0, DBL_MAX, LOG4_5, 
                    min_len, COMMON_MAX_MINICIRCLE_SIZE, &c_means[OG_MINI], og_seeds[OG_MINI], verbose);
        }

        if (l_seeds[OG_MITO] > 0)
            slim_graph(asg, sequence_og, component_g, comp_dps, OG_MITO, og_seeds[OG_MITO],
                    c_means[OG_MITO], min_len, component_v, verbose); 
        if (l_seeds[OG_PLTD] > 0)
            slim_graph(asg, sequence_og, component_g, comp_dps, OG_PLTD, og_seeds[OG_PLTD],
                    c_means[OG_PLTD], min_len, component_v, verbose);
        if (l_seeds[OG_MINI] > 0)
            slim_graph(asg, sequence_og, component_g, comp_dps, OG_MINI, og_seeds[OG_MINI],
                    c_means[OG_MINI], min_len, component_v, verbose);

        free(og_seeds[0]);
        free(og_seeds);
        free(comp_dps);
        for (j = 0; j < n_clust; ++j)
            free(clusts[j].dps);
        free(clusts);
    }
    
    free(seg_score);
    free(annot_score);
    og_component_v_destroy(sequence_og);
    og_component_v_destroy(subgraph_og);

    if (fix_og) fix_og_misclassification(component_v, verbose);
    
    qsort(component_v->a, component_v->n, sizeof(og_component_t), og_cmpfunc_r);

    return component_v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
cmpl $0x0, (%rdi)
je 0xf153
movl %r8d, %ebx
movl %ecx, %ebp
movl %edx, %r14d
movq %rdi, %r15
movl 0x130(%rsp), %eax
movq %rsi, %r13
movl 0x8(%rsi), %r12d
movl 0x18(%rdi), %ecx
movq %rcx, 0x70(%rsp)
movl %ebp, %ecx
movsd %xmm0, 0x18(%rsp)
xorl %r8d, %r8d
movq %r9, 0x60(%rsp)
movl %eax, %r9d
callq 0xc809
movq %rax, 0x68(%rsp)
subq $0x8, %rsp
movq %r15, %rdi
movq %r13, %rsi
movl %r14d, %edx
movl %ebp, %ecx
movsd 0x20(%rsp), %xmm0
movl %ebx, %r8d
movl 0x138(%rsp), %eax
pushq %rax
xorl %eax, %eax
pushq %rax
movl 0x138(%rsp), %eax
pushq %rax
callq 0xcac9
addq $0x20, %rsp
movq %rax, 0x30(%rsp)
subq $0x8, %rsp
movq %r15, %rdi
movq %r13, 0x40(%rsp)
movq %r13, %rsi
movl %r14d, %edx
movq 0x78(%rsp), %r14
movl %ebp, %ecx
movsd 0x20(%rsp), %xmm0
movl %ebx, %r8d
movl 0x128(%rsp), %ebx
movq 0x68(%rsp), %rbp
movl %ebp, %r9d
movl 0x138(%rsp), %eax
pushq %rax
xorl %eax, %eax
pushq %rax
pushq %rbx
callq 0xd476
addq $0x20, %rsp
movq %rax, %r15
leal (,%r14,4), %edi
movl $0x8, %esi
callq 0x3240
movq %rax, 0x50(%rsp)
testq %r12, %r12
je 0xe4f3
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
xorl %ecx, %ecx
movq %rcx, %rsi
shlq $0x6, %rsi
movl 0x28(%rax,%rsi), %edx
testq %rdx, %rdx
je 0xe4eb
movq 0x30(%rax,%rsi), %rsi
xorl %edi, %edi
movq (%rsi,%rdi,8), %r9
movq %r9, %r8
movl %r9d, %r10d
shrq $0x22, %r9
shrq $0x20, %r8
andl $0x3, %r8d
imull %r14d, %r8d
xorps %xmm0, %xmm0
cvtsi2sd %r10, %xmm0
addl %r9d, %r8d
movq 0x50(%rsp), %r9
ucomisd (%r9,%r8,8), %xmm0
jbe 0xe4e3
movq 0x50(%rsp), %r9
movsd %xmm0, (%r9,%r8,8)
incq %rdi
cmpq %rdi, %rdx
jne 0xe4a6
incq %rcx
cmpq %r12, %rcx
jne 0xe48f
movl $0x1, %edi
movl $0x18, %esi
callq 0x3240
movq %rax, %r13
cmpq $0x0, (%r15)
movq 0x50(%rsp), %r12
je 0xf0fb
xorl %eax, %eax
xorl %ecx, %ecx
movq %r15, 0xb0(%rsp)
movq %r13, 0x78(%rsp)
movq %rcx, 0xb8(%rsp)
movq 0x10(%r15), %rcx
shlq $0x6, %rax
leaq (%rcx,%rax), %r15
movq 0x20(%rcx,%rax), %r13
movl 0x1c(%rcx,%rax), %ebp
movq %rbp, %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
movq %rdi, 0x48(%rsp)
callq 0x32f0
movq %r15, %r9
movq %rax, %r15
movq %rbp, 0x8(%rsp)
testq %rbp, %rbp
xorpd %xmm1, %xmm1
movsd 0xafcf(%rip), %xmm2     # 0x19540
movq %r9, 0x40(%rsp)
je 0xe66b
leaq 0x18(%r15), %rax
xorl %ecx, %ecx
movl $0x3fffffff, %r8d       # imm = 0x3FFFFFFF
movq 0x8(%rsp), %r10
movl %ecx, -0x18(%rax)
movq 0x38(%r9), %rdx
movq 0x10(%rdx), %rdx
movl (%r13,%rcx,4), %esi
leaq (%rsi,%rsi,4), %rsi
movl 0x20(%rdx,%rsi,8), %edi
andl %r8d, %edi
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
movsd %xmm0, -0x10(%rax)
movl 0x18(%rdx,%rsi,8), %edx
movl %edx, -0x8(%rax)
movl $0xffffffff, -0x4(%rax) # imm = 0xFFFFFFFF
incq %rcx
movupd %xmm1, (%rax)
movl $0x0, 0x10(%rax)
addq $0x30, %rax
cmpq %rcx, %r10
jne 0xe58d
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rax
xorl %ecx, %ecx
movl (%r13,%rcx,4), %esi
shlq $0x6, %rsi
cmpl $0x0, 0x28(%rax,%rsi)
je 0xe65d
leaq (%rax,%rsi), %rdx
movq 0x30(%rax,%rsi), %rsi
xorl %edi, %edi
movq (%rsi,%rdi,8), %r9
cmpl %ebx, %r9d
jb 0xe651
movq %r9, %r8
shrq $0x20, %r8
movl %r8d, %r10d
andl $0x3, %r10d
imull %r14d, %r10d
leaq (%r12,%r10,8), %r10
movl %r9d, %r11d
xorps %xmm0, %xmm0
cvtsi2sd %r11, %xmm0
shrq $0x22, %r9
movsd (%r10,%r9,8), %xmm1
mulsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jb 0xe651
andl $0x3, %r8d
leaq (%rcx,%rcx,2), %r9
shlq $0x4, %r9
addq %r15, %r9
incl 0x18(%r9,%r8,4)
incq %rdi
movl 0x28(%rdx), %r8d
cmpq %r8, %rdi
jb 0xe5ff
incq %rcx
cmpq 0x8(%rsp), %rcx
jne 0xe5e4
movq 0x8(%rsp), %r12
testl %r12d, %r12d
jle 0xe742
movl $0x30, %edx
movq %r15, %rdi
movq %r12, %rsi
leaq 0xae0(%rip), %rcx       # 0xf16b
callq 0x30c0
movl $0x0, 0x14(%r15)
cmpq $0x1, %r12
movsd 0xaea4(%rip), %xmm4     # 0x19548
movsd 0xaea4(%rip), %xmm5     # 0x19550
movq 0x48(%rsp), %rbx
je 0xe71a
movsd 0x8(%r15), %xmm1
leaq -0x1(%r12), %rax
leaq 0x44(%r15), %rcx
movl $0x1, %edx
movsd -0xc(%rcx), %xmm0
movsd -0x3c(%rcx), %xmm2
mulsd %xmm4, %xmm2
ucomisd %xmm0, %xmm2
jb 0xe6f4
xorps %xmm2, %xmm2
cvtsi2sd %edx, %xmm2
movapd %xmm1, %xmm3
divsd %xmm2, %xmm3
mulsd %xmm5, %xmm3
ucomisd %xmm0, %xmm3
jae 0xe702
movl -0x30(%rcx), %edx
incl %edx
movl %edx, (%rcx)
movl $0x1, %edx
jmp 0xe70d
movl -0x30(%rcx), %esi
movl %esi, (%rcx)
addsd %xmm1, %xmm0
incl %edx
addq $0x30, %rcx
movapd %xmm0, %xmm1
decq %rax
jne 0xe6c7
leaq (%r12,%r12,2), %rax
shlq $0x4, %rax
movl -0x1c(%r15,%rax), %ebp
incl %ebp
movl $0x30, %edx
movq %r15, %rdi
movq %r12, %rsi
leaq 0xa4f(%rip), %rcx       # 0xf18a
callq 0x30c0
jmp 0xe749
xorl %ebp, %ebp
movq 0x48(%rsp), %rbx
movslq %ebp, %rdi
movl $0x48, %esi
callq 0x3240
testl %r12d, %r12d
jle 0xe773
xorl %edx, %edx
movslq 0x14(%r15,%rdx), %rcx
leaq (%rcx,%rcx,8), %rcx
incl 0x4(%rax,%rcx,8)
addq $0x30, %rdx
cmpq %rdx, %rbx
jne 0xe75d
movq %rax, 0x10(%rsp)
movl %ebp, %eax
movq %rax, 0x58(%rsp)
testl %ebp, %ebp
jle 0xe7b8
movq 0x10(%rsp), %rax
leaq 0x8(%rax), %rbx
xorl %r14d, %r14d
movl %r14d, -0x8(%rbx)
movslq -0x4(%rbx), %rdi
shlq $0x2, %rdi
callq 0x32f0
movq %rax, (%rbx)
movl $0x0, -0x4(%rbx)
incq %r14
addq $0x48, %rbx
cmpq %r14, 0x58(%rsp)
jne 0xe78f
testl %r12d, %r12d
movq 0x10(%rsp), %r8
movq 0x48(%rsp), %r9
jle 0xe813
xorl %eax, %eax
movslq 0x14(%r15,%rax), %rcx
movl (%r15,%rax), %edx
leaq (%rcx,%rcx,8), %rcx
movq 0x8(%r8,%rcx,8), %rsi
movslq 0x4(%r8,%rcx,8), %rdi
movl %edx, (%rsi,%rdi,4)
movsd 0x8(%r15,%rax), %xmm0
addsd 0x18(%r8,%rcx,8), %xmm0
movsd %xmm0, 0x18(%r8,%rcx,8)
movl 0x10(%r15,%rax), %edx
addl %edx, 0x10(%r8,%rcx,8)
leal 0x1(%rdi), %edx
movl %edx, 0x4(%r8,%rcx,8)
addq $0x30, %rax
cmpq %rax, %r9
jne 0xe7c9
testl %ebp, %ebp
movl 0x130(%rsp), %r9d
movq 0x68(%rsp), %r10
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
movsd 0xacf6(%rip), %xmm6     # 0x19528
movsd 0xac86(%rip), %xmm7     # 0x194c0
movsd 0xacf5(%rip), %xmm8     # 0x19538
movq 0x40(%rsp), %r11
jle 0xe882
movq 0x58(%rsp), %rax
leaq (,%rax,8), %rax
leaq (%rax,%rax,8), %rax
xorl %ecx, %ecx
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%r8,%rcx), %xmm0
movsd 0x18(%r8,%rcx), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, 0x18(%r8,%rcx)
addq $0x48, %rcx
cmpq %rcx, %rax
jne 0xe85d
movapd %xmm4, 0x20(%rsp)
movapd %xmm4, 0xa0(%rsp)
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
je 0xeb24
movq 0x10(%rsp), %rax
leaq 0x20(%rax), %r12
leaq 0x18(%r15), %rbx
xorl %r14d, %r14d
leaq (%r14,%r14,8), %rax
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rdx
movq %rdx, 0x18(%rsp)
movupd %xmm4, 0x30(%rcx,%rax,8)
movupd %xmm4, 0x20(%rcx,%rax,8)
movapd %xmm4, 0xd0(%rsp)
movapd %xmm4, 0xc0(%rsp)
movl 0x4(%rcx,%rax,8), %ebp
testq %rbp, %rbp
je 0xe94f
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %edi
movl (%r13,%rdi,4), %esi
shll $0x2, %esi
leaq (%r10,%rsi,8), %rsi
leaq (%rdi,%rdi,2), %rdi
shlq $0x4, %rdi
addq %rbx, %rdi
xorl %r8d, %r8d
movsd (%rsi,%r8,2), %xmm0
addsd (%r12,%r8,2), %xmm0
xorps %xmm1, %xmm1
cvtsi2sdl (%rdi,%r8), %xmm1
addsd 0xc0(%rsp,%r8,2), %xmm1
movsd %xmm0, (%r12,%r8,2)
movsd %xmm1, 0xc0(%rsp,%r8,2)
addq $0x4, %r8
cmpq $0x10, %r8
jne 0xe90e
incq %rdx
cmpq %rbp, %rdx
jne 0xe8f1
movq 0x10(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
addq $0x20, %rax
xorl %ecx, %ecx
movapd %xmm6, %xmm1
movapd %xmm6, %xmm0
xorl %edx, %edx
xorl %esi, %esi
movl %esi, %edi
movsd (%r12,%rcx,8), %xmm3
ucomisd %xmm0, %xmm3
jbe 0xe982
movl %ecx, %esi
movl %edi, %edx
movapd %xmm3, %xmm2
jmp 0xe99e
movl %edi, %esi
ucomisd %xmm1, %xmm3
jbe 0xe996
movl %ecx, %edx
movapd %xmm0, %xmm2
movapd %xmm3, %xmm0
jmp 0xe99e
movapd %xmm0, %xmm2
movapd %xmm1, %xmm0
incq %rcx
movapd %xmm0, %xmm1
movapd %xmm2, %xmm0
cmpq $0x4, %rcx
jne 0xe96a
movl %esi, %ecx
movsd (%rax,%rcx,8), %xmm0
movl %edx, %ecx
ucomisd (%rax,%rcx,8), %xmm0
movl $0x0, %eax
cmovnel %esi, %eax
cmovpl %esi, %eax
cmpl $0x1, %edx
jne 0xea42
cmpl $0x2, %eax
jne 0xea42
movsd 0xc8(%rsp), %xmm0
ucomisd %xmm5, %xmm0
jbe 0xea42
movq 0x18(%rsp), %rax
movsd 0x28(%rax), %xmm1
movsd 0x30(%rax), %xmm2
movapd %xmm1, %xmm0
mulsd %xmm7, %xmm0
ucomisd %xmm2, %xmm0
jbe 0xea0e
movl $0x1, %eax
cmpl $0x3, %r9d
jl 0xea42
jmp 0xeaaf
movapd %xmm1, %xmm0
mulsd %xmm8, %xmm0
movl $0x2, %eax
ucomisd %xmm2, %xmm0
jbe 0xea42
cmpl $0x3, %r9d
setl %dl
xorl %eax, %eax
movq 0x18(%rsp), %rcx
cmpl $0x3d091, 0x10(%rcx)    # imm = 0x3D091
setb %cl
orb %cl, %dl
je 0xeaaf
movb %cl, %al
incl %eax
testq %rbp, %rbp
je 0xea93
movq 0x18(%rsp), %rcx
movq 0x8(%rcx), %rcx
movl %eax, %edx
xorl %esi, %esi
movl (%rcx,%rsi,4), %edi
leaq (%rdi,%rdi,2), %r8
shlq $0x4, %r8
addq %r15, %r8
cmpl $0x0, 0x18(%r8,%rdx,4)
jle 0xea8b
movq 0x38(%r11), %r8
movq 0x10(%r8), %r8
movl (%r13,%rdi,4), %edi
leaq (%rdi,%rdi,4), %rdi
movl 0x18(%r8,%rdi,8), %edi
addl %edi, 0x20(%rsp,%rdx,4)
incl 0xa0(%rsp,%rdx,4)
incq %rsi
cmpq %rsi, %rbp
jne 0xea54
movq 0x18(%rsp), %rcx
movl %eax, 0x40(%rcx)
incq %r14
addq $0x48, %r12
cmpq 0x58(%rsp), %r14
jne 0xe8ad
jmp 0xeb24
movq 0x10542(%rip), %rax     # 0x1eff8
movq (%rax), %rdi
movq 0x18(%rsp), %rax
movsd 0x18(%rax), %xmm0
movl 0x10(%rax), %r9d
movsd 0x38(%rax), %xmm3
leaq 0xb39a(%rip), %rsi      # 0x19e6d
leaq 0xb3fb(%rip), %rdx      # 0x19ed5
movl %r14d, %ecx
movl %ebp, %r8d
movb $0x4, %al
callq 0x3290
movq 0x40(%rsp), %r11
movsd 0xaa43(%rip), %xmm8     # 0x19538
movsd 0xa9c3(%rip), %xmm7     # 0x194c0
movsd 0xaa23(%rip), %xmm6     # 0x19528
xorpd %xmm5, %xmm5
xorpd %xmm4, %xmm4
movq 0x68(%rsp), %r10
movl 0x130(%rsp), %r9d
movl $0x1, %eax
jmp 0xea42
cmpl $0x3, %r9d
movq 0x60(%rsp), %rbp
movq 0x10(%rsp), %r12
jge 0xef24
movl 0x24(%rsp), %ecx
movl 0x28(%rsp), %eax
testl %ecx, %ecx
setne %dl
testl %eax, %eax
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
movq 0x78(%rsp), %r13
jne 0xeb99
cmpl %ebp, %ecx
seta %dl
cmpl %ebp, %eax
setb %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0xeb7c
xorl %eax, %eax
movl %eax, 0x28(%rsp)
movl %eax, 0xa8(%rsp)
jmp 0xeb99
cmpl %ebp, %ecx
setb %cl
cmpl %ebp, %eax
seta %al
andb %cl, %al
cmpb $0x1, %al
jne 0xeb99
xorl %eax, %eax
movl %eax, 0x24(%rsp)
movl %eax, 0xa4(%rsp)
movl $0x20, %edi
callq 0x32f0
movq %rax, %r14
movq 0x8(%rsp), %rbx
leal (,%rbx,4), %edi
movl $0x4, %esi
callq 0x3240
movq %rax, (%r14)
leaq (,%rbx,4), %rcx
leaq (%rax,%rbx,4), %rax
movl $0x1, %edx
movq %rax, (%r14,%rdx,8)
incq %rdx
addq %rcx, %rax
cmpq $0x4, %rdx
jne 0xebd0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movapd %xmm0, 0x80(%rsp)
movl 0x24(%rsp), %ecx
movl 0x28(%rsp), %eax
testl %ecx, %ecx
setne %dl
testl %eax, %eax
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
movl 0x130(%rsp), %r10d
jne 0xecce
cmpl $0x3, %r10d
jge 0xf0b4
xorpd %xmm0, %xmm0
movq %r12, %rdi
movl 0x4(%rsp), %r12d
movl %r12d, %esi
movq %r15, %rdx
movq 0x8(%rsp), %r13
movl %r13d, %ecx
movl $0x1, %r8d
movsd 0xa840(%rip), %xmm1     # 0x19490
movl %ebp, %r9d
pushq %r10
pushq 0x8(%r14)
leaq 0x98(%rsp), %rax
pushq %rax
pushq $0x2dc6c0               # imm = 0x2DC6C0
movq %r10, %rbx
callq 0xf19b
addq $0x20, %rsp
movl %eax, 0x24(%rsp)
xorpd %xmm0, %xmm0
movq 0x10(%rsp), %rdi
movl %r12d, %esi
movq 0x10(%rsp), %r12
movq %r15, %rdx
movl %r13d, %ecx
movl $0x2, %r8d
movsd 0xa7f4(%rip), %xmm1     # 0x19490
movl %ebp, %r9d
pushq %rbx
pushq 0x10(%r14)
leaq 0xa0(%rsp), %rax
pushq %rax
pushq $0x3d090                # imm = 0x3D090
callq 0xf19b
addq $0x20, %rsp
movl %eax, 0x28(%rsp)
movq 0x78(%rsp), %r13
movq 0x38(%rsp), %rbx
jmp 0xede0
testl %ecx, %ecx
je 0xed2b
cmpl $0x3, %r10d
movq 0x38(%rsp), %rbx
jge 0xf0c6
xorpd %xmm0, %xmm0
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %r15, %rdx
movq 0x8(%rsp), %rcx
movl $0x1, %r8d
movsd 0xa78e(%rip), %xmm1     # 0x19490
movl %ebp, %r9d
pushq %r10
pushq 0x8(%r14)
leaq 0x98(%rsp), %rax
pushq %rax
pushq $0x2dc6c0               # imm = 0x2DC6C0
callq 0xf19b
addq $0x20, %rsp
movl %eax, 0x24(%rsp)
jmp 0xede0
testl %eax, %eax
movq 0x38(%rsp), %rbx
je 0xed85
cmpl $0x3, %r10d
jge 0xf0d8
xorpd %xmm0, %xmm0
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %r15, %rdx
movq 0x8(%rsp), %rcx
movl $0x2, %r8d
movsd 0xa731(%rip), %xmm1     # 0x19490
movl %ebp, %r9d
pushq %r10
pushq 0x10(%r14)
leaq 0xa0(%rsp), %rax
pushq %rax
pushq $0x3d090                # imm = 0x3D090
callq 0xf19b
addq $0x20, %rsp
movl %eax, 0x28(%rsp)
jmp 0xede0
cmpl $0x0, 0x2c(%rsp)
je 0xede0
movl 0x130(%rsp), %eax
cmpl $0x3, %eax
jge 0xf0ea
xorpd %xmm0, %xmm0
movq %r12, %rdi
movl 0x4(%rsp), %esi
movq %r15, %rdx
movq 0x8(%rsp), %rcx
movl $0x3, %r8d
movsd 0xa6d3(%rip), %xmm1     # 0x19490
movl %ebp, %r9d
pushq %rax
pushq 0x18(%r14)
leaq 0xa8(%rsp), %rax
pushq %rax
pushq $0xc350                 # imm = 0xC350
callq 0xf19b
addq $0x20, %rsp
movl %eax, 0x2c(%rsp)
cmpl $0x0, 0x24(%rsp)
je 0xee22
movq 0x8(%r14), %r9
movsd 0x88(%rsp), %xmm0
subq $0x8, %rsp
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq %r15, %rcx
movl $0x1, %r8d
movl 0x138(%rsp), %eax
pushq %rax
pushq %r13
pushq %rbp
callq 0xf793
addq $0x20, %rsp
cmpl $0x0, 0x28(%rsp)
movq 0x40(%rsp), %rdx
je 0xee69
movq 0x10(%r14), %r9
movsd 0x90(%rsp), %xmm0
subq $0x8, %rsp
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rcx
movl $0x2, %r8d
movl 0x138(%rsp), %eax
pushq %rax
pushq %r13
pushq %rbp
callq 0xf793
movq 0x60(%rsp), %rdx
addq $0x20, %rsp
cmpl $0x0, 0x2c(%rsp)
je 0xeea6
movq 0x18(%r14), %r9
movsd 0x98(%rsp), %xmm0
subq $0x8, %rsp
movq %rbx, %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rcx
movl $0x3, %r8d
movl 0x138(%rsp), %eax
pushq %rax
pushq %r13
pushq %rbp
callq 0xf793
addq $0x20, %rsp
movq (%r14), %rdi
callq 0x3060
movq %r14, %rdi
callq 0x3060
movq %r15, %rdi
callq 0x3060
cmpl $0x0, 0x4(%rsp)
je 0xeee8
movq 0x58(%rsp), %rax
shlq $0x3, %rax
leaq (%rax,%rax,8), %rbx
xorl %r14d, %r14d
movq 0x8(%r12,%r14), %rdi
callq 0x3060
addq $0x48, %r14
cmpq %r14, %rbx
jne 0xeed5
movq %r12, %rdi
callq 0x3060
movq 0xb8(%rsp), %rcx
incl %ecx
movq %rcx, %rax
movq 0xb0(%rsp), %r15
cmpq %rcx, (%r15)
movl 0x120(%rsp), %ebx
movq 0x70(%rsp), %r14
movq 0x50(%rsp), %r12
ja 0xe525
jmp 0xf0fb
movq 0x100cd(%rip), %r14     # 0x1eff8
movq (%r14), %rdi
leaq 0xafaf(%rip), %rsi      # 0x19ee4
leaq 0xaf99(%rip), %rbx      # 0x19ed5
movq %rbx, %rdx
movl 0x4(%rsp), %ebp
movl %ebp, %ecx
xorl %eax, %eax
callq 0x3290
testl %ebp, %ebp
je 0xef5a
movl %ebp, %edi
movq %r12, %rsi
callq 0x398a
movq (%r14), %rdi
leaq 0xb006(%rip), %rsi      # 0x19f6a
movq %rbx, %rdx
movq 0x8(%rsp), %rbp
movl %ebp, %ecx
xorl %eax, %eax
callq 0x3290
movl $0x30, %edx
movq %r15, %rdi
movq %rbp, %rsi
leaq 0x1e4(%rip), %rcx       # 0xf16b
callq 0x30c0
testq %rbp, %rbp
movq 0x30(%rsp), %rbp
leaq 0xaff3(%rip), %r12      # 0x19f8e
movq 0x38(%rsp), %rsi
je 0xf02e
xorl %ebx, %ebx
movl (%r15,%rbx), %eax
movq 0x10(%rbp), %rcx
movl (%r13,%rax,4), %eax
leaq (%rax,%rax,2), %rdx
shlq $0x6, %rax
movl (%rcx,%rax), %eax
movq (%r14), %rdi
movq 0x10(%rsi), %rcx
movq (%rcx,%rdx,8), %rcx
leaq 0xfb6e(%rip), %rdx      # 0x1eb40
movq (%rdx,%rax,8), %r8
movl 0x1c(%r15,%rbx), %r9d
movl 0x20(%r15,%rbx), %r10d
movsd 0x8(%r15,%rbx), %xmm0
movl 0x10(%r15,%rbx), %r11d
movl 0x14(%r15,%rbx), %r14d
subq $0x8, %rsp
movq %r12, %rsi
leaq 0xaed6(%rip), %rdx      # 0x19ed5
movb $0x1, %al
pushq %r14
movq 0xffee(%rip), %r14      # 0x1eff8
pushq %r11
pushq %r10
callq 0x3290
movq 0x58(%rsp), %rsi
movq 0x68(%rsp), %rax
addq $0x20, %rsp
addq $0x30, %rbx
cmpq %rbx, %rax
jne 0xefa8
movl $0x30, %edx
movq %r15, %rdi
movq 0x8(%rsp), %rsi
leaq 0x148(%rip), %rcx       # 0xf18a
callq 0x30c0
movq (%r14), %rdi
leaq 0xaf75(%rip), %rsi      # 0x19fc6
leaq 0xae7d(%rip), %rdx      # 0x19ed5
xorl %eax, %eax
callq 0x3290
leaq 0xfada(%rip), %rbx      # 0x1eb40
xorl %r14d, %r14d
movq 0x60(%rsp), %rbp
movq 0x10(%rsp), %r12
movq 0xff7e(%rip), %rax      # 0x1eff8
movq (%rax), %rdi
movq (%rbx), %rcx
movl 0xa0(%rsp,%r14,4), %r8d
movl 0x20(%rsp,%r14,4), %r9d
leaq 0xaf66(%rip), %rsi      # 0x19ffa
leaq 0xae3a(%rip), %rdx      # 0x19ed5
xorl %eax, %eax
callq 0x3290
incq %r14
addq $0x8, %rbx
cmpq $0x4, %r14
jne 0xf073
jmp 0xeb38
callq 0x3a80
movl 0x130(%rsp), %r10d
jmp 0xec28
callq 0x3a5b
movl 0x130(%rsp), %r10d
jmp 0xece1
callq 0x3a36
movl 0x130(%rsp), %r10d
jmp 0xed3e
callq 0x3a11
movl 0x130(%rsp), %eax
jmp 0xed9c
movq 0x68(%rsp), %rdi
callq 0x3060
movq %r12, %rdi
callq 0x3060
movq 0x30(%rsp), %rdi
callq 0xc7bc
movq %r15, %rdi
callq 0xc7bc
cmpl $0x0, 0x128(%rsp)
je 0xf138
movq %r13, %rdi
movl 0x130(%rsp), %esi
callq 0xd0fc
movq (%r13), %rsi
movq 0x10(%r13), %rdi
leaq -0x1562(%rip), %rcx     # 0xdbe5
movl $0x40, %edx
callq 0x30c0
jmp 0xf156
xorl %r13d, %r13d
movq %r13, %rax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq