// File: /workspace/github_cpp_makefile_star2_O2/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 $0x148, %rsp            # imm = 0x148
movss %xmm1, 0x54(%rsp)
movss %xmm0, 0x50(%rsp)
movq %r9, 0x8(%rsp)
movq %rcx, %r13
movq %rsi, 0x40(%rsp)
movl %edi, 0x34(%rsp)
movl 0x1d0(%rsp), %ebx
movq 0x1c0(%rsp), %r15
movq 0x1b8(%rsp), %rbp
movq 0x198(%rsp), %rdi
movq %rsi, 0x28(%rsp)
movq %rdx, 0x58(%rsp)
movq %rdx, 0x38(%rsp)
movq %rcx, 0xc8(%rsp)
movq %r8, 0x60(%rsp)
movq %r8, 0xc0(%rsp)
callq 0xc0fe9
movq %rax, %r12
movq (%r15), %rax
movq %rax, 0x48(%rsp)
movq %rax, 0x20(%rsp)
movq (%rbp), %rbp
movq %rbp, 0x18(%rsp)
leaq 0x191951(%rip), %rax    # 0x253758
movq 0x288(%rax), %rsi
testq %rsi, %rsi
jne 0xc1e1e
movq $0x0, 0x10(%rsp)
jmp 0xc1e48
movq 0x2a0(%rax), %rdx
movq 0x290(%rax), %rcx
movq 0x298(%rax), %r8
movslq 0x7c(%rax), %r9
leaq 0x1923f2(%rip), %rdi    # 0x254230
callq 0x68125
movq %rax, 0x10(%rsp)
movq 0x180(%rsp), %r14
testl %ebx, %ebx
movq 0x58(%rsp), %r15
movq %r12, 0x68(%rsp)
jne 0xc1ee4
cmpq $0x0, 0x1c8(%rsp)
leaq 0x1918e6(%rip), %rbx    # 0x253758
movq 0x40(%rsp), %r14
jne 0xc1e97
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
movq 0x48(%rsp), %rcx
movq 0x1b0(%rsp), %r8
movq %r13, %r9
callq 0xb4d21
movl 0x2a8(%rbx), %edx
movq %r14, %rdi
movq %r13, %rsi
movq 0x1c8(%rsp), %rbp
movq %rbp, %rcx
callq 0x69765
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbp, %rcx
callq 0x69765
callq 0xa4437
testl %eax, %eax
jne 0xc1f13
leaq 0x19235d(%rip), %rax    # 0x254230
movq 0x28(%rax), %rdi
movq 0x50(%rax), %rdx
xorl %esi, %esi
callq 0x20e0
jmp 0xc1f1e
movslq 0x34(%rsp), %r12
leaq 0x191868(%rip), %rbx    # 0x253758
movl 0x7c(%rbx), %eax
cmpl $0xa, %eax
pushq $0xa
popq %rsi
cmovll %eax, %esi
leaq 0x70(%rsp), %rdi
movl %r13d, %edx
callq 0x68d88
movq 0x48(%rsp), %rdx
jmp 0xc2239
movq %r14, %rdi
movq %r13, %rsi
callq 0x6a226
movq 0x1b0(%rsp), %r15
cmpq $0x0, 0x68(%rbx)
jne 0xc1f39
xorl %eax, %eax
movq 0x40(%rsp), %r14
jmp 0xc1fcc
leaq 0x1923d8(%rip), %rdi    # 0x254318
leaq 0x1922e9(%rip), %rsi    # 0x254230
callq 0x7d32
cmpq $0x0, 0x68(%rbx)
movq 0x40(%rsp), %r14
jne 0xc1f5c
xorl %eax, %eax
jmp 0xc1fcc
movslq 0x34(%rsp), %r9
movslq 0x11c(%rbx), %rax
addq %rax, %rax
subq $0x8, %rsp
leaq 0x78(%rsp), %r10
movss 0x125d3c(%rip), %xmm0   # 0x1e7cb8
movss 0x125d38(%rip), %xmm1   # 0x1e7cbc
movss 0x125d28(%rip), %xmm2   # 0x1e7cb4
movq %r14, %rdi
movq 0x60(%rsp), %rsi
movq 0x188(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq 0x198(%rsp), %r8
pushq 0x18(%rsp)
pushq %r10
pushq $0x3
pushq %rax
pushq %r15
pushq 0x78(%rsp)
pushq 0x98(%rsp)
callq 0xc110d
addq $0x40, %rsp
movq 0x68(%rbx), %rax
cmpq $0x0, 0x2a8(%rbx)
jne 0xc1ff5
xorl %ecx, %ecx
cmpq $0x1, %rax
sbbl %ecx, %ecx
orl $0x2, %ecx
movq %r14, %rdi
movq 0x58(%rsp), %rsi
movq %r13, %rdx
callq 0x7d6b3
movq 0x68(%rbx), %rax
testq %rax, %rax
je 0xc2001
leaq 0x192317(%rip), %rax    # 0x254318
leaq 0x20(%rsp), %r11
leaq 0x70(%rsp), %r10
movl 0x34(%rsp), %ebx
movl %ebx, %edi
movq %r13, %rsi
movq 0x8(%rsp), %rbp
movq %rbp, %rdx
movq 0x180(%rsp), %rcx
movq 0x190(%rsp), %r8
movq %r14, %r9
movq 0x10(%rsp), %r12
pushq %r12
pushq %rax
pushq %r11
movq %r11, %r13
pushq %r10
pushq %r15
movq 0x88(%rsp), %r14
pushq %r14
callq 0xc149c
addq $0x30, %rsp
movq %r15, %r8
movq %rax, %r15
movq %rax, 0x18(%rsp)
movslq %ebx, %rdx
movq (%r13), %rsi
leaq 0x1916ec(%rip), %rax    # 0x253758
movslq 0x11c(%rax), %rcx
movq %rcx, 0xb8(%rsp)
movq %rax, %rdi
leaq (%rcx,%rcx), %rax
xorps %xmm0, %xmm0
leaq 0xd0(%rsp), %r13
movups %xmm0, 0x40(%r13)
movups %xmm0, 0x30(%r13)
movups %xmm0, 0x20(%r13)
movq 0x40(%rsp), %rcx
movq %rcx, 0x8(%r13)
movq 0x58(%rsp), %rbx
movq %rbx, 0x10(%r13)
movq 0x180(%rsp), %r9
movl %r9d, 0x40(%r13)
movl %ebp, 0x44(%r13)
movq 0x190(%rsp), %rcx
movq %rcx, 0x50(%r13)
movq %rdx, 0xa0(%rsp)
movq %rdx, 0x58(%r13)
movq %r14, 0x68(%r13)
movq 0x40(%rsp), %r14
movq %rsi, 0x48(%rsp)
movq %rsi, (%r13)
movq %r8, 0x30(%r13)
movq %r8, %rbp
movq %rax, 0x18(%r13)
movl $0x3e19999a, 0x20(%r13) # imm = 0x3E19999A
movq $0x3, 0x28(%r13)
movsd 0x125b25(%rip), %xmm0   # 0x1e7c30
movsd %xmm0, 0x38(%r13)
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%r13)
movq %r12, 0x70(%r13)
cvtss2sd 0x50(%rsp), %xmm0
movsd %xmm0, 0xb0(%rsp)
cvtss2sd 0x54(%rsp), %xmm0
movsd %xmm0, 0xa8(%rsp)
xorl %r12d, %r12d
cmpq $0x0, 0x68(%rdi)
setne %r12b
callq 0xa4437
movsd 0x121383(%rip), %xmm2   # 0x1e34d8
movq %r13, %rdi
movq %r15, 0x98(%rsp)
movq %r15, %rsi
movq %rbx, %r13
movq %r14, %rdx
movq %rbx, %rcx
movq %rbp, %r8
movq 0x188(%rsp), %r9
movsd 0xb0(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
pushq 0x68(%rsp)
pushq 0x1d0(%rsp)
pushq $0x2
pushq %rax
pushq %r12
leaq 0x98(%rsp), %rax
pushq %rax
pushq 0x1c0(%rsp)
pushq 0xf0(%rsp)
leaq 0x1915a1(%rip), %rbx    # 0x253758
callq 0x1aeb62
addq $0x40, %rsp
testb $0x4, (%rbx)
jne 0xc21e9
movq 0x68(%rsp), %r13
movq 0x10(%rsp), %r15
movq 0x8(%rsp), %rsi
movq 0x180(%rsp), %r14
movq 0x98(%rsp), %rbp
jmp 0xc2313
subq $0x8, %rsp
leaq 0x192124(%rip), %rax    # 0x254318
movq 0xa0(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq 0x50(%rsp), %r12
movq %r12, %rdx
movq 0x1a0(%rsp), %rcx
movq %r13, %r8
movq %rbp, %r9
pushq %rax
callq 0xb33b7
popq %rcx
popq %rdx
movq 0x180(%rsp), %r14
movq %r12, %rdx
movq 0xa0(%rsp), %r12
movq %r15, %rbp
movq %r13, %r15
movslq 0x11c(%rbx), %rax
addq %rax, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x110(%rsp)
movups %xmm0, 0x100(%rsp)
movups %xmm0, 0xf0(%rsp)
movq 0x40(%rsp), %rcx
movq %rcx, 0xd8(%rsp)
movq %r15, 0xe0(%rsp)
movl %r14d, 0x110(%rsp)
movq 0x8(%rsp), %rsi
movl %esi, 0x114(%rsp)
movq 0x190(%rsp), %rcx
movq %rcx, 0x120(%rsp)
movq %r12, 0x128(%rsp)
movq 0x60(%rsp), %rcx
movq %rcx, 0x138(%rsp)
movq %rdx, 0xd0(%rsp)
movq 0x1b0(%rsp), %rcx
movq %rcx, 0x100(%rsp)
movq %rax, 0xe8(%rsp)
movl $0x3e19999a, 0xf0(%rsp) # imm = 0x3E19999A
movq $0x3, 0xf8(%rsp)
movsd 0x125945(%rip), %xmm0   # 0x1e7c30
movsd %xmm0, 0x108(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x10(%rsp), %r15
movq %r15, 0x140(%rsp)
movq 0x68(%rsp), %r13
cmpq $0x0, 0x68(%rbx)
movq %r15, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
jne 0xc2373
movq %r14, %r12
leaq 0xd0(%rsp), %rdi
movq %rbp, %rsi
movl $0x124f8, %edx          # imm = 0x124F8
callq 0x1af6b9
callq 0xa4437
movq 0x18(%rsp), %rbx
testl %eax, %eax
jne 0xc235a
leaq 0xd0(%rsp), %rsi
movq %rbx, %rdi
callq 0x857d0
leaq 0x1913f7(%rip), %r14    # 0x253758
movq 0x1b0(%rsp), %rbp
movq 0x8(%rsp), %r15
jmp 0xc243f
cvtss2sd 0x50(%rsp), %xmm0
cvtss2sd 0x54(%rsp), %xmm1
movslq 0x34(%rsp), %rax
movl 0x250(%rbx), %ecx
subq $0x70, %rsp
movq %r15, 0x68(%rsp)
leaq 0x132b4b(%rip), %rdx    # 0x1f4ee5
movq %rdx, 0x60(%rsp)
movq %r13, 0x58(%rsp)
movl %ecx, 0x50(%rsp)
leaq 0xe0(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, 0x38(%rsp)
movq 0x200(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x1f8(%rsp), %rax
movq %rax, 0x20(%rsp)
leaq 0x140(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %r14, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq %r14, %r12
movq %rbx, %r14
leaq 0x88(%rsp), %rbx
movq %rbx, (%rsp)
leaq 0x98(%rsp), %rdi
movq %rsi, %r15
leaq 0xa8(%rsp), %rsi
leaq 0x138(%rsp), %rdx
leaq 0x130(%rsp), %rcx
leaq 0x90(%rsp), %r8
movq 0x220(%rsp), %rbp
movq %rbp, %r9
callq 0xc1840
addq $0x70, %rsp
movq (%rbx), %rbx
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x180(%r14), %r9
subq $0x30, %rsp
movl %r15d, 0x18(%rsp)
movq %r12, %r15
movl %r12d, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
movq %rbx, %rdi
movq %r13, %rdx
callq 0xb3d70
addq $0x30, %rsp
cmpq $0x0, 0x40(%r14)
movq %r14, %rbx
movq %r13, %r12
jne 0xc2535
callq 0xa4437
cmpq $0x0, 0x50(%rbx)
sete %cl
cmpq $0x0, 0x58(%rbx)
sete %dl
orb %cl, %dl
movl (%rbx), %ecx
testl %eax, %eax
jne 0xc25b0
testb %dl, %dl
movq %r15, %r14
je 0xc2643
btl $0xb, %ecx
movq 0x10(%rsp), %r15
jae 0xc273a
cmpl $0x0, 0x130(%rbx)
jle 0xc273a
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r8
movslq 0x11c(%rbx), %r9
addq %r9, %r9
subq $0x8, %rsp
leaq 0xd8(%rsp), %rax
leaq 0x78(%rsp), %r10
movss 0x1257b3(%rip), %xmm0   # 0x1e7cb8
movss 0x1257af(%rip), %xmm1   # 0x1e7cbc
movss 0x12579f(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
pushq 0x1a0(%rsp)
pushq %r10
pushq 0x28(%rsp)
pushq %r14
pushq %rbp
pushq $0x3
callq 0x91945
jmp 0xc2882
movl (%rbx), %eax
btl $0xb, %eax
jae 0xc2544
addl $0xfffff800, %eax       # imm = 0xFFFFF800
movl %eax, (%rbx)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r8
movslq 0x11c(%rbx), %r9
addq %r9, %r9
movl 0x1bc(%rbx), %eax
leaq 0x70(%rsp), %r10
movss 0x125743(%rip), %xmm0   # 0x1e7cb8
movss 0x12573f(%rip), %xmm1   # 0x1e7cbc
movss 0x12572f(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
pushq %r10
pushq $0x0
pushq 0x1a8(%rsp)
pushq 0x28(%rsp)
pushq %r15
pushq %rbp
pushq $0x3
callq 0x86af7
addq $0x40, %rsp
movq 0x10(%rsp), %r15
jmp 0xc2886
testb %dl, %dl
movq %r15, %r11
je 0xc26ca
btl $0xb, %ecx
movq 0x10(%rsp), %r15
jae 0xc25ce
addl $0xfffff800, %ecx       # imm = 0xFFFFF800
movl %ecx, (%rbx)
movslq 0x11c(%rbx), %r9
addq %r9, %r9
cmpq $0x0, 0x220(%rbx)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r8
jle 0xc27ca
subq $0x8, %rsp
leaq 0xd8(%rsp), %rax
leaq 0x78(%rsp), %r10
movss 0x1256a5(%rip), %xmm0   # 0x1e7cb8
movss 0x1256a1(%rip), %xmm1   # 0x1e7cbc
movss 0x125691(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
pushq 0x1a0(%rsp)
pushq %r10
pushq 0x28(%rsp)
pushq %r11
pushq %rbp
pushq $0x3
callq 0x91b8d
jmp 0xc2882
btl $0xb, %ecx
movq 0x10(%rsp), %r15
jae 0xc2656
addl $0xfffff800, %ecx       # imm = 0xFFFFF800
movl %ecx, (%rbx)
movslq 0x11c(%rbx), %r9
addq %r9, %r9
cmpl $0x2, 0x1bc(%rbx)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r8
jg 0xc283e
subq $0x8, %rsp
leaq 0xd8(%rsp), %rax
leaq 0x78(%rsp), %r10
movss 0x12561e(%rip), %xmm0   # 0x1e7cb8
movss 0x12561a(%rip), %xmm1   # 0x1e7cbc
movss 0x12560a(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
pushq %r10
pushq 0x1a8(%rsp)
pushq 0x28(%rsp)
pushq %r14
pushq %rbp
pushq $0x3
callq 0x8c37c
jmp 0xc2882
btl $0xb, %ecx
movq 0x10(%rsp), %r15
jae 0xc26dd
addl $0xfffff800, %ecx       # imm = 0xFFFFF800
movl %ecx, (%rbx)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r8
movslq 0x11c(%rbx), %r9
addq %r9, %r9
leaq 0x70(%rsp), %rax
movss 0x1255b0(%rip), %xmm0   # 0x1e7cb8
movss 0x1255ac(%rip), %xmm1   # 0x1e7cbc
movss 0x12559c(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
pushq 0x198(%rsp)
pushq 0x18(%rsp)
pushq %r11
pushq %rbp
pushq $0x3
callq 0x9207e
addq $0x30, %rsp
jmp 0xc2886
btl $0xb, %ecx
jae 0xc2748
addl $0xfffff800, %ecx       # imm = 0xFFFFF800
movl %ecx, (%rbx)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %r8
movslq 0x11c(%rbx), %r9
addq %r9, %r9
subq $0x8, %rsp
leaq 0x78(%rsp), %rax
movss 0x125541(%rip), %xmm0   # 0x1e7cb8
movss 0x12553d(%rip), %xmm1   # 0x1e7cbc
movss 0x12552d(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
movq 0x18(%rsp), %r13
pushq %r13
pushq %r14
pushq %rbp
pushq $0x3
callq 0xb4027
addq $0x30, %rsp
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rcx
subq $0x8, %rsp
movq %r12, %rdx
movq %rbp, %r8
movl %r14d, %r9d
pushq %r13
callq 0x8d034
popq %rax
popq %rcx
jmp 0xc2886
subq $0x50, %rsp
leaq 0x120(%rsp), %rax
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x1e0(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x58(%rsp), %rax
movl %eax, 0x18(%rsp)
movl %r11d, 0x10(%rsp)
movq %rbp, 0x8(%rsp)
movq $0x3, (%rsp)
movss 0x125498(%rip), %xmm0   # 0x1e7cb8
movss 0x125494(%rip), %xmm1   # 0x1e7cbc
movss 0x125484(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
callq 0x8d2bd
addq $0x50, %rsp
jmp 0xc2886
subq $0x8, %rsp
leaq 0xd8(%rsp), %rax
leaq 0x78(%rsp), %r10
movss 0x125461(%rip), %xmm0   # 0x1e7cb8
movss 0x12545d(%rip), %xmm1   # 0x1e7cbc
movss 0x12544d(%rip), %xmm2   # 0x1e7cb4
movq %r12, %rdx
pushq %rax
pushq %r10
pushq 0x1a8(%rsp)
pushq 0x28(%rsp)
pushq %r14
pushq %rbp
pushq $0x3
callq 0x8e0ab
addq $0x40, %rsp
movq 0x20(%rsp), %rax
movq 0x1c0(%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %rax
movq 0x1b8(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x70(%rsp), %rdi
callq 0x68e8b
testq %r15, %r15
je 0xc28c5
movq %r15, %rdi
callq 0x68d7f
movq %r15, %rdi
callq 0x2220
movq %r12, %rdi
callq 0x2220
movq 0x19070c(%rip), %rax    # 0x252fe0
movq (%rax), %rdi
movl 0x150(%rbx), %edx
leaq 0x12869b(%rip), %rsi    # 0x1eaf7f
xorl %eax, %eax
callq 0x22b0
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq