// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: rescue_bubbles_by_cmk_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*, unsigned char*)
void rescue_bubbles_by_cmk_reads(ma_ug_t *i_u_g, asg_t *rg, 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, uint8_t *cmk)
{
    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, 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, rg->n_seq);
    uint8_t* circle_vis = NULL; CALLOC(circle_vis, rg->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, &(rg->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, rg, l_bub, expect_vis, 1);
            set_rtg_flag_by_bubble(bub, ug, rg, r_bub, expect_vis, 1);
            set_rtg_flag_by_bubble(bub, ug, rg, 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++) {
                        ///h is the edge of endRid
                        h = &(x->buffer[k]);
                        ///means we found a contained read
                        if(get_chimeric_reads_chain_by_broken_bub(h, sources, coverage_cut, ruIndex, ug, rg, max_hang, min_ovlp, endRid, uId, &chain_edges, &ava_cur, &test_oLen, &ava_chainLen, expect_vis, circle_vis, utg_vis, chainLenThres, 1, cmk)) {
                            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_chimeric_reads_chain_by_broken_bub(h_max, sources, coverage_cut, ruIndex, ug, rg, max_hang, min_ovlp, endRid, uId, &chain_edges, &ava_cur, &test_oLen, &ava_chainLen, expect_vis, circle_vis, NULL, chainLenThres, 1, cmk);
                        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, rg, 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(rg, 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);
                            if((is_Unitig == 1) || (is_Unitig == ((uint32_t)-1))) contain_rId = ((uint32_t)-1);///shouldn't be possible
                            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);

                            rg->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, rg, l_bub, expect_vis, 0);
            set_rtg_flag_by_bubble(bub, ug, rg, r_bub, expect_vis, 0);
            set_rtg_flag_by_bubble(bub, ug, rg, m_bub, expect_vis, 0);
        }
    }

    asg_arc_t* p = NULL;
    for (k = 0; k < new_edges.n; k++) {
        p = asg_arc_pushp(rg);
        *p = new_edges.a[k];
    }

    if(new_edges.n != 0) {
        free(rg->idx);
        rg->idx = 0;
        rg->is_srt = 0;
        asg_cleanup(rg);
        asg_symm(rg);
    }

    pre_clean(sources, coverage_cut, rg, 0);

    lable_all_bubbles(rg, 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(rg->seq[v>>1].del) continue;
        if(rg->seq[w>>1].del) continue;
        ///if this edge is at a bubble
        if(rg->seq_vis[v]!=0 && rg->seq_vis[w^1]!=0) continue;

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

    for (k = 0; k < u_vecs.a.n; k++) {
        w = (uint32_t)u_vecs.a.a[k];
        w = w<<1;
        if((!rg->seq[w>>1].del) && (get_real_length(rg, w, NULL)!=0 || get_real_length(rg, (w^1), NULL)!=0)) {
            w=w>>1;
            ruIndex->index[w] = (uint32_t)-1;
        } else {
            w=w>>1;
            rg->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 $0x208, %rsp            # imm = 0x208
movl %r9d, 0x8c(%rsp)
movq %r8, 0x80(%rsp)
movq %rcx, 0x98(%rsp)
movq %rdx, 0x110(%rsp)
movq %rdi, %r15
movq $0x0, 0x168(%rsp)
movq %rsi, 0x78(%rsp)
movl 0x14(%rsi), %r14d
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %r14
movl $0x1, %esi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x100(%rsp)
movl $0x1, %esi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x140(%rsp)
movq 0x18(%r15), %rbp
movl 0x14(%rbp), %edi
andq %rbx, %rdi
movl $0x1, %esi
callq 0x2120
movq %rax, 0x160(%rsp)
movq %r15, 0xc0(%rsp)
movq (%r15), %rax
testq %rax, %rax
je 0xf66c0
movq 0x20(%rbp), %rcx
xorl %edx, %edx
movb $0x0, 0x4(%rcx,%rdx,8)
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0xf66b1
xorps %xmm0, %xmm0
movaps %xmm0, 0x170(%rsp)
movq $0x0, 0x180(%rsp)
testl $0x7fffffff, 0x14(%rbp) # imm = 0x7FFFFFFF
movq 0x78(%rsp), %rdx
je 0xf676b
xorl %r14d, %r14d
movq 0x80(%rsp), %r12
movq 0xc0(%rsp), %rax
movq 0x10(%rax), %rax
leaq (%r14,%r14,4), %rcx
cmpl $0x0, 0xc(%rax,%rcx,8)
je 0xf675b
movq 0x20(%rbp), %rsi
cmpl $0x0, (%rsi,%r14,8)
js 0xf675b
leaq (%rax,%rcx,8), %rbx
cmpl $0x0, 0x10(%rbx)
je 0xf675b
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 0x78(%rsp), %rdx
incq %r15
movl 0x10(%rbx), %eax
cmpq %rax, %r15
jb 0xf6723
incq %r14
movl 0x14(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r14
jb 0xf66f4
movq 0x260(%rsp), %rax
movq 0xc0(%rax), %rax
xorl %ecx, %ecx
cmpq $0x0, (%rax)
je 0xf74d6
movl 0x250(%rsp), %edi
movl %edi, %r8d
addl 0x258(%rsp), %edi
movq $0x0, 0xf8(%rsp)
movq $0x0, 0x158(%rsp)
movq $0x0, 0xe8(%rsp)
xorl %esi, %esi
movq $0x0, 0xb8(%rsp)
xorl %r15d, %r15d
movq $0x0, 0x90(%rsp)
xorl %r12d, %r12d
movq %rbp, 0x150(%rsp)
movq %rdi, 0x1a8(%rsp)
movq %r8, 0x1a0(%rsp)
movq 0x10(%rax), %rax
movq %rcx, 0x198(%rsp)
leaq (%rcx,%rcx,4), %rcx
cmpl $0x3, 0x10(%rax,%rcx,8)
movq %rsi, 0xe0(%rsp)
jb 0xf74aa
leaq (%rax,%rcx,8), %r9
cmpl $0x3, 0x10(%r9)
jb 0xf74aa
movl $0x2, %r10d
movl $0x1, %r11d
movq %r9, 0x1b0(%rsp)
movq 0x18(%r9), %rax
movq (%rax,%r11,8), %rbx
shrq $0x21, %rbx
cmpq %r8, %rbx
setb %cl
cmpq %rdi, %rbx
setae %sil
orb %cl, %sil
jne 0xf7497
movq %r15, 0xd8(%rsp)
movq %r11, 0x1c8(%rsp)
movq -0x8(%rax,%r11,8), %rcx
shrq $0x21, %rcx
movq %r10, 0x1d0(%rsp)
movq (%rax,%r10,8), %r14
shrq $0x21, %r14
movq 0x260(%rsp), %rdi
movq 0xc0(%rsp), %r15
movq %r15, %rsi
movq %rcx, 0x1b8(%rsp)
movq 0x100(%rsp), %r13
movq %r13, %r8
movl $0x1, %r9d
movq %rbx, 0x148(%rsp)
movq %rdx, %rbx
callq 0xf4de5
movq 0x260(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq %r14, 0x1c0(%rsp)
movl %r14d, %ecx
movq %r13, %r8
movl $0x1, %r9d
callq 0xf4de5
movq 0x260(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq 0x148(%rsp), %rbx
movl %ebx, %ecx
movq %r13, %r8
movl $0x1, %r9d
callq 0xf4de5
movq $0x0, (%rsp)
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x1ec(%rsp), %rdx
leaq 0x1e8(%rsp), %rcx
leaq 0x168(%rsp), %r8
leaq 0x11c(%rsp), %r9
callq 0x13812e
cmpl $0x0, 0x11c(%rsp)
je 0xf73dd
xorl %ecx, %ecx
movq 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
movq 0xd8(%rsp), %r15
movq 0x90(%rsp), %rsi
movq 0x168(%rsp), %rax
movq %rcx, 0x1d8(%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 0xf73c0
leaq (%rax,%rcx,8), %rax
movq %rax, 0x1e0(%rsp)
andl $-0x2, %edi
xorl %eax, %eax
movq %rdi, %r8
movq %rdi, 0xd0(%rsp)
movq %rsi, 0x90(%rsp)
movq %rax, 0xb0(%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 0xf6a29
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 0xf6a06
testl %esi, %esi
movq 0x80(%rsp), %rdx
jne 0xf7211
xorl %eax, %eax
cmpq $0x0, 0xb0(%rsp)
sete %al
movq 0x1e0(%rsp), %rcx
movl 0x4(%rcx,%rax,4), %eax
movl %eax, %r13d
xorl $0x1, %r13d
shrl %eax
leaq (%rax,%rax,2), %rax
movq 0x110(%rsp), %rcx
cmpl $0x0, 0xc(%rcx,%rax,8)
movq %r12, 0xf0(%rsp)
movq %r15, 0xd8(%rsp)
je 0xf6c0f
leaq (%rcx,%rax,8), %r12
xorl %ebp, %ebp
movl $0xffffffff, 0xa8(%rsp) # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movq $0x0, 0x108(%rsp)
movl $0x0, 0xa0(%rsp)
xorl %ebx, %ebx
movq (%r12), %r15
addq %rbp, %r15
movq 0x160(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x140(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xcc(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x118(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x170(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %r13d, 0x10(%rsp)
movl 0x240(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, (%rsp)
movl $0x1, 0x60(%rsp)
movq %r15, %rdi
movq 0x110(%rsp), %rsi
movq 0x98(%rsp), %rdx
movq 0x80(%rsp), %rcx
movq 0xc0(%rsp), %r8
callq 0xf351d
testl %eax, %eax
je 0xf6b88
movl 0x118(%rsp), %eax
cmpl %ebx, %eax
movq 0x78(%rsp), %r9
jbe 0xf6b8f
movl 0xc8(%rsp), %ecx
movl %ecx, 0xa8(%rsp)
movl 0xcc(%rsp), %ecx
movl %ecx, 0xa0(%rsp)
movl %eax, %ebx
movq %r15, 0x108(%rsp)
jmp 0xf6bb3
movq 0x78(%rsp), %r9
jmp 0xf6bb3
jne 0xf6bb3
movl 0xa8(%rsp), %ecx
cmpl %ecx, 0xc8(%rsp)
jb 0xf6b60
jne 0xf6bb3
movl 0xa0(%rsp), %ecx
cmpl %ecx, 0xcc(%rsp)
ja 0xf6b60
incq %r14
movl 0xc(%r12), %eax
addq $0x28, %rbp
cmpq %rax, %r14
jb 0xf6aa0
testl %ebx, %ebx
sete %al
movq 0x80(%rsp), %rdx
movq 0xf0(%rsp), %r12
movq 0x150(%rsp), %rbp
movq 0xd8(%rsp), %r15
movq 0x90(%rsp), %rsi
movq 0xd0(%rsp), %r8
movq 0xb0(%rsp), %rcx
movq 0x108(%rsp), %rdi
jmp 0xf6c2b
movb $0x1, %al
xorl %edi, %edi
movq 0x90(%rsp), %rsi
movq 0xd0(%rsp), %r8
movq 0xb0(%rsp), %rcx
testb %al, %al
jne 0xf7229
movq 0x140(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0xc8(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xcc(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x118(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x170(%rsp), %rax
movq %rax, 0x20(%rsp)
movl %r13d, 0x10(%rsp)
movl 0x240(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x8c(%rsp), %eax
movl %eax, (%rsp)
movl $0x1, 0x60(%rsp)
movq $0x0, 0x50(%rsp)
movq 0x110(%rsp), %rbx
movq %rbx, %rsi
movq %rdx, %rcx
movq 0x98(%rsp), %rdx
movq 0xc0(%rsp), %r8
callq 0xf351d
movq 0x170(%rsp), %rax
testq %rax, %rax
je 0xf7204
movq 0x180(%rsp), %rcx
leaq (%rax,%rax,2), %rax
movl -0x10(%rcx,%rax,8), %ebp
movl %ebp, %eax
shrl %eax
leaq (%rax,%rax,2), %rax
leaq (%rbx,%rax,8), %r13
xorl %r12d, %r12d
movq $0x0, 0xa0(%rsp)
movq 0x98(%rsp), %r8
movq 0x78(%rsp), %rdi
movq 0xb8(%rsp), %rax
movq 0xe0(%rsp), %rsi
movl 0xc(%r13), %ebx
movb $0x1, %r14b
cmpl %ebx, %r12d
movq %rax, 0xb8(%rsp)
jae 0xf6e8f
movq %rsi, 0xe0(%rsp)
leaq 0x193a09(%rip), %rax    # 0x28a758
movss 0x158(%rax), %xmm0
movss %xmm0, 0xa8(%rsp)
movl %r12d, %eax
leaq (%rax,%rax,4), %r15
shlq $0x3, %r15
addq (%r13), %r15
subq %rax, %rbx
movl 0xc(%r15), %edx
leaq (%rdx,%rdx,2), %rcx
movl (%r8,%rcx,4), %eax
testl %eax, %eax
js 0xf6e67
movq 0x20(%rdi), %rsi
cmpl $0x0, (%rsi,%rdx,8)
js 0xf6e67
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 0x240(%rsp), %r8d
leaq 0x1f0(%rsp), %r9
callq 0xa159b
movq 0x78(%rsp), %rdi
movq 0x98(%rsp), %r8
testl %eax, %eax
js 0xf6e67
cmpl %ebp, 0x1f4(%rsp)
jne 0xf6e67
movl 0x1f8(%rsp), %eax
shrl %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x80(%rsp), %rdx
cmpq %rax, (%rdx)
jbe 0xf6e2f
movq 0x8(%rdx), %rdx
movl (%rdx,%rax,4), %edx
cmpl $-0x1, %edx
je 0xf6e2f
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
testl %edx, %edx
setns %dl
jmp 0xf6e31
xorl %edx, %edx
cmpl $-0x1, %ecx
sete %sil
orb %dl, %sil
jne 0xf6e67
movq 0xc0(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movl %ecx, %ecx
cmpl $0x0, (%rdx,%rcx,8)
js 0xf6e67
movq 0x100(%rsp), %rcx
cmpb $0x0, (%rcx,%rax)
jne 0xf6f02
incl %r12d
addq $0x28, %r15
decq %rbx
jne 0xf6d72
movq 0xb8(%rsp), %rax
movq 0xd8(%rsp), %r15
movq 0xe0(%rsp), %rsi
testb %r14b, %r14b
jne 0xf6f0d
movq 0xa0(%rsp), %r14
cmpq %rsi, %r14
jne 0xf6ed5
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 0x78(%rsp), %rdi
movq 0x98(%rsp), %r8
movq %rbx, %rsi
leaq (%r14,%r14,2), %rdx
incq %r14
movq %r14, 0xa0(%rsp)
movq 0x200(%rsp), %rcx
movq %rcx, 0x10(%rax,%rdx,8)
movups 0x1f0(%rsp), %xmm0
movups %xmm0, (%rax,%rdx,8)
jmp 0xf6d28
incl %r12d
xorl %r14d, %r14d
jmp 0xf6e77
movq %rsi, 0xe0(%rsp)
movq %rax, %rsi
movq 0xa0(%rsp), %r14
movl %r14d, %edx
callq 0xf4f30
cmpq $0x0, 0x170(%rsp)
je 0xf723b
leaq (,%r15,8), %rax
leaq (%rax,%rax,2), %rbp
movl $0x1, %edi
xorl %ecx, %ecx
movq 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
movq 0xf0(%rsp), %r12
movq 0x90(%rsp), %rsi
movl %edi, 0x108(%rsp)
movq %rsi, 0x90(%rsp)
movq %r15, 0xa8(%rsp)
movq 0x180(%rsp), %rax
leaq (%rcx,%rcx,2), %rcx
movl 0x8(%rax,%rcx,8), %r15d
movl %r15d, %r14d
shrl %r14d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpq %r14, (%rdx)
jbe 0xf6fc3
movq 0x8(%rdx), %rdx
movl (%rdx,%r14,4), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $-0x1, %esi
je 0xf6fc8
movl %esi, %r13d
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
shrl $0x1f, %esi
movl %esi, %edx
jmp 0xf6fc8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r12, 0xf0(%rsp)
cmpl $0x1, %edx
je 0xf6fda
cmpl $-0x1, %edx
jne 0xf6fe0
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq (%rax,%rcx,8), %r12
movq 0x158(%rsp), %rax
cmpq %rax, 0xf8(%rsp)
jne 0xf7032
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rsi
movq 0xe8(%rsp), %rdi
callq 0x2370
movq 0x78(%rsp), %r9
movq %rbx, 0x158(%rsp)
movq 0x98(%rsp), %rsi
jmp 0xf7042
movq 0x98(%rsp), %rsi
movq 0xe8(%rsp), %rax
shlq $0x20, %r13
orq %r14, %r13
movq %rax, 0xe8(%rsp)
movq 0xf8(%rsp), %rcx
movq %r13, (%rax,%rcx,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 0x120(%rsp), %rax
movq %rax, 0x8(%rsp)
movl %r15d, (%rsp)
movq 0x110(%rsp), %r13
movq %r13, %rdi
movl 0x8c(%rsp), %ecx
movl 0x240(%rsp), %r8d
movl %r12d, %r9d
callq 0xb2ced
movq 0x90(%rsp), %rax
cmpq %rax, 0xa8(%rsp)
jne 0xf70ee
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0xf0(%rsp), %rdi
callq 0x2370
movq %rax, %r14
jmp 0xf70f9
movq 0xf0(%rsp), %r14
movq %rax, %rbx
movq 0x130(%rsp), %rax
movq %rax, 0x10(%r14,%rbp)
movups 0x120(%rsp), %xmm0
movups %xmm0, (%r14,%rbp)
xorl $0x1, %r15d
xorl $0x1, %r12d
leaq 0x120(%rsp), %rax
movq %rax, 0x8(%rsp)
movl %r12d, (%rsp)
movq %r13, %rdi
movq 0x98(%rsp), %rsi
movl 0x8c(%rsp), %ecx
movl 0x240(%rsp), %r8d
movl %r15d, %r9d
callq 0xb2ced
movq 0xa8(%rsp), %rax
leaq 0x1(%rax), %r15
cmpq %rbx, %r15
movq %rbx, %rsi
jne 0xf719b
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 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
jmp 0xf71ab
movq 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
movq %r14, %r12
movl 0x108(%rsp), %edi
movq 0x130(%rsp), %rax
movq %rax, 0x28(%r12,%rbp)
movups 0x120(%rsp), %xmm0
movups %xmm0, 0x18(%r12,%rbp)
movl %edi, %ecx
addq $0x30, %rbp
incl %edi
incq %r15
incq 0xf8(%rsp)
cmpq %rcx, 0x170(%rsp)
ja 0xf6f67
movq 0xa8(%rsp), %r15
addq $0x2, %r15
movq 0xa0(%rsp), %r14
jmp 0xf7258
movq 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
movq 0x90(%rsp), %rsi
movq 0xd0(%rsp), %r8
movq 0xb0(%rsp), %rcx
leaq 0x1(%rcx), %rax
testq %rcx, %rcx
je 0xf69be
jmp 0xf73c0
movq 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
movq 0xf0(%rsp), %r12
movq 0x90(%rsp), %rsi
testq %r14, %r14
movq 0x150(%rsp), %rbp
je 0xf7219
movl $0x1, %ebx
xorl %eax, %eax
leaq (%rax,%rax,2), %rax
movq 0xb8(%rsp), %rcx
movups (%rcx,%rax,8), %xmm0
movaps %xmm0, 0x120(%rsp)
movq 0x10(%rcx,%rax,8), %rax
movq %rax, 0x130(%rsp)
cmpl $0x0, 0x12c(%rsp)
js 0xf73ae
cmpq %rsi, %r15
jne 0xf72d0
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 0xf72d3
movq %rsi, %r13
leaq 0x1(%r15), %r14
leaq (%r15,%r15,2), %rax
movq 0x130(%rsp), %rcx
movq %rcx, 0x10(%r12,%rax,8)
movaps 0x120(%rsp), %xmm0
movups %xmm0, (%r12,%rax,8)
movl 0x124(%rsp), %eax
movl 0x128(%rsp), %r9d
xorl $0x1, %r9d
xorl $0x1, %eax
leaq 0x120(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movl %eax, (%rsp)
movq 0x110(%rsp), %rdi
movq 0x98(%rsp), %rsi
movl 0x8c(%rsp), %ecx
movl 0x240(%rsp), %r8d
callq 0xb2ced
cmpq %r13, %r14
movq %r13, %rsi
jne 0xf7377
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 0x80(%rsp), %rdx
movq 0x78(%rsp), %r9
addq $0x2, %r15
leaq (%r14,%r14,2), %rax
movq 0x130(%rsp), %rcx
movq %rcx, 0x10(%r12,%rax,8)
movaps 0x120(%rsp), %xmm0
movups %xmm0, (%r12,%rax,8)
movq 0xa0(%rsp), %r14
movl %ebx, %eax
incl %ebx
cmpq %rax, %r14
ja 0xf726c
jmp 0xf7219
movq 0x1d8(%rsp), %rcx
incq %rcx
movl 0x11c(%rsp), %eax
cmpq %rax, %rcx
jb 0xf6970
jmp 0xf73f2
movq 0x78(%rsp), %r9
movq 0xd8(%rsp), %r15
movq 0x90(%rsp), %rsi
movq %rsi, 0x90(%rsp)
movq 0x260(%rsp), %r14
movq %r14, %rdi
movq 0xc0(%rsp), %rbx
movq %rbx, %rsi
movq %r9, %rdx
movq 0x1b8(%rsp), %rcx
movq 0x100(%rsp), %r13
movq %r13, %r8
xorl %r9d, %r9d
callq 0xf4de5
movq %r14, %rdi
movq %rbx, %rsi
movq 0x78(%rsp), %rdx
movq 0x1c0(%rsp), %rcx
movq %r13, %r8
xorl %r9d, %r9d
callq 0xf4de5
movq %r14, %rdi
movq %rbx, %rsi
movq 0x78(%rsp), %rdx
movq 0x148(%rsp), %rcx
movq %r13, %r8
xorl %r9d, %r9d
callq 0xf4de5
movq 0x78(%rsp), %rdx
movq 0x1a8(%rsp), %rdi
movq 0x1a0(%rsp), %r8
movq 0x1b0(%rsp), %r9
movq 0x1d0(%rsp), %r10
movq 0x1c8(%rsp), %r11
incq %r10
movl 0x10(%r9), %eax
incq %r11
cmpq %rax, %r10
jb 0xf6839
movq 0x198(%rsp), %rcx
incl %ecx
movq 0x260(%rsp), %rax
movq 0xc0(%rax), %rax
cmpq %rcx, (%rax)
movq 0xe0(%rsp), %rsi
ja 0xf67f3
jmp 0xf7500
xorl %r12d, %r12d
xorl %r15d, %r15d
movq $0x0, 0xb8(%rsp)
movq $0x0, 0xe8(%rsp)
movq $0x0, 0xf8(%rsp)
testq %r15, %r15
je 0xf75e0
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 0xf754f
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 0x78(%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 0xf751f
movq 0x28(%rdx), %rdi
callq 0x2220
movq 0x78(%rsp), %rax
movq $0x0, 0x28(%rax)
movq 0x78(%rsp), %rax
andb $0x7f, 0x7(%rax)
movq 0x78(%rsp), %rdi
callq 0xa02fa
movq 0x78(%rsp), %rdi
callq 0xa0333
movq 0x78(%rsp), %rdi
callq 0xa03e9
movq 0x78(%rsp), %rdx
orb $-0x80, 0x17(%rdx)
movq %r13, %r15
movq 0x268(%rsp), %rbx
movl $0x64, %ecx
xorl %r8d, %r8d
callq 0xe7e99
movq 0x78(%rsp), %rdx
testq %rax, %rax
jne 0xf75e8
movq %rdx, %rdi
callq 0xa02fa
movq 0x78(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xa6dbe
movq 0x78(%rsp), %rdi
testq %r15, %r15
je 0xf7722
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 0xf7714
movl 0x8(%r12,%rsi,8), %esi
movl %esi, %r8d
shrl %r8d
cmpl $0x0, (%r9,%r8,8)
js 0xf7714
shrq $0x20, %rdx
movq 0x30(%rdi), %r9
cmpb $0x0, (%r9,%rdx)
je 0xf7680
movq %rsi, %r8
xorq $0x1, %r8
cmpb $0x0, (%r9,%r8)
jne 0xf7714
movq 0x28(%rdi), %r8
movq (%r8,%rdx,8), %r8
movq %r8, %r10
andq %rcx, %r10
je 0xf76c5
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 0xf76bc
orb $-0x80, 0x3(%r8,%r9)
addq $0x18, %r9
cmpq %r9, %r10
jne 0xf76af
xorl $0x1, %esi
movq 0x28(%rdi), %r8
movq (%r8,%rsi,8), %r9
movq %r9, %rsi
andq %rcx, %rsi
je 0xf7714
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 0xf770b
orb $-0x80, 0x3(%r10,%r8)
addq $0x18, %r8
cmpq %r8, %rsi
jne 0xf76f7
incq %rax
movl %eax, %edx
cmpq %rdx, %r15
ja 0xf762b
callq 0xa02fa
movq 0x78(%rsp), %rdi
callq 0xa0333
movq 0x78(%rsp), %rdi
callq 0xa03e9
movq 0x78(%rsp), %rdx
orb $-0x80, 0x17(%rdx)
cmpq $0x0, 0xf8(%rsp)
je 0xf786e
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0xe8(%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 0xf783c
addl %r9d, %r9d
movq 0x78(%rsp), %r8
movq 0x28(%r8), %r8
movl %r9d, %r9d
movq (%r8,%r9,8), %r10
movq %r10, %r11
andq %rcx, %r11
je 0xf77d9
movq 0x78(%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 0xf77be
testl %ebp, %ebp
jne 0xf7827
movq 0x8(%r8,%r9,8), %r8
movq %r8, %r9
andq %rcx, %r9
je 0xf783c
movq 0x78(%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 0xf780d
testl %r11d, %r11d
je 0xf783c
movq 0x80(%rsp), %rsi
movq 0x8(%rsi), %rsi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
jmp 0xf7856
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, 0xf8(%rsp)
movq 0x78(%rsp), %rdx
ja 0xf775a
movq 0x80(%rsp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0xf78af
movq 0x80(%rsp), %rcx
movq 0x8(%rcx), %rcx
xorl %edx, %edx
cmpl $-0x2, (%rcx,%rdx,4)
jg 0xf78a5
movq 0x80(%rsp), %rsi
movq 0x8(%rsi), %rsi
movl $0xffffffff, (%rsi,%rdx,4) # imm = 0xFFFFFFFF
incq %rdx
movl %edx, %esi
cmpq %rsi, %rax
ja 0xf788c
movq %r12, %rdi
callq 0x2220
movq 0xb8(%rsp), %rdi
callq 0x2220
movq 0xe8(%rsp), %rdi
callq 0x2220
movq 0x180(%rsp), %rdi
callq 0x2220
movq 0x100(%rsp), %rdi
callq 0x2220
movq 0x140(%rsp), %rdi
callq 0x2220
movq 0x160(%rsp), %rdi
callq 0x2220
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq