// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movsd %xmm2, 0x48(%rsp)
movsd %xmm0, 0xa8(%rsp)
movq %r9, %rbx
movq %r8, 0x80(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movl 0x138(%rsp), %ecx
movsd %xmm1, 0xb8(%rsp)
movsd %xmm1, 0xb0(%rsp)
cmpq $0x1, %r9
je 0x1aebe8
leaq -0x1(%rbx), %rax
movsd 0xb8(%rsp), %xmm1
subsd 0xa8(%rsp), %xmm1
cvtsi2sd %rax, %xmm0
divsd %xmm0, %xmm1
movsd %xmm1, 0xb0(%rsp)
movq 0x120(%rsp), %r14
andq $0x0, 0x70(%rsp)
xorpd %xmm0, %xmm0
andq $0x0, 0xe0(%rsp)
movapd %xmm0, 0x60(%rsp)
movapd %xmm0, 0xd0(%rsp)
movl $0x7d0, 0x8c(%rsp) # imm = 0x7D0
testl %ecx, %ecx
je 0x1aec65
movq 0x128(%rsp), %r9
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rsi
movslq 0x44(%rax), %rdx
movslq 0x40(%rax), %rcx
leaq 0xa4b17(%rip), %rax     # 0x253758
cvttss2si 0x158(%rax), %r8
movq 0x38(%rsp), %rdi
callq 0x1ae5a4
movl 0x138(%rsp), %ecx
movq %rax, 0x90(%rsp)
jmp 0x1aec71
movq $0x0, 0x90(%rsp)
leaq 0xa4ae0(%rip), %rax     # 0x253758
cmpq $0x0, 0x2a8(%rax)
je 0x1aecd6
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
andl $0x0, 0x10(%rsp)
movl $0x1, 0x8(%rsp)
movl $0x10, (%rsp)
leaq 0x60(%rsp), %rsi
movss 0x486e5(%rip), %xmm0    # 0x1f739c
pushq $0x1
popq %r9
xorpd %xmm1, %xmm1
movq 0x38(%rsp), %rdi
movl %r14d, %edx
xorl %r8d, %r8d
callq 0x1a8999
movl 0x138(%rsp), %ecx
movq 0x130(%rsp), %r13
xorl %r15d, %r15d
testl %ecx, %ecx
movq 0x80(%rsp), %r8
cmoveq %r15, %r8
movq 0x40(%rsp), %rax
movq 0x70(%rax), %r9
leaq 0x60(%rsp), %rdx
movq 0x38(%rsp), %rdi
movl %r14d, %esi
movq %r8, 0x98(%rsp)
callq 0x1a5634
cvtsd2ss 0x48(%rsp), %xmm0
testq %rbx, %rbx
movl $0x0, %eax
movq %rax, 0xa0(%rsp)
cmovleq %r15, %rbx
movsd 0xa8(%rsp), %xmm1
movss %xmm0, 0x48(%rsp)
subq $0x1, %rbx
jb 0x1af1c9
movsd 0xb8(%rsp), %xmm2
minsd %xmm1, %xmm2
movsd 0x34856(%rip), %xmm0    # 0x1e35b0
movsd %xmm2, 0xc0(%rsp)
ucomisd %xmm2, %xmm0
movl $0x3e8, %eax            # imm = 0x3E8
movl $0x7d0, %ecx            # imm = 0x7D0
cmovbl %ecx, %eax
movl 0x138(%rsp), %ebp
testl %ebp, %ebp
movq 0xa0(%rsp), %rcx
cmovnel %eax, %ecx
movq %rcx, 0xa0(%rsp)
leaq 0xa49c1(%rip), %rax     # 0x253758
cmpq $0x0, 0x2a8(%rax)
leaq 0x60(%rsp), %r15
je 0x1aee2c
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rsp)
andl $0x0, 0x10(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x1, 0x8(%rsp)
movl $0x10, (%rsp)
xorpd %xmm1, %xmm1
movq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movl %r14d, %edx
movss 0x485b0(%rip), %xmm0    # 0x1f739c
movl 0x138(%rsp), %ecx
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x1a8999
movq 0x40(%rsp), %rax
movq 0x70(%rax), %r9
movq %r12, %rdi
movl %r14d, %esi
movq %r15, %rdx
movl 0x138(%rsp), %ecx
movq 0x98(%rsp), %r8
callq 0x1a5634
movl 0x138(%rsp), %ebp
movq %rbx, 0xc8(%rsp)
movl 0x148(%rsp), %r14d
testl %ebp, %ebp
jne 0x1aee6b
movq 0x40(%rsp), %rax
movq 0x70(%rax), %r9
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rsi
movq %r15, %rdx
movq 0x120(%rsp), %rcx
pushq $0x1
popq %r8
callq 0x1ace37
pushq $-0x1
popq %r14
movq 0x38(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x6ef72
movq 0x40(%rsp), %rbx
movq 0x70(%rbx), %r8
movq %r12, %rdi
movq 0x58(%rsp), %rsi
movq %r15, %rdx
movl %r14d, %ecx
movq %r12, %r15
movq %rsi, %r12
callq 0x1a66a4
movq 0x70(%rbx), %r9
movq %r15, %rdi
movq 0x120(%rsp), %rsi
leaq 0x60(%rsp), %r14
movq %r14, %rdx
movl %ebp, %ecx
movq 0x98(%rsp), %r8
callq 0x1a5634
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x6ef72
movq 0xa0(%rsp), %rbx
movl %ebx, (%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq 0x120(%rsp), %r14
movl %r14d, %ecx
movl %ebp, %r8d
movl 0x140(%rsp), %r9d
movss 0x48(%rsp), %xmm0
callq 0x1a6adf
movq 0x40(%rsp), %r12
movq 0x70(%r12), %r9
movq %r15, %rdi
movl %r14d, %esi
leaq 0x60(%rsp), %rdx
movl %ebp, %ecx
movq 0x98(%rsp), %r14
movq %r14, %r8
callq 0x1a5634
movq %r15, %rdi
movq %r13, %rsi
pushq $0x1
popq %rdx
callq 0x6ef72
cvtsd2ss 0xc0(%rsp), %xmm0
xorpd %xmm1, %xmm1
movupd %xmm1, 0x10(%rsp)
movl %ebx, (%rsp)
andq $0x0, 0x20(%rsp)
movl $0x1, 0x8(%rsp)
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
movq 0x120(%rsp), %r13
movl %r13d, %edx
movss 0x48(%rsp), %xmm1
movl %ebp, %ecx
movl 0x140(%rsp), %r8d
pushq $0x1
popq %r9
callq 0x1a80df
movq 0x70(%r12), %r9
leaq 0x60(%rsp), %rdx
movq %r15, %rdi
movl %r13d, %esi
movq %rdx, %r13
movl %ebp, %ecx
movq %r14, %r8
callq 0x1a5634
testl %ebp, %ebp
je 0x1af0ec
movq 0x90(%rsp), %rdi
movq %r13, %rsi
leaq 0xd0(%rsp), %rdx
movq 0x130(%rsp), %rbx
movq 0x40(%rsp), %r12
movq 0x80(%rsp), %r14
movq %r14, %rcx
movss 0x48(%rsp), %xmm0
xorl %r8d, %r8d
callq 0x1ab5b9
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x6ef72
leaq 0xa4758(%rip), %rax     # 0x253758
movq 0x188(%rax), %rcx
movq 0x120(%rsp), %rax
movl %eax, (%rsp)
movq %r15, %rdi
leaq 0x60(%rsp), %r13
movq %r13, %rsi
movss 0x4837b(%rip), %xmm0    # 0x1f73a0
movss 0x48377(%rip), %xmm1    # 0x1f73a4
movss 0x48373(%rip), %xmm2    # 0x1f73a8
movl %ebp, %edx
movq 0x50(%rsp), %r8
movq %r14, %r9
callq 0x1abc36
movq %r15, %rdi
movq %rbx, %rsi
pushq $0x1
popq %rdx
callq 0x6ef72
movq %r15, %rdi
movq %r13, %rsi
movss 0x48340(%rip), %xmm0    # 0x1f73a0
movss 0x48340(%rip), %xmm1    # 0x1f73a8
movl %ebp, %edx
movq %rbx, %rcx
callq 0x1ac316
movq 0x70(%r12), %r9
movq %r15, %rdi
movq 0x120(%rsp), %rsi
movq %r13, %rdx
movl %ebp, %ecx
movq %r14, %r8
callq 0x1a5634
movq %r12, %rdi
movq %r15, %rsi
callq 0x19bc4f
testq %rax, %rax
je 0x1af0ae
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x1a64c2
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x19b92c
testl %eax, %eax
movq 0x120(%rsp), %r14
movq 0x130(%rsp), %r13
je 0x1af1a4
movq 0x38(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x1a64c2
jmp 0x1af1a4
movq 0x38(%rsp), %r14
movq %r14, %rdi
movq 0x130(%rsp), %r15
movq %r15, %rsi
pushq $0x1
popq %rbx
movl %ebx, %edx
callq 0x6ef72
leaq 0xa4648(%rip), %rax     # 0x253758
movq 0x188(%rax), %rcx
movq 0x120(%rsp), %r12
movl %r12d, (%rsp)
movq %r14, %rdi
movq %r13, %rsi
movss 0x4826f(%rip), %xmm0    # 0x1f73a0
movss 0x4826b(%rip), %xmm1    # 0x1f73a4
movss 0x48267(%rip), %xmm2    # 0x1f73a8
xorl %edx, %edx
movq 0x50(%rsp), %r8
movq 0x80(%rsp), %r9
callq 0x1abc36
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x6ef72
movq %r14, %rdi
movq %r13, %rsi
movss 0x48230(%rip), %xmm0    # 0x1f73a0
movss 0x48230(%rip), %xmm1    # 0x1f73a8
xorl %edx, %edx
movq %r15, %rcx
callq 0x1ac316
movq 0x40(%rsp), %rax
movq 0x70(%rax), %r9
movq %r14, %rdi
movl %r12d, %esi
movq %r13, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1a5634
movq %r12, %r14
movq %r15, %r13
movsd 0xc0(%rsp), %xmm1
addsd 0xb0(%rsp), %xmm1
movss 0x48(%rsp), %xmm0
movq 0xc8(%rsp), %rbx
jmp 0x1aed3b
leaq 0xa4588(%rip), %rax     # 0x253758
cmpq $0x0, 0x2a8(%rax)
movl 0x138(%rsp), %eax
je 0x1af276
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
andl $0x0, 0x10(%rsp)
movl $0x1, 0x8(%rsp)
movl $0x10, (%rsp)
leaq 0x60(%rsp), %r14
movss 0x48184(%rip), %xmm0    # 0x1f739c
pushq $0x1
popq %r9
xorpd %xmm1, %xmm1
movq 0x38(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movq 0x120(%rsp), %rbx
movl %ebx, %edx
movl 0x138(%rsp), %ecx
xorl %r8d, %r8d
callq 0x1a8999
movq 0x40(%rsp), %rax
movq 0x70(%rax), %r9
movq %r15, %rdi
movl %ebx, %esi
movq %r14, %rdx
movl 0x138(%rsp), %ecx
movq 0x98(%rsp), %r8
callq 0x1a5634
movss 0x48(%rsp), %xmm0
movl 0x138(%rsp), %eax
testl %eax, %eax
je 0x1af492
leaq 0x60(%rsp), %r12
movq 0x58(%rsp), %r15
leaq 0xd0(%rsp), %r14
movq 0x90(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq 0x80(%rsp), %r13
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x1ab5b9
movss 0x3d7e4(%rip), %xmm0    # 0x1ecaa0
pushq $0x1
popq %rbp
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %r13, %rcx
movl %ebp, %r8d
callq 0x1ab5b9
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movl %ebp, %edx
callq 0x19b92c
testl %eax, %eax
je 0x1af2f5
movq 0x38(%rsp), %rdi
movq %r15, %rsi
callq 0x1a64c2
movq 0x38(%rsp), %r14
movq %r14, %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0x6ef72
leaq 0x60(%rsp), %rsi
movss 0x4808f(%rip), %xmm0    # 0x1f73a8
movq %r14, %rdi
movq 0x120(%rsp), %rbp
movl %ebp, %edx
movl 0x138(%rsp), %ebx
movl %ebx, %ecx
movl $0x7d0, %r8d            # imm = 0x7D0
callq 0x1acec8
movq %r15, %r13
movq %r14, %r15
movq 0x40(%rsp), %r12
movq 0x70(%r12), %r9
movq %r14, %rdi
movl %ebp, %esi
leaq 0x60(%rsp), %rdx
movl %ebx, %ecx
movq 0x80(%rsp), %rbp
movq %rbp, %r8
callq 0x1a5634
leaq 0x8c(%rsp), %r14
movl $0x1770, (%r14)         # imm = 0x1770
movq %r15, %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0x6ef72
movq %r14, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rsp)
movl $0x8, 0x8(%rsp)
movl $0x7d0, (%rsp)          # imm = 0x7D0
movss 0x426d9(%rip), %xmm0    # 0x1f1a84
movss 0x38901(%rip), %xmm1    # 0x1e7cb4
pushq $0x1
popq %r9
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
movq 0x120(%rsp), %r14
movl %r14d, %edx
movl %ebx, %ecx
movl 0x140(%rsp), %r8d
callq 0x1a80df
movq 0x70(%r12), %r9
movq %r15, %rdi
movl %r14d, %esi
leaq 0x60(%rsp), %rdx
movl %ebx, %ecx
movq %rbp, %r8
callq 0x1a5634
movslq %ebx, %rax
movq 0x150(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq %rax, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x50(%rsp), %rcx
movq %rbp, %r8
movq 0x130(%rsp), %r9
callq 0x1ae9ac
movq %r12, %rdi
movq %r15, %rsi
movl $0x124f8, %edx          # imm = 0x124F8
callq 0x1af6b9
movq (%r12), %rsi
movl 0x40(%r12), %r9d
movl 0x44(%r12), %eax
movl %eax, (%rsp)
movq %r15, %rdi
movq 0x158(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
callq 0x83295
movq %r15, %rdi
movq %r13, %rsi
movq %rbp, %rdx
callq 0xc0f3c
movq %r15, %rdi
movq %r13, %rsi
callq 0x1a64c2
movq 0x90(%rsp), %rbx
movq %rbx, %rdi
callq 0x1ae625
movq %rbx, %rdi
callq 0x2220
jmp 0x1af690
movq 0x38(%rsp), %r12
movq 0x40(%rsp), %rbx
movq 0x70(%rbx), %r9
leaq 0x60(%rsp), %r13
movq %r12, %rdi
movq 0x58(%rsp), %rsi
movq %r13, %rdx
movq 0x120(%rsp), %r14
movl %r14d, %ecx
pushq $0x1
popq %r15
movl %r15d, %r8d
callq 0x1ace37
movq %r12, %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0x6ef72
movss 0x47ec7(%rip), %xmm0    # 0x1f73a8
movq %r12, %rdi
movq %r13, %rsi
movl %r14d, %edx
xorl %ecx, %ecx
movq 0xa0(%rsp), %rbp
movl %ebp, %r8d
callq 0x1acec8
movq 0x70(%rbx), %r9
movq %r12, %rdi
movl %r14d, %esi
movq %r13, %rdx
movq %r13, %r14
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1a5634
movq %r12, %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0x6ef72
movq 0x80(%rsp), %r13
movq %r13, 0x18(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %r15d, 0x8(%rsp)
movl %ebp, (%rsp)
andq $0x0, 0x20(%rsp)
movss 0x47e57(%rip), %xmm0    # 0x1f73ac
movq %r12, %rdi
movq %r14, %rsi
movq 0x120(%rsp), %r14
movl %r14d, %edx
movss 0x48(%rsp), %xmm1
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1a80df
movq 0x70(%rbx), %r9
movq %r12, %rdi
movl %r14d, %esi
leaq 0x60(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1a5634
movq %r12, %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0x6ef72
cvtsd2ss 0xa8(%rsp), %xmm0
leaq 0x8c(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r13, 0x18(%rsp)
movq 0x50(%rsp), %r14
movq %r14, 0x10(%rsp)
movl %r15d, 0x8(%rsp)
movl %ebp, (%rsp)
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
movq 0x120(%rsp), %rbp
movl %ebp, %edx
movss 0x48(%rsp), %xmm1
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1a80df
movq 0x70(%rbx), %r9
movq %r12, %rdi
movl %ebp, %esi
leaq 0x60(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x1a5634
pushq $0x64
popq %rsi
movq %r12, %rdi
movl %r15d, %edx
callq 0x1ac895
andq $0x0, (%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq 0x58(%rsp), %r15
movq %r15, %rdx
movq %r14, %rcx
movq %r13, %r8
movq 0x130(%rsp), %r9
callq 0x1ae9ac
movq %rbx, %rdi
movq %r12, %rsi
movl $0x124f8, %edx          # imm = 0x124F8
callq 0x1af6b9
movq (%rbx), %rsi
movl 0x40(%rbx), %r9d
movl 0x44(%rbx), %eax
movl %eax, (%rsp)
movq %r12, %rdi
movq 0x158(%rsp), %rdx
movq %r15, %rcx
movq %r13, %r8
callq 0x83295
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc0f3c
movq 0x70(%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq