// File: /workspace/github_cpp_makefile_star2_O3/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 $0x188, %rsp            # imm = 0x188
movl %ecx, 0x74(%rsp)
movl %edx, 0xb4(%rsp)
movq %rsi, %r13
movq %rdi, %rbx
movq 0xc0(%rsi), %rdi
testq %rdi, %rdi
je 0x14f593
callq 0xa0761
movq %rbx, 0x60(%rsp)
movq 0xd8(%r13), %rdi
testq %rdi, %rdi
je 0x14f5a9
callq 0x2220
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
xorl %r14d, %r14d
movq %r14, 0x50(%rsp)
movq %r14, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
movq 0x60(%rsp), %r15
movq 0x18(%r15), %rbx
movl 0x14(%rbx), %eax
addl %eax, %eax
movslq %eax, %rsi
leaq 0x120(%rsp), %rdi
callq 0x14198e
movq 0xb8(%r13), %rdi
movq %rdi, 0x38(%rsp)
callq 0xb10cd
movq %rax, %rbp
movq %rbx, 0x98(%rsp)
movl 0x14(%rbx), %ebx
leal (%rbx,%rbx), %edi
shlq $0x2, %rdi
callq 0x2280
movq %rax, 0x80(%rsp)
movq 0x18(%r15), %rax
movl 0x14(%rax), %edi
addl %edi, %edi
callq 0x2280
movq %rax, 0x88(%rsp)
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x1, %esi
movq %rbx, %rdi
callq 0x2120
movq %rax, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x100(%rsp)
movq %r14, 0x110(%rsp)
movq (%rbp), %rcx
movb $0x1, %al
testq %rcx, %rcx
je 0x14f709
movq 0x38(%rsp), %rdi
movq 0x10(%rbp), %rdx
leaq (%r14,%r14,4), %rsi
cmpl $0x0, 0x10(%rdx,%rsi,8)
je 0x14f6f5
leaq (%rdx,%rsi,8), %rcx
movq 0x28(%r13), %rdx
movq 0x40(%r13), %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 0x14f6d2
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 0x14f6bd
shrl %r9d
movb %al, (%r15,%r9)
shrl %r8d
movb %al, (%r15,%r8)
incq %rdi
movl 0x10(%rcx), %r8d
cmpq %r8, %rdi
jb 0x14f68a
movq (%rbp), %rcx
movq 0x38(%rsp), %rdi
incl %r14d
cmpq %r14, %rcx
ja 0x14f66d
testq %rcx, %rcx
sete %al
jmp 0x14f70e
movq 0x38(%rsp), %rdi
movq 0x30(%r13), %rcx
testq %rcx, %rcx
je 0x14f720
decq %rcx
movq %rcx, 0x30(%r13)
jmp 0x14f722
xorl %ecx, %ecx
movq 0xb8(%r13), %rdx
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andl 0x14(%rdx), %ebx
testb %al, %al
movq %r13, 0x68(%rsp)
movq %rbp, 0x78(%rsp)
jne 0x14fe1f
movl %ebx, 0xb0(%rsp)
xorl %eax, %eax
movq $0x0, 0x90(%rsp)
movq 0x10(%rbp), %rcx
leaq (%rax,%rax,4), %rdx
movl 0x10(%rcx,%rdx,8), %eax
testl %eax, %eax
je 0x14fad0
leaq (%rcx,%rdx,8), %r14
cmpl $0x0, 0xb4(%rsp)
movq %r14, 0xa0(%rsp)
je 0x14fa7f
movl $0x1, %ebp
movl %eax, %eax
cmpq %rax, %rbp
jae 0x14fa59
movq 0x8(%rdi), %r8
movq 0x28(%rdi), %rdx
movq 0x18(%r14), %rax
movq -0x8(%rax,%rbp,8), %rcx
movq %rcx, %rsi
shrq $0x20, %rsi
movl 0x4(%rdx,%rsi,8), %edx
leaq (%rdx,%rdx,2), %rdx
movq %r8, 0xa8(%rsp)
movq %rdx, 0xd8(%rsp)
cmpb $0x1, 0x12(%r8,%rdx,8)
je 0x14fa59
movq %rcx, %rdi
shrq $0x21, %rdi
movabsq $0x100000000, %rdx      # imm = 0x100000000
andq %rdx, %rcx
movq 0x68(%rsp), %rsi
movq 0x28(%rsi), %rdx
movq 0x40(%rsi), %rsi
movq %rdi, 0xd0(%rsp)
movl (%rsi,%rdi,4), %edi
cmpq $0x1, %rcx
adcl $0x0, %edi
movl (%rdx,%rdi,4), %ebx
movq (%rax,%rbp,8), %rax
movq %rax, %rcx
shrq $0x21, %rcx
movq %rcx, 0xc8(%rsp)
movl (%rsi,%rcx,4), %ecx
btq $0x20, %rax
adcl $0x0, %ecx
movl (%rdx,%rcx,4), %r14d
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0x8(%rsp)
movl %r14d, (%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x120(%rsp), %rdx
movq 0x98(%rsp), %r13
movq %r13, %rcx
movq 0x80(%rsp), %r12
movq %r12, %r8
movl %ebx, %r9d
callq 0x14caae
xorl %eax, %eax
movq %rax, 0x8(%rsp)
movl %ebx, (%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x120(%rsp), %rdx
movq %r13, %rcx
movq %r12, %r8
movl %r14d, %r9d
callq 0x14caae
movq 0x60(%rsp), %rax
movq 0x18(%rax), %rdi
movq %rbx, %r12
xorl $0x1, %ebx
movq %r14, 0xb8(%rsp)
movl %r14d, %r13d
movq 0xa0(%rsp), %r14
xorl $0x1, %r13d
movl 0x14(%rdi), %r9d
addl %r9d, %r9d
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, (%rsp)
leaq 0x40(%rsp), %rsi
movl %ebx, %edx
movl %r13d, %ecx
movq 0x88(%rsp), %r8
callq 0x14beef
movq 0x38(%rsp), %rdi
testl %eax, %eax
je 0x14fa59
movq 0x68(%rsp), %rax
movq (%rax), %rdx
movq 0x80(%rax), %rcx
movl %r12d, %eax
shrl %eax
movl (%rdx,%rax,4), %eax
incq %rcx
cmpq %rax, %rcx
jb 0x14f979
movq 0x40(%rsp), %r8
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %r8
jne 0x14f96c
leaq (%r8,%r8), %rsi
testq %r8, %r8
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
movq %r8, 0xc0(%rsp)
callq 0x2370
movq 0xc0(%rsp), %r8
movq 0x38(%rsp), %rdi
movq %rax, 0x50(%rsp)
movq 0x68(%rsp), %rcx
movq (%rcx), %rdx
movq 0x80(%rcx), %rcx
incq %rcx
leaq 0x1(%r8), %rsi
movq %rsi, 0x40(%rsp)
movl %r12d, (%rax,%r8,4)
movq 0xb8(%rsp), %rax
shrl %eax
movl (%rdx,%rax,4), %eax
movq 0x40(%rsp), %r12
cmpq %rax, %rcx
jb 0x14f9e0
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %r12
jne 0x14f9c7
leaq (%r12,%r12), %rsi
testq %r12, %r12
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x38(%rsp), %rdi
movq %rax, 0x50(%rsp)
leaq 0x1(%r12), %rcx
movq %rcx, 0x40(%rsp)
movq 0xb8(%rsp), %rdx
movl %edx, (%rax,%r12,4)
movq %rcx, %r12
testq %r12, %r12
je 0x14fa59
movq 0xa8(%rsp), %rax
movq 0xd8(%rsp), %rcx
leaq (%rax,%rcx,8), %rax
movq 0x60(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, (%rsp)
movq $0x1, 0x30(%rsp)
movq $0x0, 0x28(%rsp)
leaq 0x40(%rsp), %rdi
movl %ebx, %esi
movq 0xd0(%rsp), %rdx
movl %r13d, %ecx
movq 0xc8(%rsp), %r8
movq 0x68(%rsp), %r9
callq 0x14c338
movq 0x38(%rsp), %rdi
movl 0x10(%r14), %eax
leaq 0x1(%rbp), %rcx
cmpq %rax, %rbp
movq %rcx, %rbp
jb 0x14f78b
cmpl $0x0, 0x74(%rsp)
movq 0x68(%rsp), %r13
je 0x14fad0
testl %eax, %eax
jne 0x14fa86
jmp 0x14fad0
cmpl $0x0, 0x74(%rsp)
je 0x14fad0
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movq 0x90(%rsp), %rcx
leal (%rcx,%rcx), %r12d
cmpl $0x0, 0x8(%rax,%r12,8)
je 0x14faf9
movq 0xa0(%rsp), %rsi
movl 0x10(%rsi), %eax
testl %eax, %eax
je 0x14fad0
movq 0x78(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl %r12d, %edx
cmpl $0x0, (%rcx,%rdx,8)
je 0x14fc8d
movq 0x90(%rsp), %rdx
incl %edx
movq %rdx, %rax
movq 0x78(%rsp), %rbp
movq %rdx, 0x90(%rsp)
cmpq %rdx, (%rbp)
ja 0x14f758
jmp 0x14fe14
movq 0xa0(%rsp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, %rsi
shrq $0x21, %rsi
movq 0x28(%r13), %rcx
movq 0x40(%r13), %rdx
movq %rsi, 0xa8(%rsp)
movl (%rdx,%rsi,4), %edx
btq $0x20, %rax
adcl $0x0, %edx
movl (%rcx,%rdx,4), %r14d
xorl %eax, %eax
movq %rax, 0x40(%rsp)
movq %rax, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
leaq 0x120(%rsp), %rdx
movq 0x98(%rsp), %rcx
movq 0x80(%rsp), %r8
movl %r14d, %r9d
callq 0x14caae
movq 0x60(%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 0x100(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rsi
movl %ebp, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x88(%rsp), %r8
callq 0x14beef
movq 0x38(%rsp), %rdi
testl %eax, %eax
je 0x14faa7
movl %r14d, %eax
shrl %eax
movq (%r13), %rcx
movq 0x80(%r13), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
movq 0x40(%rsp), %r13
cmpq %rax, %rdx
jb 0x14fc22
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %r13
jne 0x14fc12
leaq (,%r13,2), %rsi
testq %r13, %r13
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x38(%rsp), %rdi
movq %rax, 0x50(%rsp)
leaq 0x1(%r13), %rcx
movq %rcx, 0x40(%rsp)
movl %r14d, (%rax,%r13,4)
movq %rcx, %r13
testq %r13, %r13
movq 0x68(%rsp), %r13
je 0x14faa7
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
movl %ebp, %esi
movq 0xa8(%rsp), %rdx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r13, %r9
callq 0x14c338
movq 0x38(%rsp), %rdi
jmp 0x14faa7
movq 0x18(%rsi), %rcx
decl %eax
movq (%rcx,%rax,8), %rax
movq %rax, %rbx
shrq $0x21, %rbx
movabsq $0x100000000, %rcx      # imm = 0x100000000
andq %rcx, %rax
movq 0x28(%r13), %rcx
movq 0x40(%r13), %rdx
movl (%rdx,%rbx,4), %edx
cmpq $0x1, %rax
adcl $0x0, %edx
movl (%rcx,%rdx,4), %r14d
movq $0x0, 0x40(%rsp)
movq %r15, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x40(%rsp), %r12
movq %r12, %rdi
leaq 0x120(%rsp), %rdx
movq 0x98(%rsp), %rcx
movq 0x80(%rsp), %r8
movl %r14d, %r9d
callq 0x14caae
movq 0x60(%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 0x100(%rsp), %rax
movq %rax, (%rsp)
movq %r12, %rsi
movl %ebp, %edx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x88(%rsp), %r8
callq 0x14beef
movq 0x38(%rsp), %rdi
testl %eax, %eax
je 0x14fad0
movl %r14d, %eax
shrl %eax
movq (%r13), %rcx
movq 0x80(%r13), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
movq 0x40(%rsp), %r12
cmpq %rax, %rdx
jb 0x14fdb4
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %r12
jne 0x14fda3
leaq (%r12,%r12), %rsi
testq %r12, %r12
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x38(%rsp), %rdi
movq %rax, 0x50(%rsp)
leaq 0x1(%r12), %rcx
movq %rcx, 0x40(%rsp)
movl %r14d, (%rax,%r12,4)
movq %rcx, %r12
testq %r12, %r12
je 0x14fad0
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %r15, 0x18(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x40(%rsp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %ebp, %ecx
movl %ebx, %r8d
movq %r13, %r9
callq 0x14c338
movq 0x38(%rsp), %rdi
jmp 0x14fad0
movq 0x30(%r13), %rcx
movl 0xb0(%rsp), %ebx
cmpq 0x38(%r13), %rcx
jne 0x14fe55
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rax, %rsi
movq %rsi, 0x38(%r13)
movq 0x40(%r13), %rdi
shlq $0x2, %rsi
callq 0x2370
movq 0x38(%rsp), %rdi
movq %rax, 0x40(%r13)
movq 0x30(%r13), %rcx
jmp 0x14fe59
movq 0x40(%r13), %rax
movl 0x18(%r13), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r13)
movl %edx, (%rax,%rcx,4)
movq 0xb8(%r13), %rcx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x14(%rcx), %eax
cmpl $0x0, 0x74(%rsp)
je 0x14fe89
movl %eax, %ecx
subl %ebx, %ecx
addq %rcx, 0x90(%r13)
cmpl %ebx, %eax
je 0x14fe9a
movq %r13, %rdi
callq 0x13f2d9
movq 0x38(%rsp), %rdi
movq 0xe0(%rsp), %r14
movq 0xf0(%rsp), %rbx
testq %r14, %r14
je 0x14ff50
movl $0x1, %ebp
xorl %r13d, %r13d
movl $0x10, %r12d
movl 0x4(%rdi), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%rdi), %ecx
jne 0x14ff07
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
cmovel %r12d, %eax
movl %eax, (%rdi)
movq 0x38(%rsp), %rcx
movq 0x8(%rcx), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq 0x38(%rsp), %rdi
movq %rax, 0x8(%rdi)
movl 0x4(%rdi), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x14ff0b
movq 0x8(%rdi), %rax
leal 0x1(%rdx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%rdi)
movl %ecx, %ecx
leaq (%rcx,%rcx,2), %rcx
leaq (,%r13,2), %rdx
addq %r13, %rdx
movq 0x10(%rbx,%rdx,8), %rsi
movq %rsi, 0x10(%rax,%rcx,8)
movups (%rbx,%rdx,8), %xmm0
movups %xmm0, (%rax,%rcx,8)
movl %ebp, %r13d
incl %ebp
cmpq %r13, %r14
ja 0x14fec1
andb $0x7f, 0x7(%rdi)
movq %rdi, %r14
movq 0x28(%rdi), %rdi
callq 0x2220
movq $0x0, 0x28(%r14)
movq %r14, %rdi
callq 0xa0a7d
movq 0x78(%rsp), %rdi
callq 0xa0761
movq 0x148(%rsp), %rdi
callq 0x2220
movq 0x160(%rsp), %rdi
callq 0x2220
movq 0x130(%rsp), %rdi
callq 0x2220
movq 0x80(%rsp), %rdi
callq 0x2220
movq 0x50(%rsp), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq 0x110(%rsp), %rdi
callq 0x2220
movq 0x88(%rsp), %rdi
callq 0x2220
movq 0x68(%rsp), %r15
movq 0xb8(%r15), %rdi
callq 0xb10cd
movq %rax, %rbx
movq %rax, 0xc0(%r15)
movq (%rax), %r14
movq %r14, 0xd0(%r15)
movq %r14, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %rax, 0xd8(%r15)
movq %r14, 0xc8(%r15)
testq %r14, %r14
je 0x15007e
movl $0x1, %ebp
xorl %eax, %eax
movq 0x60(%rsp), %r14
leaq (%rax,%rax,4), %rdi
shlq $0x3, %rdi
addq 0x10(%rbx), %rdi
movq 0xd8(%r15), %rdx
movq %rax, %rsi
shlq $0x5, %rsi
leaq (%rdx,%rsi), %rcx
movq %rax, 0x10(%rdx,%rsi)
movb $0x0, 0x18(%rdx,%rsi)
movq %r15, %rsi
movq %r14, %rdx
callq 0x14cc0f
movl %ebp, %eax
incl %ebp
cmpq %rax, (%rbx)
ja 0x150032
movq 0xc8(%r15), %rsi
movq 0xd8(%r15), %rax
jmp 0x150080
xorl %esi, %esi
leaq -0x32f5(%rip), %rcx     # 0x14cd92
movl $0x20, %edx
movq %rax, %rdi
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x23f0