// File: chhylp123[P]hifiasm/gfa_ut.cpp
// Function: ul_clean_gfa(ug_opt_t*, asg_t*, ma_hit_t_alloc*, ma_hit_t_alloc*, R_to_U*, long, double, double, double, long, long, bub_label_t*, int, int, unsigned int, unsigned char*, char*)
void ul_clean_gfa(ug_opt_t *uopt, asg_t *sg, ma_hit_t_alloc *src, ma_hit_t_alloc *rev, R_to_U* rI, int64_t clean_round, double min_ovlp_drop_ratio, double max_ovlp_drop_ratio, 
double ou_drop_rate, int64_t max_tip, int64_t gap_fuzz, bub_label_t *b_mask_t, int32_t is_ou, int32_t is_trio, uint32_t ou_thres, uint8_t *cmk, char *o_file)
{
    #define HARD_OU_DROP 0.75
    #define HARD_OL_DROP 0.6
    #define HARD_OL_SEC_DROP 0.85
    #define HARD_ORTHOLOGY_DROP 0.4
    double step = 
        (clean_round==1?max_ovlp_drop_ratio:((max_ovlp_drop_ratio-min_ovlp_drop_ratio)/(clean_round-1)));
    double drop = min_ovlp_drop_ratio;
    int64_t i; asg64_v bu = {0,0,0}, ba = {0,0,0}; uint32_t l_drop = 2000; flex_asg_t *fg = NULL; uint32_t min_diff = 0, step_diff = 2000;
    if(is_ou) fg = init_flex_asg_t(sg, uopt->sources, uopt->min_ovlp, uopt->max_hang, asm_opt.max_hang_rate, gap_fuzz);
    // if(is_ou) update_sg_uo(sg, src);///do not do it here
    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);
    // exit(1);
    // print_raw_u2rgfa_seq(&UL_INF, rI, 1);
    // exit(1);
    // fprintf(stderr, "%.*s\tid::%u\tis_c::%u\n", 
    //                 (int)Get_NAME_LENGTH(R_INF, 10785), Get_NAME(R_INF, 10785), 10785, is_contain_r((*rI), 10785));
    // fprintf(stderr, "%.*s\tid::%u\tis_c::%u\n", 
    //             (int)Get_NAME_LENGTH(R_INF, 10790), Get_NAME(R_INF, 10790), 10790, is_contain_r((*rI), 10790));
    // fprintf(stderr, "%.*s\tid::%u\tis_c::%u\n", 
    //         (int)Get_NAME_LENGTH(R_INF, 10805), Get_NAME(R_INF, 10805), 10805, is_contain_r((*rI), 10805));
    // fprintf(stderr, "%.*s\tid::%u\tis_c::%u\n", 
    //         (int)Get_NAME_LENGTH(R_INF, 10809), Get_NAME(R_INF, 10809), 10809, is_contain_r((*rI), 10809));
    // fprintf(stderr, "%.*s\tid::%u\tis_c::%u\n", 
    //         (int)Get_NAME_LENGTH(R_INF, 10819), Get_NAME(R_INF, 10819), 10819, is_contain_r((*rI), 10819));
    // debug_info_of_specfic_node("m64011_190830_220126/47516220/ccs", sg, rI, "beg-0");
    // debug_info_of_specfic_node("bcb40bcc-d9cf-48e6-88ee-47ac3dde22ff", sg, rI, "beg-0");

    if(asm_opt.is_ont) asg_arc_cut_weak(sg, &bu, max_tip, 0.975, 0, is_ou, 0, 1, 16, UL_COV_THRES-1, 0, rev, NULL, NULL);

	asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);///p_telo
    // fprintf(stderr, "[M::%s] count_edges_v_w(sg, 49778, 49847)->%ld\n", __func__, count_edges_v_w(sg, 49778, 49847));
    // if(is_ou) dedup_contain_g(uopt, sg);
    for (i = 0; i < clean_round; i++, drop += step) {
        if(drop > max_ovlp_drop_ratio) drop = max_ovlp_drop_ratio;
        if(is_ou) {
            if(drop <= 0.500001) min_diff = step_diff>>1;
            else min_diff = step_diff;
        }

        if(asm_opt.is_ont) {
            asg_arc_cut_weak(sg, &bu, max_tip, 0.975, 0, is_ou, 0, 1, 16, UL_COV_THRES-1, 0, rev, NULL, NULL);
            asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
        }
        // fprintf(stderr, "(0):i->%ld, drop->%f\n", i, drop);
        // prt_specfic_sge(sg, 10531, 10519, "--0--");

        // print_vw_edge(sg, 34156, 34090, "0");
        // stats_chimeric(sg, src, &bu);
        if(!is_ou) asg_iterative_semi_circ(sg, src, &bu, max_tip, 1, uopt->te);///p_telo
        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 1);
        asg_arc_cut_chimeric(sg, src, &bu, is_ou?ou_thres:(uint32_t)-1, uopt->te);///p_telo

        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
        // prt_specfic_sge(sg, 10531, 10519, "--1--");
        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 0);
        asg_arc_cut_inexact(sg, src, &bu, max_tip, is_ou, is_trio, min_diff, ou_drop_rate/**, NULL**//**&dbg**/);
        // debug_edges(&dbg, d, 2);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
        // prt_specfic_sge(sg, 10531, 10519, "--2--");

        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 1);
        asg_arc_cut_length(sg, &bu, max_tip, drop, ou_drop_rate, is_ou, is_trio, 1, min_diff, 1, NULL, NULL, NULL);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);

        // prt_specfic_sge(sg, 10531, 10519, "--3--");
        // if(is_ou) asg_arc_cut_contain(fg, &bu, &ba, rI, ((i+1)<clean_round)?ou_drop_rate:-1);
        if(is_ou) {
            asg_arc_cut_contain(fg, &bu, &ba, rI, ou_drop_rate, 0);
            // dedup_contain_g(uopt, sg);
        }

        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 1);
        asg_arc_cut_bub_links(sg, &bu, HARD_OL_DROP, HARD_OL_SEC_DROP, HARD_OU_DROP, is_ou, asm_opt.large_pop_bubble_size, rev, rI, max_tip);
        // prt_specfic_sge(sg, 10531, 10519, "--4--");

        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 1);
        asg_arc_cut_complex_bub_links(sg, &bu, HARD_OL_DROP, HARD_OU_DROP, is_ou, b_mask_t);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
        // prt_specfic_sge(sg, 10531, 10519, "--5--");

        // if(i == 3) {
        //     print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty3.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);
        //     // exit(1);
        // }
        /**
        if(cmk && asm_opt.chemical_cov > FORCE_CUT) {
            asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 0);
            asg_arc_cut_chimeric_cmk(sg, &bu, max_tip, 1.1, 1.1, is_ou, 1, 1, 1, cmk, asm_opt.chemical_cov);
            asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
        }
        **/


        if(is_ou) {
            if(ul_refine_alignment(uopt, sg)) update_sg_uo(sg, src);
            if(clean_contain_g(uopt, sg, 1)) update_sg_uo(sg, src);
        }
    }

    if(asm_opt.is_ont) {
        asg_arc_cut_weak(sg, &bu, max_tip, 0.975, 0, is_ou, 0, 1, 16, UL_COV_THRES-1, 0, rev, NULL, NULL);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
    }

    if(is_ou) min_diff = step_diff;
    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty4.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);
    // debug_info_of_specfic_node("m64012_190921_234837/111673711/ccs", sg, rI, "end");
    // debug_info_of_specfic_node("m64011_190830_220126/95028102/ccs", sg, rI, "end");
    if(is_ou) {
        asg_arc_cut_contain(fg, &bu, &ba, rI, ou_drop_rate, 0);
        asg_arc_cut_contain(fg, &bu, &ba, rI, -1, 1);
        // dedup_contain_g(uopt, sg);
        if(clean_contain_g(uopt, sg, 1)) update_sg_uo(sg, src);
    }
    if(!is_ou) asg_iterative_semi_circ(sg, src, &bu, max_tip, 1, uopt->te);

    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty5.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);

    asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 0);
    asg_cut_large_indel(sg, &bu, max_tip, HARD_OU_DROP, is_ou, min_diff);///shoule we ignore ou here?
    asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);

    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty6.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);

    if(!is_ou) {
        ///asg_arc_del_triangular_directly might be unnecessary
        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 0);
        asg_arc_cut_length(sg, &bu, max_tip, HARD_ORTHOLOGY_DROP/**min_ovlp_drop_ratio**/, ou_drop_rate, is_ou, 0/**is_trio**/, is_ou?1:0, min_diff, 1, rev, rI, NULL);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);

        // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty7.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);

        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 0);
        asg_arc_cut_length(sg, &bu, max_tip, min_ovlp_drop_ratio, ou_drop_rate, is_ou, 0/**is_trio**/, is_ou?1:0, min_diff, 1, rev, rI, &l_drop);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
    } else {
        min_diff = step_diff; l_drop = 6000;
        asg_arc_identify_simple_bubbles_multi(sg, b_mask_t, 0);
        asg_arc_cut_length(sg, &bu, max_tip, 0.3, 0.9, is_ou, is_trio, 1, min_diff, 8, NULL, NULL, &l_drop);
        asg_arc_cut_tips(sg, max_tip, &bu, is_ou, is_ou?rI:NULL, uopt->te);
    }

    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.dirty8.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);

    if(!is_ou) asg_cut_semi_circ(sg, LIM_LEN, 1);
    /**
    rescue_contained_reads_aggressive(NULL, sg, src, uopt->coverage_cut, rI, uopt->max_hang, uopt->min_ovlp, 10, 1, 0, NULL, NULL, b_mask_t);
    rescue_missing_overlaps_aggressive(NULL, sg, src, uopt->coverage_cut, rI, uopt->max_hang, uopt->min_ovlp, 1, 0, NULL, b_mask_t);
    rescue_missing_overlaps_backward(NULL, sg, src, uopt->coverage_cut, rI, uopt->max_hang, uopt->min_ovlp, 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, uopt->coverage_cut, src, rev, rI, uopt->max_hang, uopt->min_ovlp);
    rescue_bubble_by_chain(sg, uopt->coverage_cut, src, rev, (asm_opt.max_short_tip*2), 0.15, 3, rI, 0.05, 0.9, uopt->max_hang, uopt->min_ovlp, 10, uopt->gap_fuzz, b_mask_t);
    **/
    post_rescue(uopt, sg, src, rev, rI, b_mask_t, is_ou, cmk);
    
    ug_ext_gfa(uopt, sg, ug_ext_len);

    // if(is_ou) dedup_contain_g(uopt, sg);
    // exit(1)

    output_unitig_graph(sg, uopt->coverage_cut, o_file, src, rI, uopt->max_hang, uopt->min_ovlp);
    // exit(1);
    // flat_bubbles(sg, ruIndex->is_het); free(ruIndex->is_het); ruIndex->is_het = NULL;
    flat_soma_v(sg, src, rI);

    ///note: although the above functions will not change the UL part, but it will change the read graph
    ///so it is necessary to run update_sg_uo
    if(is_ou) {
        update_sg_uo(sg, src);
    }
    if(is_ou) {
        des_flex_asg_t(fg); free(fg);
    }
    // print_debug_gfa(sg, NULL, uopt->coverage_cut, "UL.debug", uopt->sources, uopt->ruIndex, uopt->max_hang, uopt->min_ovlp, 1, 0, 0);
    // exit(1);
    // print_node(sg, 17078); //print_node(sg, 8311); print_node(sg, 8294);
    
    free(bu.a); free(ba.a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movl 0x38(%rbp), %eax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movsd %xmm0, -0x40(%rbp)
movsd %xmm1, -0x48(%rbp)
movsd %xmm2, -0x50(%rbp)
cmpq $0x1, -0x38(%rbp)
jne 0x320ff6
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0xb8(%rbp)
jmp 0x321019
movsd -0x48(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
movq -0x38(%rbp), %rax
subq $0x1, %rax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2100
movl $0x7d0, -0x9c(%rbp)     # imm = 0x7D0
movq $0x0, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
movl $0x7d0, -0xb0(%rbp)     # imm = 0x7D0
cmpl $0x0, 0x28(%rbp)
je 0x3210be
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x10(%rbp), %rax
movslq 0x44(%rax), %rdx
movq -0x10(%rbp), %rax
movslq 0x40(%rax), %rcx
leaq 0xa3753(%rip), %rax     # 0x3c47f8
cvttss2si 0x158(%rax), %r8
movq 0x18(%rbp), %r9
callq 0x3205a0
movq %rax, -0xa8(%rbp)
leaq 0xa3733(%rip), %rax     # 0x3c47f8
cmpq $0x0, 0x2a8(%rax)
je 0x32112e
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movl 0x28(%rbp), %ecx
movq -0x28(%rbp), %rax
leaq -0x80(%rbp), %rsi
movss 0x74fb4(%rip), %xmm0    # 0x3960a0
xorps %xmm1, %xmm1
xorl %r8d, %r8d
movl $0x1, %r9d
xorl %r10d, %r10d
movl $0x10, (%rsp)
movl $0x1, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
callq 0x316820
movq -0x18(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0xc0(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0xbc(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x32115f
movq -0x30(%rbp), %rax
movq %rax, -0xd0(%rbp)
jmp 0x32116a
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
jmp 0x32116a
movl -0xbc(%rbp), %ecx
movl -0xc0(%rbp), %esi
movq -0xc8(%rbp), %rdi
movq -0xd0(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x3216dc
movsd -0x60(%rbp), %xmm0
ucomisd -0x48(%rbp), %xmm0
jbe 0x3211c1
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x3211f4
movsd 0x61101(%rip), %xmm0    # 0x3822d0
ucomisd -0x60(%rbp), %xmm0
jb 0x3211e6
movl -0xb0(%rbp), %eax
shrl %eax
movl %eax, -0xac(%rbp)
jmp 0x3211f2
movl -0xb0(%rbp), %eax
movl %eax, -0xac(%rbp)
jmp 0x3211f4
leaq 0xa35fd(%rip), %rax     # 0x3c47f8
cmpq $0x0, 0x2a8(%rax)
je 0x3212cf
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movl 0x28(%rbp), %ecx
movq -0x28(%rbp), %rax
leaq -0x80(%rbp), %rsi
movss 0x74e7a(%rip), %xmm0    # 0x3960a0
xorps %xmm1, %xmm1
xorl %r8d, %r8d
movl $0x1, %r9d
xorl %r10d, %r10d
movl $0x10, (%rsp)
movl $0x1, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
callq 0x316820
movq -0x18(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0xd8(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0xd4(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321299
movq -0x30(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x3212a4
xorl %eax, %eax
movq %rax, -0xe8(%rbp)
jmp 0x3212a4
movl -0xd4(%rbp), %ecx
movl -0xd8(%rbp), %esi
movq -0xe0(%rbp), %rdi
movq -0xe8(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
cmpl $0x0, 0x28(%rbp)
jne 0x3212fa
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
movl $0x1, %r8d
callq 0x31d830
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xd8550
movq -0x18(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321333
movl 0x38(%rbp), %eax
movl %eax, -0xfc(%rbp)
jmp 0x321340
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0xfc(%rbp)
jmp 0x321340
movq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rdi
movl -0xfc(%rbp), %ecx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r8
leaq -0x80(%rbp), %rdx
callq 0x313750
movq -0x18(%rbp), %rax
movq %rax, -0x110(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x104(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x100(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321396
movq -0x30(%rbp), %rax
movq %rax, -0x118(%rbp)
jmp 0x3213a1
xorl %eax, %eax
movq %rax, -0x118(%rbp)
jmp 0x3213a1
movl -0x100(%rbp), %ecx
movl -0x104(%rbp), %esi
movq -0x110(%rbp), %rdi
movq -0x118(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
xorl %edx, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x10(%rbp), %rax
movl %eax, %ecx
movl 0x28(%rbp), %r8d
movl 0x30(%rbp), %r9d
movl -0xac(%rbp), %eax
movsd -0x50(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x80(%rbp), %rdx
movl %eax, (%rsp)
callq 0x313d90
movq -0x18(%rbp), %rax
movq %rax, -0x128(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x120(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x11c(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x32143d
movq -0x30(%rbp), %rax
movq %rax, -0x130(%rbp)
jmp 0x321448
xorl %eax, %eax
movq %rax, -0x130(%rbp)
jmp 0x321448
movl -0x11c(%rbp), %ecx
movl -0x120(%rbp), %esi
movq -0x128(%rbp), %rdi
movq -0x130(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movsd -0x60(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movsd -0x50(%rbp), %xmm1
cvtsd2ss %xmm1, %xmm1
movl 0x28(%rbp), %ecx
movl 0x30(%rbp), %r8d
movl -0xac(%rbp), %eax
leaq -0x80(%rbp), %rsi
movl $0x1, %r9d
xorl %r10d, %r10d
movl %eax, (%rsp)
movl $0x1, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x315a70
movq -0x18(%rbp), %rax
movq %rax, -0x140(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x138(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x134(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321517
movq -0x30(%rbp), %rax
movq %rax, -0x148(%rbp)
jmp 0x321522
xorl %eax, %eax
movq %rax, -0x148(%rbp)
jmp 0x321522
movl -0x134(%rbp), %ecx
movl -0x138(%rbp), %esi
movq -0x140(%rbp), %rdi
movq -0x148(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
cmpl $0x0, 0x28(%rbp)
je 0x32157a
movq -0xa8(%rbp), %rdi
movq -0x30(%rbp), %rcx
movsd -0x50(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x80(%rbp), %rsi
leaq -0x98(%rbp), %rdx
xorl %r8d, %r8d
callq 0x31b1c0
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movl 0x28(%rbp), %edx
leaq 0xa325e(%rip), %rax     # 0x3c47f8
movq 0x188(%rax), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %rax
leaq -0x80(%rbp), %rsi
movss 0x5daaf(%rip), %xmm0    # 0x37f068
movss 0x74ae7(%rip), %xmm1    # 0x3960a8
movss 0x5dabb(%rip), %xmm2    # 0x37f084
movl %eax, (%rsp)
callq 0x31bde0
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
movl $0x1, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movl 0x28(%rbp), %edx
movq 0x20(%rbp), %rcx
leaq -0x80(%rbp), %rsi
movss 0x5da6e(%rip), %xmm0    # 0x37f068
movss 0x5da82(%rip), %xmm1    # 0x37f084
callq 0x31c850
movq -0x18(%rbp), %rax
movq %rax, -0x158(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x150(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x14c(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321638
movq -0x30(%rbp), %rax
movq %rax, -0x160(%rbp)
jmp 0x321643
xorl %eax, %eax
movq %rax, -0x160(%rbp)
jmp 0x321643
movl -0x14c(%rbp), %ecx
movl -0x150(%rbp), %esi
movq -0x158(%rbp), %rdi
movq -0x160(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
cmpl $0x0, 0x28(%rbp)
je 0x3216ba
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2ff740
cmpq $0x0, %rax
je 0x321694
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x313360
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x2ff3e0
cmpl $0x0, %eax
je 0x3216b8
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x313360
jmp 0x3216ba
jmp 0x3216bc
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movsd -0x58(%rbp), %xmm0
addsd -0x60(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x32119d
leaq 0xa3115(%rip), %rax     # 0x3c47f8
cmpq $0x0, 0x2a8(%rax)
je 0x3217b7
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movl 0x28(%rbp), %ecx
movq -0x28(%rbp), %rax
leaq -0x80(%rbp), %rsi
movss 0x74992(%rip), %xmm0    # 0x3960a0
xorps %xmm1, %xmm1
xorl %r8d, %r8d
movl $0x1, %r9d
xorl %r10d, %r10d
movl $0x10, (%rsp)
movl $0x1, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
callq 0x316820
movq -0x18(%rbp), %rax
movq %rax, -0x170(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x168(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x164(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321781
movq -0x30(%rbp), %rax
movq %rax, -0x178(%rbp)
jmp 0x32178c
xorl %eax, %eax
movq %rax, -0x178(%rbp)
jmp 0x32178c
movl -0x164(%rbp), %ecx
movl -0x168(%rbp), %esi
movq -0x170(%rbp), %rdi
movq -0x178(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
cmpl $0x0, 0x28(%rbp)
je 0x3217c9
movl -0xb0(%rbp), %eax
movl %eax, -0xac(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321845
movq -0xa8(%rbp), %rdi
movq -0x30(%rbp), %rcx
movsd -0x50(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
leaq -0x80(%rbp), %rsi
leaq -0x98(%rbp), %rdx
xorl %r8d, %r8d
callq 0x31b1c0
movq -0xa8(%rbp), %rdi
movq -0x30(%rbp), %rcx
leaq -0x80(%rbp), %rsi
leaq -0x98(%rbp), %rdx
movss 0x5d85c(%rip), %xmm0    # 0x37f070
movl $0x1, %r8d
callq 0x31b1c0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x1, %edx
callq 0x2ff3e0
cmpl $0x0, %eax
je 0x321843
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x313360
jmp 0x321845
cmpl $0x0, 0x28(%rbp)
jne 0x321870
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq 0x10(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
movl $0x1, %r8d
callq 0x31d830
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
xorl %edx, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movl 0x28(%rbp), %ecx
movl -0xac(%rbp), %r8d
leaq -0x80(%rbp), %rsi
movss 0x5d7e5(%rip), %xmm0    # 0x37f084
callq 0x31d8e0
movq -0x18(%rbp), %rax
movq %rax, -0x188(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x180(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x17c(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x3218d5
movq -0x30(%rbp), %rax
movq %rax, -0x190(%rbp)
jmp 0x3218e0
xorl %eax, %eax
movq %rax, -0x190(%rbp)
jmp 0x3218e0
movl -0x17c(%rbp), %ecx
movl -0x180(%rbp), %esi
movq -0x188(%rbp), %rdi
movq -0x190(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
cmpl $0x0, 0x28(%rbp)
jne 0x321ade
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
xorl %edx, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movsd -0x50(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm1
movl 0x28(%rbp), %ecx
movl 0x28(%rbp), %esi
xorl %r9d, %r9d
movl $0x1, %eax
cmpl $0x0, %esi
cmovnel %eax, %r9d
movl -0xac(%rbp), %r11d
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %rax
leaq -0x80(%rbp), %rsi
movss 0x7473d(%rip), %xmm0    # 0x3960a4
xorl %r8d, %r8d
xorl %ebx, %ebx
movl %r11d, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x315a70
movq -0x18(%rbp), %rax
movq %rax, -0x1a0(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x198(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x194(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x3219c1
movq -0x30(%rbp), %rax
movq %rax, -0x1a8(%rbp)
jmp 0x3219cc
xorl %eax, %eax
movq %rax, -0x1a8(%rbp)
jmp 0x3219cc
movl -0x194(%rbp), %ecx
movl -0x198(%rbp), %esi
movq -0x1a0(%rbp), %rdi
movq -0x1a8(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
xorl %edx, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movsd -0x40(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movsd -0x50(%rbp), %xmm1
cvtsd2ss %xmm1, %xmm1
movl 0x28(%rbp), %ecx
movl 0x28(%rbp), %esi
xorl %r9d, %r9d
movl $0x1, %eax
cmpl $0x0, %esi
cmovnel %eax, %r9d
movl -0xac(%rbp), %ebx
movq -0x28(%rbp), %r11
movq -0x30(%rbp), %r10
leaq -0x80(%rbp), %rsi
xorl %r8d, %r8d
leaq -0x9c(%rbp), %rax
movl %ebx, (%rsp)
movl $0x1, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x315a70
movq -0x18(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x1b0(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x1ac(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321aa3
movq -0x30(%rbp), %rax
movq %rax, -0x1c0(%rbp)
jmp 0x321aae
xorl %eax, %eax
movq %rax, -0x1c0(%rbp)
jmp 0x321aae
movl -0x1ac(%rbp), %ecx
movl -0x1b0(%rbp), %esi
movq -0x1b8(%rbp), %rdi
movq -0x1c0(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
jmp 0x321bcd
movl -0xb0(%rbp), %eax
movl %eax, -0xac(%rbp)
movl $0x1770, -0x9c(%rbp)    # imm = 0x1770
movq -0x18(%rbp), %rdi
movq 0x20(%rbp), %rsi
xorl %edx, %edx
callq 0xd8550
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rax
movl %eax, %edx
movl 0x28(%rbp), %ecx
movl 0x30(%rbp), %r8d
movl -0xac(%rbp), %r10d
leaq -0x80(%rbp), %rsi
movss 0x6ec69(%rip), %xmm0    # 0x390790
movss 0x64d6d(%rip), %xmm1    # 0x38689c
movl $0x1, %r9d
xorl %eax, %eax
leaq -0x9c(%rbp), %rax
movl %r10d, (%rsp)
movl $0x8, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq %rax, 0x20(%rsp)
callq 0x315a70
movq -0x18(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq 0x10(%rbp), %rax
movl %eax, -0x1c8(%rbp)
movl 0x28(%rbp), %eax
movl %eax, -0x1c4(%rbp)
cmpl $0x0, 0x28(%rbp)
je 0x321b97
movq -0x30(%rbp), %rax
movq %rax, -0x1d8(%rbp)
jmp 0x321ba2
xorl %eax, %eax
movq %rax, -0x1d8(%rbp)
jmp 0x321ba2
movl -0x1c4(%rbp), %ecx
movl -0x1c8(%rbp), %esi
movq -0x1d0(%rbp), %rdi
movq -0x1d8(%rbp), %r8
movq -0x10(%rbp), %rax
movq 0x70(%rax), %r9
leaq -0x80(%rbp), %rdx
callq 0x311f60
cmpl $0x0, 0x28(%rbp)
jne 0x321be6
movq -0x18(%rbp), %rdi
movl $0x64, %esi
movl $0x1, %edx
callq 0x31d080
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movq 0x20(%rbp), %r9
movslq 0x28(%rbp), %r10
movq 0x40(%rbp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x320d00
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl $0x124f8, %edx          # imm = 0x124F8
callq 0x321cc0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq 0x48(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %r8
movq -0x10(%rbp), %rax
movl 0x40(%rax), %r9d
movq -0x10(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, (%rsp)
callq 0xfb680
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
callq 0x163ad0
cmpl $0x0, 0x28(%rbp)
je 0x321c78
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x313360
cmpl $0x0, 0x28(%rbp)
je 0x321c96
movq -0xa8(%rbp), %rdi
callq 0x320680
movq -0xa8(%rbp), %rdi
callq 0x2210
movq -0x70(%rbp), %rdi
callq 0x2210
movq -0x88(%rbp), %rdi
callq 0x2210
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %rbp
retq
nopw %cs:(%rax,%rax)