// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rescue_wrong_overlaps_to_unitigs(ma_ug_t*, asg_t*, ma_hit_t_alloc*, ma_hit_t_alloc*, ma_sub_t*, R_to_U*, int, int, long long, kvec_asg_arc_t_warp*, bub_label_t*)
void rescue_wrong_overlaps_to_unitigs(ma_ug_t *i_ug, asg_t *r_g,  ma_hit_t_alloc* sources, ma_hit_t_alloc* reverse_sources, 
ma_sub_t *coverage_cut, R_to_U* ruIndex, int max_hang, int min_ovlp, long long bubble_dist,
kvec_asg_arc_t_warp* keep_edges, bub_label_t* b_mask_t)
{
    uint32_t n_vtx, v, k, is_Unitig, uId, rId, endRid, oLen, w;
    asg_t* nsg = NULL;
    ma_utg_t* nsu = NULL;
    ma_ug_t *ug = NULL;
    asg_arc_t t, r_edge;
    ma_hit_t_alloc* x = NULL;
    ma_hit_t *h = NULL;
    ma_sub_t *sq = NULL;
    ma_sub_t *st = NULL;
    int32_t r;

    kvec_t(asg_arc_t) new_utg_edges;
    kv_init(new_utg_edges);

    kvec_t(asg_arc_t) new_rtg_edges;
    kv_init(new_rtg_edges);

    kvec_t(asg_arc_t) rbub_edges;
    kv_init(rbub_edges);

    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;

        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;

        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;
        


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



        /****************************may have bugs********************************/
        x = &(sources[(endRid>>1)]);
        for (k = 0; k < x->length; k++)
        {
            ///h is the edge of endRid
            h = &(x->buffer[k]);
            sq = &(coverage_cut[Get_qn(*h)]);
            st = &(coverage_cut[Get_tn(*h)]);
            ///sq, st, and h cannot be deleted
            if(sq->del || st->del || h->del) continue;
            r = ma_hit2arc(h, sq->e - sq->s, st->e - st->s, max_hang, 
                                            asm_opt.max_hang_rate, min_ovlp, &t);
            if(r < 0) continue;
            if((t.ul>>32) != endRid) continue;
            break;
        }
        ///means there is >0 edges
        if(k != x->length) continue;
        /****************************may have bugs********************************/




        k = 0;
        rbub_edges.n = 0;
        ///note here use reverse_sources instead of sources
        while(get_edge2existing_node_advance(ug, r_g, reverse_sources, coverage_cut, ruIndex, 
                max_hang, min_ovlp, endRid, &uId, 1, &k, &r_edge, 1))
        {
            kv_push(asg_arc_t, rbub_edges, r_edge);
        }


        
        if(rbub_edges.n > 0)
        {
            ///need to do transitive reduction
            ///note here is different to standard transitive reduction
            minor_transitive_reduction(ug, ruIndex, rbub_edges.a, rbub_edges.n);

            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;
                ///if(uId == 2474) fprintf(stderr, "###uId: %u, v: %u, r_edge.v>>1: %u\n", uId, v, r_edge.v>>1);
                kv_push(asg_arc_t, new_rtg_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(reverse_sources, coverage_cut, ruIndex, max_hang, min_ovlp, 
                (t.v^1), ((t.ul>>32)^1), &t);
                kv_push(asg_arc_t, new_rtg_edges, t);
                ///if edge does not exist in reverse, oLen won't change, it is what we want
                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);

                t.ul = v; t.ul = t.ul<<32; t.v = w;
                kv_push(asg_arc_t, new_utg_edges, t);


                t.ul = w^1; t.ul = t.ul<<32; t.v = v^1;
                kv_push(asg_arc_t, new_utg_edges, t);
            }
        }
        
    }


    nsg->seq_vis = (uint8_t*)calloc(nsg->n_seq*2, sizeof(uint8_t));    
    lable_all_bubbles(nsg, b_mask_t);

    /*********************************for debug**************************************/
    // uint32_t v_uId, w_uId;
    // if(new_utg_edges.n != new_rtg_edges.n) fprintf(stderr, "ERROR 1\n");
    // for (k = 0; k < new_utg_edges.n; k++)
    // {
    //     v = new_rtg_edges.a[k].ul>>32;
    //     v_uId = (get_corresponding_uId(ug, ruIndex, v^1)^1);
    //     w = new_rtg_edges.a[k].v;
    //     w_uId = get_corresponding_uId(ug, ruIndex, w);

    //     v = new_utg_edges.a[k].ul>>32;
    //     w = new_utg_edges.a[k].v;

    //     if(v!=v_uId || w!= w_uId)
    //     {
    //         fprintf(stderr, "\n(%u) ERROR 2\n", k);
    //         fprintf(stderr, "v>>1: %u, v&1: %u, ug->u.a[v>>1].n: %u\n", 
    //                                                     v>>1, v&1, ug->u.a[v>>1].n);
    //         fprintf(stderr, "ug->u.a[v>>1].start>>1: %u, ug->u.a[v>>1].start&1: %u\n", 
    //                                         ug->u.a[v>>1].start>>1, ug->u.a[v>>1].start&1);
    //         fprintf(stderr, "ug->u.a[v>>1].end>>1: %u, ug->u.a[v>>1].end&1: %u\n", 
    //                                         ug->u.a[v>>1].end>>1, ug->u.a[v>>1].end&1);
    //         fprintf(stderr, "w>>1: %u, w&1: %u, ug->u.a[w>>1].n: %u\n", 
    //                                                     w>>1, w&1, ug->u.a[w>>1].n);
    //         fprintf(stderr, "ug->u.a[w>>1].start>>1: %u, ug->u.a[w>>1].start&1: %u\n", 
    //                                         ug->u.a[w>>1].start>>1, ug->u.a[w>>1].start&1);
    //         fprintf(stderr, "ug->u.a[w>>1].end>>1: %u, ug->u.a[w>>1].end&1: %u\n", 
    //                                         ug->u.a[w>>1].end>>1, ug->u.a[w>>1].end&1);
    //         fprintf(stderr, "v_uId>>1: %u, v_uId&1: %u\n", v_uId>>1, v_uId&1);
    //         fprintf(stderr, "w_uId>>1: %u, w_uId&1: %u\n", w_uId>>1, w_uId&1);
    //         v = new_rtg_edges.a[k].ul>>32;
    //         w = new_rtg_edges.a[k].v;
    //         get_R_to_U(ruIndex, v>>1, &uId, &is_Unitig);
    //         fprintf(stderr, "v(read)>>1: %u, v(read)&1: %u, uId: %u, is_Unitig: %u\n", 
    //                                     v>>1, v&1, uId, is_Unitig);
    //         get_R_to_U(ruIndex, w>>1, &uId, &is_Unitig);
    //         fprintf(stderr, "w(read)>>1: %u, w(read)&1: %u, uId: %u, is_Unitig: %u\n", 
    //                                     w>>1, w&1, uId, is_Unitig);

            
    //     }
    // }
    /*********************************for debug**************************************/

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

        if(nsg->seq[v>>1].del) continue;
        if(nsg->seq[w>>1].del) continue;
        ///if this edge is at a bubble
        if(nsg->seq_vis[v]!=0 && nsg->seq_vis[w^1]!=0)
        {
            ///fprintf(stderr, "v>>1: %u, w>>1: %u\n", v>>1, w>>1);
            continue;
        } 

        asg_arc_del(nsg, v, w, 1);
        asg_arc_del(nsg, w^1, v^1, 1);
        new_rtg_edges.a[k].del = 1;
    }
    asg_cleanup(nsg);
    free(nsg->seq_vis); nsg->seq_vis = NULL;

    /*********************************for debug**************************************/
    asg_arc_t* p = NULL;
    uint32_t e_occ = 0;
    for (k = 0; k < new_rtg_edges.n; k++)
    {
        if(new_rtg_edges.a[k].del) continue;
        p = asg_arc_pushp(r_g);
        *p = new_rtg_edges.a[k];
        e_occ++;
        if(keep_edges) kv_push(asg_arc_t, keep_edges->a, new_rtg_edges.a[k]);
    }

    if(e_occ != 0)
    {
        free(r_g->idx);
        r_g->idx = 0;
        r_g->is_srt = 0;
        asg_cleanup(r_g);
    }
    /*********************************for debug**************************************/

    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_utg_edges);
    kv_destroy(new_rtg_edges);
    kv_destroy(rbub_edges);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, %rbp
movq %r8, 0x60(%rsp)
movq %rcx, 0x98(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r11
movq %rdi, 0xa8(%rsp)
testq %rdi, %rdi
jne 0xfbc95
movq %r12, %rdi
callq 0xb0285
movq %rax, %r11
movq 0x18(%rax), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
je 0xfbc95
movq 0x20(%rax), %rcx
xorl %edx, %edx
movb $0x0, 0x4(%rcx,%rdx,8)
incq %rdx
movl 0x14(%rax), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
cmpq %rsi, %rdx
jb 0xfbc7f
movq %rbx, 0xb0(%rsp)
movq 0x18(%r11), %r15
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andl 0x14(%r15), %ebx
je 0xfbd3d
xorl %r14d, %r14d
movl %r14d, 0xc(%rsp)
movq %r11, %r13
movq 0x10(%r11), %rax
leaq (%r14,%r14,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xfbd24
movq 0x20(%r15), %rdx
cmpl $0x0, (%rdx,%r14,8)
js 0xfbd24
leaq (%rax,%rcx,8), %rbx
movl $0x0, 0x8(%rsp)
cmpl $0x0, 0x10(%rbx)
je 0xfbd24
xorl %eax, %eax
movq 0x18(%rbx), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rsi
shrq $0x21, %rsi
movl 0xc(%rsp), %edx
movq 0x20(%r12), %rax
leaq (%rax,%rsi,8), %r8
addq $0x4, %r8
movq %rbp, %rdi
movl $0x1, %ecx
callq 0xa1cd4
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl 0x10(%rbx), %eax
jb 0xfbce9
incq %r14
movl 0x14(%r15), %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
cmpq %rbx, %r14
movq %r13, %r11
jb 0xfbcb3
testl %ebx, %ebx
movq %rbp, 0x48(%rsp)
movq %r11, 0x18(%rsp)
je 0xfc459
addl %ebx, %ebx
xorl %r14d, %r14d
movq $0x0, 0xa0(%rsp)
movq $0x0, 0x40(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x78(%rsp)
xorl %r9d, %r9d
movq $0x0, 0x70(%rsp)
movq $0x0, 0x90(%rsp)
xorl %r10d, %r10d
movq %r15, 0x68(%rsp)
movl %r14d, %eax
shrl %eax
movl %eax, 0xc(%rsp)
movq 0x20(%r15), %rcx
cmpl $0x0, (%rcx,%rax,8)
js 0xfc44b
movq 0x10(%r11), %rcx
leaq (%rax,%rax,4), %r13
cmpl $0x0, 0xc(%rcx,%r13,8)
je 0xfc44b
leaq (%rcx,%r13,8), %rax
cmpl $0x0, (%rax)
js 0xfc44b
cmpl $-0x1, 0x4(%rax)
je 0xfc44b
cmpl $-0x1, 0x8(%rax)
je 0xfc44b
movq 0x28(%r15), %rcx
movq (%rcx,%r14,8), %rcx
movq %rcx, %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rdx
je 0xfbe3b
movq 0x8(%r15), %rsi
shrq $0x20, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rsi,%rcx,8), %rcx
addq $0xc, %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rcx,%rsi), %r8d
notl %r8d
shrl $0x1f, %r8d
addl %r8d, %edi
addq $0x18, %rsi
cmpq %rsi, %rdx
jne 0xfbe1c
testl %edi, %edi
jne 0xfc44b
movq %r13, 0xb8(%rsp)
leaq 0x4(%rax), %rcx
addq $0x8, %rax
testb $0x1, %r14b
cmovneq %rcx, %rax
movl (%rax), %eax
movq %rax, %rcx
xorq $0x1, %rcx
movq %rcx, 0x50(%rsp)
shrl %eax
leaq (%rax,%rax,2), %rax
movq 0xb0(%rsp), %rcx
movl 0xc(%rcx,%rax,8), %ebp
movl $0x0, 0x8(%rsp)
testq %rbp, %rbp
movq %r9, 0x38(%rsp)
movq %r10, 0x10(%rsp)
je 0xfbf52
leaq (%rcx,%rax,8), %rax
movq (%rax), %r15
leaq 0x18e8bc(%rip), %rax    # 0x28a758
movss 0x158(%rax), %xmm0
movss %xmm0, 0x80(%rsp)
xorl %r13d, %r13d
movl 0x4(%r15), %eax
leaq (%rax,%rax,2), %rcx
movq 0x60(%rsp), %rax
movl (%rax,%rcx,4), %eax
testl %eax, %eax
js 0xfbf33
movl 0xc(%r15), %edx
leaq (%rdx,%rdx,2), %rdx
movq 0x60(%rsp), %rsi
leaq (%rsi,%rdx,4), %rdx
movl (%rdx), %edi
testl %edi, %edi
js 0xfbf33
cmpq $0x0, 0x18(%r15)
js 0xfbf33
movq 0x60(%rsp), %rsi
leaq (%rsi,%rcx,4), %rcx
movl 0x4(%rcx), %esi
subl %eax, %esi
movl 0x4(%rdx), %edx
subl %edi, %edx
movq %r15, %rdi
movl 0x110(%rsp), %ecx
movss 0x80(%rsp), %xmm0
movl 0x118(%rsp), %r8d
leaq 0x20(%rsp), %r9
callq 0xa159b
movq 0x10(%rsp), %r10
movq 0x38(%rsp), %r9
testl %eax, %eax
js 0xfbf33
movq 0x50(%rsp), %rax
cmpl %eax, 0x24(%rsp)
je 0xfbf4b
incq %r13
movl %r13d, 0x8(%rsp)
addq $0x28, %r15
cmpq %r13, %rbp
jne 0xfbeb0
movl %ebp, %r13d
movq 0x18(%rsp), %r11
jmp 0xfbf55
xorl %r13d, %r13d
cmpl %ebp, %r13d
jne 0xfc09e
movl $0x0, 0x8(%rsp)
subq $0x8, %rsp
movq %r11, %rdi
movq %r12, %rsi
movq 0xa0(%rsp), %rdx
movq 0x68(%rsp), %rcx
movq 0x50(%rsp), %rbp
movq %rbp, %r8
movl 0x118(%rsp), %r9d
movl $0x1, %eax
pushq %rax
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
pushq %rax
leaq 0x34(%rsp), %rax
pushq %rax
pushq 0x80(%rsp)
movl 0x150(%rsp), %eax
pushq %rax
callq 0x102d41
addq $0x40, %rsp
testl %eax, %eax
je 0xfc0a8
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0xa0(%rsp), %rax
cmpq %rax, %r13
movq 0x40(%rsp), %rdi
jne 0xfc014
leaq (%rax,%rax), %rbp
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbp
leaq (,%rbp,8), %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq %rax, %rdi
movq %rbp, 0xa0(%rsp)
movq 0x48(%rsp), %rbp
incq %r13
movq 0xd0(%rsp), %rax
movq %rax, 0x10(%rdi,%r15)
movups 0xc0(%rsp), %xmm0
movq %rdi, 0x40(%rsp)
movups %xmm0, (%rdi,%r15)
subq $0x8, %rsp
movq 0x20(%rsp), %rdi
movq %r12, %rsi
movq 0xa0(%rsp), %rdx
movq 0x68(%rsp), %rcx
movq %rbp, %r8
movl 0x118(%rsp), %r9d
movl $0x1, %eax
pushq %rax
leaq 0xd0(%rsp), %r10
pushq %r10
leaq 0x20(%rsp), %r10
pushq %r10
pushq %rax
leaq 0x34(%rsp), %rax
pushq %rax
pushq 0x80(%rsp)
movl 0x150(%rsp), %eax
pushq %rax
callq 0x102d41
addq $0x40, %rsp
addq $0x18, %r15
testl %eax, %eax
jne 0xfbfd1
jmp 0xfc0ab
movq 0x48(%rsp), %rbp
jmp 0xfc446
xorl %r13d, %r13d
testq %r13, %r13
movq 0x40(%rsp), %rdx
je 0xfc437
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rbp, %rsi
movl %r13d, %ecx
callq 0xf24f6
movq %r15, %r11
movq 0x40(%rsp), %rcx
movl $0x0, 0x8(%rsp)
movl %r14d, %eax
xorl $0x1, %eax
movl %eax, 0x50(%rsp)
movq %r14, %rax
shlq $0x20, %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
movq 0x38(%rsp), %r9
movq 0x10(%rsp), %r10
movq %r12, 0x88(%rsp)
leaq (%rax,%rax,2), %rax
movups (%rcx,%rax,8), %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x10(%rcx,%rax,8), %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x2c(%rsp)
js 0xfc422
movq %r10, 0x10(%rsp)
movq %r9, %r15
movl 0x28(%rsp), %edx
movq %r11, %r12
movq %r11, %rdi
movq %rbp, %rsi
callq 0xf2482
cmpl $-0x1, %eax
je 0xfc18b
movl %eax, %ebp
movq 0x78(%rsp), %rax
cmpq %rax, 0x58(%rsp)
movq %r15, %rdi
jne 0xfc1ad
leaq (%rax,%rax), %r15
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r15
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq %rax, %rdi
movq %r15, 0x78(%rsp)
movq 0x18(%rsp), %r12
jmp 0xfc1b2
movq 0x48(%rsp), %rbp
movq 0x40(%rsp), %rcx
movq %r15, %r9
movq 0x10(%rsp), %r10
movq %r12, %r11
movq 0x88(%rsp), %r12
jmp 0xfc422
movq %rax, 0x78(%rsp)
movq 0x58(%rsp), %rax
leaq 0x1(%rax), %r15
leaq (%rax,%rax,2), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rdi,%rax,8)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%rdi,%rax,8)
movl 0x2c(%rsp), %r8d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %r8d
movq 0x10(%r12), %rax
movq 0xb8(%rsp), %rdx
movl (%rax,%rdx,8), %edx
andl %ecx, %edx
movzwl 0x30(%rsp), %eax
movq %rdi, %r12
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x32(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x68(%rsp), %rdi
movl %r14d, %esi
movl %ebp, %ecx
pushq %rax
pushq %r10
callq 0xe907b
addq $0x10, %rsp
movl 0x24(%rsp), %eax
movl 0x28(%rsp), %r9d
xorl $0x1, %r9d
xorl $0x1, %eax
movq 0x98(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl 0x110(%rsp), %ecx
movl 0x118(%rsp), %r8d
leaq 0x20(%rsp), %rdx
pushq %rdx
pushq %rax
callq 0xb2ced
addq $0x10, %rsp
movq %r15, 0x38(%rsp)
movq 0x78(%rsp), %rax
cmpq %rax, %r15
jne 0xfc299
leaq (%rax,%rax), %r15
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r15
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rsi
movq %r12, %rdi
callq 0x2370
movq %r15, 0x78(%rsp)
jmp 0xfc29c
movq %r12, %rax
movq 0x88(%rsp), %r12
movq 0x38(%rsp), %rcx
leaq (%rcx,%rcx,2), %rdx
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movaps 0x20(%rsp), %xmm0
movq %rax, 0x38(%rsp)
movups %xmm0, (%rax,%rdx,8)
movl 0x2c(%rsp), %r8d
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %r8d
movl %ebp, %r15d
xorl $0x1, %r15d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %rax
movl %ebp, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rcx
movl (%rax,%rcx,8), %edx
andl %esi, %edx
movzwl 0x30(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x32(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x68(%rsp), %rdi
movl %r15d, %esi
movl 0x50(%rsp), %ecx
pushq %rax
pushq %r10
callq 0xe907b
addq $0x10, %rsp
movq 0x80(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %ebp, 0x28(%rsp)
movq 0x90(%rsp), %rdx
cmpq %rdx, 0x70(%rsp)
jne 0xfc36e
leaq (%rdx,%rdx), %rbp
testq %rdx, %rdx
movl $0x2, %eax
cmoveq %rax, %rbp
leaq (,%rbp,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x10(%rsp), %rdi
callq 0x2370
movq %rax, %r10
movq %rbp, %rdx
jmp 0xfc373
movq 0x10(%rsp), %r10
movq 0x70(%rsp), %rax
leaq 0x1(%rax), %rbp
leaq (%rax,%rax,2), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%r10,%rax,8)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r10,%rax,8)
shlq $0x20, %r15
movq %r15, 0x20(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x28(%rsp)
cmpq %rdx, %rbp
jne 0xfc3db
leaq (%rdx,%rdx), %r15
testq %rdx, %rdx
movl $0x2, %eax
cmoveq %rax, %r15
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rsi
movq %r10, %rdi
callq 0x2370
movq %rax, %r10
movq %r15, 0x90(%rsp)
jmp 0xfc3e3
movq %rdx, 0x90(%rsp)
movq 0x18(%rsp), %r11
movq 0x38(%rsp), %r9
addq $0x2, 0x58(%rsp)
addq $0x2, 0x70(%rsp)
leaq (,%rbp,2), %rax
addq %rbp, %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x10(%r10,%rax,8)
movaps 0x20(%rsp), %xmm0
movups %xmm0, (%r10,%rax,8)
movq 0x48(%rsp), %rbp
movq 0x40(%rsp), %rcx
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpq %rax, %r13
ja 0xfc109
jmp 0xfc446
movq 0x18(%rsp), %r11
movq 0x38(%rsp), %r9
movq 0x10(%rsp), %r10
movq 0x68(%rsp), %r15
incq %r14
cmpq %rbx, %r14
jne 0xfbd9b
jmp 0xfc47a
xorl %r10d, %r10d
movq $0x0, 0x70(%rsp)
xorl %r9d, %r9d
movq $0x0, 0x58(%rsp)
movq $0x0, 0x40(%rsp)
movq %r11, %rbx
movq %r10, 0x10(%rsp)
movl 0x14(%r15), %edi
addl %edi, %edi
movl $0x1, %esi
movq %r9, %r14
callq 0x2120
movq %rax, 0x30(%r15)
movq %r15, %rdi
callq 0xa02fa
movq %r15, %rdi
movq 0x130(%rsp), %rsi
xorl %edx, %edx
callq 0xa6dbe
movq 0x10(%rsp), %r10
movl $0x0, 0x8(%rsp)
movq 0x70(%rsp), %r11
testq %r11, %r11
je 0xfc5dd
movq %r14, %r9
xorl %ecx, %ecx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq (%rcx,%rcx,2), %rdx
movq (%r10,%rdx,8), %rcx
movq 0x20(%r15), %rsi
movq %rcx, %rdi
shrq $0x21, %rdi
cmpl $0x0, (%rsi,%rdi,8)
js 0xfc5ca
movl 0x8(%r10,%rdx,8), %edx
movl %edx, %edi
shrl %edi
cmpl $0x0, (%rsi,%rdi,8)
js 0xfc5ca
shrq $0x20, %rcx
movq 0x30(%r15), %rsi
cmpb $0x0, (%rsi,%rcx)
je 0xfc527
movq %rdx, %rdi
xorq $0x1, %rdi
cmpb $0x0, (%rsi,%rdi)
jne 0xfc5ca
movq 0x28(%r15), %rsi
movq (%rsi,%rcx,8), %rdi
movq %rdi, %rsi
andq %rax, %rsi
je 0xfc56c
movq 0x8(%r15), %r8
shrq $0x20, %rdi
shlq $0x3, %rsi
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rdi,2), %rdi
leaq (%r8,%rdi,8), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
cmpl %edx, -0x4(%rdi,%r8)
jne 0xfc563
orb $-0x80, 0x3(%rdi,%r8)
addq $0x18, %r8
cmpq %r8, %rsi
jne 0xfc556
xorl $0x1, %edx
movq 0x28(%r15), %rsi
movq (%rsi,%rdx,8), %rsi
movq %rsi, %rdx
andq %rax, %rdx
je 0xfc5b9
movq 0x8(%r15), %rdi
shrq $0x20, %rsi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rsi,%rsi,2), %rsi
leaq (%rdi,%rsi,8), %rsi
addq $0xc, %rsi
xorl %edi, %edi
movl -0x4(%rsi,%rdi), %r8d
xorl %ecx, %r8d
cmpl $0x1, %r8d
jne 0xfc5b0
orb $-0x80, 0x3(%rsi,%rdi)
addq $0x18, %rdi
cmpq %rdi, %rdx
jne 0xfc59d
movl 0x8(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
orl $0x80000000, 0xc(%r9,%rcx,8) # imm = 0x80000000
movl 0x8(%rsp), %ecx
incl %ecx
movl %ecx, 0x8(%rsp)
cmpq %rcx, %r11
ja 0xfc4d8
movq %r15, %rdi
callq 0xa02fa
movq 0x30(%r15), %rdi
callq 0x2220
movq $0x0, 0x30(%r15)
movl $0x0, 0x8(%rsp)
cmpq $0x0, 0x58(%rsp)
je 0xfc75d
movq %r14, %rdi
movq 0x128(%rsp), %rbx
xorl %eax, %eax
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl $0x10, %r15d
xorl %r13d, %r13d
leaq (%rax,%rax,2), %rax
cmpl $0x0, 0xc(%rdi,%rax,8)
js 0xfc718
movl 0x4(%r12), %ecx
andl %ebp, %ecx
movl (%r12), %eax
cmpl %eax, %ecx
jne 0xfc66a
leal (%rax,%rax), %ecx
testl %eax, %eax
cmovel %r15d, %ecx
movl %ecx, (%r12)
movq 0x8(%r12), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %r14, %rdi
movq %rax, 0x8(%r12)
movl 0x4(%r12), %eax
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leal 0x1(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %edx, %eax
incl %r13d
movq 0x8(%r12), %rdx
movl %eax, 0x4(%r12)
leaq (%rcx,%rcx,2), %rax
movl 0x8(%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
movups (%rdi,%rcx,8), %xmm0
movups %xmm0, (%rdx,%rax,8)
movq 0x10(%rdi,%rcx,8), %rcx
movq %rcx, 0x10(%rdx,%rax,8)
testq %rbx, %rbx
je 0xfc718
movq 0x8(%rbx), %rax
cmpq %rax, (%rbx)
jne 0xfc6ec
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq 0x10(%rbx), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %r14, %rdi
movq %rax, 0x10(%rbx)
movl 0x8(%rsp), %eax
leaq (%rax,%rax,2), %rax
movq (%rbx), %rcx
movq 0x10(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbx)
leaq (%rcx,%rcx,2), %rcx
movq 0x10(%rdi,%rax,8), %rsi
movq %rsi, 0x10(%rdx,%rcx,8)
movups (%rdi,%rax,8), %xmm0
movups %xmm0, (%rdx,%rcx,8)
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpq %rax, 0x58(%rsp)
ja 0xfc625
testl %r13d, %r13d
movq 0x48(%rsp), %rbp
movq 0x18(%rsp), %rbx
je 0xfc75d
movq 0x28(%r12), %rdi
callq 0x2220
movq $0x0, 0x28(%r12)
andb $0x7f, 0x7(%r12)
movq %r12, %rdi
callq 0xa02fa
movq (%rbp), %rax
testq %rax, %rax
movq 0x10(%rsp), %rdi
je 0xfc7a8
movq 0x8(%rbp), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpl $-0x1, %esi
je 0xfc796
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl %esi, 0xc(%rsp)
cmpl $0x0, (%rcx,%rdx,4)
jns 0xfc79e
movq 0x8(%rbp), %rsi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
jmp 0xfc79e
movl $0xffffffff, 0xc(%rsp)  # imm = 0xFFFFFFFF
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0xfc771
cmpq $0x0, 0xa8(%rsp)
jne 0xfc7c0
movq %rbx, %rdi
callq 0xa0004
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2220
movq 0x40(%rsp), %rdi
callq 0x2220
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq