// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/Purge_Dups.cpp
// Function: purge_dups(ma_ug_t*, asg_t*, ma_sub_t*, ma_hit_t_alloc*, ma_hit_t_alloc*, R_to_U*, kvec_asg_arc_t_warp*, float, unsigned int, int, int, float, unsigned int, unsigned int, hap_cov_t*, unsigned int, unsigned int)
void purge_dups(ma_ug_t *ug, asg_t *read_g, ma_sub_t* coverage_cut, ma_hit_t_alloc* sources, 
ma_hit_t_alloc* reverse_sources, R_to_U* ruIndex, kvec_asg_arc_t_warp* edge, float density, 
uint32_t purege_minLen, int max_hang, int min_ovlp, float drop_ratio, uint32_t just_contain, 
uint32_t just_coverage, hap_cov_t *cov, uint32_t collect_p_trans, uint32_t collect_p_trans_f)
{
    p_g_t *pg = NULL;
    asg_t* nsg = ug->g;
    uint32_t v, rId, uId, i, offset;
    ma_utg_t* reads = NULL;
    uint64_t* position_index = NULL;
    if(cov) position_index = cov->pos_idx;
    else position_index = (uint64_t*)malloc(sizeof(uint64_t)*read_g->n_seq);
    memset(position_index, -1, sizeof(uint64_t)*read_g->n_seq);
    
    hap_overlaps_list all_ovlp;
    init_hap_overlaps_list(&all_ovlp, nsg->n_seq);
    hap_overlaps_list back_all_ovlp;
    init_hap_overlaps_list(&back_all_ovlp, nsg->n_seq);
    asg_arc_t t, *p = NULL;
    int r;
    hap_alignment_struct_pip hap_buf;
    long long k_mer_only, coverage_only;

    if(asm_opt.hom_global_coverage != -1)
    {
        hap_buf.cov_threshold = (asm_opt.hom_global_coverage_set?
                (((double)asm_opt.hom_global_coverage)*((double)HOM_PEAK_RATE)):(asm_opt.hom_global_coverage));
    }
    else
    {
        hap_buf.cov_threshold = get_read_coverage_thres(ug, read_g, ruIndex, position_index, 
        sources, coverage_cut, read_g->n_seq, COV_COUNT, &k_mer_only, &coverage_only);
    }
    
    
    for (v = 0; v < nsg->n_seq; v++)
    {
        uId = v;
        reads = &(ug->u.a[uId]);
        for (i = 0, offset = 0; i < reads->n; i++)
        {
            rId = reads->a[i]>>33;
            set_R_to_U(ruIndex, rId, uId, 1, &(read_g->seq[rId].c));

            position_index[rId] = offset;
            position_index[rId] = position_index[rId] << 32;
            position_index[rId] = position_index[rId] | (uint64_t)i;

            offset += (uint32_t)reads->a[i];
        }
    }

    // if(just_coverage == 0)
    // {
    //     ma_ug_seq(ug, read_g, coverage_cut, sources, edge, max_hang, min_ovlp, 0, 0);
    // }
    // init_ug_idx(ug, asm_opt.k_mer_length, asm_opt.polyploidy, 2, !just_coverage);
    
    init_hap_alignment_struct_pip(&hap_buf, asm_opt.thread_num, nsg->n_seq, ug, read_g,  
    sources, reverse_sources, ruIndex, coverage_cut, position_index, density, max_hang, min_ovlp, 
    0.1, &all_ovlp, cov);
    
    if(hap_buf.cov_threshold < 0)
    {
        if(if_ploid_sample(ug, read_g, ruIndex, sources, reverse_sources, coverage_cut, 
        &hap_buf, &all_ovlp, &back_all_ovlp, purege_minLen, 0.333))
        {
            ///if peak is het, coverage peak is more reliable 
            hap_buf.cov_threshold = coverage_only * HET_PEAK_RATE;
        }
        else
        {
            ///if peak is homo, k-mer peak is more reliable 
            hap_buf.cov_threshold = k_mer_only * HOM_PEAK_RATE;
        }
    }
    if(asm_opt.hom_global_coverage == -1) asm_opt.hom_global_coverage = hap_buf.cov_threshold;
    if(asm_opt.pur_global_coverage != -1) hap_buf.cov_threshold = asm_opt.pur_global_coverage;
    fprintf(stderr, "[M::%s] homozygous read coverage threshold: %d\n", __func__, asm_opt.hom_global_coverage_set?
                            asm_opt.hom_global_coverage:(int)(((double)asm_opt.hom_global_coverage)/((double)HOM_PEAK_RATE)));
    fprintf(stderr, "[M::%s] purge duplication coverage threshold: %lld\n", __func__, hap_buf.cov_threshold);
    if(just_coverage) goto end_coverage;

    kt_for(asm_opt.thread_num, hap_alignment_advance_worker, &hap_buf, nsg->n_seq);
    
    ///if(debug_enable) print_all_purge_ovlp(ug, &all_ovlp);
    filter_hap_overlaps_by_length(&all_ovlp, purege_minLen);

    // normalize_hap_overlaps_advance(&all_ovlp, &back_all_ovlp, ug, read_g, reverse_sources, ruIndex);
    pg = init_p_g_t(ug, cov, read_g);
    normalize_hap_overlaps_advance_by_p_g_t(&all_ovlp, &back_all_ovlp, ug, read_g, reverse_sources, ruIndex, pg, cov, 0.8);

    if(collect_p_trans && collect_p_trans_f == 0)
    {
        collect_purge_trans_cov(ug, &all_ovlp, cov, position_index);
    } 
    
    if(asm_opt.polyploidy <= 2)
    {
        mc_solve(&all_ovlp, cov->t_ch, NULL, ug, read_g, 0.8, R_INF.trio_flag, 1, NULL, 1, NULL, NULL, 1, 0);
    } 
    
    if(collect_p_trans && collect_p_trans_f == 1)
    {
        collect_purge_trans_cov(ug, &all_ovlp, cov, position_index);
    } 

    ///normalize_hap_overlaps_advance(&all_ovlp, &back_all_ovlp, ug, read_g, reverse_sources, ruIndex);
    ///debug_hap_overlaps(&all_ovlp, &back_all_ovlp);

    remove_contained_haplotig(&all_ovlp, ug, nsg, pg->pg_h_lev, cov);
    
    if(just_contain == 0)
    {
        for (v = 0; v < all_ovlp.num; v++)
        {
            uId = v;
            if(pg->pg_h_lev->seq[uId].del || pg->pg_h_lev->seq[uId].c == ALTER_LABLE) continue;
            for (i = 0; i < all_ovlp.x[uId].a.n; i++)
            {
                if(all_ovlp.x[uId].a.a[i].status == DELETE) continue;
                if(pg->pg_h_lev->seq[all_ovlp.x[uId].a.a[i].xUid].c == ALTER_LABLE||
                   pg->pg_h_lev->seq[all_ovlp.x[uId].a.a[i].xUid].del||
                   pg->pg_h_lev->seq[all_ovlp.x[uId].a.a[i].yUid].c == ALTER_LABLE||
                   pg->pg_h_lev->seq[all_ovlp.x[uId].a.a[i].yUid].del)
                {
                    continue;
                }

                
                ///print_hap_paf(ug, &(all_ovlp.x[uId].a.a[i]));
                
                r = get_hap_arch(&(all_ovlp.x[uId].a.a[i]), ug->u.a[all_ovlp.x[uId].a.a[i].xUid].len, 
                ug->u.a[all_ovlp.x[uId].a.a[i].yUid].len, max_hang, asm_opt.max_hang_rate, min_ovlp, &t);
                
                if(r < 0) continue;
                p = asg_arc_pushp(pg->pg_h_lev);
                *p = t;
            }
        }

        asg_cleanup(pg->pg_h_lev);
		asg_symm(pg->pg_h_lev);
        ///may need to do transitive reduction
        clean_purge_graph(pg->pg_h_lev, drop_ratio, 1);

        // if(debug_enable) print_purge_gfa(ug, purge_g);
        // if(debug_enable) print_all_purge_ovlp(ug, &all_ovlp);
        /*******************************for debug************************************/
        // print_het_ovlp(pg, ug, &all_ovlp, 0.8);
        /*******************************for debug************************************/

        link_unitigs(pg->pg_h_lev, ug, &all_ovlp, ruIndex, reverse_sources, coverage_cut, read_g, position_index, 
        &(hap_buf.buf[0].u_buffer), &(hap_buf.buf[0].u_buffer_tailIndex), &(hap_buf.buf[0].u_buffer_prevIndex),
        max_hang, min_ovlp, edge, hap_buf.buf[0].visit, cov);
    }

    for (v = 0; v < all_ovlp.num; v++)
    {
        uId = v;
        if(pg->pg_h_lev->seq[uId].c == ALTER_LABLE)
        {
            ug->g->seq[uId].c = ALTER_LABLE;
        }
    }

    end_coverage:
    uint32_t is_Unitig;
    for (v = 0; v < ruIndex->len; v++)
    {
        get_R_to_U(ruIndex, v, &uId, &is_Unitig);
        if(is_Unitig == 1) ruIndex->index[v] = (uint32_t)-1;
    }
    asg_cleanup(nsg);
    destory_hap_overlaps_list(&all_ovlp);
    destory_hap_overlaps_list(&back_all_ovlp);
    if(cov) memset(position_index, -1, sizeof(uint64_t)*read_g->n_seq);
    else free(position_index);
    destory_hap_alignment_struct_pip(&hap_buf);
    destory_p_g_t(&pg);
    // if(just_coverage == 0)
    // {
    //     des_ug_idx();
    //     for (i = 0; i < ug->u.n; i++)
    //     {
    //         free(ug->u.a[i].s);
    //         ug->u.a[i].s = NULL;
    //     }
    // }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movss %xmm1, 0x64(%rsp)
movss %xmm0, 0x68(%rsp)
movq %r9, 0x20(%rsp)
movq %r8, 0x78(%rsp)
movq %rcx, 0x50(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, %rbx
andq $0x0, 0x90(%rsp)
movq 0x1a0(%rsp), %rax
movq %rdi, 0x8(%rsp)
movq 0x18(%rdi), %rcx
movq %rcx, 0x40(%rsp)
testq %rax, %rax
jne 0x129b7
movl 0x14(%rbx), %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
shlq $0x3, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, %r15
jmp 0x129ca
movq 0x10(%rax), %r15
movl 0x14(%rbx), %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
shlq $0x3, %r14
movq %r15, %rdi
movl $0xff, %esi
movq %r14, %rdx
callq 0x20e0
movq 0x40(%rsp), %rax
movl 0x14(%rax), %ebp
movl %ebp, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movl %r13d, 0x38(%rsp)
imulq $0x18, %r13, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, 0x30(%rsp)
testq %r13, %r13
jne 0x12a19
movl %r13d, 0x88(%rsp)
movq %r14, %rdi
callq 0x2280
jmp 0x12a39
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movl %r13d, 0x88(%rsp)
pushq $0x1
popq %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, 0x80(%rsp)
leaq 0x282d10(%rip), %rcx    # 0x295758
movl 0x144(%rcx), %eax
cmpl $-0x1, %eax
jne 0x12aac
movl 0x14(%rbx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq 0x98(%rsp), %r10
leaq 0xa0(%rsp), %r11
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq 0x20(%rsp), %rdx
movq %r15, %rcx
movq 0x50(%rsp), %r8
movq 0x58(%rsp), %r9
pushq %r10
pushq %r11
pushq $0x400                  # imm = 0x400
pushq %rax
callq 0x109ee3
addq $0x20, %rsp
movq 0x40(%rsp), %rcx
movl 0x14(%rcx), %ebp
movl %ebp, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
jmp 0x12ac6
cmpl $0x0, 0x148(%rcx)
cvtsi2sd %eax, %xmm0
je 0x12ac1
mulsd 0x22329f(%rip), %xmm0   # 0x235d60
cvttsd2si %xmm0, %rax
movq %rbx, 0x48(%rsp)
movq %rax, 0x128(%rsp)
testl %r13d, %r13d
movq %r15, 0x18(%rsp)
jne 0x12ae4
xorl %edx, %edx
jmp 0x12b8a
xorl %esi, %esi
pushq $0x1
popq %r14
movl %esi, %r13d
movl %esi, 0x2c(%rsp)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r15
imulq $0x28, %rsi, %rax
cmpl $0x0, 0x10(%r15,%rax)
je 0x12b76
movq %rsi, 0x10(%rsp)
addq %rax, %r15
movq 0x18(%r15), %rax
xorl %r12d, %r12d
xorl %ebx, %ebx
movq (%rax,%r12,8), %rbp
shrq $0x21, %rbp
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
leaq (%rax,%rbp,8), %r8
addq $0x4, %r8
movq 0x20(%rsp), %rdi
movl %ebp, %esi
movl %r13d, %edx
movl %r14d, %ecx
callq 0xa27e9
movq %rbx, %rax
shlq $0x20, %rax
addq %r12, %rax
movq 0x18(%rsp), %rdx
movq %rax, (%rdx,%rbp,8)
movq 0x18(%r15), %rax
addl (%rax,%r12,8), %ebx
incq %r12
movl 0x10(%r15), %edx
cmpq %rdx, %r12
jb 0x12b17
movq 0x40(%rsp), %rax
movl 0x14(%rax), %ebp
movq 0x10(%rsp), %rsi
incq %rsi
movl %ebp, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rsi
jb 0x12aea
movq %r13, 0x70(%rsp)
movl 0x178(%rsp), %r15d
leaq 0x282bba(%rip), %rax    # 0x295758
movl 0x7c(%rax), %esi
leaq 0x30(%rsp), %r14
leaq 0xc0(%rsp), %r13
movss 0x2231fa(%rip), %xmm1   # 0x235db0
movq %r13, %rdi
movq 0x8(%rsp), %rcx
movq 0x48(%rsp), %rbx
movq %rbx, %r8
movq 0x50(%rsp), %r9
movss 0x68(%rsp), %xmm0
pushq 0x1a0(%rsp)
pushq %r14
movl 0x198(%rsp), %eax
pushq %rax
movl 0x198(%rsp), %eax
pushq %rax
pushq 0x38(%rsp)
pushq 0x80(%rsp)
pushq 0x50(%rsp)
pushq 0xb0(%rsp)
callq 0x10a26d
addq $0x40, %rsp
movq 0x68(%r13), %rcx
testq %rcx, %rcx
jns 0x12c73
leaq 0x80(%rsp), %rax
movsd 0x226abe(%rip), %xmm0   # 0x2396e0
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
pushq %r15
pushq %rax
pushq %r14
pushq %r13
callq 0x115ffb
addq $0x20, %rsp
xorl %ecx, %ecx
testl %eax, %eax
leaq 0xa0(%rsp), %rax
leaq 0x98(%rsp), %rdx
cmoveq %rax, %rdx
cvtsi2sdq (%rdx), %xmm0
sete %cl
leaq 0x226a3f(%rip), %rax    # 0x2396a0
mulsd (%rax,%rcx,8), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x128(%rsp)
leaq 0x282ade(%rip), %rdx    # 0x295758
movl 0x144(%rdx), %eax
cmpl $-0x1, %eax
jne 0x12c8d
movl %ecx, 0x144(%rdx)
movl %ecx, %eax
movl 0x198(%rsp), %ebp
movslq 0x14c(%rdx), %rcx
cmpq $-0x1, %rcx
movq 0x1a0(%rsp), %r12
je 0x12cb1
movq %rcx, 0x128(%rsp)
movq 0x282328(%rip), %rbx    # 0x294fe0
movq (%rbx), %rdi
cmpl $0x0, 0x148(%rdx)
cvtsi2sd %eax, %xmm0
divsd 0x223092(%rip), %xmm0   # 0x235d60
cvttsd2si %xmm0, %ecx
cmovnel %eax, %ecx
leaq 0x226ed1(%rip), %rsi    # 0x239bad
leaq 0x226efa(%rip), %r13    # 0x239bdd
movq %rdx, %r14
movq %r13, %rdx
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rdi
movq 0x128(%rsp), %rcx
leaq 0x226ee6(%rip), %rsi    # 0x239be8
movq %r13, %rdx
xorl %eax, %eax
callq 0x22b0
testl %ebp, %ebp
movq 0x48(%rsp), %rbx
jne 0x13121
movl 0x1b0(%rsp), %eax
movl 0x1a8(%rsp), %ebp
movl 0x7c(%r14), %edi
movl %eax, %r14d
movq 0x40(%rsp), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq 0x10355d(%rip), %rsi    # 0x1162a0
leaq 0xc0(%rsp), %rdx
callq 0x108f2c
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movl %r15d, %esi
callq 0x111dbd
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x117a91
movq %rax, 0x90(%rsp)
subq $0x8, %rsp
leaq 0x88(%rsp), %rsi
movsd 0x21e824(%rip), %xmm0   # 0x2315b0
movq %r13, %rdi
movq %rax, 0x18(%rsp)
pushq %rax
callq 0x1117f7
popq %rax
popq %rcx
testl %ebp, %ebp
sete %al
testl %r14d, %r14d
setne %cl
orb %al, %cl
jne 0x12dc2
leaq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
callq 0x11821a
leaq 0x28298f(%rip), %rax    # 0x295758
cmpl $0x2, 0x1bc(%rax)
jg 0x12e2c
movq 0xa8(%r12), %rsi
leaq 0x28344f(%rip), %rax    # 0x296230
movq 0x28(%rax), %r9
subq $0x40, %rsp
pushq $0x1
popq %rax
movl %eax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
movl %eax, 0x10(%rsp)
movl %eax, (%rsp)
andl $0x0, 0x30(%rsp)
andq $0x0, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
movsd 0x21e797(%rip), %xmm0   # 0x2315b0
xorl %edx, %edx
movq 0x48(%rsp), %rcx
movq %rbx, %r8
callq 0x1e07b
addq $0x40, %rsp
movl 0x190(%rsp), %ebx
testl %ebp, %ebp
sete %al
cmpl $0x1, %r14d
setne %cl
orb %al, %cl
jne 0x12e5a
leaq 0x30(%rsp), %rsi
movq 0x8(%rsp), %rdi
movq %r12, %rdx
movq 0x18(%rsp), %rcx
callq 0x11821a
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rcx
leaq 0x30(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %r12, %r8
callq 0x117936
testl %ebx, %ebx
je 0x12e8d
movq 0x70(%rsp), %r12
movq 0x48(%rsp), %rbx
jmp 0x130dd
movl 0x38(%rsp), %eax
testl %eax, %eax
movq 0x70(%rsp), %r12
movq 0x10(%rsp), %r8
je 0x13049
xorl %edx, %edx
movl %edx, %r12d
movl %edx, 0x2c(%rsp)
movq 0x28(%r8), %rcx
movq 0x20(%rcx), %rcx
cmpl $0x0, (%rcx,%rdx,8)
js 0x1303b
cmpb $0x1, 0x4(%rcx,%rdx,8)
je 0x1303b
movq 0x30(%rsp), %rbp
movl %edx, %ecx
imulq $0x18, %rcx, %r15
cmpq $0x0, (%rbp,%r15)
je 0x1303b
movq %rdx, 0x50(%rsp)
pushq $0x1
popq %r13
xorl %eax, %eax
movq 0x10(%rbp,%r15), %rdi
shlq $0x6, %rax
cmpb $0x2, 0x2(%rdi,%rax)
je 0x13021
addq %rax, %rdi
movq 0x28(%r8), %r14
movq 0x20(%r14), %rcx
movl 0x24(%rdi), %eax
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0x13021
cmpl $0x0, (%rcx,%rax,8)
js 0x13021
movl 0x28(%rdi), %edx
cmpb $0x1, 0x4(%rcx,%rdx,8)
je 0x13021
cmpl $0x0, (%rcx,%rdx,8)
js 0x13021
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
imulq $0x28, %rax, %rax
movl (%rcx,%rax), %esi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %esi
imulq $0x28, %rdx, %rax
movl (%rcx,%rax), %edx
andl %r8d, %edx
leaq 0x2827f4(%rip), %rax    # 0x295758
movss 0x158(%rax), %xmm0
movl 0x180(%rsp), %ecx
movl 0x188(%rsp), %r8d
movq %r12, %rbx
leaq 0xa8(%rsp), %r9
callq 0x1129ef
movq 0x10(%rsp), %r8
testl %eax, %eax
js 0x13021
movq %r14, %rdi
movl 0x4(%r14), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%r14), %ecx
jne 0x12fe3
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
pushq $0x10
popq %rcx
cmovel %ecx, %eax
movl %eax, (%rdi)
movq 0x8(%rdi), %rdi
imulq $0x18, %rax, %rsi
callq 0x2370
movq %r14, %rdi
movq 0x10(%rsp), %r8
movq %rbx, %r12
movq %rax, 0x8(%r14)
movl 0x4(%r14), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x12fe7
movq 0x8(%rdi), %rax
leal 0x1(%rdx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%rdi)
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
movq 0xb8(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movupd 0xa8(%rsp), %xmm0
movupd %xmm0, (%rax,%rcx)
movq 0x30(%rsp), %rbp
movl %r13d, %eax
incl %r13d
cmpq %rax, (%rbp,%r15)
ja 0x12eeb
movl 0x38(%rsp), %eax
movq 0x50(%rsp), %rdx
incq %rdx
movl %eax, %ecx
cmpq %rcx, %rdx
jb 0x12ea5
movq 0x28(%r8), %rdi
movq %r8, %rbx
callq 0xa0a7d
movq 0x28(%rbx), %rdi
callq 0xa0c1e
movq 0x28(%rbx), %rdi
pushq $0x1
popq %rsi
movss 0x64(%rsp), %xmm0
callq 0x113106
movq 0x28(%rbx), %rdi
movq 0xc0(%rsp), %rax
leaq 0x30(%rax), %r10
leaq 0x50(%rax), %r11
leaq 0x30(%rsp), %rdx
movq 0x8(%rsp), %rsi
movq 0x20(%rsp), %rcx
movq 0x78(%rsp), %r8
movq 0x58(%rsp), %r9
pushq 0x1a0(%rsp)
pushq 0x8(%rax)
addq $0x70, %rax
pushq 0x180(%rsp)
movl 0x1a0(%rsp), %ebx
pushq %rbx
movl 0x1a0(%rsp), %ebx
pushq %rbx
pushq %rax
pushq %r11
pushq %r10
pushq 0x58(%rsp)
movq 0x90(%rsp), %rbx
pushq %rbx
callq 0x115607
addq $0x50, %rsp
movl 0x38(%rsp), %eax
testq %rax, %rax
je 0x1311c
movq 0x10(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq 0x20(%rcx), %rcx
xorl %r12d, %r12d
cmpb $0x1, 0x4(%rcx,%r12,8)
jne 0x13111
movq 0x8(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movb $0x1, 0x4(%rdx,%r12,8)
incq %r12
cmpq %r12, %rax
jne 0x130f6
decl %r12d
movl %r12d, 0x2c(%rsp)
movq 0x20(%rsp), %rax
cmpq $0x0, (%rax)
je 0x13169
xorl %r14d, %r14d
leaq 0x2c(%rsp), %r13
leaq 0x6c(%rsp), %rbp
movq 0x20(%rsp), %rdi
movl %r14d, %esi
movq %r13, %rdx
movq %rbp, %rcx
callq 0xa3c62
movq 0x20(%rsp), %rcx
cmpl $0x1, 0x6c(%rsp)
jne 0x13161
movq 0x8(%rcx), %rax
orl $-0x1, (%rax,%r14,4)
incl %r14d
cmpq %r14, (%rcx)
ja 0x13139
movq 0x40(%rsp), %rdi
callq 0xa0a7d
leaq 0x30(%rsp), %rdi
callq 0x10a43d
leaq 0x80(%rsp), %rdi
callq 0x10a43d
cmpq $0x0, 0x1a0(%rsp)
je 0x131b3
movl 0x14(%rbx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x3, %rdx
movq 0x18(%rsp), %rdi
movl $0xff, %esi
callq 0x20e0
jmp 0x131bd
movq 0x18(%rsp), %rdi
callq 0x2220
leaq 0xc0(%rsp), %rdi
callq 0x10a3b3
leaq 0x90(%rsp), %rdi
callq 0x117e01
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq