// File: chhylp123[P]hifiasm/hic.cpp
// Function: resolve_bubble_chain_tangle(ma_ug_t*, bubble_type*)
void resolve_bubble_chain_tangle(ma_ug_t* ug, bubble_type* bub)
{
    // double index_time = yak_realtime();
    ma_ug_t *bub_ug = bub->b_ug;
    asg_t *bsg = bub->b_g;
    uint32_t k, i, v, n_vx, new_bub;
    n_vx = MAX((MAX(ug->g->n_seq<<1, bub->b_ug->g->n_seq<<1)), bub->b_g->n_seq<<1);
    buf_t b; memset(&b, 0, sizeof(buf_t));
    kvec_t_u32_warp stack, stack2, res_btg, res_utg;
    kv_init(stack.a); kv_init(stack2.a); kv_init(res_btg.a); kv_init(res_utg.a);
    kvec_asg_arc_t_warp edges; kv_init(edges.a);
    uint8_t *is_vis = NULL; CALLOC(is_vis, n_vx);
    uint8_t *is_vis2 = NULL; CALLOC(is_vis2, n_vx);
    uint8_t *is_used = NULL; CALLOC(is_used, n_vx);
    uint8_t *chain_flag = NULL; CALLOC(chain_flag, n_vx);
    kvec_t(uint64_t) occ_idx; kv_init(occ_idx); uint64_t tmp, *p = NULL;
    double side_rate = 2.5, total_rate = 8;
    uint32_t b_utg_beg, b_utg_sink, b_tg_beg, b_tg_sink, utg_beg, utg_sink;
    

    while(1)
    {
        occ_idx.n = 0; edges.a.n = 0;
        if(n_vx < (uint32_t)(MAX((MAX(ug->g->n_seq<<1, bub->b_ug->g->n_seq<<1)), bub->b_g->n_seq<<1)))
        {
            n_vx = MAX((MAX(ug->g->n_seq<<1, bub->b_ug->g->n_seq<<1)), bub->b_g->n_seq<<1);
            is_vis = (uint8_t*)realloc(is_vis, n_vx);
            is_vis2 = (uint8_t*)realloc(is_vis2, n_vx);
            is_used = (uint8_t*)realloc(is_used, n_vx);
            chain_flag = (uint8_t*)realloc(chain_flag, n_vx);
        }
        memset(is_vis, 0, n_vx);
        memset(is_vis2, 0, n_vx);
        memset(is_used, 0, n_vx);
        memset(chain_flag, 0, n_vx);
        if(bub->num.n > 0) bub->num.n--;
        new_bub = bub->b_g->n_seq;
        //label all unitigs in bubble chain
        for (k = 0; k < bub_ug->g->n_seq; k++)
        {
            kv_pushp(uint64_t, occ_idx, &p);
            (*p) = get_btg_occ(bub, k);
            (*p) <<= 32; (*p) += k;
            set_b_utg_weight_flag(bub, NULL, k<<1, chain_flag, 1, NULL);
        }
        radix_sort_hc64(occ_idx.a, occ_idx.a + occ_idx.n);
        for (k = 0; k < occ_idx.n>>1; ++k) 
        {
            tmp = occ_idx.a[k];
            occ_idx.a[k] = occ_idx.a[occ_idx.n - k - 1];
            occ_idx.a[occ_idx.n - k - 1] = tmp;
        }

        for (k = 0; k < bub_ug->g->n_seq; k++)///start from the longest chain
        {
            v = ((uint32_t)(occ_idx.a[k]))<<1;
            if(is_used[v] == 0 && asg_arc_n(bub_ug->g, v) > 0)
            {
                if(find_bubble_tangle(bub, ug, is_vis, is_vis2, v, side_rate, total_rate, &stack, &stack2, 
                        &res_btg, &res_utg, chain_flag, &b_utg_beg, &b_utg_sink, &b_tg_beg, &b_tg_sink, 
                        &utg_beg, &utg_sink))
                {
                    if(utg_beg != (uint32_t)-1 && (!IF_HOM(utg_beg>>1, *bub)))
                    {
                        kv_push(uint32_t, res_utg.a, utg_beg);
                    } 
                    if(utg_sink != (uint32_t)-1 && (!IF_HOM(utg_sink>>1, *bub)))
                    {
                        kv_push(uint32_t, res_utg.a, utg_sink);
                    }

                    for (i = 0; i < res_btg.a.n; i++)
                    {
                        is_used[res_btg.a.a[i]] = 1; 
                        is_used[res_btg.a.a[i]^1] = 1; 
                    }
                    if(b_utg_beg != (uint32_t)-1) is_used[b_utg_beg] = 1;
                    if(b_utg_sink != (uint32_t)-1) is_used[b_utg_sink] = 1;
                    if(b_tg_beg != (uint32_t)-1) b_tg_beg>>=1;
                    if(b_tg_sink != (uint32_t)-1) b_tg_sink>>=1;    
                    update_bubble_graph(&res_utg, utg_beg, b_tg_beg, utg_sink, b_tg_sink, 
                    bub, &edges, bsg, NULL, NULL, ug, NULL, 0);
                    drop_g_edges_by_utg(bub, bsg, bub_ug, &res_btg, b_utg_beg, b_utg_sink);
                }
            }
            

            v ^= 1;
            if(is_used[v] == 0 && asg_arc_n(bub_ug->g, v) > 0)
            {

                if(find_bubble_tangle(bub, ug, is_vis, is_vis2, v, side_rate, total_rate, &stack, &stack2, 
                        &res_btg, &res_utg, chain_flag, &b_utg_beg, &b_utg_sink, &b_tg_beg, &b_tg_sink, 
                        &utg_beg, &utg_sink))
                {
                    if(utg_beg != (uint32_t)-1 && (!IF_HOM(utg_beg>>1, *bub)))
                    {
                        kv_push(uint32_t, res_utg.a, utg_beg);
                    } 
                    if(utg_sink != (uint32_t)-1 && (!IF_HOM(utg_sink>>1, *bub)))
                    {
                        kv_push(uint32_t, res_utg.a, utg_sink);
                    }

                    for (i = 0; i < res_btg.a.n; i++)
                    {
                        is_used[res_btg.a.a[i]] = 1; 
                        is_used[res_btg.a.a[i]^1] = 1; 
                    }

                    if(b_utg_beg != (uint32_t)-1) is_used[b_utg_beg] = 1;
                    if(b_utg_sink != (uint32_t)-1) is_used[b_utg_sink] = 1;
                    if(b_tg_beg != (uint32_t)-1) b_tg_beg>>=1;
                    if(b_tg_sink != (uint32_t)-1) b_tg_sink>>=1;
                    /*******************************for debug************************************/
                    // if(utg_beg == (utg_sink^1))
                    // {
                    //     print_b_utg_occ(bub, b_utg_beg>>1);
                    //     print_b_utg_occ(bub, b_utg_sink>>1);
                    //     print_b_utg_occ(bub, 42);
                    //     ///print_debug_bubble_graph(bub, ug, asm_opt.output_file_name);
                    // }
                    /*******************************for debug************************************/
                    update_bubble_graph(&res_utg, utg_beg, b_tg_beg, utg_sink, b_tg_sink, bub, &edges, bsg, NULL, NULL, ug, NULL, 0);
                    drop_g_edges_by_utg(bub, bsg, bub_ug, &res_btg, b_utg_beg, b_utg_sink);
                    ///fprintf(stderr, "->>>>>>beg=btg%.6ul, sink=btg%.6ul\n", (b_utg_beg>>1)+1, (b_utg_sink>>1)+1);
                }
            }
        }
        kv_push(uint32_t, bub->num, bub->list.n);
        new_bub = bub->b_g->n_seq - new_bub;
        bub->tangle_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);
        update_bsg(bsg, &edges);
        
        ma_ug_destroy(bub_ug);
        bub_ug = ma_ug_gen(bub->b_g);
        bub->b_ug = bub_ug;
        ///fprintf(stderr, "new_bub: %u, bub->tangle_bub: %lu\n", new_bub, bub->tangle_bub);
        if(new_bub == 0) break;
    }

    kv_destroy(bub->chain_weight);
    ma_utg_t *u = NULL;
    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);

    ///debug_tangle_bubble(bub);

    free(is_vis); free(is_vis2); free(is_used); free(chain_flag); free(b.b.a); 
    kv_destroy(occ_idx); kv_destroy(stack.a); kv_destroy(stack2.a); 
    kv_destroy(res_btg.a); kv_destroy(res_utg.a); kv_destroy(edges.a);

    ///print_debug_bubble_graph(bub, ug, asm_opt.output_file_name);
    // fprintf(stderr, "[M::%s::%.3f]\n", __func__, yak_realtime()-index_time);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movq %rdi, -0x30(%rbp)
movq %rsi, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movq -0x38(%rbp), %rcx
movq 0xc0(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e2fb4
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1e4(%rbp)
jmp 0x1e2fd3
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1e4(%rbp)
movl -0x1e4(%rbp), %eax
movq -0x38(%rbp), %rcx
movq 0xb8(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e306a
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movq -0x38(%rbp), %rcx
movq 0xc0(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e303d
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1e8(%rbp)
jmp 0x1e305c
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1e8(%rbp)
movl -0x1e8(%rbp), %eax
movl %eax, -0x1ec(%rbp)
jmp 0x1e3085
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1ec(%rbp)
movl -0x1ec(%rbp), %eax
movl %eax, -0x58(%rbp)
leaq -0xc8(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0x100(%rbp)
movq $0x0, -0x108(%rbp)
movq $0x0, -0xf8(%rbp)
movq $0x0, -0x120(%rbp)
movq $0x0, -0x128(%rbp)
movq $0x0, -0x118(%rbp)
movq $0x0, -0x140(%rbp)
movq $0x0, -0x148(%rbp)
movq $0x0, -0x138(%rbp)
movq $0x0, -0x160(%rbp)
movq $0x0, -0x168(%rbp)
movq $0x0, -0x158(%rbp)
movq $0x0, -0x170(%rbp)
movl -0x58(%rbp), %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x170(%rbp)
movq $0x0, -0x178(%rbp)
movl -0x58(%rbp), %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x178(%rbp)
movq $0x0, -0x180(%rbp)
movl -0x58(%rbp), %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x180(%rbp)
movq $0x0, -0x188(%rbp)
movl -0x58(%rbp), %eax
movl %eax, %edi
movl $0x1, %esi
callq 0x2140
movq %rax, -0x188(%rbp)
movq $0x0, -0x198(%rbp)
movq $0x0, -0x1a0(%rbp)
movq $0x0, -0x190(%rbp)
movq $0x0, -0x1b0(%rbp)
movsd 0x1a3672(%rip), %xmm0   # 0x386870
movsd %xmm0, -0x1b8(%rbp)
movsd 0x1a8c92(%rip), %xmm0   # 0x38bea0
movsd %xmm0, -0x1c0(%rbp)
movq $0x0, -0x1a0(%rbp)
movq $0x0, -0x168(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x1f0(%rbp)
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movq -0x38(%rbp), %rcx
movq 0xc0(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e327f
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1f4(%rbp)
jmp 0x1e329e
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1f4(%rbp)
movl -0x1f4(%rbp), %eax
movq -0x38(%rbp), %rcx
movq 0xb8(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e3335
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movq -0x38(%rbp), %rcx
movq 0xc0(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e3308
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1f8(%rbp)
jmp 0x1e3327
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1f8(%rbp)
movl -0x1f8(%rbp), %eax
movl %eax, -0x1fc(%rbp)
jmp 0x1e3350
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x1fc(%rbp)
movl -0x1f0(%rbp), %eax
movl -0x1fc(%rbp), %ecx
cmpl %ecx, %eax
jae 0x1e34e8
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movq -0x38(%rbp), %rcx
movq 0xc0(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e33ae
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x200(%rbp)
jmp 0x1e33cd
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x200(%rbp)
movl -0x200(%rbp), %eax
movq -0x38(%rbp), %rcx
movq 0xb8(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e3464
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movq -0x38(%rbp), %rcx
movq 0xc0(%rcx), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shll %ecx
cmpl %ecx, %eax
jl 0x1e3437
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x204(%rbp)
jmp 0x1e3456
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x204(%rbp)
movl -0x204(%rbp), %eax
movl %eax, -0x208(%rbp)
jmp 0x1e347f
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x208(%rbp)
movl -0x208(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0x170(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %esi
callq 0x2360
movq %rax, -0x170(%rbp)
movq -0x178(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %esi
callq 0x2360
movq %rax, -0x178(%rbp)
movq -0x180(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %esi
callq 0x2360
movq %rax, -0x180(%rbp)
movq -0x188(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %esi
callq 0x2360
movq %rax, -0x188(%rbp)
movq -0x170(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movq -0x178(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movq -0x180(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movq -0x188(%rbp), %rdi
movl -0x58(%rbp), %eax
movl %eax, %edx
xorl %esi, %esi
callq 0x2100
movq -0x38(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jbe 0x1e354f
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x30(%rax)
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, -0x5c(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x40(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x1e3689
jmp 0x1e358a
movq -0x1a0(%rbp), %rax
cmpq -0x198(%rbp), %rax
jne 0x1e35f1
cmpq $0x0, -0x198(%rbp)
je 0x1e35b7
movq -0x198(%rbp), %rax
shlq %rax
movq %rax, -0x210(%rbp)
jmp 0x1e35c5
movl $0x2, %eax
movq %rax, -0x210(%rbp)
jmp 0x1e35c5
movq -0x210(%rbp), %rax
movq %rax, -0x198(%rbp)
movq -0x190(%rbp), %rdi
movq -0x198(%rbp), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, -0x190(%rbp)
movq -0x190(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x1a0(%rbp)
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x1b0(%rbp)
movq -0x38(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x1e0800
movl %eax, %eax
movl %eax, %ecx
movq -0x1b0(%rbp), %rax
movq %rcx, (%rax)
movq -0x1b0(%rbp), %rax
movq (%rax), %rcx
shlq $0x20, %rcx
movq %rcx, (%rax)
movl -0x4c(%rbp), %eax
movl %eax, %ecx
movq -0x1b0(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x38(%rbp), %rdi
movl -0x4c(%rbp), %edx
shll %edx
movq -0x188(%rbp), %rcx
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, %r8d
movq %r9, %rsi
callq 0x1e0580
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1e356c
movq -0x190(%rbp), %rdi
movq -0x190(%rbp), %rsi
movq -0x1a0(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x1ba0f0
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x1a0(%rbp), %rcx
shrq %rcx
cmpq %rcx, %rax
jae 0x1e3730
movq -0x190(%rbp), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x1a8(%rbp)
movq -0x190(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movl -0x4c(%rbp), %edx
subq %rdx, %rcx
subq $0x1, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x190(%rbp), %rax
movl -0x4c(%rbp), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x1a8(%rbp), %rdx
movq -0x190(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movl -0x4c(%rbp), %esi
subq %rsi, %rcx
subq $0x1, %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1e36b1
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movq -0x40(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x1e3f5b
movq -0x190(%rbp), %rax
movl -0x4c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
shll %eax
movl %eax, -0x54(%rbp)
movq -0x180(%rbp), %rax
movl -0x54(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x1e3b54
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, %eax
jbe 0x1e3b54
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x170(%rbp), %rdx
movq -0x178(%rbp), %rcx
movl -0x54(%rbp), %r8d
movsd -0x1b8(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movq -0x188(%rbp), %r12
leaq -0xe8(%rbp), %r9
leaq -0x108(%rbp), %rax
movq %rax, -0x228(%rbp)
leaq -0x128(%rbp), %rax
movq %rax, -0x220(%rbp)
leaq -0x148(%rbp), %r13
leaq -0x1c4(%rbp), %r15
leaq -0x1c8(%rbp), %r14
leaq -0x1cc(%rbp), %rbx
leaq -0x1d0(%rbp), %r11
leaq -0x1d4(%rbp), %r10
leaq -0x1d8(%rbp), %rax
movq %rax, -0x218(%rbp)
movq -0x228(%rbp), %rax
movq %rax, (%rsp)
movq -0x220(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x218(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1e1140
cmpl $0x0, %eax
je 0x1e3b52
cmpl $-0x1, -0x1d4(%rbp)
je 0x1e3942
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x1d4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e3942
jmp 0x1e38b4
movq -0x148(%rbp), %rax
cmpq -0x140(%rbp), %rax
jne 0x1e391b
cmpq $0x0, -0x140(%rbp)
je 0x1e38e1
movq -0x140(%rbp), %rax
shlq %rax
movq %rax, -0x230(%rbp)
jmp 0x1e38ef
movl $0x2, %eax
movq %rax, -0x230(%rbp)
jmp 0x1e38ef
movq -0x230(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x138(%rbp)
movl -0x1d4(%rbp), %edx
movq -0x138(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x148(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e3942
cmpl $-0x1, -0x1d8(%rbp)
je 0x1e3a0b
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x1d8(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e3a0b
jmp 0x1e397d
movq -0x148(%rbp), %rax
cmpq -0x140(%rbp), %rax
jne 0x1e39e4
cmpq $0x0, -0x140(%rbp)
je 0x1e39aa
movq -0x140(%rbp), %rax
shlq %rax
movq %rax, -0x238(%rbp)
jmp 0x1e39b8
movl $0x2, %eax
movq %rax, -0x238(%rbp)
jmp 0x1e39b8
movq -0x238(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x138(%rbp)
movl -0x1d8(%rbp), %edx
movq -0x138(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x148(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e3a0b
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpq -0x128(%rbp), %rax
jae 0x1e3a5e
movq -0x180(%rbp), %rax
movq -0x118(%rbp), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movb $0x1, (%rax,%rcx)
movq -0x180(%rbp), %rax
movq -0x118(%rbp), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1e3a12
cmpl $-0x1, -0x1c4(%rbp)
je 0x1e3a78
movq -0x180(%rbp), %rax
movl -0x1c4(%rbp), %ecx
movb $0x1, (%rax,%rcx)
cmpl $-0x1, -0x1c8(%rbp)
je 0x1e3a92
movq -0x180(%rbp), %rax
movl -0x1c8(%rbp), %ecx
movb $0x1, (%rax,%rcx)
cmpl $-0x1, -0x1cc(%rbp)
je 0x1e3aa9
movl -0x1cc(%rbp), %eax
shrl %eax
movl %eax, -0x1cc(%rbp)
cmpl $-0x1, -0x1d0(%rbp)
je 0x1e3ac0
movl -0x1d0(%rbp), %eax
shrl %eax
movl %eax, -0x1d0(%rbp)
movl -0x1d4(%rbp), %esi
movl -0x1cc(%rbp), %edx
movl -0x1d8(%rbp), %ecx
movl -0x1d0(%rbp), %r8d
movq -0x38(%rbp), %r9
movq -0x48(%rbp), %r10
movq -0x30(%rbp), %rax
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %r11
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x1deb20
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl -0x1c4(%rbp), %r8d
movl -0x1c8(%rbp), %r9d
leaq -0x128(%rbp), %rcx
callq 0x1e22d0
jmp 0x1e3b54
movl -0x54(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x180(%rbp), %rax
movl -0x54(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x1e3f4b
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x54(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x0, %eax
jbe 0x1e3f4b
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x170(%rbp), %rdx
movq -0x178(%rbp), %rcx
movl -0x54(%rbp), %r8d
movsd -0x1b8(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movq -0x188(%rbp), %r12
leaq -0xe8(%rbp), %r9
leaq -0x108(%rbp), %rax
movq %rax, -0x250(%rbp)
leaq -0x128(%rbp), %rax
movq %rax, -0x248(%rbp)
leaq -0x148(%rbp), %r13
leaq -0x1c4(%rbp), %r15
leaq -0x1c8(%rbp), %r14
leaq -0x1cc(%rbp), %rbx
leaq -0x1d0(%rbp), %r11
leaq -0x1d4(%rbp), %r10
leaq -0x1d8(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x250(%rbp), %rax
movq %rax, (%rsp)
movq -0x248(%rbp), %rax
movq %rax, 0x8(%rsp)
movq -0x240(%rbp), %rax
movq %r13, 0x10(%rsp)
movq %r12, 0x18(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x28(%rsp)
movq %rbx, 0x30(%rsp)
movq %r11, 0x38(%rsp)
movq %r10, 0x40(%rsp)
movq %rax, 0x48(%rsp)
callq 0x1e1140
cmpl $0x0, %eax
je 0x1e3f49
cmpl $-0x1, -0x1d4(%rbp)
je 0x1e3d39
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x1d4(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e3d39
jmp 0x1e3cab
movq -0x148(%rbp), %rax
cmpq -0x140(%rbp), %rax
jne 0x1e3d12
cmpq $0x0, -0x140(%rbp)
je 0x1e3cd8
movq -0x140(%rbp), %rax
shlq %rax
movq %rax, -0x258(%rbp)
jmp 0x1e3ce6
movl $0x2, %eax
movq %rax, -0x258(%rbp)
jmp 0x1e3ce6
movq -0x258(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x138(%rbp)
movl -0x1d4(%rbp), %edx
movq -0x138(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x148(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e3d39
cmpl $-0x1, -0x1d8(%rbp)
je 0x1e3e02
movq -0x38(%rbp), %rax
movq (%rax), %rax
movl -0x1d8(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x38(%rbp), %rcx
movq 0x80(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0x1e3e02
jmp 0x1e3d74
movq -0x148(%rbp), %rax
cmpq -0x140(%rbp), %rax
jne 0x1e3ddb
cmpq $0x0, -0x140(%rbp)
je 0x1e3da1
movq -0x140(%rbp), %rax
shlq %rax
movq %rax, -0x260(%rbp)
jmp 0x1e3daf
movl $0x2, %eax
movq %rax, -0x260(%rbp)
jmp 0x1e3daf
movq -0x260(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, -0x138(%rbp)
movl -0x1d8(%rbp), %edx
movq -0x138(%rbp), %rax
movq -0x148(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x148(%rbp)
movl %edx, (%rax,%rcx,4)
jmp 0x1e3e02
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpq -0x128(%rbp), %rax
jae 0x1e3e55
movq -0x180(%rbp), %rax
movq -0x118(%rbp), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movb $0x1, (%rax,%rcx)
movq -0x180(%rbp), %rax
movq -0x118(%rbp), %rcx
movl -0x50(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movb $0x1, (%rax,%rcx)
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1e3e09
cmpl $-0x1, -0x1c4(%rbp)
je 0x1e3e6f
movq -0x180(%rbp), %rax
movl -0x1c4(%rbp), %ecx
movb $0x1, (%rax,%rcx)
cmpl $-0x1, -0x1c8(%rbp)
je 0x1e3e89
movq -0x180(%rbp), %rax
movl -0x1c8(%rbp), %ecx
movb $0x1, (%rax,%rcx)
cmpl $-0x1, -0x1cc(%rbp)
je 0x1e3ea0
movl -0x1cc(%rbp), %eax
shrl %eax
movl %eax, -0x1cc(%rbp)
cmpl $-0x1, -0x1d0(%rbp)
je 0x1e3eb7
movl -0x1d0(%rbp), %eax
shrl %eax
movl %eax, -0x1d0(%rbp)
movl -0x1d4(%rbp), %esi
movl -0x1cc(%rbp), %edx
movl -0x1d8(%rbp), %ecx
movl -0x1d0(%rbp), %r8d
movq -0x38(%rbp), %r9
movq -0x48(%rbp), %r10
movq -0x30(%rbp), %rax
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %r11
xorl %ebx, %ebx
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq %rax, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movq $0x0, 0x30(%rsp)
callq 0x1deb20
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movl -0x1c4(%rbp), %r8d
movl -0x1c8(%rbp), %r9d
leaq -0x128(%rbp), %rcx
callq 0x1e22d0
jmp 0x1e3f4b
jmp 0x1e3f4d
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1e3737
jmp 0x1e3f5d
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x38(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x1e3fcf
movq -0x38(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1e3f8e
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
shlq %rax
movq %rax, -0x268(%rbp)
jmp 0x1e3f9c
movl $0x2, %eax
movq %rax, -0x268(%rbp)
jmp 0x1e3f9c
movq -0x268(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x38(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movl %edx, (%rax,%rcx,4)
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
addq 0x98(%rax), %rcx
movq %rcx, 0x98(%rax)
cmpl $0x0, -0x5c(%rbp)
je 0x1e4036
movq -0x38(%rbp), %rdi
callq 0x1c6cf0
movq -0x48(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x1e2c80
movq -0x40(%rbp), %rdi
callq 0xcd6f0
movq -0x38(%rbp), %rax
movq 0xb8(%rax), %rdi
callq 0xe5910
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xc0(%rax)
cmpl $0x0, -0x5c(%rbp)
jne 0x1e407a
jmp 0x1e407f
jmp 0x1e3216
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x2210
movq $0x0, -0x1e0(%rbp)
movq -0x38(%rbp), %rax
movq 0xc0(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq $0x0, 0xc8(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xd0(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
shlq $0x5, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xd8(%rax)
movq -0x40(%rbp), %rax
movq (%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0xc8(%rax)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x40(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x1e4198
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x50(%rbp), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x1e0(%rbp)
movl -0x50(%rbp), %eax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x50(%rbp), %edx
shlq $0x5, %rdx
addq %rdx, %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rax
movl -0x50(%rbp), %ecx
shlq $0x5, %rcx
addq %rcx, %rax
movb $0x0, 0x18(%rax)
movq -0x1e0(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rcx
movl -0x50(%rbp), %eax
shlq $0x5, %rax
addq %rax, %rcx
callq 0x1df840
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1e4101
movq -0x38(%rbp), %rax
movq 0xd8(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0xc8(%rax), %rsi
movl $0x20, %edx
leaq -0x473a(%rip), %rcx     # 0x1dfa80
callq 0x23e0
movq -0x170(%rbp), %rdi
callq 0x2210
movq -0x178(%rbp), %rdi
callq 0x2210
movq -0x180(%rbp), %rdi
callq 0x2210
movq -0x188(%rbp), %rdi
callq 0x2210
movq -0x80(%rbp), %rdi
callq 0x2210
movq -0x190(%rbp), %rdi
callq 0x2210
movq -0xd8(%rbp), %rdi
callq 0x2210
movq -0xf8(%rbp), %rdi
callq 0x2210
movq -0x118(%rbp), %rdi
callq 0x2210
movq -0x138(%rbp), %rdi
callq 0x2210
movq -0x158(%rbp), %rdi
callq 0x2210
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopw %cs:(%rax,%rax)