// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: clean_graph(int, ma_hit_t_alloc*, ma_hit_t_alloc*, long long, unsigned long*, long long, long long, long long, long long, float, float, char*, long long, int, R_to_U*, asg_t**, ma_sub_t**, unsigned char*, int)
void clean_graph(
int min_dp, ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, 
long long n_read, uint64_t* readLen, long long mini_overlap_length, 
long long max_hang_length, long long clean_round, long long gap_fuzz,
float min_ovlp_drop_ratio, float max_ovlp_drop_ratio, char* output_file_name, 
long long bubble_dist, int read_graph, R_to_U* ruIndex, asg_t **sg_ptr, 
ma_sub_t **coverage_cut_ptr, uint8_t *cmk, int debug_g)
{
    char *o_file = get_outfile_name(output_file_name);
	ma_sub_t *coverage_cut = *coverage_cut_ptr;
	asg_t *sg = *sg_ptr;
    bub_label_t b_mask_t;
    ug_opt_t uopt; 
    telo_end_t *te = NULL;

    if(asm_opt.telo_motif) te = gen_telo_end_t(&R_INF, asm_opt.telo_motif, asm_opt.telo_mic_sc, asm_opt.telo_pen, asm_opt.telo_drop, asm_opt.thread_num);

    if(debug_g) 
    {
        init_bub_label_t(&b_mask_t, MIN(10, asm_opt.thread_num), n_read);
        goto debug_gfa;
    }
    ///just for debug
    if(!cmk) renew_graph_init(sources, reverse_sources, sg, coverage_cut, ruIndex, n_read);
    // if(asm_opt.is_ont) handle_chemical_arc(asm_opt.thread_num, R_INF.total_reads);
    // if(asm_opt.is_ont) handle_chemical_r(asm_opt.thread_num, R_INF.total_reads);
    
    ///it's hard to say which function is better       
    ///normalize_ma_hit_t_single_side(sources, n_read);

    normalize_ma_hit_t_single_side_advance(sources, n_read, asm_opt.is_ont, cmk);
    // normalize_ma_hit_t_single_side_advance_mult(sources, n_read, asm_opt.thread_num);
    normalize_ma_hit_t_single_side_advance(reverse_sources, n_read, 0, cmk);
    // normalize_ma_hit_t_single_side_advance_mult(reverse_sources, n_read, asm_opt.thread_num);

    if (ha_opt_triobin(&asm_opt))
    {
        drop_edges_by_trio(sources, n_read);
    }
    else
    {
        memset(R_INF.trio_flag, AMBIGU, R_INF.total_reads*sizeof(uint8_t));
    }
    if(asm_opt.ar) init_all_ul_t(&UL_INF, &R_INF);
    // if (asm_opt.flag & HA_F_VERBOSE_GFA) {
    //     write_debug_graph(NULL, sources, coverage_cut, output_file_name, reverse_sources, ruIndex, &UL_INF);
    //     debug_gfa:;
    // }
    ///should recover edges from sources by using UL alignments
    // prt_specific_overlap(sources, 22233, 22235, "0-a");
    // prt_specific_overlap(sources, 22235, 22233, "0-a");
    if(asm_opt.ar) {
        create_ul_info(sources, reverse_sources, max_hang_length, mini_overlap_length, gap_fuzz, min_dp, readLen, coverage_cut, ruIndex, 
        (asm_opt.max_short_tip*2), 0.15, 3, 0.05, 0.9, &b_mask_t, te);
    } 
    // prt_specific_overlap(sources, 22233, 22235, "0-b");
    // prt_specific_overlap(sources, 22235, 22233, "0-b");
    // prt_dbg_rid_ovlp(sources, 27087, NULL, "0-a");
    if(!(asm_opt.is_ont)) clean_weak_ma_hit_t(sources, reverse_sources, n_read, asm_opt.ar?UL_COV_THRES:(uint32_t)-1);
    // prt_dbg_rid_ovlp(sources, 27087, NULL, "0-b");
    // prt_specific_overlap(sources, 22233, 22235, "0-c");
    // prt_specific_overlap(sources, 22235, 22233, "0-c");
    sg = gen_init_sg(min_dp, n_read, mini_overlap_length, max_hang_length, gap_fuzz, sources, readLen, ruIndex, 
    &b_mask_t, &coverage_cut, asm_opt.ar?&UL_INF:NULL, te);
    // if(asm_opt.ar) exit(1);
    /**
    ///print_binned_reads(sources, n_read, coverage_cut);
    
    ///ma_hit_sub is just use to init coverage_cut,
    ///it seems we do not need ma_hit_cut & ma_hit_flt
    ma_hit_sub(min_dp, sources, n_read, readLen, mini_overlap_length, &coverage_cut);
    detect_chimeric_reads(sources, n_read, readLen, coverage_cut, asm_opt.max_ov_diff_final * 2.0, asm_opt.ar?&UL_INF:NULL);
    ma_hit_cut(sources, n_read, readLen, mini_overlap_length, &coverage_cut);
    ///print_binned_reads(sources, n_read, coverage_cut);
    ma_hit_flt(sources, n_read, coverage_cut, max_hang_length, mini_overlap_length);
    ///fix_binned_reads(sources, n_read, coverage_cut);
    ///just need to deal with trio here
    ma_hit_contained_advance(sources, n_read, coverage_cut, ruIndex, max_hang_length, mini_overlap_length);
    sg = ma_sg_gen(sources, n_read, coverage_cut, max_hang_length, mini_overlap_length);
    ///debug_info_of_specfic_node((char*)"m64043_200504_050026/93784180/ccs", sg, ruIndex, (char*)"sbsbsb");
    init_bub_label_t(&b_mask_t, MIN(10, asm_opt.thread_num), sg->n_seq);
    asg_arc_del_trans(sg, gap_fuzz);
    asm_opt.coverage = get_coverage(sources, coverage_cut, n_read);
    **/
    if(VERBOSE >= 1)
    {
        char* unlean_name = (char*)malloc(strlen(output_file_name)+25);
        sprintf(unlean_name, "%s.unclean", output_file_name);
        output_read_graph(sg, coverage_cut, unlean_name, n_read);
        free(unlean_name);
    }


    // if (asm_opt.flag & HA_F_VERBOSE_GFA) {
    //     write_debug_graph(sg, sources, coverage_cut, output_file_name, reverse_sources, ruIndex, &UL_INF);
    //     debug_gfa:;
    // }
    
    gen_ug_opt_t(&uopt, sources, reverse_sources, max_hang_length, mini_overlap_length, gap_fuzz, min_dp, readLen, coverage_cut, ruIndex, 
            (asm_opt.max_short_tip*2), 0.15, 3, 0.05, 0.9, &b_mask_t, te);
    ul_clean_gfa(&uopt, sg, sources, reverse_sources, ruIndex, clean_round, min_ovlp_drop_ratio, max_ovlp_drop_ratio, 
    0.6, asm_opt.max_short_tip, gap_fuzz, &b_mask_t, !!asm_opt.ar, ha_opt_triobin(&asm_opt), UL_COV_THRES, cmk, o_file);
    ///@brief debug
    if (asm_opt.flag & HA_F_VERBOSE_GFA) {
        write_debug_graph(sg, sources, coverage_cut, output_file_name, reverse_sources, ruIndex, &UL_INF);
        debug_gfa:;
        gen_ug_opt_t(&uopt, sources, reverse_sources, max_hang_length, mini_overlap_length, gap_fuzz, min_dp, readLen, coverage_cut, ruIndex, 
                (asm_opt.max_short_tip*2), 0.15, 3, 0.05, 0.9, &b_mask_t, te);
        // set_hom_global_coverage(&asm_opt, sg, coverage_cut, sources, reverse_sources, ruIndex, max_hang_length, mini_overlap_length);
    }

    if(asm_opt.ar) {
        gradually_renew_g(&sources, &reverse_sources, &n_read, &readLen, &coverage_cut, ruIndex, 
        &sg, mini_overlap_length, max_hang_length, &uopt, clean_round, min_ovlp_drop_ratio, 
        max_ovlp_drop_ratio, asm_opt.max_short_tip, gap_fuzz, min_dp, &b_mask_t, 
        ha_opt_triobin(&asm_opt), asm_opt.ul_clean_round, o_file, "re", te);
    } else {
        ug_ext_gfa(&uopt, sg, ug_ext_len);
        if(!ha_opt_triobin(&asm_opt)) {
            // output_unitig_graph(sg, coverage_cut, "pre_clean", sources, ruIndex, max_hang_length, mini_overlap_length);
            hic_clean_adv(sg, &uopt);
        }
    }

    /**
    if(asm_opt.ar) {
        renew_g(&sources, &reverse_sources, &n_read, &readLen, &coverage_cut, ruIndex, &sg, mini_overlap_length, max_hang_length,
        &uopt, clean_round, min_ovlp_drop_ratio, max_ovlp_drop_ratio, asm_opt.max_short_tip, &b_mask_t, 
        ha_opt_triobin(&asm_opt), o_file);
        ///make sure uopt has been updated; not necessary
        gen_ug_opt_t(&uopt, sources, reverse_sources, max_hang_length, mini_overlap_length, gap_fuzz, min_dp, readLen, coverage_cut, ruIndex, 
            (asm_opt.max_short_tip*2), 0.15, 3, 0.05, 0.9, &b_mask_t);
    }
    **/
    // print_debug_gfa(sg, NULL, coverage_cut, "UL.debug", sources, ruIndex, max_hang_length, mini_overlap_length, 0, 0, 0);
    /**
    asg_cut_tip(sg, asm_opt.max_short_tip);
    ///debug_info_of_specfic_node("m64043_200505_112554/8849050/ccs", sg, "inner_1");
    ///drop_inexact_edegs_at_bubbles(sg, bubble_dist);
    
    if(clean_round > 0)
    {
        double cut_step;
        if(clean_round == 1)
        {
            cut_step = max_ovlp_drop_ratio;
        }
        else
        {
            cut_step = (max_ovlp_drop_ratio - min_ovlp_drop_ratio) / (clean_round - 1);
        }
        double drop_ratio = min_ovlp_drop_ratio;
        int i = 0;
        for (i = 0; i < clean_round; i++, drop_ratio += cut_step)
        {
            if(drop_ratio > max_ovlp_drop_ratio)
            {
                drop_ratio = max_ovlp_drop_ratio;
            }

            if(VERBOSE >= 1)
            {
                fprintf(stderr, "\n\n**********%d-th round drop: drop_ratio = %f**********\n", 
                i, drop_ratio);
            }

            ///just topological clean
            pre_clean(sources, coverage_cut, sg, 1);
            ///asg_arc_del_orthology(sg, reverse_sources, drop_ratio, asm_opt.max_short_tip);
            // asg_arc_del_orthology_multiple_way(sg, reverse_sources, drop_ratio, asm_opt.max_short_tip);
            // asg_cut_tip(sg, asm_opt.max_short_tip);

            asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 1);
            //reomve edge between two chromesomes
            //this node must be a single read
            asg_arc_del_false_node(sg, sources, asm_opt.max_short_tip);
            asg_cut_tip(sg, asm_opt.max_short_tip);

            ///asg_arc_identify_simple_bubbles_multi(sg, 1);
            asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 0);
            ///asg_arc_del_short_diploid_unclean_exact(sg, drop_ratio, sources);
            if (ha_opt_triobin(&asm_opt))
            {
                asg_arc_del_short_diploid_by_exact_trio(sg, asm_opt.max_short_tip, sources);
            }
            else
            {
                asg_arc_del_short_diploid_by_exact(sg, asm_opt.max_short_tip, sources);
            }
            asg_cut_tip(sg, asm_opt.max_short_tip);

            asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 1);
            if (ha_opt_triobin(&asm_opt))
            {
                asg_arc_del_short_diploid_by_length_trio(sg, drop_ratio, asm_opt.max_short_tip, reverse_sources, 
                asm_opt.max_short_tip, 1, 1, 0, 0, ruIndex);
            }
            else
            {
                asg_arc_del_short_diploid_by_length(sg, drop_ratio, asm_opt.max_short_tip, reverse_sources, 
                asm_opt.max_short_tip, 1, 1, 0, 0, ruIndex);
            }
            asg_cut_tip(sg, asm_opt.max_short_tip);

            asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 1);
            asg_arc_del_short_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, asm_opt.max_short_tip, ruIndex);     
    
            asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 1);
            asg_arc_del_complex_false_link(sg, 0.6, 0.85, bubble_dist, reverse_sources, asm_opt.max_short_tip);

            asg_cut_tip(sg, asm_opt.max_short_tip);
        }
    }
    if(VERBOSE >= 1)
    {
        fprintf(stderr, "\n\n**********final clean**********\n");
    }


    pre_clean(sources, coverage_cut, sg, 1);


    asg_arc_del_short_diploi_by_suspect_edge(sg, asm_opt.max_short_tip);
    asg_cut_tip(sg, asm_opt.max_short_tip);
    asg_arc_del_triangular_directly(sg, asm_opt.max_short_tip, reverse_sources, ruIndex);


    asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 0);
    asg_arc_del_orthology_multiple_way(sg, reverse_sources, 0.4, asm_opt.max_short_tip, ruIndex);
    asg_cut_tip(sg, asm_opt.max_short_tip);




    asg_arc_identify_simple_bubbles_multi(sg, &b_mask_t, 0);
    asg_arc_del_too_short_overlaps(sg, 2000, min_ovlp_drop_ratio, reverse_sources, asm_opt.max_short_tip, ruIndex);
    asg_cut_tip(sg, asm_opt.max_short_tip);

    asg_arc_del_simple_circle_untig(sources, coverage_cut, sg, 100, 0);
    
    ///note: don't apply asg_arc_del_too_short_overlaps() after this function!!!!
    rescue_contained_reads_aggressive(NULL, sg, sources, coverage_cut, ruIndex, max_hang_length, 
    mini_overlap_length, 10, 1, 0, NULL, NULL, &b_mask_t);
    rescue_missing_overlaps_aggressive(NULL, sg, sources, coverage_cut, ruIndex, max_hang_length,
    mini_overlap_length, 1, 0, NULL, &b_mask_t);
    rescue_missing_overlaps_backward(NULL, sg, sources, coverage_cut, ruIndex, max_hang_length, 
    mini_overlap_length, 10, 1, 0, &b_mask_t);
    // rescue_wrong_overlaps_to_unitigs(NULL, sg, sources, reverse_sources, coverage_cut, ruIndex, 
    // max_hang_length, mini_overlap_length, bubble_dist, NULL);
    // rescue_no_coverage_aggressive(sg, sources, reverse_sources, &coverage_cut, ruIndex, max_hang_length, 
    // mini_overlap_length, bubble_dist, 10);

    
    set_hom_global_coverage(&asm_opt, sg, coverage_cut, sources, reverse_sources, ruIndex, 
    max_hang_length, mini_overlap_length);

    rescue_bubble_by_chain(sg, coverage_cut, sources, reverse_sources, (asm_opt.max_short_tip*2), 0.15, 3, 
    ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, 10, gap_fuzz, &b_mask_t);
    

    output_unitig_graph(sg, coverage_cut, o_file, sources, ruIndex, max_hang_length, mini_overlap_length);
    // flat_bubbles(sg, ruIndex->is_het); free(ruIndex->is_het); ruIndex->is_het = NULL;
    flat_soma_v(sg, sources, ruIndex);
    **/

    output_contig_graph_primary_pre(sg, coverage_cut, o_file, sources, reverse_sources, 
        asm_opt.small_pop_bubble_size, asm_opt.max_short_tip, ruIndex, max_hang_length, mini_overlap_length, &uopt);
    
    // if(asm_opt.ar) {
    //     char *op_file = get_outfile_name(o_file);
    //     ul_clean_gfa(&uopt, sg, sources, reverse_sources, ruIndex, clean_round, min_ovlp_drop_ratio, max_ovlp_drop_ratio, 
    //     0.6, asm_opt.max_short_tip, gap_fuzz, &b_mask_t, 0/**!!asm_opt.ar**/, ha_opt_triobin(&asm_opt), UL_COV_THRES, op_file);
    //     output_contig_graph_primary_pre(sg, coverage_cut, op_file, sources, reverse_sources, 
    //     asm_opt.small_pop_bubble_size, asm_opt.max_short_tip, ruIndex, max_hang_length, mini_overlap_length, &uopt);
    //     free(op_file);
    // }
    /**
    if (asm_opt.flag & HA_F_VERBOSE_GFA)
    {
        write_debug_graph(sg, sources, coverage_cut, output_file_name, n_read, reverse_sources, ruIndex);
        debug_gfa:;
    }**/

    if(asm_opt.fn_bin_poy)
    {
        if(asm_opt.flag & HA_F_PARTITION) asm_opt.flag -= HA_F_PARTITION;
        output_poly_trio(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 0.15, 3, ruIndex, 
        0.05, 0.9, max_hang_length, mini_overlap_length, gap_fuzz, 0, &b_mask_t, asm_opt.polyploidy);
    }
    else if (ha_opt_triobin(&asm_opt) && ha_opt_hic(&asm_opt))
    {
        if(asm_opt.flag & HA_F_PARTITION) asm_opt.flag -= HA_F_PARTITION;
        benchmark_hic_graph(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 0.15, 3, 
        ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, gap_fuzz, &b_mask_t);
    }
    else if (ha_opt_triobin(&asm_opt))
    {   
        if(asm_opt.flag & HA_F_PARTITION) asm_opt.flag -= HA_F_PARTITION;
        // output_trio_graph(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
        // 0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, 0, gap_fuzz, &uopt, &b_mask_t);
        if(asm_opt.trio_cov_het_ovlp > 0) {
            output_bp_trio_graph(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
            0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, &b_mask_t, gap_fuzz, &uopt);
        } else {
            output_trio_graph_joint(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
            0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, gap_fuzz, &b_mask_t, NULL, NULL, &uopt);
        }
    }
    else if(ha_opt_hic(&asm_opt))
    {
        if(asm_opt.flag & HA_F_PARTITION) asm_opt.flag -= HA_F_PARTITION;
        if(asm_opt.polyploidy <= 2) {
            output_hic_graph(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
            0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, gap_fuzz, &b_mask_t, &uopt);
        } else {
            output_hic_graph_mmhap(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
            0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, gap_fuzz, &b_mask_t, &uopt);
        }
        
        // output_hic_graph_polyploid(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
        // 0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, gap_fuzz, &b_mask_t);
    }
    else if((asm_opt.flag & HA_F_PARTITION) && (asm_opt.purge_level_primary > 0))
    {
        output_bp_graph(sg, coverage_cut, o_file, sources, reverse_sources, (asm_opt.max_short_tip*2), 
        0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, &b_mask_t, gap_fuzz, &uopt);
    }
    else
    {
        if(asm_opt.flag & HA_F_PARTITION) asm_opt.flag -= HA_F_PARTITION;
        output_contig_graph_primary(sg, coverage_cut, o_file, sources, reverse_sources, 
        (asm_opt.max_short_tip*2), 0.15, 3, ruIndex, 0.05, 0.9, max_hang_length, mini_overlap_length, &b_mask_t);

        output_contig_graph_alternative(sg, coverage_cut, o_file, sources, ruIndex, max_hang_length, mini_overlap_length);
    }

	*coverage_cut_ptr = coverage_cut;
	*sg_ptr = sg;
    destory_bub_label_t(&b_mask_t); 
    if(te) {
        destory_telo_end_t(te); free(te); te = NULL;
    }
    free(o_file); ///if(asm_opt.ar) destory_all_ul_t(&UL_INF); 
    fprintf(stderr, "Inconsistency threshold for low-quality regions in BED files: %u%%\n", asm_opt.bed_inconsist_rate);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movss %xmm1, 0x3c(%rsp)
movss %xmm0, 0x38(%rsp)
movq %r9, %r15
movl %edi, %ebp
movl 0x180(%rsp), %ebx
movq 0x170(%rsp), %r12
movq 0x168(%rsp), %r14
movq 0x148(%rsp), %rdi
movq %rsi, (%rsp)
movq %rdx, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
movq %r8, 0x30(%rsp)
callq 0xffed8
movq %rax, 0x48(%rsp)
movq (%r12), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %rax
movq %rax, 0x8(%rsp)
leaq 0x27b60e(%rip), %r12    # 0x28a758
movq 0x288(%r12), %rsi
testq %rsi, %rsi
jne 0xf162
movq $0x0, 0x28(%rsp)
jmp 0xf190
movq 0x2a0(%r12), %rdx
movq 0x290(%r12), %rcx
movq 0x298(%r12), %r8
movslq 0x7c(%r12), %r9
leaq 0x27c0aa(%rip), %rdi    # 0x28b230
callq 0x9eb5a
movq %rax, 0x28(%rsp)
movq 0x130(%rsp), %r13
movslq %ebp, %rax
movq %rax, 0x40(%rsp)
testl %ebx, %ebx
jne 0xf242
movq 0x178(%rsp), %r14
testq %r14, %r14
movq 0x160(%rsp), %rbx
jne 0xf1dd
movq (%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x20(%rsp), %r9
movq %rbx, %r8
callq 0xf1d09
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x2a8(%r12), %edx
movq %r14, %rcx
callq 0xa05b8
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
xorl %edx, %edx
movq %r14, %rcx
callq 0xa05b8
cmpq $0x0, 0x20(%r12)
movq 0x140(%rsp), %r14
je 0xf222
cmpq $0x0, 0x28(%r12)
jne 0xf232
cmpq $0x0, 0x30(%r12)
je 0xf276
cmpq $0x0, 0x38(%r12)
je 0xf276
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
callq 0xa1300
jmp 0xf28c
movl 0x7c(%r12), %eax
cmpl $0xa, %eax
pushq $0xa
popq %rsi
cmovll %eax, %esi
movl 0x20(%rsp), %edx
leaq 0xc8(%rsp), %rdi
callq 0x9fac0
movq 0x160(%rsp), %r14
movq 0x140(%rsp), %rbp
jmp 0xf5b2
leaq 0x27bfb3(%rip), %rax    # 0x28b230
movq 0x28(%rax), %rdi
movq 0x50(%rax), %rdx
xorl %esi, %esi
callq 0x20e0
cmpq $0x0, 0x68(%r12)
je 0xf2a7
leaq 0x27c07d(%rip), %rdi    # 0x28b318
leaq 0x27bf8e(%rip), %rsi    # 0x28b230
callq 0x347e4
cmpq $0x0, 0x68(%r12)
je 0xf357
movq (%rsp), %rax
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rsi
movslq 0x11c(%r12), %r8
addq %r8, %r8
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %rdi
movaps %xmm0, (%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x50(%rdi)
movaps %xmm0, 0x60(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movq %rax, 0x8(%rdi)
movq %rcx, 0x10(%rdi)
movl %r13d, 0x40(%rdi)
movl %r15d, 0x44(%rdi)
movq %r14, 0x50(%rdi)
movq 0x40(%rsp), %rax
movq %rax, 0x58(%rdi)
movq %rdx, 0x68(%rdi)
movq %rsi, (%rdi)
movq %rbx, 0x30(%rdi)
movq %r8, 0x18(%rdi)
movl $0x3e19999a, 0x20(%rdi) # imm = 0x3E19999A
movq $0x3, 0x28(%rdi)
movabsq $0x3f6666663d4ccccd, %rax # imm = 0x3F6666663D4CCCCD
movq %rax, 0x38(%rdi)
leaq 0xc8(%rsp), %rax
movq %rax, 0x60(%rdi)
movq 0x28(%rsp), %rax
movq %rax, 0x70(%rdi)
callq 0x27fdb
cmpq $0x0, 0x2a8(%r12)
jne 0xf382
movq (%rsp), %rdi
movq 0x18(%rsp), %rsi
xorl %ecx, %ecx
cmpq $0x1, 0x68(%r12)
movq 0x20(%rsp), %rdx
sbbl %ecx, %ecx
orl $0x2, %ecx
callq 0xb775c
movq %r13, %rcx
movq 0x20(%rsp), %rsi
movq (%rsp), %r9
movq 0x30(%rsp), %rax
movq 0x68(%r12), %r10
testq %r10, %r10
je 0xf3a4
leaq 0x27bf74(%rip), %r10    # 0x28b318
leaq 0x10(%rsp), %rbx
leaq 0xc8(%rsp), %rbp
movq 0x40(%rsp), %r13
movl %r13d, %edi
movq %r15, %rdx
movq %r14, %r8
movq 0x28(%rsp), %r11
pushq %r11
pushq %r10
pushq %rbx
pushq %rbp
movq %r15, %rbp
movq %r11, %r15
movq 0x180(%rsp), %r14
pushq %r14
pushq %rax
callq 0x1001f2
addq $0x30, %rsp
movq %rax, 0x8(%rsp)
movq (%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rsi
movq (%rbx), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0xc0(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movq 0x130(%rsp), %r8
movl %r8d, 0x90(%rsp)
movq %rbp, 0xf0(%rsp)
movl %ebp, 0x94(%rsp)
movq 0x140(%rsp), %rbp
movq %rbp, 0xa0(%rsp)
movq %r13, 0xa8(%rsp)
leaq 0xc8(%rsp), %r13
movq %rsi, 0xb8(%rsp)
movslq 0x11c(%r12), %r10
movq %rdi, 0x50(%rsp)
leaq (%r10,%r10), %rsi
movq %r14, 0x80(%rsp)
movq %rsi, 0x68(%rsp)
movl $0x3e19999a, 0x70(%rsp) # imm = 0x3E19999A
movq $0x3, 0x78(%rsp)
movabsq $0x3f6666663d4ccccd, %rsi # imm = 0x3F6666663D4CCCCD
movq %rsi, 0x88(%rsp)
movq %r13, 0xb0(%rsp)
movq %r15, 0xc0(%rsp)
cvtss2sd 0x38(%rsp), %xmm0
xorl %r11d, %r11d
cmpq $0x0, 0x68(%r12)
cvtss2sd 0x3c(%rsp), %xmm1
setne %r11b
cmpq $0x0, 0x20(%r12)
je 0xf50d
cmpq $0x0, 0x28(%r12)
je 0xf50d
pushq $0x1
popq %rbx
movq 0x178(%rsp), %r14
jmp 0xf52a
xorl %ebx, %ebx
cmpq $0x0, 0x30(%r12)
movq 0x178(%rsp), %r14
je 0xf52a
xorl %ebx, %ebx
cmpq $0x0, 0x38(%r12)
setne %bl
leaq 0x50(%rsp), %rdi
movsd 0x215f51(%rip), %xmm2   # 0x225488
movq %rax, %rsi
movq 0x160(%rsp), %r8
movq 0x138(%rsp), %r9
pushq 0x48(%rsp)
pushq %r14
pushq $0x2
pushq %rbx
pushq %r11
pushq %r13
movq %r8, %r14
pushq %rbp
pushq %r10
callq 0x1ef069
addq $0x40, %rsp
testb $0x4, (%r12)
movq 0xf0(%rsp), %r15
movq 0x130(%rsp), %r13
je 0xf694
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %r8
subq $0x8, %rsp
leaq 0x27bd79(%rip), %rax    # 0x28b318
movq 0x150(%rsp), %rcx
movq %r14, %r9
pushq %rax
callq 0xd700
popq %rcx
popq %rdx
movq (%rsp), %rax
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rsi
movslq 0x11c(%r12), %rdi
addq %rdi, %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0xb0(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x80(%rsp)
andq $0x0, 0xc0(%rsp)
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movl %r13d, 0x90(%rsp)
movl %r15d, 0x94(%rsp)
movq %rbp, 0xa0(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rdx, 0xb8(%rsp)
movq %rsi, 0x50(%rsp)
movq %r14, 0x80(%rsp)
movq %rdi, 0x68(%rsp)
movl $0x3e19999a, 0x70(%rsp) # imm = 0x3E19999A
movq $0x3, 0x78(%rsp)
movabsq $0x3f6666663d4ccccd, %rax # imm = 0x3F6666663D4CCCCD
movq %rax, 0x88(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0xc0(%rsp)
cmpq $0x0, 0x68(%r12)
jne 0xf6f1
movq 0x8(%rsp), %rsi
leaq 0x50(%rsp), %rdi
movl $0x124f8, %edx          # imm = 0x124F8
callq 0x1efbb6
cmpq $0x0, 0x20(%r12)
movq 0x48(%rsp), %rbx
je 0xf6c9
cmpq $0x0, 0x28(%r12)
jne 0xf7b0
cmpq $0x0, 0x30(%r12)
je 0xf6dd
cmpq $0x0, 0x38(%r12)
jne 0xf7b0
movq 0x8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0xc04b2
jmp 0xf7b0
cvtss2sd 0x38(%rsp), %xmm0
cvtss2sd 0x3c(%rsp), %xmm1
movl 0x250(%r12), %eax
subq $0x70, %rsp
movq 0x98(%rsp), %rcx
movq %rcx, 0x68(%rsp)
leaq 0x227630(%rip), %rcx    # 0x236d4d
movq %rcx, 0x60(%rsp)
movq 0xb8(%rsp), %rbx
movq %rbx, 0x58(%rsp)
movl %eax, 0x50(%rsp)
leaq 0x138(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x38(%rsp)
movq %rbp, 0x30(%rsp)
movq 0x1a8(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movq %r15, 0x8(%rsp)
leaq 0x78(%rsp), %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x88(%rsp), %rsi
leaq 0x90(%rsp), %rdx
leaq 0xa0(%rsp), %rcx
leaq 0x80(%rsp), %r8
movq %r14, %r9
callq 0x1005e8
addq $0x70, %rsp
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x180(%r12), %r9
subq $0x30, %rsp
movl %r15d, 0x18(%rsp)
movl %r13d, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, %rdx
callq 0xd9d9
addq $0x30, %rsp
cmpq $0x0, 0x40(%r12)
jne 0xf8a2
cmpq $0x0, 0x20(%r12)
sete %cl
cmpq $0x0, 0x28(%r12)
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0xf821
cmpq $0x0, 0x30(%r12)
je 0xf99a
cmpq $0x0, 0x38(%r12)
je 0xf99a
cmpq $0x0, 0x50(%r12)
je 0xf99a
cmpq $0x0, 0x58(%r12)
je 0xf99a
movl (%r12), %eax
btl $0xb, %eax
jae 0xf84c
addl $0xfffff800, %eax       # imm = 0xFFFFF800
movl %eax, (%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r8
movslq 0x11c(%r12), %r9
addq %r9, %r9
leaq 0xc8(%rsp), %rax
movss 0x21a346(%rip), %xmm0   # 0x229bc0
movss 0x21a342(%rip), %xmm1   # 0x229bc4
movss 0x21a332(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %rbp
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0xa252
addq $0x30, %rsp
jmp 0xf915
movl (%r12), %eax
btl $0xb, %eax
jae 0xf8b5
addl $0xfffff800, %eax       # imm = 0xFFFFF800
movl %eax, (%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r8
movslq 0x11c(%r12), %r9
addq %r9, %r9
movl 0x1bc(%r12), %eax
leaq 0xc8(%rsp), %r10
movss 0x21a2d5(%rip), %xmm0   # 0x229bc0
movss 0x21a2d1(%rip), %xmm1   # 0x229bc4
movss 0x21a2c1(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq $0x0
pushq %rbp
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0xc1fc1
addq $0x40, %rsp
movq 0x10(%rsp), %rax
movq 0x170(%rsp), %rcx
movq %rax, (%rcx)
movq 0x8(%rsp), %rax
movq 0x168(%rsp), %rcx
movq %rax, (%rcx)
leaq 0xc8(%rsp), %rdi
callq 0x9fbe6
cmpq $0x0, 0x28(%rsp)
je 0xf960
movq 0x28(%rsp), %r14
movq 0x10(%r14), %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq 0x27a671(%rip), %rax    # 0x289fe0
movq (%rax), %rdi
movl 0x150(%r12), %edx
leaq 0x21d50e(%rip), %rsi    # 0x22ce8f
xorl %eax, %eax
callq 0x22b0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %al, %al
je 0xf9b6
cmpq $0x0, 0x30(%r12)
je 0xfa9f
cmpq $0x0, 0x38(%r12)
je 0xfa9f
movl (%r12), %eax
btl $0xb, %eax
jae 0xf9c9
addl $0xfffff800, %eax       # imm = 0xFFFFF800
movl %eax, (%r12)
movslq 0x11c(%r12), %r9
addq %r9, %r9
cmpq $0x0, 0x220(%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r8
jle 0xfa34
subq $0x8, %rsp
leaq 0x58(%rsp), %rax
leaq 0xd0(%rsp), %r10
movss 0x21a1b5(%rip), %xmm0   # 0x229bc0
movss 0x21a1b1(%rip), %xmm1   # 0x229bc4
movss 0x21a1a1(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %rbp
pushq %r10
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0x9fcf
jmp 0xf911
subq $0x50, %rsp
leaq 0xa0(%rsp), %rax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rsp)
leaq 0x118(%rsp), %rax
movq %rax, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
movl %r15d, 0x18(%rsp)
movl %r13d, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq $0x3, (%rsp)
movss 0x21a142(%rip), %xmm0   # 0x229bc0
movss 0x21a13e(%rip), %xmm1   # 0x229bc4
movss 0x21a12e(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
callq 0x8ae6
addq $0x50, %rsp
jmp 0xf915
cmpq $0x0, 0x50(%r12)
movl (%r12), %eax
je 0xfb35
cmpq $0x0, 0x58(%r12)
je 0xfb35
btl $0xb, %eax
jae 0xfac6
addl $0xfffff800, %eax       # imm = 0xFFFFF800
movl %eax, (%r12)
movslq 0x11c(%r12), %r9
addq %r9, %r9
cmpl $0x2, 0x1bc(%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r8
jg 0xfc35
subq $0x8, %rsp
leaq 0x58(%rsp), %rax
leaq 0xd0(%rsp), %r10
movss 0x21a0b4(%rip), %xmm0   # 0x229bc0
movss 0x21a0b0(%rip), %xmm1   # 0x229bc4
movss 0x21a0a0(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq %rbp
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0xc7ab7
jmp 0xf911
btl $0xb, %eax
jae 0xfba6
cmpl $0x0, 0x130(%r12)
jle 0xfba6
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r8
movslq 0x11c(%r12), %r9
addq %r9, %r9
subq $0x8, %rsp
leaq 0x58(%rsp), %rax
leaq 0xd0(%rsp), %r10
movss 0x21a043(%rip), %xmm0   # 0x229bc0
movss 0x21a03f(%rip), %xmm1   # 0x229bc4
movss 0x21a02f(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %rbp
pushq %r10
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0x9d87
jmp 0xf911
btl $0xb, %eax
jae 0xfbb5
addl $0xfffff800, %eax       # imm = 0xFFFFF800
movl %eax, (%r12)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
movq 0x18(%rsp), %r8
movslq 0x11c(%r12), %r9
addq %r9, %r9
subq $0x8, %rsp
leaq 0xd0(%rsp), %rax
movss 0x219fd9(%rip), %xmm0   # 0x229bc0
movss 0x219fd5(%rip), %xmm1   # 0x229bc4
movss 0x219fc5(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0xdca8
addq $0x30, %rsp
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rcx
subq $0x8, %rsp
movq %rbx, %rdx
movq %r14, %r8
movl %r13d, %r9d
pushq %r15
callq 0x88b8
popq %rax
popq %rcx
jmp 0xf915
subq $0x8, %rsp
leaq 0x58(%rsp), %rax
leaq 0xd0(%rsp), %r10
movss 0x219f72(%rip), %xmm0   # 0x229bc0
movss 0x219f6e(%rip), %xmm1   # 0x229bc4
movss 0x219f5e(%rip), %xmm2   # 0x229bbc
movq %rbx, %rdx
pushq %rax
pushq %r10
pushq %rbp
pushq %r15
pushq %r13
pushq %r14
pushq $0x3
callq 0xc8d09
jmp 0xf911