// File: 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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
movl %edx, -0x2c(%rbp)
movl %ecx, -0x30(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0xc0(%rax)
je 0x1e429c
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0xcd6f0
movq -0x28(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
je 0x1e42ba
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x2210
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movslq %eax, %rsi
leaq -0xf0(%rbp), %rdi
callq 0x1cb9c0
movq -0x28(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0xf8(%rbp)
movq $0x0, -0x100(%rbp)
movq -0x28(%rbp), %rax
movq 0xb8(%rax), %rdi
callq 0xe5910
movq %rax, -0x100(%rbp)
movq -0x88(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x128(%rbp)
movq $0x0, -0x138(%rbp)
movl -0x128(%rbp), %eax
movl %eax, %edi
shlq $0x2, %rdi
callq 0x2270
movq %rax, -0x138(%rbp)
movq $0x0, -0x140(%rbp)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movslq %eax, %rdi
shlq $0x0, %rdi
callq 0x2270
movq %rax, -0x140(%rbp)
movq $0x0, -0x158(%rbp)
movq $0x0, -0x160(%rbp)
movq $0x0, -0x150(%rbp)
movq $0x0, -0x168(%rbp)
movl -0x128(%rbp), %eax
shrl %eax
movl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x168(%rbp)
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
movq -0x100(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1e4559
movq -0x100(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x104(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1e445b
jmp 0x1e4545
movl $0x0, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x1e4543
movq -0x28(%rbp), %rdi
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x10c(%rbp), %ecx
movq (%rax,%rcx,8), %rsi
shrq $0x21, %rsi
leaq -0x118(%rbp), %rdx
leaq -0x124(%rbp), %rcx
leaq -0x170(%rbp), %r8
leaq -0x174(%rbp), %r9
xorl %eax, %eax
movq $0x0, (%rsp)
callq 0x1c4b20
movl $0x0, -0x108(%rbp)
movl -0x108(%rbp), %eax
cmpl -0x174(%rbp), %eax
jae 0x1e4505
movq -0x168(%rbp), %rax
movq -0x170(%rbp), %rcx
movl -0x108(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movl -0x108(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x108(%rbp)
jmp 0x1e44c7
movq -0x168(%rbp), %rax
movl -0x118(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movq -0x168(%rbp), %rax
movl -0x124(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0x1e4465
jmp 0x1e4545
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x1e441a
movq -0x28(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jbe 0x1e4574
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x12c(%rbp)
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
movq -0x100(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1e5088
movq -0x100(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x104(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jne 0x1e45d8
jmp 0x1e5074
cmpl $0x0, -0x2c(%rbp)
je 0x1e4ad9
movl $0x0, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movq -0x78(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x1e4ad7
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movq -0x78(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jb 0x1e4616
jmp 0x1e4ac3
movq -0xf8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xf8(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x78(%rbp), %rdx
movq 0x18(%rdx), %rdx
movl -0x10c(%rbp), %esi
movq (%rdx,%rsi,8), %rdx
shrq $0x20, %rdx
movq (%rcx,%rdx,8), %rcx
shrq $0x20, %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x1, %eax
jne 0x1e4667
jmp 0x1e4ac3
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x10c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x110(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x10c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
andq $0x1, %rax
movl %eax, -0x114(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x188(%rbp)
movl -0x110(%rbp), %eax
movq %rax, -0x180(%rbp)
cmpl $0x1, -0x114(%rbp)
jne 0x1e46d4
leaq -0x118(%rbp), %rax
movq %rax, -0x190(%rbp)
jmp 0x1e46df
xorl %eax, %eax
movq %rax, -0x190(%rbp)
jmp 0x1e46df
movq -0x190(%rbp), %rax
movq %rax, -0x198(%rbp)
cmpl $0x0, -0x114(%rbp)
jne 0x1e4706
leaq -0x118(%rbp), %rax
movq %rax, -0x1a0(%rbp)
jmp 0x1e4711
xorl %eax, %eax
movq %rax, -0x1a0(%rbp)
jmp 0x1e4711
movq -0x198(%rbp), %rdx
movq -0x180(%rbp), %rsi
movq -0x188(%rbp), %rdi
movq -0x1a0(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
movq $0x0, (%rsp)
callq 0x1c4b20
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x10c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x11c(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movl -0x10c(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
andq $0x1, %rax
xorq $0x1, %rax
movl %eax, -0x120(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x1b0(%rbp)
movl -0x11c(%rbp), %eax
movq %rax, -0x1a8(%rbp)
cmpl $0x1, -0x120(%rbp)
jne 0x1e47bd
leaq -0x124(%rbp), %rax
movq %rax, -0x1b8(%rbp)
jmp 0x1e47c8
xorl %eax, %eax
movq %rax, -0x1b8(%rbp)
jmp 0x1e47c8
movq -0x1b8(%rbp), %rax
movq %rax, -0x1c0(%rbp)
cmpl $0x0, -0x120(%rbp)
jne 0x1e47ef
leaq -0x124(%rbp), %rax
movq %rax, -0x1c8(%rbp)
jmp 0x1e47fa
xorl %eax, %eax
movq %rax, -0x1c8(%rbp)
jmp 0x1e47fa
movq -0x1c0(%rbp), %rdx
movq -0x1a8(%rbp), %rsi
movq -0x1b0(%rbp), %rdi
movq -0x1c8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
movq $0x0, (%rsp)
callq 0x1c4b20
movq $0x0, -0x50(%rbp)
movq -0x28(%rbp), %rsi
movq -0x88(%rbp), %rcx
movq -0x138(%rbp), %r8
movl -0x118(%rbp), %r9d
movl -0x124(%rbp), %eax
leaq -0x50(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
xorl %r10d, %r10d
movl %eax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x1df630
movq -0x28(%rbp), %rsi
movq -0x88(%rbp), %rcx
movq -0x138(%rbp), %r8
movl -0x124(%rbp), %r9d
movl -0x118(%rbp), %eax
leaq -0x50(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
xorl %r10d, %r10d
movl %eax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x1df630
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x118(%rbp), %edx
xorl $0x1, %edx
movl -0x124(%rbp), %ecx
xorl $0x1, %ecx
movq -0x140(%rbp), %r8
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
shll %r9d
leaq -0x50(%rbp), %rsi
leaq -0x160(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
callq 0x1de300
cmpl $0x0, %eax
jne 0x1e4919
jmp 0x1e4ac3
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl -0x118(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e49b0
jmp 0x1e4943
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x1e4992
cmpq $0x0, -0x48(%rbp)
je 0x1e4964
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x1d0(%rbp)
jmp 0x1e4972
movl $0x2, %eax
movq %rax, -0x1d0(%rbp)
jmp 0x1e4972
movq -0x1d0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movl -0x118(%rbp), %edx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e49b0
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl -0x124(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e4a47
jmp 0x1e49da
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x1e4a29
cmpq $0x0, -0x48(%rbp)
je 0x1e49fb
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x1d8(%rbp)
jmp 0x1e4a09
movl $0x2, %eax
movq %rax, -0x1d8(%rbp)
jmp 0x1e4a09
movq -0x1d8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movl -0x124(%rbp), %edx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e4a47
cmpq $0x0, -0x50(%rbp)
jbe 0x1e4ac1
movl -0x118(%rbp), %esi
xorl $0x1, %esi
movl -0x110(%rbp), %edx
movl -0x124(%rbp), %ecx
xorl $0x1, %ecx
movl -0x11c(%rbp), %r8d
movq -0x28(%rbp), %r9
movq -0xf8(%rbp), %rbx
movq -0x80(%rbp), %r11
movq -0x168(%rbp), %r10
movq -0x20(%rbp), %rax
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %r14
xorl %r15d, %r15d
movq %r14, (%rsp)
movq %rbx, 0x8(%rsp)
movq %r11, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x1, 0x30(%rsp)
callq 0x1deb20
jmp 0x1e4ac3
movl -0x10c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10c(%rbp)
jmp 0x1e45ec
jmp 0x1e4ad9
cmpl $0x0, -0x30(%rbp)
je 0x1e5072
movq -0x78(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jbe 0x1e4da0
movq -0x100(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x104(%rbp), %ecx
shll %ecx
addl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, %eax
jne 0x1e4da0
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
shrq $0x21, %rax
movl %eax, -0x110(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
shrq $0x20, %rax
andq $0x1, %rax
xorq $0x1, %rax
movl %eax, -0x114(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movl -0x110(%rbp), %eax
movq %rax, -0x1e0(%rbp)
cmpl $0x1, -0x114(%rbp)
jne 0x1e4b7d
leaq -0x118(%rbp), %rax
movq %rax, -0x1f0(%rbp)
jmp 0x1e4b88
xorl %eax, %eax
movq %rax, -0x1f0(%rbp)
jmp 0x1e4b88
movq -0x1f0(%rbp), %rax
movq %rax, -0x1f8(%rbp)
cmpl $0x0, -0x114(%rbp)
jne 0x1e4baf
leaq -0x118(%rbp), %rax
movq %rax, -0x200(%rbp)
jmp 0x1e4bba
xorl %eax, %eax
movq %rax, -0x200(%rbp)
jmp 0x1e4bba
movq -0x1f8(%rbp), %rdx
movq -0x1e0(%rbp), %rsi
movq -0x1e8(%rbp), %rdi
movq -0x200(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
movq $0x0, (%rsp)
callq 0x1c4b20
movq $0x0, -0x50(%rbp)
movq -0x28(%rbp), %rsi
movq -0x88(%rbp), %rcx
movq -0x138(%rbp), %r8
movl -0x118(%rbp), %r9d
leaq -0x50(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq $0x0, 0x8(%rsp)
callq 0x1df630
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x118(%rbp), %edx
xorl $0x1, %edx
movq -0x140(%rbp), %r8
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
shll %r9d
leaq -0x50(%rbp), %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq -0x160(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
callq 0x1de300
cmpl $0x0, %eax
je 0x1e4d9e
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl -0x118(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e4d2a
jmp 0x1e4cbd
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x1e4d0c
cmpq $0x0, -0x48(%rbp)
je 0x1e4cde
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x208(%rbp)
jmp 0x1e4cec
movl $0x2, %eax
movq %rax, -0x208(%rbp)
jmp 0x1e4cec
movq -0x208(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movl -0x118(%rbp), %edx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e4d2a
cmpq $0x0, -0x50(%rbp)
jbe 0x1e4d9c
movl -0x118(%rbp), %esi
xorl $0x1, %esi
movl -0x110(%rbp), %edx
movq -0x28(%rbp), %r9
movq -0xf8(%rbp), %r11
movq -0x168(%rbp), %r10
movq -0x20(%rbp), %rax
leaq -0x50(%rbp), %rdi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
leaq -0x70(%rbp), %rbx
xorl %ecx, %ecx
movl %r8d, %ecx
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x1deb20
jmp 0x1e4d9e
jmp 0x1e4da0
movq -0x78(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jbe 0x1e5070
movq -0x100(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x104(%rbp), %ecx
shll %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, %eax
jne 0x1e5070
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x21, %rax
movl %eax, -0x11c(%rbp)
movq -0x78(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x78(%rbp), %rcx
movl 0x10(%rcx), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
andq $0x1, %rax
movl %eax, -0x120(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x218(%rbp)
movl -0x11c(%rbp), %eax
movq %rax, -0x210(%rbp)
cmpl $0x1, -0x120(%rbp)
jne 0x1e4e4d
leaq -0x124(%rbp), %rax
movq %rax, -0x220(%rbp)
jmp 0x1e4e58
xorl %eax, %eax
movq %rax, -0x220(%rbp)
jmp 0x1e4e58
movq -0x220(%rbp), %rax
movq %rax, -0x228(%rbp)
cmpl $0x0, -0x120(%rbp)
jne 0x1e4e7f
leaq -0x124(%rbp), %rax
movq %rax, -0x230(%rbp)
jmp 0x1e4e8a
xorl %eax, %eax
movq %rax, -0x230(%rbp)
jmp 0x1e4e8a
movq -0x228(%rbp), %rdx
movq -0x210(%rbp), %rsi
movq -0x218(%rbp), %rdi
movq -0x230(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %r8
movq $0x0, (%rsp)
callq 0x1c4b20
movq $0x0, -0x50(%rbp)
movq -0x28(%rbp), %rsi
movq -0x88(%rbp), %rcx
movq -0x138(%rbp), %r8
movl -0x124(%rbp), %r9d
movq -0x168(%rbp), %rax
leaq -0x50(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq %rax, 0x8(%rsp)
callq 0x1df630
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x124(%rbp), %edx
xorl $0x1, %edx
movq -0x140(%rbp), %r8
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
shll %r9d
leaq -0x50(%rbp), %rsi
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq -0x160(%rbp), %rax
xorl %r10d, %r10d
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
callq 0x1de300
cmpl $0x0, %eax
je 0x1e506e
movq -0x28(%rbp), %rax
movq (%rax), %rax
movl -0x124(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x28(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e4ffb
jmp 0x1e4f8e
movq -0x50(%rbp), %rax
cmpq -0x48(%rbp), %rax
jne 0x1e4fdd
cmpq $0x0, -0x48(%rbp)
je 0x1e4faf
movq -0x48(%rbp), %rax
shlq %rax
movq %rax, -0x238(%rbp)
jmp 0x1e4fbd
movl $0x2, %eax
movq %rax, -0x238(%rbp)
jmp 0x1e4fbd
movq -0x238(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x40(%rbp)
movl -0x124(%rbp), %edx
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x50(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e4ffb
cmpq $0x0, -0x50(%rbp)
jbe 0x1e506c
movl -0x124(%rbp), %ecx
xorl $0x1, %ecx
movl -0x11c(%rbp), %r8d
movq -0x28(%rbp), %r9
movq -0xf8(%rbp), %r11
movq -0x168(%rbp), %r10
movq -0x20(%rbp), %rax
leaq -0x50(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x70(%rbp), %rbx
xorl %esi, %esi
movl %edx, %esi
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x1deb20
jmp 0x1e506e
jmp 0x1e5070
jmp 0x1e5072
jmp 0x1e5074
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x1e4597
jmp 0x1e508a
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x28(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x1e50fc
movq -0x28(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1e50bb
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
shlq %rax
movq %rax, -0x240(%rbp)
jmp 0x1e50c9
movl $0x2, %eax
movq %rax, -0x240(%rbp)
jmp 0x1e50c9
movq -0x240(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x28(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x28(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0x12c(%rbp), %eax
movl %eax, -0x12c(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x1e5163
movl -0x12c(%rbp), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
addq 0x90(%rax), %rcx
movq %rcx, 0x90(%rax)
cmpl $0x0, -0x12c(%rbp)
je 0x1e5175
movq -0x28(%rbp), %rdi
callq 0x1c6cf0
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
cmpq -0x70(%rbp), %rax
jae 0x1e51d7
movq -0xf8(%rbp), %rdi
callq 0x1cef50
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rcx
movl -0x104(%rbp), %eax
imulq $0x18, %rax, %rax
addq %rax, %rcx
movq -0x80(%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 -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x1e517f
movq -0xf8(%rbp), %rax
movl 0x4(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
orl $0x0, %ecx
movl %ecx, 0x4(%rax)
movq -0xf8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2210
movq -0xf8(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0xf8(%rbp), %rdi
callq 0xcdd10
movq -0x100(%rbp), %rdi
callq 0xcd6f0
leaq -0xf0(%rbp), %rdi
callq 0x1cbb60
movq -0x138(%rbp), %rdi
callq 0x2210
movq -0x40(%rbp), %rdi
callq 0x2210
movq -0x60(%rbp), %rdi
callq 0x2210
movq -0x168(%rbp), %rdi
callq 0x2210
movq -0x150(%rbp), %rdi
callq 0x2210
movq -0x140(%rbp), %rdi
callq 0x2210
movq -0x28(%rbp), %rax
movq 0xb8(%rax), %rdi
callq 0xe5910
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0xc0(%rax)
movq -0x28(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x100(%rbp)
movq -0x28(%rbp), %rax
movq $0x0, 0xc8(%rax)
movq -0x100(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0xd0(%rax)
movq -0x100(%rbp), %rax
movq (%rax), %rdi
shlq $0x5, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0xd8(%rax)
movq -0x100(%rbp), %rax
movq (%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0xc8(%rax)
movl $0x0, -0x104(%rbp)
movl -0x104(%rbp), %eax
movq -0x100(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1e53b5
movq -0x100(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x104(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movl -0x104(%rbp), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x104(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x104(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movb $0x0, 0x18(%rax)
movq -0x78(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rcx
movl -0x104(%rbp), %eax
shlq $0x5, %rax
addq %rax, %rcx
callq 0x1df840
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x1e5306
movq -0x28(%rbp), %rax
movq 0xd8(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0xc8(%rax), %rsi
movl $0x20, %edx
leaq -0x5957(%rip), %rcx     # 0x1dfa80
callq 0x23e0
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopw (%rax,%rax)