// File: 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
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq %r8, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movq $0x0, -0xd0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xf0(%rbp)
movq $0x0, -0xe0(%rbp)
movq $0x0, -0x100(%rbp)
movq $0x0, -0x108(%rbp)
movq $0x0, -0xf8(%rbp)
movq $0x0, -0x118(%rbp)
movq $0x0, -0x120(%rbp)
movq $0x0, -0x110(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x15da60
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x15daad
movq -0x20(%rbp), %rdi
callq 0xe5910
movq %rax, -0x80(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x80(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x15daab
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x48(%rbp), %ecx
movb $0x0, 0x4(%rax,%rcx,8)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x15da74
jmp 0x15daad
movq -0x80(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x70(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x15db86
movl -0x48(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x54(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x15db00
jmp 0x15db78
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x48(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x15db18
jmp 0x15db78
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x15db76
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x58(%rbp)
movq -0x40(%rbp), %rdi
movl -0x58(%rbp), %esi
movl -0x54(%rbp), %edx
movq -0x20(%rbp), %rax
movq 0x20(%rax), %r8
movl -0x58(%rbp), %eax
shlq $0x3, %rax
addq %rax, %r8
addq $0x4, %r8
movl $0x1, %ecx
callq 0xd0e20
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x15db1f
jmp 0x15db78
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x15dac0
movq -0x70(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jae 0x15e3db
movl -0x48(%rbp), %eax
shrl %eax
movl %eax, -0x54(%rbp)
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x54(%rbp), %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x15dbcd
jmp 0x15e3cd
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x54(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x15dbf2
jmp 0x15e3cd
movq -0x78(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x15dc14
movq -0x78(%rbp), %rax
cmpl $-0x1, 0x4(%rax)
je 0x15dc14
movq -0x78(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x15dc19
jmp 0x15e3cd
movq -0x70(%rbp), %rdi
movl -0x48(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x166b50
cmpl $0x0, %eax
je 0x15dc33
jmp 0x15e3cd
movl -0x48(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x15dc4d
movq -0x78(%rbp), %rax
movl 0x4(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x15dc5a
movq -0x78(%rbp), %rax
movl 0x8(%rax), %eax
xorl $0x1, %eax
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movl -0x5c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xb8(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0xb8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x15ddb4
movq -0xb8(%rbp), %rax
movq (%rax), %rax
movl -0x4c(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc0(%rbp)
movq -0x38(%rbp), %rax
movq -0xc0(%rbp), %rcx
movq (%rcx), %rcx
shrq $0x20, %rcx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xc8(%rbp)
movq -0x38(%rbp), %rax
movq -0xc0(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x15dd1c
movq -0xd0(%rbp), %rax
movl (%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x15dd1c
movq -0xc0(%rbp), %rax
movq 0x18(%rax), %rax
shrq $0x3f, %rax
cmpl $0x0, %eax
je 0x15dd21
jmp 0x15dda6
movq -0xc0(%rbp), %rdi
movq -0xc8(%rbp), %rax
movl 0x4(%rax), %esi
movq -0xc8(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %esi
movq -0xd0(%rbp), %rax
movl 0x4(%rax), %edx
movq -0xd0(%rbp), %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl %eax, %edx
movl 0x10(%rbp), %ecx
leaq 0x266a92(%rip), %rax    # 0x3c47f8
movss 0x158(%rax), %xmm0
movl 0x18(%rbp), %r8d
leaq -0x98(%rbp), %r9
callq 0xd0300
movl %eax, -0xd4(%rbp)
cmpl $0x0, -0xd4(%rbp)
jge 0x15dd8f
jmp 0x15dda6
movq -0x98(%rbp), %rax
shrq $0x20, %rax
movl -0x5c(%rbp), %ecx
cmpq %rcx, %rax
je 0x15dda4
jmp 0x15dda6
jmp 0x15ddb4
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x15dc7a
movl -0x4c(%rbp), %eax
movq -0xb8(%rbp), %rcx
cmpl 0xc(%rcx), %eax
je 0x15ddc8
jmp 0x15e3cd
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x120(%rbp)
movq -0x80(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl 0x10(%rbp), %r9d
movl 0x18(%rbp), %r14d
movl -0x5c(%rbp), %ebx
leaq -0x54(%rbp), %r11
leaq -0x4c(%rbp), %r10
leaq -0xb0(%rbp), %rax
movl %r14d, (%rsp)
movl %ebx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movq %rax, 0x28(%rsp)
movl $0x1, 0x30(%rsp)
callq 0x169940
cmpl $0x0, %eax
je 0x15deeb
jmp 0x15de3f
movq -0x120(%rbp), %rax
cmpq -0x118(%rbp), %rax
jne 0x15dea3
cmpq $0x0, -0x118(%rbp)
je 0x15de6c
movq -0x118(%rbp), %rax
shlq %rax
movq %rax, -0x138(%rbp)
jmp 0x15de7a
movl $0x2, %eax
movq %rax, -0x138(%rbp)
jmp 0x15de7a
movq -0x138(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x110(%rbp), %rdi
imulq $0x18, -0x118(%rbp), %rsi
callq 0x2360
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq -0x120(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x120(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0xb0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xa8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xa0(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x15ddda
cmpq $0x0, -0x120(%rbp)
jbe 0x15e3cb
movq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x110(%rbp), %rdx
movq -0x120(%rbp), %rax
movl %eax, %ecx
callq 0x1516a0
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x120(%rbp), %rax
jae 0x15e3c9
movq -0x110(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x98(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x90(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x88(%rbp)
movl -0x8c(%rbp), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x15df71
jmp 0x15e3bb
movq -0x80(%rbp), %rdi
movq -0x40(%rbp), %rsi
movl -0x90(%rbp), %edx
callq 0x1515e0
movl %eax, -0x64(%rbp)
cmpl $-0x1, -0x64(%rbp)
jne 0x15df92
jmp 0x15e3bb
jmp 0x15df94
movq -0x108(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x15dff8
cmpq $0x0, -0x100(%rbp)
je 0x15dfc1
movq -0x100(%rbp), %rax
shlq %rax
movq %rax, -0x140(%rbp)
jmp 0x15dfcf
movl $0x2, %eax
movq %rax, -0x140(%rbp)
jmp 0x15dfcf
movq -0x140(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rdi
imulq $0x18, -0x100(%rbp), %rsi
callq 0x2360
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x108(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x8c(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x60(%rbp)
movq -0x70(%rbp), %rdi
movl -0x48(%rbp), %esi
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x48(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl -0x64(%rbp), %ecx
movl -0x60(%rbp), %r8d
movw -0x88(%rbp), %ax
shrw $0xe, %ax
andw $0x1, %ax
movb %al, %r9b
movb -0x86(%rbp), %r10b
movw -0x88(%rbp), %ax
shrw $0xf, %ax
movzbl %r9b, %r9d
movzbl %r10b, %r10d
movl %r10d, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
callq 0x141be0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl 0x10(%rbp), %ecx
movl 0x18(%rbp), %r8d
movl -0x90(%rbp), %r9d
xorl $0x1, %r9d
movq -0x98(%rbp), %rax
shrq $0x20, %rax
xorq $0x1, %rax
movl %eax, %r10d
leaq -0x98(%rbp), %rax
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0xe9560
movq -0x108(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x15e15a
cmpq $0x0, -0x100(%rbp)
je 0x15e123
movq -0x100(%rbp), %rax
shlq %rax
movq %rax, -0x148(%rbp)
jmp 0x15e131
movl $0x2, %eax
movq %rax, -0x148(%rbp)
jmp 0x15e131
movq -0x148(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xf8(%rbp), %rdi
imulq $0x18, -0x100(%rbp), %rsi
callq 0x2360
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movq -0x108(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x108(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x8c(%rbp), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x60(%rbp)
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %esi
xorl $0x1, %esi
movq -0x80(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x64(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl -0x48(%rbp), %ecx
xorl $0x1, %ecx
movl -0x60(%rbp), %r8d
movw -0x88(%rbp), %ax
shrw $0xe, %ax
andw $0x1, %ax
movb %al, %r9b
movb -0x86(%rbp), %r10b
movw -0x88(%rbp), %ax
shrw $0xf, %ax
movzbl %r9b, %r9d
movzbl %r10b, %r10d
movl %r10d, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
callq 0x141be0
movl -0x48(%rbp), %eax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x98(%rbp)
movl -0x64(%rbp), %eax
movl %eax, -0x90(%rbp)
movq -0xf0(%rbp), %rax
cmpq -0xe8(%rbp), %rax
jne 0x15e2a2
cmpq $0x0, -0xe8(%rbp)
je 0x15e26b
movq -0xe8(%rbp), %rax
shlq %rax
movq %rax, -0x150(%rbp)
jmp 0x15e279
movl $0x2, %eax
movq %rax, -0x150(%rbp)
jmp 0x15e279
movq -0x150(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rdi
imulq $0x18, -0xe8(%rbp), %rsi
callq 0x2360
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xf0(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x64(%rbp), %eax
xorl $0x1, %eax
movl %eax, %eax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
shlq $0x20, %rax
movq %rax, -0x98(%rbp)
movl -0x48(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x90(%rbp)
movq -0xf0(%rbp), %rax
cmpq -0xe8(%rbp), %rax
jne 0x15e376
cmpq $0x0, -0xe8(%rbp)
je 0x15e33f
movq -0xe8(%rbp), %rax
shlq %rax
movq %rax, -0x158(%rbp)
jmp 0x15e34d
movl $0x2, %eax
movq %rax, -0x158(%rbp)
jmp 0x15e34d
movq -0x158(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rdi
imulq $0x18, -0xe8(%rbp), %rsi
callq 0x2360
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
movq -0xf0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0xf0(%rbp)
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq -0x98(%rbp), %rcx
movq %rcx, (%rax)
movq -0x90(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x88(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x15e3bb
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x15df1d
jmp 0x15e3cb
jmp 0x15e3cd
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x15db9e
movq -0x70(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movslq %eax, %rdi
movl $0x1, %esi
callq 0x2140
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x70(%rbp), %rdi
movq 0x30(%rbp), %rsi
callq 0x151020
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0xf0(%rbp), %rax
jae 0x15e523
movq -0xe0(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
shrq $0x20, %rax
movl %eax, -0x48(%rbp)
movq -0xe0(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x48(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x15e476
jmp 0x15e515
movq -0x70(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x64(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x15e495
jmp 0x15e515
movq -0x70(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x48(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x15e4c4
movq -0x70(%rbp), %rax
movq 0x30(%rax), %rax
movl -0x64(%rbp), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
je 0x15e4c4
jmp 0x15e515
movq -0x70(%rbp), %rdi
movl -0x48(%rbp), %esi
movl -0x64(%rbp), %edx
movl $0x1, %ecx
callq 0xd6530
movq -0x70(%rbp), %rdi
movl -0x64(%rbp), %esi
xorl $0x1, %esi
movl -0x48(%rbp), %edx
xorl $0x1, %edx
movl $0x1, %ecx
callq 0xd6530
movq -0xf8(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x80000000, %ecx       # imm = 0x80000000
movl %ecx, 0xc(%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x15e415
movq -0x70(%rbp), %rdi
callq 0xcdd10
movq -0x70(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x2210
movq -0x70(%rbp), %rax
movq $0x0, 0x30(%rax)
movq $0x0, -0x128(%rbp)
movl $0x0, -0x12c(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpq -0x108(%rbp), %rax
jae 0x15e6b3
movq -0xf8(%rbp), %rax
movl -0x4c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x15e592
jmp 0x15e6a5
movq -0x20(%rbp), %rdi
callq 0xd4050
movq %rax, -0x128(%rbp)
movq -0xf8(%rbp), %rcx
movl -0x4c(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq -0x128(%rbp), %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
movl -0x12c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x12c(%rbp)
cmpq $0x0, 0x28(%rbp)
je 0x15e6a3
jmp 0x15e5ec
movq 0x28(%rbp), %rax
movq (%rax), %rax
movq 0x28(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x15e65a
movq 0x28(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x15e61c
movq 0x28(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x160(%rbp)
jmp 0x15e62a
movl $0x2, %eax
movq %rax, -0x160(%rbp)
jmp 0x15e62a
movq -0x160(%rbp), %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x28(%rbp), %rax
imulq $0x18, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq 0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0xf8(%rbp), %rcx
movl -0x4c(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq 0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rbp), %rsi
movq (%rsi), %rdx
movq %rdx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rcx
movq %rcx, 0x10(%rax)
jmp 0x15e6a3
jmp 0x15e6a5
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x15e561
cmpl $0x0, -0x12c(%rbp)
je 0x15e6f1
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2210
movq -0x20(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rdi
callq 0xcdd10
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x15e73d
movq -0x40(%rbp), %rdi
movl -0x48(%rbp), %esi
leaq -0x54(%rbp), %rdx
leaq -0x50(%rbp), %rcx
callq 0xd3d50
cmpl $0x1, -0x50(%rbp)
jne 0x15e730
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x48(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x15e732
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x15e6f8
cmpq $0x0, -0x18(%rbp)
jne 0x15e74d
movq -0x80(%rbp), %rdi
callq 0xcd6f0
movq -0xe0(%rbp), %rdi
callq 0x2210
movq -0xf8(%rbp), %rdi
callq 0x2210
movq -0x110(%rbp), %rdi
callq 0x2210
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r14
popq %rbp
retq
nopl (%rax)