// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rescue_bubbles_by_contained_reads(ma_ug_t*, asg_t*, ma_hit_t_alloc*, ma_sub_t*, R_to_U*, int, int, unsigned int, unsigned int, unsigned int, bubble_type*, bub_label_t*)
void rescue_bubbles_by_contained_reads(ma_ug_t *i_u_g, asg_t *r_g, ma_hit_t_alloc* sources, ma_sub_t *coverage_cut, 
R_to_U* ruIndex, int max_hang, int min_ovlp, uint32_t chainLenThres, uint32_t beg_idx, uint32_t occ, bubble_type* bub, 
bub_label_t* b_mask_t)
{
    asg_t* nsg = NULL;
    uint32_t beg_utg, sink_utg, *a = NULL, n, i, bub_i, k_i, k_v, k, uId, endRid, is_Unitig, contain_rId;
    uint32_t ava_max, ava_ol_max, ava_min_chain, ava_cur, test_oLen, ava_chainLen, is_update, v, w;
    uint64_t l_bub, m_bub, r_bub, /**bub_0, bub_1,**/ a_nodes;
    ma_ug_t* ug = i_u_g;
    ma_utg_t *nsu = NULL, *u = NULL;
    ma_hit_t_alloc* x = NULL;
    ma_hit_t *h = NULL, *h_max = NULL;
    uint8_t* expect_vis = NULL; CALLOC(expect_vis, r_g->n_seq);
    uint8_t* circle_vis = NULL; CALLOC(circle_vis, r_g->n_seq);
    uint8_t* utg_vis = NULL; CALLOC(utg_vis, ug->g->n_seq);
    asg_arc_t t, t_max, r_edge;

    for (v = 0; v < ug->u.n; v++) ug->g->seq[v].c = PRIMARY_LABLE;
    
    kvec_t(asg_arc_t) new_edges;
    kv_init(new_edges);

    kvec_t(asg_arc_t) rbub_edges;
    kv_init(rbub_edges);

    kvec_t_u64_warp u_vecs;
    kv_init(u_vecs.a);

    kvec_asg_arc_t_warp chain_edges;
    kv_init(chain_edges.a);

    nsg = ug->g;
    for (v = 0; v < nsg->n_seq; v++)
    {
        uId = v;
        nsu = &(ug->u.a[uId]);
        if(nsu->m == 0) continue;
        if(nsg->seq[v].del) continue;
        for (k = 0; k < nsu->n; k++) 
        {
            set_R_to_U(ruIndex, nsu->a[k]>>33, uId, 1, &(r_g->seq[nsu->a[k]>>33].c));
        }
    }


    for (i = 0; i < bub->b_ug->u.n; i++)
    {
        u = &(bub->b_ug->u.a[i]);
        if(u->n < 3) continue; ///should be at least 3
        for (bub_i = 1; bub_i+1 < u->n; bub_i++)
        {
            m_bub = u->a[bub_i]>>33; l_bub = r_bub = (uint64_t)-1;
            if(m_bub < beg_idx || m_bub >= beg_idx + occ) continue;
            l_bub = u->a[bub_i-1]>>33;
            r_bub = u->a[bub_i+1]>>33;

            set_rtg_flag_by_bubble(bub, ug, r_g, l_bub, expect_vis, 1);
            set_rtg_flag_by_bubble(bub, ug, r_g, r_bub, expect_vis, 1);
            set_rtg_flag_by_bubble(bub, ug, r_g, m_bub, expect_vis, 1);

            get_bubbles(bub, m_bub, &beg_utg, &sink_utg, &a, &n, NULL);
            for (k_i = 0; k_i < n; k_i++)
            {
                uId = a[k_i]>>1;
                nsu = &(ug->u.a[uId]);
                if(nsu->m == 0) continue;
                for (k_v = 0; k_v < 2; k_v++)
                {
                    v = (uId<<1) + k_v;
                    if(get_real_length(nsg, v, NULL) != 0) continue;

                    if(v&1)
                    {
                        endRid = nsu->start^1;
                    }
                    else
                    {
                        endRid = nsu->end^1;
                    }

                    //x is the end read of a tip
                    ///find all overlap of x
                    x = &(sources[(endRid>>1)]);
                    ava_ol_max = ava_max = 0; ava_min_chain = (uint32_t)-1;
                    h_max = NULL;
                    for (k = 0; k < x->length; k++)
                    {
                        ///fprintf(stderr, "k: %u\n", k);
                        ///h is the edge of endRid
                        h = &(x->buffer[k]);
                        ///means we found a contained read
                        if(get_contained_reads_chain_by_broken_bub(h, sources, coverage_cut, ruIndex, ug, r_g, 
                        max_hang, min_ovlp, endRid, uId, &chain_edges, &ava_cur, &test_oLen, &ava_chainLen, 
                        expect_vis, circle_vis, utg_vis, chainLenThres, 1))
                        {
                            is_update = 0;

                            if(ava_cur > ava_max)
                            {
                                is_update = 1;
                            }
                            else if(ava_cur == ava_max)
                            {
                                if(ava_chainLen < ava_min_chain)
                                {
                                    is_update = 1;
                                }
                                else if(ava_chainLen == ava_min_chain && test_oLen > ava_ol_max)
                                {
                                    is_update = 1;
                                }
                            }

                            if(is_update)
                            {
                                ava_min_chain = ava_chainLen;
                                ava_max = ava_cur;
                                ava_ol_max = test_oLen;
                                h_max = h;
                            }
                        }
                    }

                    if(ava_max > 0)
                    {
                        ///fprintf(stderr, "ava_max: %u\n", ava_max);
                        get_contained_reads_chain_by_broken_bub(h_max, sources, coverage_cut, ruIndex, ug, r_g, 
                        max_hang, min_ovlp, endRid, uId, &chain_edges, &ava_cur, &test_oLen, &ava_chainLen, 
                        expect_vis, circle_vis, NULL, chainLenThres, 1);
                        if(chain_edges.a.n < 1) continue;
                        ///the last cantained read
                        t_max = chain_edges.a.a[chain_edges.a.n-1];

                        k = 0; rbub_edges.n = 0;
                        ///edges from the last contained read to other unitigs

                        while(get_edge2existing_node_advance_by_broken_bub(ug, r_g, sources, coverage_cut, 
                        ruIndex, expect_vis, max_hang, min_ovlp, t_max.v, &k, &r_edge, 1))
                        {
                            kv_push(asg_arc_t, rbub_edges, r_edge);
                        }

                        ///need to do transitive reduction
                        ///note here is different to standard transitive reduction
                        minor_transitive_reduction_r_g(r_g, rbub_edges.a, rbub_edges.n);

                        for (k = 0; k < chain_edges.a.n; k++)
                        {
                            t_max = chain_edges.a.a[k];
                            ///save all infor for reverting
                            get_R_to_U(ruIndex, t_max.v>>1, &contain_rId, &is_Unitig);
                            a_nodes=contain_rId; 
                            a_nodes=a_nodes<<32; 
                            a_nodes=a_nodes|((uint64_t)(t_max.v>>1));
                            kv_push(uint64_t, u_vecs.a, a_nodes);

                            r_g->seq[t_max.v>>1].del = 0;
                            coverage_cut[t_max.v>>1].del = 0;
                            coverage_cut[t_max.v>>1].c = PRIMARY_LABLE;

                            get_edge_from_source(sources, coverage_cut, ruIndex, max_hang, min_ovlp, 
                            (t_max.ul>>32), t_max.v, &t);
                            kv_push(asg_arc_t, new_edges, t);

                            get_edge_from_source(sources, coverage_cut, ruIndex, max_hang, min_ovlp, 
                            (t_max.v^1), ((t_max.ul>>32)^1), &t);
                            kv_push(asg_arc_t, new_edges, t);
                        }


                        for (k = 0; k < rbub_edges.n; k++)
                        {
                            t = rbub_edges.a[k];
                            if(t.del) continue;
                    
                            kv_push(asg_arc_t, new_edges, t);
                            get_edge_from_source(sources, coverage_cut, ruIndex, max_hang, min_ovlp, 
                            (t.v^1), ((t.ul>>32)^1), &t);
                            kv_push(asg_arc_t, new_edges, t);
                        }

                    }
                }
            }
            

            set_rtg_flag_by_bubble(bub, ug, r_g, l_bub, expect_vis, 0);
            set_rtg_flag_by_bubble(bub, ug, r_g, r_bub, expect_vis, 0);
            set_rtg_flag_by_bubble(bub, ug, r_g, m_bub, expect_vis, 0);
        }
    }

    asg_arc_t* p = NULL;
    for (k = 0; k < new_edges.n; k++)
    {
        p = asg_arc_pushp(r_g);
        *p = new_edges.a[k];
    }
    if(new_edges.n != 0)
    {
        free(r_g->idx);
        r_g->idx = 0;
        r_g->is_srt = 0;
        asg_cleanup(r_g);
        asg_symm(r_g);
    }

    pre_clean(sources, coverage_cut, r_g, 0);

    lable_all_bubbles(r_g, b_mask_t);

    for (k = 0; k < new_edges.n; k++)
    {
        v = new_edges.a[k].ul>>32;
        w = new_edges.a[k].v;

        if(r_g->seq[v>>1].del) continue;
        if(r_g->seq[w>>1].del) continue;
        ///if this edge is at a bubble
        if(r_g->seq_vis[v]!=0 && r_g->seq_vis[w^1]!=0) continue;

        asg_arc_del(r_g, v, w, 1);
        asg_arc_del(r_g, w^1, v^1, 1);
    }
    asg_cleanup(r_g);
    asg_symm(r_g);

    for (k = 0; k < u_vecs.a.n; k++)
    {
        w = (uint32_t)u_vecs.a.a[k];
        w = w<<1;
        if((!r_g->seq[w>>1].del) && 
                    (get_real_length(r_g, w, NULL)!=0 || get_real_length(r_g, (w^1), NULL)!=0))
        {
            w=w>>1;
            ruIndex->index[w] = (uint32_t)-1;
        }
        else
        {
            w=w>>1;
            r_g->seq[w].del = 1;
            coverage_cut[w].del = 1;
        }
    }
    
    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;
    }

    // fprintf(stderr, "M::%s has done!\n", __func__);
    // print_bubble_filling_status(ug, r_g, ruIndex, bub, beg_idx, occ, new_edges.a, new_edges.n);

    kv_destroy(new_edges);
    kv_destroy(rbub_edges);
    kv_destroy(u_vecs.a);
    kv_destroy(chain_edges.a);
    free(expect_vis);
    free(circle_vis);
    free(utg_vis);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movl %r9d, 0x8c(%rsp)
movq %r8, 0x78(%rsp)
movq %rcx, 0x98(%rsp)
movq %rdx, 0x100(%rsp)
movq %rdi, %r15
movq $0x0, 0x158(%rsp)
movq %rsi, 0x70(%rsp)
movl 0x14(%rsi), %r14d
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %r14
movl $0x1, %esi
movq %r14, %rdi
callq 0x2120
movq %rax, 0xf0(%rsp)
movl $0x1, %esi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x138(%rsp)
movq 0x18(%r15), %rbp
movl 0x14(%rbp), %edi
andq %rbx, %rdi
movl $0x1, %esi
callq 0x2120
movq %rax, 0x150(%rsp)
movq %r15, 0xc0(%rsp)
movq (%r15), %rax
testq %rax, %rax
je 0xf53b1
movq 0x20(%rbp), %rcx
xorl %edx, %edx
movb $0x0, 0x4(%rcx,%rdx,8)
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0xf53a2
xorps %xmm0, %xmm0
movaps %xmm0, 0x160(%rsp)
movq $0x0, 0x170(%rsp)
testl $0x7fffffff, 0x14(%rbp) # imm = 0x7FFFFFFF
movq 0x70(%rsp), %rdx
je 0xf5455
xorl %r14d, %r14d
movq 0x78(%rsp), %r12
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%r14,%r14,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xf5445
movq 0x20(%rbp), %rsi
cmpl $0x0, (%rsi,%r14,8)
js 0xf5445
leaq (%rax,%rcx,8), %rbx
cmpl $0x0, 0x10(%rbx)
je 0xf5445
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rsi
shrq $0x21, %rsi
movq 0x20(%rdx), %rax
leaq (%rax,%rsi,8), %r8
addq $0x4, %r8
movq %r12, %rdi
movl %r14d, %edx
movl $0x1, %ecx
callq 0xa1cd4
movq 0x70(%rsp), %rdx
incq %r15
movl 0x10(%rbx), %eax
cmpq %rax, %r15
jb 0xf540d
incq %r14
movl 0x14(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r14
jb 0xf53de
movq 0x250(%rsp), %rax
movq 0xc0(%rax), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax)
je 0xf61c4
movl 0x240(%rsp), %edi
movl %edi, %r8d
addl 0x248(%rsp), %edi
xorl %ebx, %ebx
movq $0x0, 0x148(%rsp)
movq $0x0, 0xe0(%rsp)
xorl %esi, %esi
movq $0x0, 0xb0(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x90(%rsp)
xorl %r12d, %r12d
movq %rbp, 0x130(%rsp)
movq %rdi, 0x198(%rsp)
movq %r8, 0x190(%rsp)
movq 0x10(%rax), %rax
movq %rcx, 0x188(%rsp)
leaq (%rcx,%rcx,4), %rcx
cmpl $0x3, 0x10(%rax,%rcx,8)
movq %rsi, 0xd8(%rsp)
jb 0xf6198
leaq (%rax,%rcx,8), %r9
cmpl $0x3, 0x10(%r9)
jb 0xf6198
movl $0x2, %r10d
movl $0x1, %r11d
movq %r9, 0x1a0(%rsp)
movq 0x18(%r9), %rax
movq (%rax,%r11,8), %r14
shrq $0x21, %r14
cmpq %r8, %r14
setb %cl
cmpq %rdi, %r14
setae %sil
orb %cl, %sil
jne 0xf6185
movq %r15, 0xd0(%rsp)
movq %rbx, 0x80(%rsp)
movq %r11, 0x1b8(%rsp)
movq -0x8(%rax,%r11,8), %rcx
shrq $0x21, %rcx
movq %r10, 0x1c0(%rsp)
movq (%rax,%r10,8), %rbx
shrq $0x21, %rbx
movq %r14, 0x128(%rsp)
movq 0x250(%rsp), %rdi
movq 0xc0(%rsp), %r15
movq %r15, %rsi
movq %rcx, 0x1a8(%rsp)
movq 0xf0(%rsp), %r13
movq %r13, %r8
movl $0x1, %r9d
movq %rdx, %r14
callq 0xf4de5
movq 0x250(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, 0x1b0(%rsp)
movl %ebx, %ecx
movq %r13, %r8
movl $0x1, %r9d
callq 0xf4de5
movq 0x250(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq 0x128(%rsp), %rcx
movq %r13, %r8
movl $0x1, %r9d
callq 0xf4de5
movq $0x0, (%rsp)
movq %rbx, %rdi
movq 0x128(%rsp), %rsi
leaq 0x1dc(%rsp), %rdx
leaq 0x1d8(%rsp), %rcx
leaq 0x158(%rsp), %r8
leaq 0x10c(%rsp), %r9
callq 0x13812e
cmpl $0x0, 0x10c(%rsp)
je 0xf60bc
xorl %ecx, %ecx
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
movq 0x80(%rsp), %rbx
movq 0xd0(%rsp), %r15
movq 0x90(%rsp), %rsi
movq 0x158(%rsp), %rax
movq %rcx, 0x1c8(%rsp)
movl (%rax,%rcx,4), %edi
movl %edi, %ecx
shrl %ecx
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%rcx,%rcx,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xf609f
leaq (%rax,%rcx,8), %rax
movq %rax, 0x1d0(%rsp)
andl $-0x2, %edi
xorl %eax, %eax
movq %rdi, %r8
movq %rdi, 0xa0(%rsp)
movq %rsi, 0x90(%rsp)
movq %rax, 0x140(%rsp)
orq %r8, %rax
movq 0x28(%rbp), %rcx
movq (%rcx,%rax,8), %rax
movq %rax, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0xf5715
movq 0x8(%rbp), %rdx
shrq $0x20, %rax
leaq (%rax,%rax,2), %rax
leaq (%rdx,%rax,8), %rax
addq $0xc, %rax
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0xf56f5
testl %esi, %esi
movq 0x78(%rsp), %rdx
jne 0xf5ed7
xorl %eax, %eax
cmpq $0x0, 0x140(%rsp)
sete %al
movq 0x1d0(%rsp), %rcx
movl 0x4(%rcx,%rax,4), %eax
movl %eax, %r13d
xorl $0x1, %r13d
shrl %eax
leaq (%rax,%rax,2), %rax
movq 0x100(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
movq %r12, 0xe8(%rsp)
movq %rbx, 0x80(%rsp)
movq %r15, 0xd0(%rsp)
je 0xf58fd
leaq (%rcx,%rax,8), %r12
xorl %ebp, %ebp
movl $0xffffffff, 0xa8(%rsp) # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movq $0x0, 0xf8(%rsp)
movl $0x0, 0xb8(%rsp)
xorl %ebx, %ebx
movq (%r12), %r15
addq %rbp, %r15
movq 0x150(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xcc(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x108(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %r13d, 0x10(%rsp)
movl 0x230(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, (%rsp)
movl $0x1, 0x60(%rsp)
movq %r15, %rdi
movq 0x100(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x78(%rsp), %rcx
movq 0xc0(%rsp), %r8
callq 0xf30ec
testl %eax, %eax
je 0xf5879
movl 0x108(%rsp), %eax
cmpl %ebx, %eax
movq 0x70(%rsp), %r9
jbe 0xf5880
movl 0xc8(%rsp), %ecx
movl %ecx, 0xa8(%rsp)
movl 0xcc(%rsp), %ecx
movl %ecx, 0xb8(%rsp)
movl %eax, %ebx
movq %r15, 0xf8(%rsp)
jmp 0xf58a4
movq 0x70(%rsp), %r9
jmp 0xf58a4
jne 0xf58a4
movl 0xa8(%rsp), %ecx
cmpl %ecx, 0xc8(%rsp)
jb 0xf5851
jne 0xf58a4
movl 0xb8(%rsp), %ecx
cmpl %ecx, 0xcc(%rsp)
ja 0xf5851
incq %r14
movl 0xc(%r12), %eax
addq $0x28, %rbp
cmpq %rax, %r14
jb 0xf5794
testl %ebx, %ebx
sete %al
movq 0x78(%rsp), %rdx
movq 0xe8(%rsp), %r12
movq 0x80(%rsp), %rbx
movq 0x130(%rsp), %rbp
movq 0xd0(%rsp), %r15
movq 0x90(%rsp), %rsi
movq 0xa0(%rsp), %r8
movq 0xf8(%rsp), %rdi
jmp 0xf5911
movb $0x1, %al
xorl %edi, %edi
movq 0x90(%rsp), %rsi
movq 0xa0(%rsp), %r8
testb %al, %al
jne 0xf5ee7
movq 0x138(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xcc(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x108(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x160(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %r13d, 0x10(%rsp)
movl 0x230(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, (%rsp)
movl $0x1, 0x60(%rsp)
movq $0x0, 0x50(%rsp)
movq %rdx, %rcx
movq 0x100(%rsp), %r14
movq %r14, %rsi
movq 0x98(%rsp), %rdx
movq 0xc0(%rsp), %r8
callq 0xf30ec
movq 0x160(%rsp), %rax
testq %rax, %rax
je 0xf5ecd
movq 0x170(%rsp), %rcx
leaq (%rax,%rax,2), %rax
movl -0x10(%rcx,%rax,8), %r12d
movl %r12d, %eax
shrl %eax
leaq (%rax,%rax,2), %rax
leaq (%r14,%rax,8), %r13
xorl %ebp, %ebp
movq $0x0, 0xb8(%rsp)
movq 0x98(%rsp), %r8
movq 0x70(%rsp), %rdi
movq 0xb0(%rsp), %rax
movq 0xd8(%rsp), %rsi
movl 0xc(%r13), %r14d
movb $0x1, %bl
cmpl %r14d, %ebp
movq %rax, 0xb0(%rsp)
jae 0xf5b71
movq %rsi, 0xd8(%rsp)
leaq 0x194d23(%rip), %rax    # 0x28a758
movss 0x158(%rax), %xmm0
movss %xmm0, 0xa8(%rsp)
movl %ebp, %eax
leaq (%rax,%rax,4), %r15
shlq $0x3, %r15
addq (%r13), %r15
subq %rax, %r14
movl 0xc(%r15), %edx
leaq (%rdx,%rdx,2), %rcx
movl (%r8,%rcx,4), %eax
testl %eax, %eax
js 0xf5b4a
movq 0x20(%rdi), %rsi
cmpl $0x0, (%rsi,%rdx,8)
js 0xf5b4a
movl 0x4(%r15), %edx
leaq (%rdx,%rdx,2), %rdx
leaq (%r8,%rdx,4), %rdx
leaq (%r8,%rcx,4), %rcx
movl 0x4(%rdx), %esi
movl (%rdx), %edx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %edx
subl %edx, %esi
movl 0x4(%rcx), %edx
subl %eax, %edx
movq %r15, %rdi
movl 0x8c(%rsp), %ecx
movss 0xa8(%rsp), %xmm0
movl 0x230(%rsp), %r8d
leaq 0x1e0(%rsp), %r9
callq 0xa159b
movq 0x70(%rsp), %rdi
movq 0x98(%rsp), %r8
testl %eax, %eax
js 0xf5b4a
cmpl %r12d, 0x1e4(%rsp)
jne 0xf5b4a
movl 0x1e8(%rsp), %eax
shrl %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x78(%rsp), %rdx
cmpq %rax, (%rdx)
jbe 0xf5b12
movq 0x8(%rdx), %rdx
movl (%rdx,%rax,4), %edx
cmpl $-0x1, %edx
je 0xf5b12
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
testl %edx, %edx
setns %dl
jmp 0xf5b14
xorl %edx, %edx
cmpl $-0x1, %ecx
sete %sil
orb %dl, %sil
jne 0xf5b4a
movq 0xc0(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movl %ecx, %ecx
cmpl $0x0, (%rdx,%rcx,8)
js 0xf5b4a
movq 0xf0(%rsp), %rcx
cmpb $0x0, (%rcx,%rax)
jne 0xf5be3
incl %ebp
addq $0x28, %r15
decq %r14
jne 0xf5a57
movq 0xb0(%rsp), %rax
movq 0xd0(%rsp), %r15
movq 0xd8(%rsp), %rsi
testb %bl, %bl
movq 0xb8(%rsp), %r14
jne 0xf5bec
cmpq %rsi, %r14
jne 0xf5bb6
leaq (%rsi,%rsi), %rbx
testq %rsi, %rsi
movl $0x2, %ecx
cmoveq %rcx, %rbx
leaq (,%rbx,8), %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x2370
movq 0x70(%rsp), %rdi
movq 0x98(%rsp), %r8
movq %rbx, %rsi
leaq (%r14,%r14,2), %rdx
incq %r14
movq %r14, 0xb8(%rsp)
movq 0x1f0(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movups 0x1e0(%rsp), %xmm0
movups %xmm0, (%rax,%rdx,8)
jmp 0xf5a0f
incl %ebp
xorl %ebx, %ebx
jmp 0xf5b59
movq %rsi, 0xd8(%rsp)
movq %rax, %rsi
movl %r14d, %edx
callq 0xf4f30
cmpq $0x0, 0x160(%rsp)
movq 0x80(%rsp), %rbx
je 0xf5f01
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rbp
movl $0x1, %ecx
xorl %eax, %eax
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
movq 0xe8(%rsp), %r12
movq 0x90(%rsp), %rsi
movl %ecx, 0xf8(%rsp)
movq %r12, 0xe8(%rsp)
movq %r15, 0xa8(%rsp)
movq 0x170(%rsp), %rcx
leaq (%rax,%rax,2), %rax
movl 0x8(%rcx,%rax,8), %r15d
movl %r15d, %r14d
shrl %r14d
movabsq $-0x100000000, %r13     # imm = 0xFFFFFFFF00000000
cmpq %r14, (%rdx)
jbe 0xf5c9d
movq 0x8(%rdx), %rdx
movl (%rdx,%r14,4), %edx
movl %edx, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
cmpl $-0x1, %edx
cmovel %edx, %r13d
shlq $0x20, %r13
movq %rsi, 0x90(%rsp)
movq (%rcx,%rax,8), %r12
movq 0x148(%rsp), %rax
cmpq %rax, %rbx
movq %rbx, 0x80(%rsp)
jne 0xf5d02
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rsi
movq 0xe0(%rsp), %rdi
callq 0x2370
movq 0x70(%rsp), %r9
movq %rbx, 0x148(%rsp)
movq 0x80(%rsp), %rbx
movq 0x98(%rsp), %rsi
jmp 0xf5d12
movq 0x98(%rsp), %rsi
movq 0xe0(%rsp), %rax
orq %r14, %r13
movq %rax, 0xe0(%rsp)
movq %r13, (%rax,%rbx,8)
movq 0x20(%r9), %rax
andl $0x7fffffff, (%rax,%r14,8) # imm = 0x7FFFFFFF
leaq (%r14,%r14,2), %rax
andb $0x7f, 0x3(%rsi,%rax,4)
movb $0x0, 0x8(%rsi,%rax,4)
shrq $0x20, %r12
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movl %r15d, (%rsp)
movq 0x100(%rsp), %r13
movq %r13, %rdi
movl 0x8c(%rsp), %ecx
movl 0x230(%rsp), %r8d
movl %r12d, %r9d
callq 0xb2ced
movq 0x90(%rsp), %rax
cmpq %rax, 0xa8(%rsp)
jne 0xf5db2
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0xe8(%rsp), %rdi
callq 0x2370
movq %rax, %r14
jmp 0xf5dbd
movq 0xe8(%rsp), %r14
movq %rax, %rbx
movq 0x120(%rsp), %rax
movq %rax, 0x10(%r14,%rbp)
movups 0x110(%rsp), %xmm0
movups %xmm0, (%r14,%rbp)
xorl $0x1, %r15d
xorl $0x1, %r12d
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rsp)
movl %r12d, (%rsp)
movq %r13, %rdi
movq 0x98(%rsp), %rsi
movl 0x8c(%rsp), %ecx
movl 0x230(%rsp), %r8d
movl %r15d, %r9d
callq 0xb2ced
movq 0xa8(%rsp), %rax
leaq 0x1(%rax), %r15
cmpq %rbx, %r15
movq %rbx, %rsi
jne 0xf5e5c
leaq (%rsi,%rsi), %rbx
testq %rsi, %rsi
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
movq %r14, %rdi
callq 0x2370
movq %rax, %r12
movq %rbx, %rsi
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
jmp 0xf5e69
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
movq %r14, %r12
movq 0x80(%rsp), %rbx
movq 0xa0(%rsp), %r8
movl 0xf8(%rsp), %ecx
movq 0x120(%rsp), %rax
movq %rax, 0x28(%r12,%rbp)
movups 0x110(%rsp), %xmm0
movups %xmm0, 0x18(%r12,%rbp)
movl %ecx, %eax
addq $0x30, %rbp
incl %ecx
incq %r15
incq %rbx
cmpq %rax, 0x160(%rsp)
ja 0xf5c43
movq 0xa8(%rsp), %r15
addq $0x2, %r15
movq 0xb8(%rsp), %r14
jmp 0xf5f23
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
movq 0x90(%rsp), %rsi
movq 0xa0(%rsp), %r8
movq 0x140(%rsp), %rcx
leaq 0x1(%rcx), %rax
testq %rcx, %rcx
je 0xf56ad
jmp 0xf609f
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
movq 0xe8(%rsp), %r12
movq 0x90(%rsp), %rsi
movq 0xa0(%rsp), %r8
testq %r14, %r14
je 0xf6092
movq %rbx, %rbp
movl $0x1, %ebx
xorl %eax, %eax
leaq (%rax,%rax,2), %rax
movq 0xb0(%rsp), %rcx
movups (%rcx,%rax,8), %xmm0
movaps %xmm0, 0x110(%rsp)
movq 0x10(%rcx,%rax,8), %rax
movq %rax, 0x120(%rsp)
cmpl $0x0, 0x11c(%rsp)
js 0xf6075
cmpq %rsi, %r15
jne 0xf5f9a
leaq (%rsi,%rsi), %r14
testq %rsi, %rsi
movl $0x2, %eax
cmoveq %rax, %r14
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %rsi
movq %r12, %rdi
callq 0x2370
movq %rax, %r12
movq %r14, %r13
jmp 0xf5f9d
movq %rsi, %r13
leaq 0x1(%r15), %r14
leaq (%r15,%r15,2), %rax
movq 0x120(%rsp), %rcx
movq %rcx, 0x10(%r12,%rax,8)
movaps 0x110(%rsp), %xmm0
movups %xmm0, (%r12,%rax,8)
movl 0x114(%rsp), %eax
movl 0x118(%rsp), %r9d
xorl $0x1, %r9d
xorl $0x1, %eax
leaq 0x110(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movl %eax, (%rsp)
movq 0x100(%rsp), %rdi
movq 0x98(%rsp), %rsi
movl 0x8c(%rsp), %ecx
movl 0x230(%rsp), %r8d
callq 0xb2ced
cmpq %r13, %r14
movq %r13, %rsi
jne 0xf6041
movq %r15, %r13
leaq (%rsi,%rsi), %r15
testq %rsi, %rsi
movl $0x2, %eax
cmoveq %rax, %r15
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rsi
movq %r12, %rdi
callq 0x2370
movq %rax, %r12
movq %r15, %rsi
movq %r13, %r15
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %r9
addq $0x2, %r15
leaq (%r14,%r14,2), %rax
movq 0x120(%rsp), %rcx
movq %rcx, 0x10(%r12,%rax,8)
movaps 0x110(%rsp), %xmm0
movups %xmm0, (%r12,%rax,8)
movq 0xb8(%rsp), %r14
movl %ebx, %eax
incl %ebx
cmpq %rax, %r14
ja 0xf5f36
movq %rbp, %rbx
movq 0x130(%rsp), %rbp
jmp 0xf5edf
movq 0x130(%rsp), %rbp
jmp 0xf5ee7
movq 0x1c8(%rsp), %rcx
incq %rcx
movl 0x10c(%rsp), %eax
cmpq %rax, %rcx
jb 0xf565f
jmp 0xf60d9
movq 0x70(%rsp), %r9
movq 0x80(%rsp), %rbx
movq 0xd0(%rsp), %r15
movq 0x90(%rsp), %rsi
movq %rsi, 0x90(%rsp)
movq 0x250(%rsp), %rdi
movq 0xc0(%rsp), %r14
movq %r14, %rsi
movq %r9, %rdx
movq 0x1a8(%rsp), %rcx
movq 0xf0(%rsp), %r13
movq %r13, %r8
xorl %r9d, %r9d
callq 0xf4de5
movq 0x250(%rsp), %rdi
movq %r14, %rsi
movq 0x70(%rsp), %rdx
movq 0x1b0(%rsp), %rcx
movq %r13, %r8
xorl %r9d, %r9d
callq 0xf4de5
movq 0x250(%rsp), %rdi
movq %r14, %rsi
movq 0x70(%rsp), %rdx
movq 0x128(%rsp), %rcx
movq %r13, %r8
xorl %r9d, %r9d
callq 0xf4de5
movq 0x70(%rsp), %rdx
movq 0x198(%rsp), %rdi
movq 0x190(%rsp), %r8
movq 0x1a0(%rsp), %r9
movq 0x1c0(%rsp), %r10
movq 0x1b8(%rsp), %r11
incq %r10
movl 0x10(%r9), %eax
incq %r11
cmpq %rax, %r10
jb 0xf5519
movq 0x188(%rsp), %rcx
incl %ecx
movq 0x250(%rsp), %rax
movq 0xc0(%rax), %rax
cmpq %rcx, (%rax)
movq 0xd8(%rsp), %rsi
ja 0xf54d3
jmp 0xf61e4
xorl %r12d, %r12d
xorl %r15d, %r15d
movq $0x0, 0xb0(%rsp)
movq $0x0, 0xe0(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x80(%rsp)
testq %r15, %r15
je 0xf62cc
movq %r15, %r13
movl $0x1, %ebx
xorl %r15d, %r15d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl $0x10, %r14d
movl 0x4(%rdx), %ecx
andl %ebp, %ecx
movl (%rdx), %eax
cmpl %eax, %ecx
jne 0xf623b
leal (%rax,%rax), %ecx
testl %eax, %eax
cmovel %r14d, %ecx
movl %ecx, (%rdx)
movq 0x8(%rdx), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq 0x70(%rsp), %rdx
movq %rax, 0x8(%rdx)
movq 0x8(%rdx), %rax
movl 0x4(%rdx), %ecx
movl %ecx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
leal 0x1(%rcx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %esi, %ecx
movl %ecx, 0x4(%rdx)
leaq (%rdi,%rdi,2), %rcx
leaq (%r15,%r15,2), %rdi
movq 0x10(%r12,%rdi,8), %rsi
movq %rsi, 0x10(%rax,%rcx,8)
movups (%r12,%rdi,8), %xmm0
movups %xmm0, (%rax,%rcx,8)
movl %ebx, %r15d
incl %ebx
cmpq %r15, %r13
ja 0xf620b
movq 0x28(%rdx), %rdi
callq 0x2220
movq 0x70(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x70(%rsp), %rax
andb $0x7f, 0x7(%rax)
movq 0x70(%rsp), %rdi
callq 0xa02fa
movq 0x70(%rsp), %rdi
callq 0xa0333
movq 0x70(%rsp), %rdi
callq 0xa03e9
movq 0x70(%rsp), %rdx
orb $-0x80, 0x17(%rdx)
movq %r13, %r15
movq 0x258(%rsp), %rbx
movl $0x64, %ecx
xorl %r8d, %r8d
callq 0xe7e99
movq 0x70(%rsp), %rdx
testq %rax, %rax
jne 0xf62d4
movq %rdx, %rdi
callq 0xa02fa
movq 0x70(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xa6dbe
movq 0x70(%rsp), %rdi
testq %r15, %r15
movq 0x80(%rsp), %rbx
je 0xf6416
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq (%rax,%rax,2), %rsi
movq (%r12,%rsi,8), %rdx
movq 0x20(%rdi), %r9
movq %rdx, %r8
shrq $0x21, %r8
cmpl $0x0, (%r9,%r8,8)
js 0xf6408
movl 0x8(%r12,%rsi,8), %esi
movl %esi, %r8d
shrl %r8d
cmpl $0x0, (%r9,%r8,8)
js 0xf6408
shrq $0x20, %rdx
movq 0x30(%rdi), %r9
cmpb $0x0, (%r9,%rdx)
je 0xf6374
movq %rsi, %r8
xorq $0x1, %r8
cmpb $0x0, (%r9,%r8)
jne 0xf6408
movq 0x28(%rdi), %r8
movq (%r8,%rdx,8), %r8
movq %r8, %r10
andq %rcx, %r10
je 0xf63b9
movq 0x8(%rdi), %r9
shrq $0x20, %r8
shlq $0x3, %r10
leaq (%r10,%r10,2), %r10
leaq (%r8,%r8,2), %r8
leaq (%r9,%r8,8), %r8
addq $0xc, %r8
xorl %r9d, %r9d
cmpl %esi, -0x4(%r8,%r9)
jne 0xf63b0
orb $-0x80, 0x3(%r8,%r9)
addq $0x18, %r9
cmpq %r9, %r10
jne 0xf63a3
xorl $0x1, %esi
movq 0x28(%rdi), %r8
movq (%r8,%rsi,8), %r9
movq %r9, %rsi
andq %rcx, %rsi
je 0xf6408
movq 0x8(%rdi), %r8
shrq $0x20, %r9
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%r9,%r9,2), %r9
leaq (%r8,%r9,8), %r10
addq $0xc, %r10
xorl %r8d, %r8d
movl -0x4(%r10,%r8), %r9d
xorl %edx, %r9d
cmpl $0x1, %r9d
jne 0xf63ff
orb $-0x80, 0x3(%r10,%r8)
addq $0x18, %r8
cmpq %r8, %rsi
jne 0xf63eb
incq %rax
movl %eax, %edx
cmpq %rdx, %r15
ja 0xf631f
callq 0xa02fa
movq 0x70(%rsp), %rdi
callq 0xa0333
movq 0x70(%rsp), %rdi
callq 0xa03e9
movq 0x70(%rsp), %rdx
orb $-0x80, 0x17(%rdx)
testq %rbx, %rbx
je 0xf6564
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0xe0(%rsp), %rsi
movq (%rsi,%rax,8), %r9
movq 0x20(%rdx), %rsi
movl %r9d, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rsi,%rdx,8), %edi
testl %edi, %edi
js 0xf6537
addl %r9d, %r9d
movq 0x70(%rsp), %r8
movq 0x28(%r8), %r8
movl %r9d, %r9d
movq (%r8,%r9,8), %r10
movq %r10, %r11
andq %rcx, %r11
je 0xf64cf
movq 0x70(%rsp), %rbx
movq 0x8(%rbx), %rbx
shrq $0x20, %r10
leaq (%r10,%r10,2), %r10
leaq (%rbx,%r10,8), %r10
addq $0xc, %r10
shlq $0x3, %r11
leaq (%r11,%r11,2), %r11
xorl %ebx, %ebx
xorl %ebp, %ebp
movl (%r10,%rbx), %r14d
notl %r14d
shrl $0x1f, %r14d
addl %r14d, %ebp
addq $0x18, %rbx
cmpq %rbx, %r11
jne 0xf64ac
testl %ebp, %ebp
movq 0x80(%rsp), %rbx
jne 0xf6525
movq 0x8(%r8,%r9,8), %r8
movq %r8, %r9
andq %rcx, %r9
je 0xf6537
movq 0x70(%rsp), %r10
movq 0x8(%r10), %r10
shrq $0x20, %r8
leaq (%r8,%r8,2), %r8
leaq (%r10,%r8,8), %r8
addq $0xc, %r8
shlq $0x3, %r9
leaq (%r9,%r9,2), %r9
xorl %r10d, %r10d
xorl %r11d, %r11d
movl (%r8,%r10), %ebx
notl %ebx
shrl $0x1f, %ebx
addl %ebx, %r11d
addq $0x18, %r10
cmpq %r10, %r9
jne 0xf6503
testl %r11d, %r11d
movq 0x80(%rsp), %rbx
je 0xf6537
movq 0x78(%rsp), %rsi
movq 0x8(%rsi), %rsi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
jmp 0xf6551
orl $0x80000000, %edi       # imm = 0x80000000
movl %edi, (%rsi,%rdx,8)
leaq (%rdx,%rdx,2), %rdx
movq 0x98(%rsp), %rsi
orb $-0x80, 0x3(%rsi,%rdx,4)
incq %rax
movl %eax, %edx
cmpq %rdx, %rbx
movq 0x70(%rsp), %rdx
ja 0xf6448
movq 0x78(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0xf659c
movq 0x78(%rsp), %rcx
movq 0x8(%rcx), %rcx
xorl %edx, %edx
cmpl $-0x2, (%rcx,%rdx,4)
jg 0xf6592
movq 0x78(%rsp), %rsi
movq 0x8(%rsi), %rsi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0xf657c
movq %r12, %rdi
callq 0x2220
movq 0xb0(%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
movq 0x170(%rsp), %rdi
callq 0x2220
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0x138(%rsp), %rdi
callq 0x2220
movq 0x150(%rsp), %rdi
callq 0x2220
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq