// File: /workspace/github_cpp_makefile_star2_O3/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 $0x108, %rsp            # imm = 0x108
movq %r9, %r15
movq %r8, 0x18(%rsp)
movq %rcx, 0xc0(%rsp)
movq %rdx, %rbp
movq %rsi, %r12
movq 0x160(%rsp), %r14
testq %rdi, %rdi
movq %rdi, 0xe0(%rsp)
je 0xff513
movq %rdi, %rbx
movq 0x18(%rdi), %r13
movl 0x14(%r13), %edi
movl %edi, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movq %rbx, 0x68(%rsp)
jmp 0xff552
movq %r12, %rdi
callq 0xb10cd
movq %rax, 0x68(%rsp)
movq 0x18(%rax), %r13
movl 0x14(%r13), %edi
testl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
je 0xfff7a
movq 0x20(%r13), %rcx
xorl %edx, %edx
movb $0x0, 0x4(%rcx,%rdx,8)
incq %rdx
movl 0x14(%r13), %edi
movl %edi, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %rdx
jb 0xff53a
testl %eax, %eax
je 0xfff7a
movq %rbp, 0xd8(%rsp)
xorl %ebx, %ebx
movq %r13, 0x8(%rsp)
movl %ebx, 0x64(%rsp)
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%rbx,%rbx,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xff5e1
movq 0x20(%r13), %rdx
cmpl $0x0, (%rdx,%rbx,8)
js 0xff5e1
leaq (%rax,%rcx,8), %r14
movl $0x0, (%rsp)
cmpl $0x0, 0x10(%r14)
je 0xff5e1
xorl %r13d, %r13d
movq 0x18(%r14), %rax
movq (%rax,%r13,8), %rsi
shrq $0x21, %rsi
movq 0x20(%r12), %rax
leaq (%rax,%rsi,8), %r8
addq $0x4, %r8
movq %r15, %rdi
movl %ebx, %edx
movl $0x1, %ecx
callq 0xa27e9
incq %r13
movl %r13d, (%rsp)
movl 0x10(%r14), %eax
cmpq %rax, %r13
jb 0xff5a0
movq 0x8(%rsp), %r13
movl 0x14(%r13), %edi
incq %rbx
movl %edi, %ebp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
cmpq %rbp, %rbx
jb 0xff569
testl %ebp, %ebp
je 0xfffc6
addl %ebp, %ebp
xorl %r14d, %r14d
movq $0x0, 0xd0(%rsp)
xorl %r10d, %r10d
movq $0x0, 0x80(%rsp)
movq $0x0, 0xb8(%rsp)
movq $0x0, 0x28(%rsp)
xorl %r11d, %r11d
movq $0x0, 0xb0(%rsp)
xorl %eax, %eax
movq 0x18(%rsp), %rbx
movl %r14d, %edx
shrl %edx
movl %edx, 0x64(%rsp)
movq 0x20(%r13), %rcx
cmpl $0x0, (%rcx,%rdx,8)
js 0xfff35
movq 0x68(%rsp), %rcx
movq 0x10(%rcx), %rcx
leaq (%rdx,%rdx,4), %rdx
cmpl $0x0, 0xc(%rcx,%rdx,8)
je 0xfff35
leaq (%rcx,%rdx,8), %r9
cmpl $0x0, (%r9)
js 0xfff35
cmpl $-0x1, 0x4(%r9)
je 0xfff35
cmpl $-0x1, 0x8(%r9)
je 0xfff35
movq %rdx, 0xc8(%rsp)
movq 0x28(%r13), %rcx
movq (%rcx,%r14,8), %rcx
movq %rcx, %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rdx
je 0xff6f7
movq 0x8(%r13), %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 0xff6d8
testl %edi, %edi
jne 0xfff35
leaq 0x4(%r9), %rcx
addq $0x8, %r9
testb $0x1, %r14b
cmovneq %rcx, %r9
movl (%r9), %ecx
movq %rcx, %rdx
xorq $0x1, %rdx
movq %rdx, 0xa0(%rsp)
shrl %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0xd8(%rsp), %rdx
movl 0xc(%rdx,%rcx,8), %r8d
movq 0x30(%rsp), %rsi
movl $0x0, (%rsp)
testq %r8, %r8
movq %r14, 0x58(%rsp)
movq %rax, 0x10(%rsp)
movq %r10, 0x90(%rsp)
movq %r11, 0x70(%rsp)
je 0xffa2a
movq %rsi, 0xa8(%rsp)
leaq (%rdx,%rcx,8), %rax
movq (%rax), %rsi
leaq 0x195fea(%rip), %rax    # 0x295758
movss 0x158(%rax), %xmm0
movl 0x38(%rsp), %eax
movl %eax, 0x9c(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x98(%rsp)
movzwl 0x40(%rsp), %eax
movl %eax, 0x8c(%rsp)
movb 0x42(%rsp), %al
movb %al, 0x7(%rsp)
addq $0x21, %rsi
xorl %ecx, %ecx
movq %r8, 0x50(%rsp)
movq -0x21(%rsi), %r11
movq %r11, %rax
shrq $0x20, %rax
leaq (%rax,%rax,2), %r9
movl (%rbx,%r9,4), %eax
testl %eax, %eax
js 0xff8d0
movl -0x15(%rsi), %r13d
leaq (,%r13,2), %rdx
addq %r13, %rdx
leaq (%rbx,%rdx,4), %rdi
movl (%rdi), %edx
testl %edx, %edx
js 0xff811
movq -0x9(%rsi), %r10
testq %r10, %r10
js 0xff811
movl 0x4(%rdi), %r8d
subl %edx, %r8d
movq %r10, 0xe8(%rsp)
testl %r10d, %r10d
js 0xff81b
movl -0x11(%rsi), %edi
movl -0xd(%rsi), %edx
subl %edx, %r8d
movl %r8d, %r10d
movl %edi, 0x24(%rsp)
movl %edi, %r8d
jmp 0xff82a
movq 0x8(%rsp), %r13
jmp 0xff8d0
movl -0x11(%rsi), %r10d
movl -0xd(%rsi), %edx
subl %edx, %r8d
movl %r10d, 0x24(%rsp)
leaq (%rbx,%r9,4), %rdi
movl 0x4(%rdi), %ebx
subl %eax, %ebx
cmpl %r11d, %r8d
movl %r11d, %edi
cmovll %r8d, %edi
movl -0x19(%rsi), %eax
movl %ebx, %r9d
movl %eax, 0x78(%rsp)
subl %eax, %r9d
cmpl %r10d, %r9d
movl %r10d, %eax
cmovll %r9d, %eax
movl 0x140(%rsp), %r14d
cmpl %r14d, %edi
jg 0xff8bc
cmpl %r14d, %eax
jg 0xff8bc
movl 0x78(%rsp), %r14d
subl %r11d, %r14d
cvtsi2ss %r14, %xmm1
addl %edi, %r14d
addl %eax, %r14d
xorps %xmm2, %xmm2
cvtsi2ss %r14, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
ja 0xff8ab
subl 0x24(%rsp), %edx
xorps %xmm1, %xmm1
cvtsi2ss %rdx, %xmm1
addl %edi, %eax
addl %edx, %eax
xorps %xmm2, %xmm2
cvtsi2ss %rax, %xmm2
mulss %xmm0, %xmm2
ucomiss %xmm1, %xmm2
jbe 0xff8e8
movq 0x8(%rsp), %r13
movq 0x18(%rsp), %rbx
movq 0x58(%rsp), %r14
jmp 0xff8cb
movq 0x8(%rsp), %r13
movq 0x58(%rsp), %r14
movq 0x18(%rsp), %rbx
movq 0x50(%rsp), %r8
incq %rcx
movl %ecx, (%rsp)
addq $0x28, %rsi
cmpq %rcx, %r8
jne 0xff7ab
jmp 0xff9f1
cmpl %r10d, %r9d
setl 0x24(%rsp)
setg %r9b
cmpl %r8d, %r11d
setg %dl
setl %dil
orb %r9b, %dl
cmpb $0x1, %dl
jne 0xff8ab
orb 0x24(%rsp), %dil
je 0xff8ab
movl 0x148(%rsp), %edx
cmpl %edx, %r14d
jl 0xff8ab
cmpl %edx, %eax
movq 0x58(%rsp), %r14
jl 0xff9e7
movq 0xe8(%rsp), %r9
testl %r9d, %r9d
setns %dl
addl 0x78(%rsp), %r10d
movl %ebx, %edi
subl %r10d, %edi
xorl %r10d, %r10d
movl %r11d, %eax
subl %r8d, %eax
setle %r10b
setg %r8b
cmovlel %edi, %eax
xorb %dl, %r8b
movzbl %r8b, %edx
shrq $0x1f, %r11
andl $-0x2, %r11d
orq %r10, %r11
leal (%rdx,%r13,2), %edx
movl %edx, 0x9c(%rsp)
movq %r11, %rdx
shlq $0x20, %rdx
addq %rax, %rdx
movq %rdx, 0xa8(%rsp)
subl %eax, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl %ebx, 0x98(%rsp)
shrl $0x10, %r9d
andl $0x4000, %r9d           # imm = 0x4000
movl 0x8c(%rsp), %edi
andl $0x3fff, %edi           # imm = 0x3FFF
orl %r9d, %edi
movb -0x1(%rsi), %dl
movb %dl, 0x7(%rsp)
movzbl (%rsi), %edx
shll $0xf, %edx
orl %edi, %edx
movl %edx, 0x8c(%rsp)
testl %eax, %eax
js 0xff9e7
cmpl 0xa0(%rsp), %r11d
movq 0x8(%rsp), %r13
movq 0x18(%rsp), %rbx
movq 0x50(%rsp), %r8
jne 0xff8d0
jmp 0xfff43
movq 0x8(%rsp), %r13
jmp 0xff8c6
movl 0x9c(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x98(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x8c(%rsp), %eax
movw %ax, 0x40(%rsp)
movb 0x7(%rsp), %al
movb %al, 0x42(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0xffa3a
xorl %ecx, %ecx
movq %rsi, 0x30(%rsp)
cmpl %r8d, %ecx
jne 0xfff03
movl $0x0, (%rsp)
subq $0x8, %rsp
movq 0x70(%rsp), %rdi
movq %r12, %rsi
movq 0xc8(%rsp), %rdx
movq %rbx, %rcx
movq %r15, %r8
movl 0x148(%rsp), %r9d
movl $0x1, %eax
pushq %rax
leaq 0x100(%rsp), %r10
pushq %r10
leaq 0x18(%rsp), %r10
pushq %r10
pushq %rax
leaq 0x8c(%rsp), %rax
pushq %rax
pushq 0xd0(%rsp)
movl 0x180(%rsp), %eax
pushq %rax
callq 0x1072ad
addq $0x40, %rsp
testl %eax, %eax
je 0xfff03
movq %r15, 0x78(%rsp)
xorl %r14d, %r14d
xorl %ebx, %ebx
xorl %r13d, %r13d
movq 0x90(%rsp), %r10
cmpq 0xd0(%rsp), %r13
jne 0xffaf1
testq %r13, %r13
movq %rbx, %rcx
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0xd0(%rsp)
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
movq %r10, %rdi
callq 0x2370
movq %rax, %r10
movq 0x78(%rsp), %r8
movl 0x148(%rsp), %r11d
movl 0x140(%rsp), %r9d
incq %r13
movq 0x100(%rsp), %rax
movq %rax, 0x10(%r10,%r14)
movups 0xf0(%rsp), %xmm0
movups %xmm0, (%r10,%r14)
subq $0x8, %rsp
movq 0x70(%rsp), %rdi
movq %r12, %rsi
movq 0xc8(%rsp), %rdx
movq 0x20(%rsp), %rcx
movl $0x1, %eax
pushq %rax
leaq 0x100(%rsp), %r15
pushq %r15
leaq 0x18(%rsp), %r15
pushq %r15
pushq %rax
leaq 0x8c(%rsp), %rax
pushq %rax
pushq 0xd0(%rsp)
pushq %r11
movq %r10, %r15
callq 0x1072ad
movq %r15, %r10
addq $0x40, %rsp
addq $0x2, %rbx
addq $0x18, %r14
testl %eax, %eax
jne 0xffab9
testq %r13, %r13
je 0xfff17
movq 0x68(%rsp), %rdi
movq 0x78(%rsp), %rsi
movq %r10, %rdx
movl %r13d, %ecx
callq 0xf48e8
movq %r15, %r10
movl $0x0, (%rsp)
movq 0x58(%rsp), %rax
movl %eax, %ecx
xorl $0x1, %ecx
movl %ecx, 0x24(%rsp)
shlq $0x20, %rax
movq %rax, 0x50(%rsp)
xorl %r14d, %r14d
movq 0x10(%rsp), %rax
movq 0x70(%rsp), %r11
leaq (%r14,%r14,2), %rcx
movups (%r10,%rcx,8), %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x10(%r10,%rcx,8), %rcx
movq %rcx, 0x40(%rsp)
cmpl $0x0, 0x3c(%rsp)
js 0xffee7
movq %r11, 0x70(%rsp)
movq %rax, 0x10(%rsp)
movl 0x38(%rsp), %edx
movq 0x68(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0xf488a
cmpl $-0x1, %eax
je 0xffc60
movl %eax, %ebx
movq 0x80(%rsp), %rcx
movq 0xb8(%rsp), %r14
cmpq %r14, %rcx
jne 0xffc72
leaq (%rcx,%rcx), %r14
testq %rcx, %rcx
movl $0x2, %eax
cmoveq %rax, %r14
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x28(%rsp), %rdi
callq 0x2370
movq 0x80(%rsp), %rcx
movq %rax, %rsi
jmp 0xffc77
movq 0x10(%rsp), %rax
movq %r15, %r10
movq 0x70(%rsp), %r11
jmp 0xffee7
movq 0x28(%rsp), %rsi
movq 0xc8(%rsp), %rdx
movq %rsi, 0x28(%rsp)
leaq 0x1(%rcx), %rax
movq %rax, 0xa0(%rsp)
leaq (%rcx,%rcx,2), %rax
movq 0x40(%rsp), %rcx
movq %rcx, 0x10(%rsi,%rax,8)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rsi,%rax,8)
movl 0x3c(%rsp), %r8d
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %r8d
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rax
movl (%rax,%rdx,8), %edx
andl %ecx, %edx
movzwl 0x40(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x42(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x8(%rsp), %rdi
movq 0x58(%rsp), %rsi
movl %ebx, %ecx
pushq %rax
pushq %r10
callq 0xeaa02
addq $0x10, %rsp
movl 0x34(%rsp), %eax
movl 0x38(%rsp), %r9d
xorl $0x1, %r9d
xorl $0x1, %eax
movq 0xc0(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x140(%rsp), %ecx
movl 0x148(%rsp), %r8d
leaq 0x30(%rsp), %rdx
pushq %rdx
pushq %rax
callq 0xb3df3
movq 0xb0(%rsp), %rcx
addq $0x10, %rsp
cmpq %r14, %rcx
movq %r14, %rax
jne 0xffd77
leaq (%rax,%rax), %r14
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %r14
leaq (,%r14,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x28(%rsp), %rdi
callq 0x2370
movq 0xa0(%rsp), %rcx
movq %r14, 0xb8(%rsp)
jmp 0xffd84
movq %rax, 0xb8(%rsp)
movq 0x28(%rsp), %rax
leaq (%rcx,%rcx,2), %rdx
movq 0x40(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movaps 0x30(%rsp), %xmm0
movq %rax, 0x28(%rsp)
movups %xmm0, (%rax,%rdx,8)
movl 0x3c(%rsp), %r8d
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl %esi, %r8d
movl %ebx, %r14d
xorl $0x1, %r14d
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rax
movl %ebx, %ecx
shrl %ecx
leaq (%rcx,%rcx,4), %rcx
movl (%rax,%rcx,8), %edx
andl %esi, %edx
movzwl 0x40(%rsp), %eax
movl %eax, %r9d
shrl $0xe, %r9d
movzbl 0x42(%rsp), %r10d
shrl $0xf, %eax
andl $0x1, %r9d
movq 0x8(%rsp), %rdi
movl %r14d, %esi
movl 0x24(%rsp), %ecx
pushq %rax
pushq %r10
callq 0xeaa02
addq $0x10, %rsp
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movl %ebx, 0x38(%rsp)
movq 0x70(%rsp), %r11
movq 0xb0(%rsp), %rsi
cmpq %rsi, %r11
jne 0xffe4b
leaq (%r11,%r11), %rbx
testq %r11, %r11
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x10(%rsp), %rdi
callq 0x2370
movq %rbx, %rsi
movq 0x70(%rsp), %r11
jmp 0xffe50
movq 0x10(%rsp), %rax
leaq 0x1(%r11), %rbx
leaq (%r11,%r11,2), %rdx
movq 0x40(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rax,%rdx,8)
shlq $0x20, %r14
movq %r14, 0x30(%rsp)
movl 0x24(%rsp), %ecx
movl %ecx, 0x38(%rsp)
cmpq %rsi, %rbx
jne 0xffeb4
leaq (%rsi,%rsi), %r14
testq %rsi, %rsi
movl $0x2, %ecx
cmoveq %rcx, %r14
leaq (,%r14,8), %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x2370
movq 0x70(%rsp), %r11
movq %r14, 0xb0(%rsp)
jmp 0xffebc
movq %rsi, 0xb0(%rsp)
movq %r15, %r10
addq $0x2, 0x80(%rsp)
addq $0x2, %r11
leaq (%rbx,%rbx,2), %rdx
movq 0x40(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movaps 0x30(%rsp), %xmm0
movups %xmm0, (%rax,%rdx,8)
movl (%rsp), %r14d
incl %r14d
movl %r14d, (%rsp)
cmpq %r14, %r13
ja 0xffbd1
movq 0x78(%rsp), %r15
movq 0x8(%rsp), %r13
jmp 0xfff2b
movq 0x10(%rsp), %rax
movq 0x90(%rsp), %r10
movq 0x70(%rsp), %r11
jmp 0xfff35
movq 0x10(%rsp), %rax
movq 0x78(%rsp), %r15
movq 0x8(%rsp), %r13
movq 0x70(%rsp), %r11
movq 0x18(%rsp), %rbx
movq 0x58(%rsp), %r14
incq %r14
cmpq %rbp, %r14
jne 0xff648
jmp 0xfffa8
movl 0x9c(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x98(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x8c(%rsp), %eax
movw %ax, 0x40(%rsp)
movb 0x7(%rsp), %al
movb %al, 0x42(%rsp)
movq 0xa8(%rsp), %rsi
jmp 0xffa2c
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x28(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
jmp 0xffffa
movq %r10, 0x90(%rsp)
movq %rax, 0x10(%rsp)
movl 0x14(%r13), %edi
movq 0x160(%rsp), %r14
movq %r11, %rbp
jmp 0xffffa
movq $0x0, 0x10(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x28(%rsp)
movq $0x0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movq 0x160(%rsp), %r14
addl %edi, %edi
movl $0x1, %esi
callq 0x2120
movq %rax, 0x30(%r13)
movq %r13, %rdi
callq 0xa0a7d
xorl %ebx, %ebx
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xa7e08
movl $0x0, (%rsp)
testq %rbp, %rbp
movq 0x10(%rsp), %r10
je 0x100144
movq %rbp, %r11
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq (%rbx,%rbx,2), %rdx
movq (%r10,%rdx,8), %rcx
movq 0x20(%r13), %rsi
movq %rcx, %rdi
shrq $0x21, %rdi
cmpl $0x0, (%rsi,%rdi,8)
js 0x100136
movl 0x8(%r10,%rdx,8), %edx
movl %edx, %edi
shrl %edi
cmpl $0x0, (%rsi,%rdi,8)
js 0x100136
shrq $0x20, %rcx
movq 0x30(%r13), %rsi
cmpb $0x0, (%rsi,%rcx)
je 0x10008d
movq %rdx, %rdi
xorq $0x1, %rdi
cmpb $0x0, (%rsi,%rdi)
jne 0x100136
movq 0x8(%r13), %rsi
movq 0x28(%r13), %rdi
movq (%rdi,%rcx,8), %r8
movq %r8, %r9
andq %rax, %r9
je 0x1000da
shrq $0x20, %r8
shlq $0x3, %r9
leaq (%r9,%r9,2), %rdi
leaq (%r8,%r8,2), %r8
leaq (%rsi,%r8,8), %rsi
addq $0xc, %rsi
xorl %r8d, %r8d
cmpl %edx, -0x4(%rsi,%r8)
jne 0x1000c9
orb $-0x80, 0x3(%rsi,%r8)
addq $0x18, %r8
cmpq %r8, %rdi
jne 0x1000bc
movq 0x8(%r13), %rsi
movq 0x28(%r13), %rdi
xorl $0x1, %edx
movq (%rdi,%rdx,8), %rdi
movq %rdi, %rdx
andq %rax, %rdx
je 0x10011f
shrq $0x20, %rdi
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rdx
leaq (%rdi,%rdi,2), %rdi
leaq (%rsi,%rdi,8), %rsi
addq $0xc, %rsi
xorl %edi, %edi
movl -0x4(%rsi,%rdi), %r8d
xorl %ecx, %r8d
cmpl $0x1, %r8d
jne 0x100116
orb $-0x80, 0x3(%rsi,%rdi)
addq $0x18, %rdi
cmpq %rdi, %rdx
jne 0x100103
movl (%rsp), %ecx
leaq (%rcx,%rcx,2), %rcx
movq 0x28(%rsp), %rdx
orl $0x80000000, 0xc(%rdx,%rcx,8) # imm = 0x80000000
movl (%rsp), %ebx
incl %ebx
movl %ebx, (%rsp)
cmpq %rbx, %r11
ja 0x10003e
movq %r13, %rdi
callq 0xa0a7d
movq 0x30(%r13), %rdi
callq 0x2220
movq $0x0, 0x30(%r13)
movl $0x0, (%rsp)
movq 0x80(%rsp), %r10
testq %r10, %r10
movq 0x28(%rsp), %r9
je 0x1002d4
movq 0x158(%rsp), %rbx
xorl %ecx, %ecx
movl $0x10, %ebp
movl $0x2, %r14d
xorl %r13d, %r13d
leaq (%rcx,%rcx,2), %rax
cmpl $0x0, 0xc(%r9,%rax,8)
js 0x1002a0
movl 0x4(%r12), %esi
movl %esi, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpl (%r12), %edx
jne 0x1001f7
leal (%rdx,%rdx), %eax
testl %edx, %edx
cmovel %ebp, %eax
movl %eax, (%r12)
movq 0x8(%r12), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq 0x80(%rsp), %r10
movq 0x28(%rsp), %r9
movq %rax, 0x8(%r12)
movl 0x4(%r12), %esi
movl %esi, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl (%rsp), %ecx
jmp 0x1001fc
movq 0x8(%r12), %rax
leal 0x1(%rsi), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl $0x80000000, %esi       # imm = 0x80000000
orl %edi, %esi
incl %r13d
movl %esi, 0x4(%r12)
movl %edx, %edx
leaq (%rdx,%rdx,2), %rsi
movl %ecx, %edx
leaq (%rdx,%rdx,2), %rdi
movq 0x10(%r9,%rdi,8), %r8
movq %r8, 0x10(%rax,%rsi,8)
movups (%r9,%rdi,8), %xmm0
movups %xmm0, (%rax,%rsi,8)
testq %rbx, %rbx
je 0x1002a0
movq (%rbx), %rsi
movq 0x10(%rbx), %rax
cmpq 0x8(%rbx), %rsi
jne 0x10027e
leaq (%rsi,%rsi), %rcx
testq %rsi, %rsi
cmoveq %r14, %rcx
movq %rcx, 0x8(%rbx)
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
movq %rax, %rdi
callq 0x2370
movq 0x80(%rsp), %r10
movq 0x28(%rsp), %r9
movq %rax, 0x10(%rbx)
movl (%rsp), %edx
movq (%rbx), %rsi
movl %edx, %ecx
leaq (%rdx,%rdx,2), %rdx
leaq 0x1(%rsi), %rdi
movq %rdi, (%rbx)
leaq (%rsi,%rsi,2), %rsi
movq 0x10(%r9,%rdx,8), %rdi
movq %rdi, 0x10(%rax,%rsi,8)
movups (%r9,%rdx,8), %xmm0
movups %xmm0, (%rax,%rsi,8)
incl %ecx
movl %ecx, (%rsp)
cmpq %rcx, %r10
ja 0x100192
testl %r13d, %r13d
je 0x1002d4
movq 0x28(%r12), %rdi
callq 0x2220
movq $0x0, 0x28(%r12)
andb $0x7f, 0x7(%r12)
movq %r12, %rdi
callq 0xa0a7d
movq (%r15), %rax
testq %rax, %rax
movq 0xe0(%rsp), %r8
movq 0x10(%rsp), %rdi
je 0x100322
movq 0x8(%r15), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpl $-0x1, %esi
je 0x100310
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movl %esi, 0x64(%rsp)
cmpl $0x0, (%rcx,%rdx,4)
jns 0x100318
movl $0xffffffff, (%rcx,%rdx,4) # imm = 0xFFFFFFFF
jmp 0x100318
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0x1002ef
testq %r8, %r8
jne 0x100336
movq 0x68(%rsp), %rdi
callq 0xa0761
movq 0x10(%rsp), %rdi
callq 0x2220
movq 0x28(%rsp), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq