// File: /workspace/github_cpp_makefile_star2_O2/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 $0x118, %rsp            # imm = 0x118
movss %xmm1, 0x50(%rsp)
movss %xmm0, 0x40(%rsp)
movq %r9, %r13
movq %r8, 0x58(%rsp)
movq %rcx, %rbp
movq %rdx, 0x48(%rsp)
movq %rsi, %rbx
andq $0x0, 0x60(%rsp)
movq 0x180(%rsp), %rax
movq %rdi, (%rsp)
movq 0x18(%rdi), %rcx
movq %rcx, 0x30(%rsp)
testq %rax, %rax
jne 0xd3472
movl 0x14(%rbx), %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
shlq $0x3, %r14
movq %r14, %rdi
callq 0x2280
movq %rax, %r15
jmp 0xd3485
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
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
movq 0x30(%rsp), %r12
movl 0x14(%r12), %esi
andl %r14d, %esi
leaq 0x20(%rsp), %rdi
callq 0xc7c9b
andl 0x14(%r12), %r14d
leaq 0x78(%rsp), %rdi
movl %r14d, %esi
callq 0xc7c9b
leaq 0x18028d(%rip), %rcx    # 0x253758
movl 0x144(%rcx), %eax
cmpl $-0x1, %eax
movq %rbx, 0x10(%rsp)
movq %r15, 0x8(%rsp)
movq %rbp, 0x38(%rsp)
jne 0xd3521
movl 0x14(%rbx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq 0x68(%rsp), %r10
leaq 0x70(%rsp), %r11
movq (%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %rbp, %r8
movq 0x48(%rsp), %r9
pushq %r10
pushq %r11
pushq $0x400                  # imm = 0x400
pushq %rax
callq 0xc77be
addq $0x20, %rsp
jmp 0xd353b
cmpl $0x0, 0x148(%rcx)
cvtsi2sd %eax, %xmm0
je 0xd3536
mulsd 0x11472a(%rip), %xmm0   # 0x1e7c60
cvttsd2si %xmm0, %rax
movq %rax, 0x108(%rsp)
xorl %r14d, %r14d
leaq 0x20(%rsp), %rbx
movq 0x30(%rsp), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %r14
jae 0xd35d5
movl %r14d, 0x1c(%rsp)
imulq $0x28, %r14, %rbx
movq (%rsp), %rax
addq 0x10(%rax), %rbx
xorl %r15d, %r15d
xorl %r12d, %r12d
movl 0x10(%rbx), %eax
cmpq %rax, %r15
jae 0xd35ca
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rbp
shrq $0x21, %rbp
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rax
leaq (%rax,%rbp,8), %r8
addq $0x4, %r8
movq %r13, %rdi
movl %ebp, %esi
movl %r14d, %edx
pushq $0x1
popq %rcx
callq 0x6ab56
movq %r12, %rax
shlq $0x20, %rax
addq %r15, %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0x18(%rbx), %rax
addl (%rax,%r15,8), %r12d
incq %r15
jmp 0xd3575
movl %r14d, %ebp
incq %r14
jmp 0xd3546
leaq 0x18017c(%rip), %rax    # 0x253758
movl 0x7c(%rax), %esi
leaq 0xa0(%rsp), %r14
movss 0x1146c1(%rip), %xmm1   # 0x1e7cb0
movq %r14, %rdi
movq (%rsp), %rcx
movq 0x10(%rsp), %r8
movq 0x38(%rsp), %r9
movss 0x40(%rsp), %xmm0
pushq 0x180(%rsp)
pushq %rbx
movl 0x178(%rsp), %eax
pushq %rax
movl 0x178(%rsp), %eax
pushq %rax
pushq 0x28(%rsp)
pushq 0x70(%rsp)
movq %r13, %r15
pushq %r13
pushq 0x90(%rsp)
callq 0xc7b1c
addq $0x40, %rsp
movq 0x68(%r14), %rcx
testq %rcx, %rcx
jns 0xd36a5
movsd 0x117f74(%rip), %xmm0   # 0x1eb5c0
movq (%rsp), %rdi
movq 0x10(%rsp), %rsi
movl 0x158(%rsp), %eax
pushq %rax
leaq 0x80(%rsp), %rax
pushq %rax
pushq %rbx
pushq %r14
callq 0xd1288
addq $0x20, %rsp
xorl %ecx, %ecx
testl %eax, %eax
leaq 0x70(%rsp), %rax
leaq 0x68(%rsp), %rdx
cmoveq %rax, %rdx
cvtsi2sdq (%rdx), %xmm0
sete %cl
leaq 0x117eed(%rip), %rax    # 0x1eb580
mulsd (%rax,%rcx,8), %xmm0
cvttsd2si %xmm0, %rcx
movq %rcx, 0x108(%rsp)
leaq 0x1800ac(%rip), %rdx    # 0x253758
movl 0x144(%rdx), %eax
cmpl $-0x1, %eax
jne 0xd36bf
movl %ecx, 0x144(%rdx)
movl %ecx, %eax
movslq 0x14c(%rdx), %rcx
cmpq $-0x1, %rcx
je 0xd36d4
movq %rcx, 0x108(%rsp)
movq 0x17f905(%rip), %rbx    # 0x252fe0
movq (%rbx), %rdi
cmpl $0x0, 0x148(%rdx)
cvtsi2sd %eax, %xmm0
divsd 0x11456f(%rip), %xmm0   # 0x1e7c60
cvttsd2si %xmm0, %ecx
cmovnel %eax, %ecx
leaq 0x11838e(%rip), %rsi    # 0x1eba8d
leaq 0x1183b7(%rip), %r13    # 0x1ebabd
xorl %r14d, %r14d
movq %rdx, %r12
movq %r13, %rdx
xorl %eax, %eax
callq 0x22b0
movq (%rbx), %rdi
movq 0x108(%rsp), %rcx
leaq 0x1183a0(%rip), %rsi    # 0x1ebac8
movq %r13, %rdx
xorl %eax, %eax
callq 0x22b0
cmpl $0x0, 0x178(%rsp)
jne 0xd3b0d
movl 0x7c(%r12), %edi
movq 0x30(%rsp), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq -0x2362(%rip), %rsi     # 0xd13f8
leaq 0xa0(%rsp), %rdx
callq 0xc67c0
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
movl 0x158(%rsp), %esi
callq 0xce0d3
movq (%rsp), %rdi
movq 0x180(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0xd2857
movq %rax, %r12
movq %rax, 0x60(%rsp)
subq $0x8, %rsp
leaq 0x80(%rsp), %rsi
movsd 0x10fd53(%rip), %xmm0   # 0x1e3500
movq %rbx, %rdi
pushq %rax
callq 0xcdbd9
popq %rax
popq %rcx
cmpl $0x0, 0x188(%rsp)
sete %al
cmpl $0x0, 0x190(%rsp)
setne %cl
orb %al, %cl
jne 0xd37ed
leaq 0x20(%rsp), %rsi
movq (%rsp), %rdi
movq 0x180(%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0xd2f60
leaq 0x17ff64(%rip), %rax    # 0x253758
cmpl $0x2, 0x1bc(%rax)
jg 0xd3860
movq 0x180(%rsp), %rax
movq 0xa8(%rax), %rsi
leaq 0x180a1d(%rip), %rax    # 0x254230
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 0x60(%rsp), %rdi
movsd 0x10fcb5(%rip), %xmm0   # 0x1e3500
xorl %edx, %edx
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %r8
callq 0x12b808
addq $0x40, %rsp
cmpl $0x0, 0x188(%rsp)
sete %al
cmpl $0x1, 0x190(%rsp)
setne %cl
orb %al, %cl
jne 0xd3895
leaq 0x20(%rsp), %rsi
movq (%rsp), %rdi
movq 0x180(%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0xd2f60
movq 0x28(%r12), %rcx
leaq 0x20(%rsp), %rdi
movq (%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x180(%rsp), %r8
callq 0xd2317
cmpl $0x0, 0x170(%rsp)
jne 0xd3ad6
xorl %ebx, %ebx
movl 0x28(%rsp), %eax
cmpq %rax, %rbx
jae 0xd3a49
movl %ebx, %ebp
movl %ebx, 0x1c(%rsp)
movq 0x28(%r12), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rbx,8)
js 0xd38ee
cmpb $0x1, 0x4(%rax,%rbx,8)
jne 0xd38f3
incq %rbx
jmp 0xd38c5
movl %ebx, %eax
xorl %r13d, %r13d
imulq $0x18, %rax, %r8
movq %r8, 0x38(%rsp)
movl %r13d, %r13d
movq 0x20(%rsp), %rax
cmpq %r13, (%rax,%r8)
jbe 0xd38ee
addq %r8, %rax
movq 0x10(%rax), %rdi
movq %r13, %rax
shlq $0x6, %rax
cmpb $0x2, 0x2(%rdi,%rax)
je 0xd3a41
addq %rax, %rdi
movq 0x28(%r12), %r9
movq 0x20(%r9), %rcx
movl 0x24(%rdi), %eax
cmpb $0x1, 0x4(%rcx,%rax,8)
je 0xd3a41
cmpl $0x0, (%rcx,%rax,8)
js 0xd3a41
movl 0x28(%rdi), %edx
cmpb $0x1, 0x4(%rcx,%rdx,8)
je 0xd3a41
cmpl $0x0, (%rcx,%rdx,8)
js 0xd3a41
movq (%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 0x17fdcb(%rip), %rax    # 0x253758
movss 0x158(%rax), %xmm0
movl 0x160(%rsp), %ecx
movl 0x168(%rsp), %r8d
movq %r9, 0x40(%rsp)
leaq 0x88(%rsp), %r9
callq 0xced50
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %r8
testl %eax, %eax
js 0xd3a41
movl 0x4(%rdi), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%rdi), %ecx
jne 0xd3a08
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 0x40(%rsp), %rdi
movq 0x38(%rsp), %r8
movq %rax, 0x8(%rdi)
movl 0x4(%rdi), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0xd3a0c
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 0x98(%rsp), %rdx
movq %rdx, 0x10(%rax,%rcx)
movupd 0x88(%rsp), %xmm0
movupd %xmm0, (%rax,%rcx)
incl %r13d
jmp 0xd3901
movq 0x28(%r12), %rdi
callq 0x694eb
movq 0x28(%r12), %rdi
callq 0x69638
movq 0x28(%r12), %rdi
pushq $0x1
popq %rsi
movss 0x50(%rsp), %xmm0
callq 0xcf2e6
movq 0x28(%r12), %rdi
movq 0xa0(%rsp), %rax
leaq 0x30(%rax), %r10
leaq 0x50(%rax), %r11
leaq 0x20(%rsp), %rdx
movq (%rsp), %rsi
movq %r15, %rcx
movq 0x58(%rsp), %r8
movq 0x48(%rsp), %r9
pushq 0x180(%rsp)
pushq 0x8(%rax)
addq $0x70, %rax
pushq 0x160(%rsp)
movl 0x180(%rsp), %ebx
pushq %rbx
movl 0x180(%rsp), %ebx
pushq %rbx
pushq %rax
pushq %r11
pushq %r10
pushq 0x48(%rsp)
pushq 0x58(%rsp)
callq 0xd0caf
addq $0x50, %rsp
movl 0x28(%rsp), %eax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0xd3b09
movq 0x28(%r12), %rdx
movq 0x20(%rdx), %rdx
cmpb $0x1, 0x4(%rdx,%rcx,8)
jne 0xd3b02
movq (%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movb $0x1, 0x4(%rdx,%rcx,8)
movl %ecx, %ebp
incq %rcx
jmp 0xd3adc
movl %ebp, 0x1c(%rsp)
leaq 0x1c(%rsp), %r13
leaq 0x54(%rsp), %rbp
movl %r14d, %r14d
cmpq %r14, (%r15)
jbe 0xd3b45
movq %r15, %rdi
movl %r14d, %esi
movq %r13, %rdx
movq %rbp, %rcx
callq 0x6c2a2
cmpl $0x1, 0x54(%rsp)
jne 0xd3b40
movq 0x8(%r15), %rax
orl $-0x1, (%rax,%r14,4)
incl %r14d
jmp 0xd3b17
movq 0x30(%rsp), %rdi
callq 0x694eb
leaq 0x20(%rsp), %rdi
callq 0xc7ce0
leaq 0x78(%rsp), %rdi
callq 0xc7ce0
cmpq $0x0, 0x180(%rsp)
je 0xd3b91
movq 0x10(%rsp), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x3, %rdx
movq 0x8(%rsp), %rdi
movl $0xff, %esi
callq 0x20e0
jmp 0xd3b9b
movq 0x8(%rsp), %rdi
callq 0x2220
leaq 0xa0(%rsp), %rdi
callq 0xc7c5b
leaq 0x60(%rsp), %rdi
callq 0xd2b41
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq