// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/hic.cpp
// Function: update_bubble_chain(ma_ug_t*, bubble_type*, unsigned int, unsigned int)
void update_bubble_chain(ma_ug_t* ug, bubble_type* bub, uint32_t is_middle, uint32_t is_end)
{
    // double index_time = yak_realtime();
    if(bub->b_ug) ma_ug_destroy(bub->b_ug);
    if(bub->chain_weight.a) kv_destroy(bub->chain_weight);
    kvec_t_u32_warp broken;
    kv_init(broken.a);
    kvec_asg_arc_t_warp edges;
    kv_init(edges.a);
    ma_utg_t *u = NULL;
    asg_arc_t *t = NULL;
    asg_t *sg = ug->g;
    pdq pq;
    init_pdq(&pq, sg->n_seq<<1);
    asg_t *bsg = bub->b_g;
    ma_ug_t *bub_ug = NULL;
    bub_ug = ma_ug_gen(bub->b_g);
    uint32_t i, j, k_i, rId_0, ori_0, root_0, rId_1, ori_1, root_1, n_vtx = sg->n_seq<<1, new_bub;
    uint32_t *pre = NULL; MALLOC(pre, n_vtx); 
    uint8_t* vis_flag = NULL; MALLOC(vis_flag, ug->g->n_seq*2);
    kvec_t_u32_warp stack; kv_init(stack.a);
    ///chain_w_type x;
    ///uint64_t end_thres;

    uint8_t *bsg_idx = NULL; CALLOC(bsg_idx, n_vtx>>1); 
    for (i = 0; i < bub_ug->u.n; i++)///label all unitigs within the bubble chains
    {
        u = &(bub_ug->u.a[i]);///a bubble chain
        if(u->n == 0) continue;
        for (k_i = 0; k_i < u->n; k_i++)
        {
            uint32_t *a, n;
            get_bubbles(bub, u->a[k_i]>>33, &root_0, &root_1, &a, &n, NULL);
            for (j = 0; j < n; j++)
            {
                bsg_idx[a[j]>>1] = 1;
            }
            bsg_idx[root_0>>1] = 1;
            bsg_idx[root_1>>1] = 1;
        }
    }

    if(bub->num.n > 0) bub->num.n--;
    new_bub = bub->b_g->n_seq;
    for (i = 0; i < bub_ug->u.n; i++)
    {
        u = &(bub_ug->u.a[i]);///bubble chain
        if(u->n == 0) continue;
        ///end_thres = calculate_chain_weight(u, bub, ug, &x);
        if(is_middle)
        {
            for (k_i = 0; k_i < u->n; k_i++)
            {
                if(k_i+1 >= u->n) continue;
                ///note: must igore .del here, since bsg might be changed
                t = &(arc_first(bsg, u->a[k_i]>>32));
                if(t->el == 1) continue;///if a[k_i] and a[k_i+1] are directly connected without any tangle involoved

                rId_0 = u->a[k_i]>>33;
                ori_0 = u->a[k_i]>>32&1;
                get_bubbles(bub, rId_0, ori_0 == 1?&root_0:NULL, ori_0 == 0?&root_0:NULL, NULL, NULL, NULL);
                
                rId_1 = u->a[k_i+1]>>33;
                ori_1 = (u->a[k_i+1]>>32&1)^1;
                get_bubbles(bub, rId_1, ori_1 == 1?&root_1:NULL, ori_1 == 0?&root_1:NULL, NULL, NULL, NULL);

                broken.a.n = 0;///just collect all nodes between root_0 and root_1
                get_related_bub_nodes(&broken, bub, &pq, sg, pre, root_0, root_1, NULL);
                get_related_bub_nodes(&broken, bub, &pq, sg, pre, root_1, root_0, NULL);
                ///no need to cut the edge, we still have chance to flip by chain
                if(double_check_broken_bubble(ug->g, &broken, root_0^1, root_1^1, vis_flag, 
                                                                    ug->g->n_seq*2, &stack, NULL, NULL/**bsg, t**/) == 0)
                {
                    continue;
                }
                if(!IF_HOM(root_0>>1, *bub)) kv_push(uint32_t, broken.a, root_0);
                if(!IF_HOM(root_1>>1, *bub)) kv_push(uint32_t, broken.a, root_1);
                if(broken.a.n > 0)
                {
                    update_bubble_graph(&broken, root_0^1, rId_0, root_1^1, rId_1, bub, &edges, bsg, t, bsg_idx, ug, NULL, 1);
                }
            }
        }


        if(is_end)
        {
            if(u->n >0 && arc_cnt(bub_ug->g, (i<<1)+1) == 0)
            {
                rId_0 = u->a[0]>>33;
                ori_0 = (u->a[0]>>32&1)^1;
                get_bubbles(bub, rId_0, ori_0 == 1?&root_0:NULL, ori_0 == 0?&root_0:NULL, NULL, NULL, NULL);
                broken.a.n = 0;
                get_related_bub_nodes(&broken, bub, &pq, sg, pre, root_0, (uint32_t)-1, NULL);

                if(double_check_broken_bubble(ug->g, &broken, root_0^1, (uint32_t)-1, vis_flag, 
                                                                    ug->g->n_seq*2, &stack, NULL, NULL))
                {
                    if(!IF_HOM(root_0>>1, *bub)) kv_push(uint32_t, broken.a, root_0);
                    if(broken.a.n > 0)
                    {
                        ///fprintf(stderr, "root_0: utg%.6ul, broken.a.n: %u\n", (root_0>>1)+1, (uint32_t)broken.a.n);
                        update_bubble_graph(&broken, root_0^1, rId_0, (uint32_t)-1, (uint32_t)-1, bub, &edges, bsg, NULL, bsg_idx, ug, NULL, 0);
                    }
                }   
            }

        
            if(u->n >0 && arc_cnt(bub_ug->g, i<<1) == 0)
            {
                rId_1 = u->a[u->n-1]>>33;
                ori_1 = u->a[u->n-1]>>32&1;
                get_bubbles(bub, rId_1, ori_1 == 1?&root_1:NULL, ori_1 == 0?&root_1:NULL, NULL, NULL, NULL);
                broken.a.n = 0;
                get_related_bub_nodes(&broken, bub, &pq, sg, pre, root_1, (uint32_t)-1, bsg_idx);

                if(double_check_broken_bubble(ug->g, &broken, root_1^1, (uint32_t)-1, vis_flag, 
                                                                    ug->g->n_seq*2, &stack, NULL, NULL))
                {
                    if(!IF_HOM(root_1>>1, *bub)) kv_push(uint32_t, broken.a, root_1);
                    if(broken.a.n > 0)
                    {
                        ///fprintf(stderr, "root_1: utg%.6ul, broken.a.n: %u\n", (root_1>>1)+1, (uint32_t)broken.a.n);
                        update_bubble_graph(&broken, (uint32_t)-1, (uint32_t)-1, root_1^1, rId_1, bub, &edges, bsg, NULL, bsg_idx, ug, NULL, 0);
                    }

                }
            }
        }
    }
    kv_push(uint32_t, bub->num, bub->list.n);
    new_bub = bub->b_g->n_seq - new_bub;
    if(is_end) bub->b_end_bub += new_bub;
    ///actually not useful, and may have bug when one bubble at multipe chains
    if(new_bub) update_bub_b_s_idx(bub);


    for (i = 0; i < edges.a.n; i++)
    {        
        t = asg_arc_pushp(bsg);
        *t = edges.a.a[i];
    }

    bsg->is_srt = 0; free(bsg->idx); bsg->idx = 0;
    asg_cleanup(bsg);
    ma_ug_destroy(bub_ug);
    destory_pdq(&pq);
    free(pre);
    kv_destroy(broken.a);
    kv_destroy(edges.a);
    free(bsg_idx);
    kv_destroy(stack.a); 
    free(vis_flag);

    bub->b_ug = ma_ug_gen(bub->b_g);
    bub_ug = bub->b_ug;
    kv_malloc(bub->chain_weight, bub_ug->u.n); bub->chain_weight.n = bub_ug->u.n;
    for (i = 0; i < bub_ug->u.n; i++)
    {
        u = &(bub_ug->u.a[i]);
        bub->chain_weight.a[i].id = i;
        // if(u->n <= 1) ///not a chain
        // {
        //     bub->chain_weight.a[i].b_occ = bub->chain_weight.a[i].g_occ = 0;
        //     bub->chain_weight.a[i].del = 1;
        // } 
        // else
        {
            bub->chain_weight.a[i].del = 0;
            calculate_chain_weight(u, bub, ug, &(bub->chain_weight.a[i]));
        }
    }

    qsort(bub->chain_weight.a, bub->chain_weight.n, sizeof(chain_w_type), cmp_chain_weight);



    /**
    uint32_t d_v, d_u, v;
    for (i = 0; i < bsg->n_arc; i++)
    {
        d_v = (uint32_t)(bsg->arc[i].ul>>32);
        d_u = bsg->arc[i].v;
        for (v = 0; v < bsg->n_arc; v++)
        {
            if(((bsg->arc[v].ul>>32) == (d_u^1)) && (bsg->arc[v].v == (d_v^1))) break;      
        }

        if(v == bsg->n_arc)
        {
            fprintf(stderr, "hahaha, el: %u, ul>>33: %lu, ul&1: %lu, v>>1: %u, v&1: %u\n", 
                    bsg->arc[i].el, bsg->arc[i].ul>>33, (bsg->arc[i].ul>>32)&1, bsg->arc[i].v>>1, bsg->arc[i].v&1);
        }
        // else
        // {
        //     fprintf(stderr, "hehehe, el: %u, ul>>33: %lu, ul&1: %lu, v>>1: %u, v&1: %u\n", 
        //             bsg->arc[i].el, bsg->arc[i].ul>>33, (bsg->arc[i].ul>>32)&1, bsg->arc[i].v>>1, bsg->arc[i].v&1);
        // }
    }

    asg_arc_t *av = NULL, *au = NULL;
    uint32_t nv, nu;
    for (v = 0; v < (uint32_t)(bsg->n_seq<<1); v++)
    {
        av = asg_arc_a(bsg, v);
        nv = asg_arc_n(bsg, v);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;

            au = asg_arc_a(bsg, av[i].v^1);
            nu = asg_arc_n(bsg, av[i].v^1);
            for (k_i = 0; k_i < nu; k_i++)
            {
                if(au[k_i].del) continue;
                if(au[k_i].v == (v^1)) break;
            }
            if(k_i == nu) fprintf(stderr, "hahaha: v: %u, u: %u\n", v, av[i].v);
        }        
    }
    **/
    // fprintf(stderr, "[M::%s::%.3f]\n", __func__, yak_realtime()-index_time);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movl %ecx, 0x94(%rsp)
movl %edx, 0xbc(%rsp)
movq %rdi, %r15
movq 0xc0(%rsi), %rdi
testq %rdi, %rdi
movq %rsi, 0x40(%rsp)
je 0x148f83
callq 0xa0004
movq 0x40(%rsp), %rsi
movq 0xd8(%rsi), %rdi
testq %rdi, %rdi
je 0x148f94
callq 0x2220
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
xorl %r14d, %r14d
movq %r14, 0x60(%rsp)
movq %r14, 0xe0(%rsp)
movaps %xmm0, 0xd0(%rsp)
movq 0x18(%r15), %rbx
movl 0x14(%rbx), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x130(%rsp), %rdi
callq 0x13bb82
movq 0x40(%rsp), %rax
movq 0xb8(%rax), %rdi
movq %rdi, 0x48(%rsp)
callq 0xb0285
movq %rax, %r13
movq %rbx, 0xb0(%rsp)
movl 0x14(%rbx), %ebx
leal (%rbx,%rbx), %edi
shlq $0x2, %rdi
callq 0x2280
movq %rax, 0x98(%rsp)
movq %r15, 0x78(%rsp)
movq 0x18(%r15), %rax
movl 0x14(%rax), %edi
addl %edi, %edi
callq 0x2280
movq %rax, 0xa0(%rsp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x1, %esi
movq %rbx, %rdi
callq 0x2120
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
movq %r14, 0x120(%rsp)
cmpq %r14, (%r13)
je 0x1490ec
movb $0x1, %al
movq 0x10(%r13), %rcx
leaq (%r14,%r14,4), %rdx
cmpl $0x0, 0x10(%rcx,%rdx,8)
je 0x1490df
leaq (%rcx,%rdx,8), %rcx
cmpl $0x0, 0x10(%rcx)
je 0x1490df
movq 0x40(%rsp), %rsi
movq 0x28(%rsi), %rdx
movq 0x40(%rsi), %rsi
xorl %edi, %edi
movq 0x18(%rcx), %r8
movq (%r8,%rdi,8), %r8
shrq $0x21, %r8
movl (%rsi,%r8,4), %r10d
movl 0x4(%rsi,%r8,4), %r11d
subl %r10d, %r11d
leal 0x1(%r10), %r8d
movl (%rdx,%r10,4), %r9d
movl (%rdx,%r8,4), %r8d
addl $-0x2, %r11d
je 0x1490c5
leaq (%rdx,%r10,4), %r10
movl %r11d, %r11d
xorl %ebx, %ebx
movl 0x8(%r10,%rbx,4), %r12d
shrl %r12d
movb $0x1, (%r15,%r12)
incq %rbx
cmpq %rbx, %r11
jne 0x1490b0
shrl %r9d
movb %al, (%r15,%r9)
shrl %r8d
movb %al, (%r15,%r8)
incq %rdi
movl 0x10(%rcx), %r8d
cmpq %r8, %rdi
jb 0x14907d
incl %r14d
cmpq %r14, (%r13)
ja 0x149055
movq 0x40(%rsp), %rdi
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x149101
decq %rax
movq %rax, 0x30(%rdi)
movq 0xb8(%rdi), %rax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl 0x14(%rax), %ecx
movl %ecx, 0xb8(%rsp)
cmpq $0x0, (%r13)
movq 0x48(%rsp), %r8
movq %r13, 0xc0(%rsp)
je 0x149898
movabsq $0x100000000, %r12      # imm = 0x100000000
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x10(%r13), %rcx
leaq (%rax,%rax,4), %rax
cmpl $0x0, 0x10(%rcx,%rax,8)
je 0x1494f7
movq %rbx, 0xa8(%rsp)
leaq (%rcx,%rax,8), %r9
cmpl $0x0, 0xbc(%rsp)
movq %r9, 0x80(%rsp)
je 0x1494ab
movl 0x10(%r9), %eax
testl %eax, %eax
je 0x1494ab
movl $0x1, %r14d
movl %eax, %eax
cmpq %rax, %r14
jae 0x149497
movq 0x8(%r8), %r10
movq 0x28(%r8), %rdx
movq 0x18(%r9), %rax
movq -0x8(%rax,%r14,8), %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
movl 0x4(%rdx,%rsi,8), %edx
leaq (%rdx,%rdx,2), %rdx
movq %r10, 0x88(%rsp)
movq %rdx, 0x108(%rsp)
cmpb $0x1, 0x12(%r10,%rdx,8)
je 0x149497
movq %rcx, %rdx
shrq $0x21, %rdx
testq %r12, %rcx
jne 0x1491e2
movq 0x40(%rdi), %rcx
movl (%rcx,%rdx,4), %ecx
incl %ecx
jmp 0x1491e9
movq 0x40(%rdi), %rcx
movl (%rcx,%rdx,4), %ecx
movq (%rax,%r14,8), %rax
movq %rax, %rsi
shrq $0x21, %rsi
testq %r12, %rax
movq %rdx, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
jne 0x149212
movq 0x40(%rdi), %rax
movl (%rax,%rsi,4), %eax
jmp 0x14921b
movq 0x40(%rdi), %rax
movl (%rax,%rsi,4), %eax
incl %eax
movq 0x28(%rdi), %rdx
movl %ecx, %ecx
movl (%rdx,%rcx,4), %r12d
movq 0x28(%rdi), %rcx
movl %eax, %eax
movl (%rcx,%rax,4), %ebp
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movq %rax, 0x8(%rsp)
movl %ebp, (%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x130(%rsp), %rdx
movq 0xb0(%rsp), %r13
movq %r13, %rcx
movq 0x98(%rsp), %rbx
movq %rbx, %r8
movl %r12d, %r9d
callq 0x146405
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movl %r12d, (%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x130(%rsp), %rdx
movq %r13, %rcx
movq %rbx, %r8
movl %ebp, %r9d
callq 0x146405
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
movq %r12, %rbx
movl %r12d, %r13d
xorl $0x1, %r13d
movq %rbp, 0xc8(%rsp)
xorl $0x1, %ebp
movl 0x14(%rdi), %r9d
addl %r9d, %r9d
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, (%rsp)
leaq 0x50(%rsp), %rsi
movl %r13d, %edx
movl %ebp, %ecx
movq 0xa0(%rsp), %r8
callq 0x1458a8
movq 0x40(%rsp), %rdi
testl %eax, %eax
movq 0x48(%rsp), %r8
movabsq $0x100000000, %r12      # imm = 0x100000000
movq 0x80(%rsp), %r9
je 0x149497
movl %ebp, %r12d
movl %ebx, %eax
shrl %eax
movq (%rdi), %rcx
movq 0x80(%rdi), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x14937b
movq %rbx, %rbp
movq 0x50(%rsp), %rbx
movq 0x58(%rsp), %rax
cmpq %rax, %rbx
jne 0x14936a
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x80(%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
leaq 0x1(%rbx), %rcx
movq %rcx, 0x50(%rsp)
movl %ebp, (%rax,%rbx,4)
movq 0xc8(%rsp), %rax
shrl %eax
movq (%rdi), %rcx
movq 0x80(%rdi), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x1493fc
movq 0x50(%rsp), %rbp
movq 0x58(%rsp), %rax
cmpq %rax, %rbp
jne 0x1493e3
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x80(%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
leaq 0x1(%rbp), %rcx
movq %rcx, 0x50(%rsp)
movq 0xc8(%rsp), %rcx
movl %ecx, (%rax,%rbp,4)
cmpq $0x0, 0x50(%rsp)
movl %r12d, %r10d
movabsq $0x100000000, %r12      # imm = 0x100000000
je 0x149497
movq 0x88(%rsp), %rax
movq 0x108(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq 0x78(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %r8, 0x8(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq $0x1, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
leaq 0x50(%rsp), %rdi
movl %r13d, %esi
movq 0x100(%rsp), %rdx
movl %r10d, %ecx
movq 0xf8(%rsp), %r8
movq 0x40(%rsp), %r9
callq 0x145cd9
movq 0x80(%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
movl 0x10(%r9), %eax
leaq 0x1(%r14), %rcx
cmpq %rax, %r14
movq %rcx, %r14
jb 0x149184
cmpl $0x0, 0x94(%rsp)
movq 0xc0(%rsp), %r13
movq 0xa8(%rsp), %rbx
je 0x1494f7
cmpl $0x0, 0x10(%r9)
je 0x1494de
movq 0x18(%r13), %rax
movq 0x28(%rax), %rax
leal (%rbx,%rbx), %ecx
cmpl $0x0, 0x8(%rax,%rcx,8)
je 0x14950b
movl 0x10(%r9), %eax
testl %eax, %eax
je 0x1494f7
movq 0x18(%r13), %rcx
movq 0x28(%rcx), %rcx
leal (%rbx,%rbx), %edx
cmpl $0x0, (%rcx,%rdx,8)
je 0x14952f
incl %ebx
movq %rbx, %rax
cmpq %rbx, (%r13)
ja 0x14913d
jmp 0x149898
movq 0x18(%r9), %rax
movq (%rax), %rax
movq %rax, %rcx
shrq $0x21, %rcx
testq %r12, %rax
movq %rcx, 0x88(%rsp)
jne 0x14955f
movq 0x40(%rdi), %rax
movl (%rax,%rcx,4), %eax
jmp 0x149568
movq 0x18(%r9), %rcx
decl %eax
movq (%rcx,%rax,8), %rax
movq %rax, %rcx
shrq $0x21, %rcx
testq %r12, %rax
movq %rcx, 0x88(%rsp)
jne 0x149708
movq 0x40(%rdi), %rax
movl (%rax,%rcx,4), %eax
incl %eax
jmp 0x14970f
movq 0x40(%rdi), %rax
movl (%rax,%rcx,4), %eax
incl %eax
movq 0x28(%rdi), %rcx
movl %eax, %eax
movl (%rcx,%rax,4), %r14d
xorl %eax, %eax
movq %rax, 0x50(%rsp)
movq %rax, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
leaq 0x130(%rsp), %rdx
movq 0xb0(%rsp), %rcx
movq 0x98(%rsp), %r8
movl %r14d, %r9d
callq 0x146405
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
movl %r14d, %ebp
xorl $0x1, %ebp
movl 0x14(%rdi), %r9d
addl %r9d, %r9d
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rsi
movl %ebp, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0xa0(%rsp), %r8
callq 0x1458a8
movq 0x40(%rsp), %rdi
testl %eax, %eax
movq 0x48(%rsp), %r8
movq 0xa8(%rsp), %rbx
movq 0x80(%rsp), %r9
je 0x1494de
movl %r14d, %eax
shrl %eax
movq (%rdi), %rcx
movq 0x80(%rdi), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x149690
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %rax
cmpq %rax, %r12
jne 0x149673
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x80(%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
leaq 0x1(%r12), %rcx
movq %rcx, 0x50(%rsp)
movl %r14d, (%rax,%r12,4)
movabsq $0x100000000, %r12      # imm = 0x100000000
cmpq $0x0, 0x50(%rsp)
je 0x1494de
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %r8, 0x8(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x50(%rsp), %rdi
movl %ebp, %esi
movq 0x88(%rsp), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq 0x40(%rsp), %r9
callq 0x145cd9
movq 0x80(%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
jmp 0x1494de
movq 0x40(%rdi), %rax
movl (%rax,%rcx,4), %eax
movq 0x28(%rdi), %rcx
movl %eax, %eax
movl (%rcx,%rax,4), %r14d
movq $0x0, 0x50(%rsp)
movq %r15, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
leaq 0x130(%rsp), %rdx
movq 0xb0(%rsp), %rcx
movq 0x98(%rsp), %r8
movl %r14d, %r9d
callq 0x146405
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rdi
movl %r14d, %ebp
xorl $0x1, %ebp
movl 0x14(%rdi), %r9d
addl %r9d, %r9d
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rsi
movl %ebp, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0xa0(%rsp), %r8
callq 0x1458a8
movq 0x40(%rsp), %rdi
testl %eax, %eax
movq 0x48(%rsp), %r8
movq 0xa8(%rsp), %rbx
je 0x1494f7
movl %r14d, %eax
shrl %eax
movq (%rdi), %rcx
movq 0x80(%rdi), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x149829
movq 0x50(%rsp), %r12
movq 0x58(%rsp), %rax
cmpq %rax, %r12
jne 0x14980c
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rax
leaq 0x1(%r12), %rcx
movq %rcx, 0x50(%rsp)
movl %r14d, (%rax,%r12,4)
movabsq $0x100000000, %r12      # imm = 0x100000000
cmpq $0x0, 0x50(%rsp)
je 0x1494f7
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0x78(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %r8, 0x8(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x50(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
movq 0x88(%rsp), %r8
movq 0x40(%rsp), %r9
callq 0x145cd9
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
jmp 0x1494f7
movq 0x38(%rdi), %rax
cmpq %rax, 0x30(%rdi)
jne 0x1498d1
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x38(%rdi)
movq 0x40(%rdi), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x48(%rsp), %r8
movq 0x40(%rsp), %rdi
movq %rax, 0x40(%rdi)
movl 0x18(%rdi), %eax
movq 0x40(%rdi), %rcx
movq 0x30(%rdi), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x30(%rdi)
movl %eax, (%rcx,%rdx,4)
movq 0xb8(%rdi), %rcx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x14(%rcx), %eax
cmpl $0x0, 0x94(%rsp)
movl 0xb8(%rsp), %edx
je 0x149912
movl %eax, %ecx
subl %edx, %ecx
addq %rcx, 0x90(%rdi)
cmpl %edx, %eax
je 0x149920
callq 0x1394bc
movq 0x48(%rsp), %r8
movq 0xd0(%rsp), %rbx
testq %rbx, %rbx
je 0x1499d4
movl $0x1, %ebp
movq 0xe0(%rsp), %r14
xorl %r13d, %r13d
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl 0x4(%r8), %ecx
andl %r12d, %ecx
movl (%r8), %eax
cmpl %eax, %ecx
jne 0x14997f
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%r8)
movq 0x8(%r8), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq 0x48(%rsp), %r8
movq %rax, 0x8(%r8)
movq 0x8(%r8), %rax
movl 0x4(%r8), %ecx
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leal 0x1(%rcx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %esi, %ecx
movl %ecx, 0x4(%r8)
leaq (%rdx,%rdx,2), %rcx
leaq (,%r13,2), %rdx
addq %r13, %rdx
movq 0x10(%r14,%rdx,8), %rsi
movq %rsi, 0x10(%rax,%rcx,8)
movups (%r14,%rdx,8), %xmm0
movups %xmm0, (%rax,%rcx,8)
movl %ebp, %r13d
incl %ebp
cmpq %r13, %rbx
ja 0x149947
andb $0x7f, 0x7(%r8)
movq 0x28(%r8), %rdi
movq %r8, %rbx
callq 0x2220
xorl %r14d, %r14d
movq %r14, 0x28(%rbx)
movq %rbx, %rdi
callq 0xa02fa
movq 0xc0(%rsp), %rdi
callq 0xa0004
movq 0x158(%rsp), %rdi
callq 0x2220
movq 0x170(%rsp), %rdi
callq 0x2220
movq 0x140(%rsp), %rdi
callq 0x2220
movq 0x98(%rsp), %rdi
callq 0x2220
movq 0x60(%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq 0x120(%rsp), %rdi
callq 0x2220
movq 0xa0(%rsp), %rdi
callq 0x2220
movq 0x40(%rsp), %r12
movq 0xb8(%r12), %rdi
callq 0xb0285
movq %rax, %rbx
movq %rax, 0xc0(%r12)
movq %r14, 0xc8(%r12)
movq (%rax), %r15
movq %r15, 0xd0(%r12)
movq %r15, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %r12, %r8
movq %rax, 0xd8(%r12)
movq %r15, 0xc8(%r12)
cmpq %r14, (%rbx)
movq 0x78(%rsp), %r14
je 0x149b0f
movl $0x1, %ebp
xorl %eax, %eax
leaq (%rax,%rax,4), %rdi
shlq $0x3, %rdi
addq 0x10(%rbx), %rdi
movq 0xd8(%r8), %rdx
movq %rax, %rsi
shlq $0x5, %rsi
leaq (%rdx,%rsi), %rcx
movq %rax, 0x10(%rdx,%rsi)
movb $0x0, 0x18(%rdx,%rsi)
movq %r8, %rsi
movq %r14, %rdx
callq 0x14655c
movq 0x40(%rsp), %r8
movl %ebp, %eax
incl %ebp
cmpq %rax, (%rbx)
ja 0x149ace
movq 0xc8(%r8), %rsi
movq 0xd8(%r8), %rdi
leaq -0x3466(%rip), %rcx     # 0x1466be
movl $0x20, %edx
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x23f0