// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rescue_contained_reads_aggressive(ma_ug_t*, asg_t*, ma_hit_t_alloc*, ma_sub_t*, R_to_U*, int, int, unsigned int, unsigned int, unsigned int, kvec_asg_arc_t_warp*, kvec_t_u32_warp*, bub_label_t*)
void rescue_contained_reads_aggressive(ma_ug_t *i_ug, 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 is_bubble_check, uint32_t is_primary_check, kvec_asg_arc_t_warp* new_rtg_edges, 
kvec_t_u32_warp* new_rtg_nodes, bub_label_t* b_mask_t)
{
    uint32_t n_vtx, v, k, contain_rId, is_Unitig, uId, rId, endRid, oLen, w, max_oLen, max_oLen_i = (uint32_t)-1;
    uint32_t ava_max, ava_ol_max, ava_min_chain, ava_cur, ava_chainLen, test_oLen, is_update;
    asg_t* nsg = NULL;
    ma_utg_t* nsu = NULL;
    asg_arc_t t, t_max, r_edge;
    t_max.v = t_max.ul = t.v = t.ul = (uint32_t)-1;
    ma_hit_t *h = NULL, *h_max = NULL;
    ma_hit_t_alloc* x = NULL;
    ma_ug_t* ug = NULL;
    uint64_t a_nodes;
    
    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_t_u32_warp chain_buffer;
    kv_init(chain_buffer.a);

    kvec_asg_arc_t_warp chain_edges;
    kv_init(chain_edges.a);

    if(i_ug != NULL)
    {
        ug = i_ug;
    }
    else
    {
        ug = ma_ug_gen(r_g);
        for (v = 0; v < ug->g->n_seq; v++)
        {
            ug->g->seq[v].c = PRIMARY_LABLE;
        }
    }
    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;
        if(is_primary_check && nsg->seq[v].c==ALTER_LABLE) continue;
        for (k = 0; k < nsu->n; k++)
        {
            rId = nsu->a[k]>>33;
            set_R_to_U(ruIndex, rId, uId, 1, &(r_g->seq[rId].c));
        }
    }




    n_vtx = nsg->n_seq * 2;
    for (v = 0; v < n_vtx; v++)
    {
        uId = v>>1;
        if(nsg->seq[uId].del) continue;
        if(is_primary_check && nsg->seq[uId].c==ALTER_LABLE) continue;
        nsu = &(ug->u.a[uId]);
        if(nsu->m == 0) continue;
        if(nsu->circ || nsu->start == UINT32_MAX || nsu->end == UINT32_MAX) continue;
        if(get_real_length(nsg, v, NULL) != 0) continue;
        ///we probably don't need this line
        ///if(get_real_length(nsg, v^1, 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++)
        {
            ///h is the edge of endRid
            h = &(x->buffer[k]);
            ///means we found a contained read
            if(get_contained_reads_chain(h, sources, coverage_cut, ruIndex, ug, r_g, 
            max_hang, min_ovlp, endRid, uId, &chain_buffer, NULL, &ava_cur, &test_oLen, 
            &ava_chainLen, chainLenThres, 1))
            {
                is_update = 0;
                if(ava_chainLen < ava_min_chain)
                {
                    is_update = 1;
                }
                else if(ava_chainLen == ava_min_chain)
                {
                    if(ava_cur > ava_max)
                    {
                        is_update = 1;
                    }
                    else if(ava_cur == ava_max && 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)
        {
            //get all edges between contained reads
            get_contained_reads_chain(h_max, sources, coverage_cut, ruIndex, ug, r_g, 
            max_hang, min_ovlp, endRid, uId, &chain_buffer, &chain_edges, &ava_cur, &test_oLen, 
            &ava_chainLen, 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(ug, r_g, sources, coverage_cut, ruIndex, 
                    max_hang, min_ovlp, t_max.v, chain_buffer.a.a, chain_buffer.a.n, &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(ug, ruIndex, rbub_edges.a, rbub_edges.n);
            if(is_primary_check)
            {
                max_oLen = 0; max_oLen_i = (uint32_t)-1;
                for (k = 0; k < rbub_edges.n; k++)
                {
                    t = rbub_edges.a[k];
                    if(t.del) continue;
                    if(t.ol > max_oLen)
                    {
                        max_oLen = t.ol;
                        max_oLen_i = k;
                    }
                }

                if(max_oLen_i == (uint32_t)-1) continue;
                t = rbub_edges.a[max_oLen_i];
                w = get_corresponding_uId(ug, ruIndex, t.v);
                if(w == ((uint32_t)(-1))) continue;
                if(get_real_length(nsg, w^1, NULL)!=0) continue;
            }
            
            //recover all contained reads
            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);


                //(t_max.ul>>32)----->(t_max.v/r_edge.ul>>32)----->r_edge.v
                //need to recover (t_max.v/r_edge.ul>>32), 1. set .del = 0 2. set ruIndex
                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;
                //add recover to the end of the unitig
                append_rId_to_Unitig(r_g, ug, v, t_max.v, sources, coverage_cut, ruIndex, max_hang, 
                min_ovlp);

                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);
            }

            if(is_primary_check)
            {
                t = rbub_edges.a[max_oLen_i];
                w = get_corresponding_uId(ug, ruIndex, t.v);
                if(w == ((uint32_t)(-1))) continue;
                kv_push(asg_arc_t, new_edges, t);
                oLen = t.ol;
                asg_append_edges_to_srt(nsg, v, ug->u.a[v>>1].len, w, oLen, t.strong, t.el, t.no_l_indel);

                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);
                oLen = t.ol;
                asg_append_edges_to_srt(nsg, w^1, ug->u.a[w>>1].len, v^1, oLen, t.strong, t.el, t.no_l_indel);
            }
            else
            {
                for (k = 0; k < rbub_edges.n; k++)
                {
                    t = rbub_edges.a[k];
                    if(t.del) continue;
                    w = get_corresponding_uId(ug, ruIndex, t.v);
                    if(w == ((uint32_t)(-1))) continue;
            
                    kv_push(asg_arc_t, new_edges, t);
                    oLen = t.ol;
                    asg_append_edges_to_srt(nsg, v, ug->u.a[v>>1].len, w, oLen, t.strong, t.el, t.no_l_indel);


                    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);
                    oLen = t.ol;
                    asg_append_edges_to_srt(nsg, w^1, ug->u.a[w>>1].len, v^1, oLen, t.strong, t.el, t.no_l_indel);
                }
            }
            
        }
    }

    asg_arc_t* p = NULL;
    if(is_bubble_check)
    {
        
        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);
        }
        
        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);


        // w=max_contain_rId; w=w<<32; w=w|(t_max.v>>1);
        // kv_push(uint64_t, u_vecs.a, w);
        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) continue;
            if(!r_g->seq[w>>1].del && get_real_length(r_g, (w^1), NULL)!=0) continue;
            w=w>>1;
            r_g->seq[w].del = 1;
            coverage_cut[w].del = 1;
            set_R_to_U(ruIndex, ((uint32_t)(u_vecs.a.a[k])), (u_vecs.a.a[k]>>32), 0, NULL);
        }
    }

    ///actually we don't update sources
    ///during the the primary_check, we need to recover everything for r_g, coverage_cut and ruIndex
    if(is_primary_check)
    {
        ///don't remove nodes and edges
        /**
        for (k = 0; k < u_vecs.a.n; k++)
        {
            w = (uint32_t)u_vecs.a.a[k];
            r_g->seq[w].del = 1;
            coverage_cut[w].del = 1;
            set_R_to_U(ruIndex, ((uint32_t)(u_vecs.a.a[k])), (u_vecs.a.a[k]>>32), 0);
        }
        **/
       if(new_rtg_nodes)
       {
           for(k = 0; k < u_vecs.a.n; k++)
           {
                w = (uint32_t)u_vecs.a.a[k];
                kv_push(uint32_t, new_rtg_nodes->a, w);
           }
       }

       
        for (k = 0; k < new_edges.n; k++)
        {
            p = asg_arc_pushp(r_g);
            *p = new_edges.a[k];
            if(new_rtg_edges) kv_push(asg_arc_t, new_rtg_edges->a, 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);
        }
    }


    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;
    }


    if(i_ug == NULL) ma_ug_destroy(ug);
    kv_destroy(new_edges);
    kv_destroy(rbub_edges);
    kv_destroy(u_vecs.a);
    kv_destroy(chain_buffer.a);
    kv_destroy(chain_edges.a);
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %r9, 0x90(%rsp)
movq %r8, %r12
movq %rcx, 0x80(%rsp)
movq %rdx, 0x70(%rsp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x20(%rsp)
orl $-0x1, 0x28(%rsp)
movq %rsi, %r13
andq $0x0, 0x130(%rsp)
andq $0x0, 0x100(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0xf0(%rsp)
testq %rdi, %rdi
movq %rdi, 0x110(%rsp)
je 0x9b18b
movq 0x18(%rdi), %rax
movq %rax, 0x10(%rsp)
movq %rdi, 0x18(%rsp)
jmp 0x9b1bf
movq %r13, %rdi
callq 0x76d91
movq %rax, 0x18(%rsp)
movq 0x18(%rax), %rdx
xorl %eax, %eax
movl 0x14(%rdx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
jae 0x9b1ba
movq 0x20(%rdx), %rcx
movb $0x0, 0x4(%rcx,%rax,8)
incq %rax
jmp 0x9b19e
movq %rdx, 0x10(%rsp)
xorl %r14d, %r14d
pushq $0x1
popq %rbp
movq 0x10(%rsp), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %r14
jae 0x9b24f
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rbx
imulq $0x28, %r14, %rax
cmpl $0x0, 0xc(%rbx,%rax)
je 0x9b20e
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %rcx
cmpl $0x0, (%rcx,%r14,8)
js 0x9b20e
cmpl $0x0, 0x1a8(%rsp)
je 0x9b213
cmpb $0x1, 0x4(%rcx,%r14,8)
jne 0x9b213
incq %r14
jmp 0x9b1c5
addq %rax, %rbx
xorl %r15d, %r15d
movl %r15d, (%rsp)
movl 0x10(%rbx), %eax
cmpq %rax, %r15
jae 0x9b20e
movq 0x18(%rbx), %rax
movq (%rax,%r15,8), %rsi
shrq $0x21, %rsi
movq 0x20(%r13), %rax
leaq (%rax,%rsi,8), %r8
addq $0x4, %r8
movq %r12, %rdi
movl %r14d, %edx
movl %ebp, %ecx
callq 0x6ab56
incq %r15
jmp 0x9b219
movq %r12, 0x40(%rsp)
addl %ecx, %ecx
xorl %edi, %edi
pushq $-0x1
popq %rax
movl %eax, 0xa4(%rsp)
movq $0x0, 0x60(%rsp)
movq $0x0, 0x50(%rsp)
xorl %r15d, %r15d
movq $0x0, 0xe8(%rsp)
xorl %esi, %esi
movq $0x0, 0x98(%rsp)
movq $0x0, 0xd8(%rsp)
movq $0x0, 0xb8(%rsp)
movq %r13, 0xb0(%rsp)
movq 0x1b0(%rsp), %r12
movq 0x10(%rsp), %rbp
movq %rcx, 0x48(%rsp)
movq %rbp, 0x10(%rsp)
cmpl %ecx, %esi
movq %rdi, 0x8(%rsp)
je 0x9be9e
movl %esi, %r14d
shrl %r14d
movq 0x20(%rbp), %rax
cmpl $0x0, (%rax,%r14,8)
js 0x9b69d
cmpl $0x0, 0x1a8(%rsp)
je 0x9b300
cmpb $0x1, 0x4(%rax,%r14,8)
je 0x9b69d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rbx
imulq $0x28, %r14, %rax
cmpl $0x0, 0xc(%rbx,%rax)
je 0x9b69d
addq %rax, %rbx
cmpl $0x0, (%rbx)
js 0x9b69d
cmpl $-0x1, 0x4(%rbx)
je 0x9b69d
cmpl $-0x1, 0x8(%rbx)
je 0x9b69d
movq %rax, 0xd0(%rsp)
movq %rbp, %rdi
movl %esi, %ebp
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
je 0x9b366
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rcx
movl %ebp, %esi
movq 0x10(%rsp), %rbp
jmp 0x9b69d
movq %r15, 0x58(%rsp)
leaq 0x4(%rbx), %rax
addq $0x8, %rbx
movl %ebp, 0x4(%rsp)
testb $0x1, %bpl
cmovneq %rax, %rbx
movl (%rbx), %eax
movl %eax, %ecx
xorl $0x1, %ecx
movq %rcx, 0x78(%rsp)
shrl %eax
imulq $0x18, %rax, %rbp
addq 0x70(%rsp), %rbp
xorl %edx, %edx
movl $0x0, 0x68(%rsp)
xorl %ebx, %ebx
pushq $-0x1
popq %r12
xorl %r15d, %r15d
movl %edx, (%rsp)
cmpl 0xc(%rbp), %edx
jae 0x9b499
movl %edx, %eax
movq %r13, %r9
imulq $0x28, %rax, %r13
addq (%rbp), %r13
subq $0x8, %rsp
movq %r13, %rdi
movq 0x78(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x20(%rsp), %r8
pushq $0x1
movl 0x1a8(%rsp), %eax
pushq %rax
leaq 0xdc(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
leaq 0xd4(%rsp), %rax
pushq %rax
pushq $0x0
leaq 0x158(%rsp), %rax
pushq %rax
pushq %r14
pushq 0xc0(%rsp)
movl 0x1e0(%rsp), %eax
pushq %rax
pushq 0xe8(%rsp)
callq 0xb5935
addq $0x60, %rsp
testl %eax, %eax
je 0x9b477
movl 0xc4(%rsp), %eax
cmpl %r12d, %eax
jae 0x9b455
movl 0xac(%rsp), %ecx
movl %ecx, 0x68(%rsp)
movl 0xa8(%rsp), %ecx
jmp 0x9b47f
jne 0x9b477
movl 0xac(%rsp), %edx
movl 0xa8(%rsp), %ecx
cmpl 0x68(%rsp), %edx
jbe 0x9b471
movl %edx, 0x68(%rsp)
jmp 0x9b47f
jne 0x9b477
cmpl %ebx, %ecx
ja 0x9b47f
movl %ebx, %ecx
movl %r12d, %eax
movq %r15, %r13
movl (%rsp), %edx
incl %edx
movl %ecx, %ebx
movl %eax, %r12d
movq %r13, %r15
movq 0xb0(%rsp), %r13
jmp 0x9b3a9
cmpl $0x0, 0x68(%rsp)
je 0x9b67d
subq $0x8, %rsp
movq %r15, %rdi
movq 0x78(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x20(%rsp), %r8
movq %r13, %r9
pushq $0x1
movl 0x1a8(%rsp), %eax
pushq %rax
leaq 0xdc(%rsp), %rax
pushq %rax
leaq 0xc8(%rsp), %rax
pushq %rax
leaq 0xd4(%rsp), %rax
pushq %rax
leaq 0x120(%rsp), %rax
pushq %rax
leaq 0x158(%rsp), %rax
pushq %rax
pushq %r14
pushq 0xc0(%rsp)
movl 0x1e0(%rsp), %eax
pushq %rax
pushq 0xe8(%rsp)
callq 0xb5935
addq $0x60, %rsp
movq 0xf0(%rsp), %rax
testq %rax, %rax
movq 0x1b0(%rsp), %r12
je 0x9b685
movq 0x100(%rsp), %rcx
imulq $0x18, %rax, %rax
movl -0x10(%rcx,%rax), %ebx
andl $0x0, (%rsp)
xorl %r14d, %r14d
xorl %ebp, %ebp
movq 0x58(%rsp), %r15
movl 0x120(%rsp), %eax
subq $0x8, %rsp
movq 0x20(%rsp), %rdi
movq %r13, %rsi
movq 0x78(%rsp), %rdx
movq 0x88(%rsp), %rcx
movq 0x48(%rsp), %r8
movq 0x98(%rsp), %r9
pushq $0x1
leaq 0x150(%rsp), %r10
pushq %r10
leaq 0x18(%rsp), %r10
pushq %r10
pushq %rax
pushq 0x158(%rsp)
pushq %rbx
movl 0x1c8(%rsp), %eax
pushq %rax
callq 0xc47e9
addq $0x40, %rsp
testl %eax, %eax
je 0x9b60a
movq 0xe8(%rsp), %rax
cmpq %rax, %rbp
jne 0x9b5e4
movq %r15, %rdi
leaq (%rax,%rax), %r15
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r15
imulq $0x18, %r15, %rsi
callq 0x2370
movq %r15, 0xe8(%rsp)
movq %rax, %r15
incq %rbp
movq 0x150(%rsp), %rax
movq %rax, 0x10(%r15,%r14)
movups 0x140(%rsp), %xmm0
movups %xmm0, (%r15,%r14)
addq $0x18, %r14
jmp 0x9b554
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xb5486
cmpl $0x0, 0x1a8(%rsp)
je 0x9b703
xorl %eax, %eax
xorl %ecx, %ecx
pushq $-0x1
popq %r9
movq 0x10(%rsp), %rbx
movl %eax, %edx
cmpq %rdx, %rbp
jbe 0x9b6a4
imulq $0x18, %rdx, %rdx
movups (%r15,%rdx), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x10(%r15,%rdx), %rdx
movq %rdx, 0x30(%rsp)
movl 0x2c(%rsp), %edx
testl %edx, %edx
setns %dil
cmpl %ecx, %edx
seta %r8b
movl %eax, %esi
testb %r8b, %dil
jne 0x9b674
movl %ecx, %edx
movl %r9d, %esi
incl %eax
movl %edx, %ecx
movl %esi, %r9d
jmp 0x9b639
movq 0x1b0(%rsp), %r12
movq 0x58(%rsp), %r15
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rbp
movq 0x48(%rsp), %rcx
movl 0x4(%rsp), %esi
incl %esi
jmp 0x9b2c8
movl %eax, (%rsp)
cmpl $-0x1, %r9d
je 0x9bb76
movl %r9d, 0xa4(%rsp)
movl %r9d, %eax
imulq $0x18, %rax, %rax
movups (%r15,%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x10(%r15,%rax), %rax
movq %rax, 0x30(%rsp)
movl 0x28(%rsp), %edx
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xb542c
cmpl $-0x1, %eax
je 0x9bb80
xorl $0x1, %eax
movq %rbx, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
jne 0x9b68a
movq 0x50(%rsp), %rdx
imulq $0x18, %rdx, %rax
movq %rax, 0x78(%rsp)
leaq 0x2(,%rdx,2), %rbx
movq 0xb8(%rsp), %rax
leaq (,%rax,8), %rax
movq %rax, 0x118(%rsp)
xorl %r14d, %r14d
xorl %eax, %eax
movq %r15, 0x58(%rsp)
movq 0x8(%rsp), %rdi
movq %rbp, 0xc8(%rsp)
movq %rdx, 0x50(%rsp)
leaq (%rdx,%r14), %rcx
movq %rcx, 0x88(%rsp)
movl %eax, (%rsp)
movl %eax, %ecx
cmpq %rcx, 0xf0(%rsp)
movq %r14, 0x68(%rsp)
jbe 0x9ba11
movq %rbx, 0xe0(%rsp)
movq 0x100(%rsp), %rax
imulq $0x18, %rcx, %rcx
movl 0x8(%rax,%rcx), %r15d
movl %r15d, %ebx
shrl %ebx
movabsq $-0x100000000, %r12     # imm = 0xFFFFFFFF00000000
movq 0x40(%rsp), %rdx
cmpq %rbx, (%rdx)
jbe 0x9b7c4
movq 0x40(%rsp), %rdx
movq 0x8(%rdx), %rdx
movl (%rdx,%rbx,4), %edx
movl %edx, %r12d
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
cmpl $-0x1, %edx
cmovel %edx, %r12d
shlq $0x20, %r12
movq %rdi, 0x8(%rsp)
movq (%rax,%rcx), %r13
movq 0xd8(%rsp), %rax
cmpq %rax, 0xb8(%rsp)
jne 0x9b80c
leaq (%rax,%rax), %rbp
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rbp
leaq (,%rbp,8), %rsi
movq 0x98(%rsp), %rdi
callq 0x2370
movq %rbp, 0xd8(%rsp)
jmp 0x9b814
movq 0x98(%rsp), %rax
movl 0x4(%rsp), %edx
orq %rbx, %r12
movq %rax, 0x98(%rsp)
movq 0x118(%rsp), %rcx
addq %rcx, %rax
movq %r12, (%rax,%r14,4)
movq 0xb0(%rsp), %rdi
movq 0x20(%rdi), %rax
andl $0x7fffffff, (%rax,%rbx,8) # imm = 0x7FFFFFFF
imulq $0xc, %rbx, %rax
movq 0x80(%rsp), %rbx
andb $0x7f, 0x3(%rbx,%rax)
movb $0x0, 0x8(%rbx,%rax)
subq $0x8, %rsp
movq 0x20(%rsp), %rsi
movl %r15d, %ecx
movq 0x78(%rsp), %rbp
movq %rbp, %r8
movq %rbx, %r9
movl 0x198(%rsp), %eax
pushq %rax
movq 0xa0(%rsp), %r14
pushq %r14
movq 0x58(%rsp), %r12
pushq %r12
callq 0xb4dd7
addq $0x20, %rsp
shrq $0x20, %r13
movq %rbp, %rdi
movq %rbx, %rsi
movl %r14d, %ecx
movl 0x190(%rsp), %r8d
movl %r13d, %r9d
leaq 0x20(%rsp), %rax
pushq %rax
pushq %r15
callq 0x79204
popq %rcx
popq %rdx
movq 0x60(%rsp), %rax
cmpq %rax, 0x88(%rsp)
jne 0x9b8f0
leaq (%rax,%rax), %rbx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rbx
imulq $0x18, %rbx, %rsi
movq 0x8(%rsp), %rdi
callq 0x2370
movq %rax, %r14
movq 0x50(%rsp), %rcx
jmp 0x9b8fd
movq 0x8(%rsp), %r14
movq 0x50(%rsp), %rcx
movq %rax, %rbx
movq 0x68(%rsp), %rax
leaq (%rcx,%rax), %rbp
incq %rbp
movq 0x30(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rax, 0x10(%r14,%rcx)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r14,%rcx)
xorl $0x1, %r15d
xorl $0x1, %r13d
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x90(%rsp), %rcx
movl 0x190(%rsp), %r8d
movl %r15d, %r9d
leaq 0x20(%rsp), %rax
pushq %rax
pushq %r13
callq 0x79204
popq %rcx
popq %rdx
cmpq %rbx, %rbp
jne 0x9b99e
testq %rbp, %rbp
movq 0xe0(%rsp), %rbx
movq %rbx, %rcx
pushq $0x2
popq %rax
cmoveq %rax, %rcx
movq %rcx, 0x60(%rsp)
imulq $0x18, %rcx, %rsi
movq %r14, %rdi
callq 0x2370
movq %rax, %rdi
movq 0xb0(%rsp), %r13
movq 0x58(%rsp), %r15
movq 0xc8(%rsp), %rbp
jmp 0x9b9c3
movq %rbx, 0x60(%rsp)
movq 0xb0(%rsp), %r13
movq 0x58(%rsp), %r15
movq %r14, %rdi
movq 0xc8(%rsp), %rbp
movq 0xe0(%rsp), %rbx
movq 0x30(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rax, 0x28(%rdi,%rcx)
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x18(%rdi,%rcx)
movl (%rsp), %eax
incl %eax
movq 0x68(%rsp), %r14
addq $0x2, %r14
addq $0x30, %rcx
movq %rcx, 0x78(%rsp)
addq $0x4, %rbx
incq 0xb8(%rsp)
movq 0x1b0(%rsp), %r12
movq 0x50(%rsp), %rdx
jmp 0x9b74d
cmpl $0x0, 0x1a8(%rsp)
je 0x9bb96
movq %rdx, %rbp
movq %rdi, %rbx
movl 0xa4(%rsp), %eax
imulq $0x18, %rax, %rax
movups (%r15,%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x10(%r15,%rax), %rax
movq %rax, 0x30(%rsp)
movl 0x28(%rsp), %edx
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xb542c
cmpl $-0x1, %eax
je 0x9bdd7
movl %eax, %r15d
movq 0x60(%rsp), %r14
cmpq %r14, 0x88(%rsp)
movq %rbx, %r12
jne 0x9ba95
leaq (%r14,%r14), %rbx
testq %r14, %r14
pushq $0x2
popq %rax
cmoveq %rax, %rbx
imulq $0x18, %rbx, %rsi
movq %r12, %rdi
callq 0x2370
movq %rax, %r12
movq %rbx, %r14
movq %rbp, %rbx
subq %r14, %rbx
addq 0x68(%rsp), %rbx
movq 0x30(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rax, 0x10(%r12,%rcx)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r12,%rcx)
movl 0x2c(%rsp), %r8d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %r8d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xd0(%rsp), %rdx
movl (%rax,%rdx), %edx
andl %ecx, %edx
movzwl 0x30(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x32(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
movl %r15d, %ecx
pushq %rax
pushq %r10
callq 0xac072
popq %rcx
popq %rdx
movl 0x24(%rsp), %eax
movl 0x28(%rsp), %r9d
xorl $0x1, %r9d
xorl $0x1, %eax
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x90(%rsp), %rcx
movl 0x190(%rsp), %r8d
leaq 0x20(%rsp), %rdx
pushq %rdx
pushq %rax
callq 0x79204
popq %rcx
popq %rdx
incq %rbx
jne 0x9bdf1
leaq (%r14,%r14), %rbx
testq %r14, %r14
pushq $0x2
popq %rax
cmoveq %rax, %rbx
imulq $0x18, %rbx, %rsi
movq %r12, %rdi
callq 0x2370
movq %rax, %r14
movq %rbx, 0x60(%rsp)
jmp 0x9bdf9
pushq $-0x1
popq %rax
movl %eax, 0xa4(%rsp)
movq 0x8(%rsp), %rdi
movq 0x48(%rsp), %rcx
movl 0x4(%rsp), %esi
movq %rbx, %rbp
jmp 0x9b69d
movl 0x4(%rsp), %esi
movl %esi, %eax
xorl $0x1, %eax
movl %eax, 0x8(%rsp)
xorl %ebx, %ebx
movq 0x48(%rsp), %rcx
movl %ebx, (%rsp)
movl %ebx, %eax
cmpq %rax, %rbp
jbe 0x9bdc5
imulq $0x18, %rax, %rax
movups (%r15,%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x10(%r15,%rax), %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x2c(%rsp)
js 0x9bdbe
movq %rdi, %r14
movl 0x28(%rsp), %edx
movq 0x18(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0xb542c
cmpl $-0x1, %eax
je 0x9bd0b
movl %eax, %r15d
movq 0x60(%rsp), %rbp
cmpq %rbp, 0x88(%rsp)
jne 0x9bc30
leaq (,%rbp,2), %rbx
testq %rbp, %rbp
pushq $0x2
popq %rax
cmoveq %rax, %rbx
imulq $0x18, %rbx, %rsi
movq %r14, %rdi
callq 0x2370
movq %rax, %r14
movq %rbx, %rbp
movq 0x88(%rsp), %rax
leaq 0x1(%rax), %rbx
imulq $0x18, %rax, %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%r14,%rax)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r14,%rax)
movl 0x2c(%rsp), %r8d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %r8d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xd0(%rsp), %rdx
movl (%rax,%rdx), %edx
andl %ecx, %edx
movzwl 0x30(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x32(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
movl %r15d, %ecx
pushq %rax
pushq %r10
callq 0xac072
popq %rcx
popq %rdx
movl 0x24(%rsp), %eax
movl 0x28(%rsp), %r9d
xorl $0x1, %r9d
xorl $0x1, %eax
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x90(%rsp), %rcx
movl 0x190(%rsp), %r8d
leaq 0x20(%rsp), %rdx
pushq %rdx
pushq %rax
callq 0x79204
popq %rcx
popq %rdx
cmpq %rbp, %rbx
jne 0x9bd21
movq %r14, %rdi
leaq (,%rbp,2), %r14
testq %rbp, %rbp
pushq $0x2
popq %rax
cmoveq %rax, %r14
imulq $0x18, %r14, %rsi
callq 0x2370
movq %r14, 0x60(%rsp)
jmp 0x9bd29
movq 0x58(%rsp), %r15
movq %r14, %rdi
movq 0x48(%rsp), %rcx
movl 0x4(%rsp), %esi
jmp 0x9bdbe
movq %rbp, 0x60(%rsp)
movq %r14, %rax
addq $0x2, 0x88(%rsp)
imulq $0x18, %rbx, %rdx
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rax,%rdx)
movq %rax, %rbx
movl 0x2c(%rsp), %r8d
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %r8d
movl %r15d, %esi
xorl $0x1, %esi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
shrl %r15d
imulq $0x28, %r15, %rcx
movl (%rax,%rcx), %edx
andl %edi, %edx
movzwl 0x30(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x32(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x10(%rsp), %rdi
movl 0x8(%rsp), %ecx
pushq %rax
pushq %r10
callq 0xac072
movq %rbx, %rdi
addq $0x10, %rsp
movl (%rsp), %ebx
movq 0x58(%rsp), %r15
movq 0x48(%rsp), %rcx
movl 0x4(%rsp), %esi
movq 0xc8(%rsp), %rbp
incl %ebx
jmp 0x9bbaa
movq 0x88(%rsp), %rax
movq %rax, 0x50(%rsp)
jmp 0x9b35c
movq 0x88(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %r15
movq %rbx, %rdi
jmp 0x9b68f
movq %r14, 0x60(%rsp)
movq %r12, %r14
movq 0x68(%rsp), %rax
addq %rax, %rbp
addq $0x2, %rbp
movq %rbp, 0x50(%rsp)
movq 0x30(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rax, 0x28(%r14,%rcx)
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0x18(%r14,%rcx)
movl 0x2c(%rsp), %r8d
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %r8d
movl %r15d, %esi
xorl $0x1, %esi
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
shrl %r15d
imulq $0x28, %r15, %rcx
movl (%rax,%rcx), %edx
andl %edi, %edx
movl 0x4(%rsp), %ebx
movl %ebx, %ecx
xorl $0x1, %ecx
movzwl 0x30(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x32(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x10(%rsp), %rbp
movq %rbp, %rdi
pushq %rax
pushq %r10
callq 0xac072
movl %ebx, %esi
movq %r14, %rdi
addq $0x10, %rsp
movq 0x58(%rsp), %r15
movq 0x48(%rsp), %rcx
movq 0x1b0(%rsp), %r12
jmp 0x9b69d
movq %r15, %r14
cmpl $0x0, 0x1a0(%rsp)
movq 0x50(%rsp), %rbp
je 0x9c094
xorl %eax, %eax
movl %eax, (%rsp)
movl %eax, %eax
cmpq %rax, %rbp
jbe 0x9bee9
movq %r13, %rdi
callq 0x6c45d
movl (%rsp), %ecx
imulq $0x18, %rcx, %rdx
movq 0x8(%rsp), %rdi
movq 0x10(%rdi,%rdx), %rsi
movq %rsi, 0x10(%rax)
movups (%rdi,%rdx), %xmm0
movups %xmm0, (%rax)
leal 0x1(%rcx), %eax
jmp 0x9beb6
testq %rbp, %rbp
je 0x9bf09
movq 0x28(%r13), %rdi
callq 0x2220
andq $0x0, 0x28(%r13)
andb $0x7f, 0x7(%r13)
movq %r13, %rdi
callq 0x694eb
xorl %ebx, %ebx
movq 0x70(%rsp), %rdi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0xb4c38
movq %r13, %rdi
movq 0x1c0(%rsp), %rsi
callq 0xb5068
pushq $0x1
popq %rbp
movq 0x8(%rsp), %rsi
movl %ebx, (%rsp)
movl %ebx, %eax
cmpq %rax, 0x50(%rsp)
jbe 0x9bfc6
imulq $0x18, %rax, %rcx
movq (%rsi,%rcx), %r15
movq 0x20(%r13), %rax
movq %r15, %rdx
shrq $0x21, %rdx
cmpl $0x0, (%rax,%rdx,8)
js 0x9bfb7
movl 0x8(%rsi,%rcx), %edx
movl %edx, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x9bfb7
shrq $0x20, %r15
movq 0x30(%r13), %rax
movq %rdx, %r13
xorq $0x1, %r13
cmpb $0x0, (%rax,%r15)
je 0x9bf86
cmpb $0x0, (%rax,%r13)
jne 0x9bfb7
movq 0xb0(%rsp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
movl %ebp, %ecx
callq 0x6db50
xorl $0x1, %r15d
movq %rbx, %rdi
movl %r13d, %esi
movl %r15d, %edx
movl %ebp, %ecx
callq 0x6db50
movq 0x8(%rsp), %rsi
movl (%rsp), %ebx
incl %ebx
movq 0xb0(%rsp), %r13
jmp 0x9bf32
movq %r13, %rdi
callq 0x694eb
xorl %eax, %eax
movq 0x1b0(%rsp), %r12
movq 0x50(%rsp), %rbp
movl %eax, (%rsp)
movl %eax, %eax
cmpq %rax, 0xb8(%rsp)
jbe 0x9c094
movq 0x98(%rsp), %rcx
movq (%rcx,%rax,8), %r15
movq 0x20(%r13), %rax
movl %r15d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl (%rax,%rbx,8), %ecx
testl %ecx, %ecx
js 0x9c04b
addl %r15d, %r15d
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
jne 0x9c08a
movq 0x20(%r13), %rax
movl (%rax,%rbx,8), %ecx
testl %ecx, %ecx
js 0x9c04b
orl $0x1, %r15d
movq %r13, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0xc2e7a
testl %eax, %eax
jne 0x9c08a
movq 0x20(%r13), %rax
movl (%rax,%rbx,8), %ecx
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, (%rax,%rbx,8)
imulq $0xc, %rbx, %rax
movq 0x80(%rsp), %rcx
orb $-0x80, 0x3(%rcx,%rax)
movl (%rsp), %eax
movq 0x98(%rsp), %rcx
movq (%rcx,%rax,8), %rsi
movq %rsi, %rdx
shrq $0x20, %rdx
movq 0x40(%rsp), %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x6ab56
movl (%rsp), %eax
incl %eax
jmp 0x9bfdd
cmpl $0x0, 0x1a8(%rsp)
movq %r14, %r15
movq 0x8(%rsp), %rdi
je 0x9c1e2
movq 0x1b8(%rsp), %r14
testq %r14, %r14
je 0x9c11b
xorl %eax, %eax
movl %eax, (%rsp)
movl %eax, %eax
cmpq %rax, 0xb8(%rsp)
jbe 0x9c11b
movq 0x98(%rsp), %rcx
movl (%rcx,%rax,8), %ebx
movq (%r14), %rcx
movq 0x10(%r14), %rax
cmpq 0x8(%r14), %rcx
jne 0x9c10a
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x8(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%r14)
movq (%r14), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movl %ebx, (%rax,%rcx,4)
movl (%rsp), %eax
incl %eax
jmp 0x9c0b9
xorl %ecx, %ecx
movl %ecx, (%rsp)
movl %ecx, %eax
cmpq %rax, %rbp
jbe 0x9c1bd
movq %r13, %rdi
callq 0x6c45d
movq 0x8(%rsp), %rdi
movl (%rsp), %ecx
imulq $0x18, %rcx, %rdx
movups (%rdi,%rdx), %xmm0
movups %xmm0, (%rax)
movq 0x10(%rdi,%rdx), %rdx
movq %rdx, 0x10(%rax)
testq %r12, %r12
je 0x9c1b6
movq (%r12), %rdx
movq 0x10(%r12), %rax
cmpq 0x8(%r12), %rdx
jne 0x9c194
leaq (%rdx,%rdx), %rcx
testq %rdx, %rdx
pushq $0x2
popq %rdx
cmoveq %rdx, %rcx
movq %rcx, 0x8(%r12)
imulq $0x18, %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%r12)
movl (%rsp), %ecx
movq (%r12), %rdx
imulq $0x18, %rcx, %rsi
leaq 0x1(%rdx), %r8
movq %r8, (%r12)
imulq $0x18, %rdx, %rdx
movq 0x10(%rdi,%rsi), %r8
movq %r8, 0x10(%rax,%rdx)
movups (%rdi,%rsi), %xmm0
movups %xmm0, (%rax,%rdx)
incl %ecx
jmp 0x9c11d
testq %rbp, %rbp
je 0x9c1e2
movq 0x28(%r13), %rdi
callq 0x2220
andq $0x0, 0x28(%r13)
andb $0x7f, 0x7(%r13)
movq %r13, %rdi
callq 0x694eb
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq (%rsi), %rax
xorl %ecx, %ecx
movq 0x98(%rsp), %rbx
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x9c20d
movq 0x8(%rsi), %rdx
cmpl $-0x2, (%rdx,%rcx,4)
jg 0x9c209
orl $-0x1, (%rdx,%rcx,4)
incl %ecx
jmp 0x9c1f4
cmpq $0x0, 0x110(%rsp)
jne 0x9c227
movq 0x18(%rsp), %rdi
callq 0x6921d
movq 0x8(%rsp), %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq 0x130(%rsp), %rdi
callq 0x2220
movq 0x100(%rsp), %rdi
callq 0x2220
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq