// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/hic.cpp
// Function: clean_bubble_chain_by_hic(ma_ug_t*, kv_u_trans_t*, bubble_type*)
void clean_bubble_chain_by_hic(ma_ug_t* ug, kv_u_trans_t *ta, bubble_type* bub)
{   
    double index_time = yak_realtime();
    ma_ug_t *bs_ug = bub->b_ug;
    uint32_t v, u, i, m, max_i, nv, rv, n_vx, root, flag_pri = 1, flag_aux = 2, flag_ava = 4, occ;
    double w, cutoff = 2;
    uint32_t max_w_occ = 4;
    asg_arc_t *av = NULL;
    n_vx = bs_ug->g->n_seq << 1;
    uint8_t *vis = NULL; CALLOC(vis, ug->g->n_seq<<1);
    uint8_t *is_vis = NULL; CALLOC(is_vis, ug->g->n_seq<<1);
    uint8_t *is_used = NULL; CALLOC(is_used, n_vx);
    uint8_t *dedup = NULL; CALLOC(dedup, ug->g->n_seq<<1);
    buf_t b; memset(&b, 0, sizeof(buf_t));
    kvec_t_u32_warp stack, result, res_utg;
    kv_init(stack.a); kv_init(result.a); kv_init(res_utg.a);
    double *e_w = NULL; MALLOC(e_w, bs_ug->g->n_arc);
    uint32_t *e_occ = NULL, *a_occ = NULL; CALLOC(e_occ, bs_ug->g->n_arc);
    double *aw = NULL, max_w = 0;
    kvec_asg_arc_t_warp edges; kv_init(edges.a);
    ma_ug_t *back_bs_ug = copy_untig_graph(bs_ug);

    for (i = 0; i < bs_ug->g->n_arc; i++)///weight of bs_ug's edges
    {
        e_w[i] = -1;
    }

    for (i = 0; i < bs_ug->g->n_seq; i++)///init all chain with flag_aux 
    {
        set_b_utg_weight_flag(bub, &b, i<<1, vis, flag_aux, NULL);
    }


    for (v = 0; v < n_vx; v++)
    {
        av = asg_arc_a(bs_ug->g, v);
        nv = asg_arc_n(bs_ug->g, v);
        aw = (&e_w[bs_ug->g->idx[v]>>32]);
        a_occ = (&e_occ[bs_ug->g->idx[v]>>32]);
        if(nv <= 1 || get_real_length(bs_ug->g, v, NULL) <= 1) continue;
        set_b_utg_weight_flag_xor(bub, bs_ug, &b, v^1, vis, flag_pri, NULL);

        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            w = get_chain_weight_hic(bub, bs_ug, &b, av[i].v, v, ta, vis, is_vis, ug, &stack, &result, flag_pri, flag_ava, NULL, &occ);
            aw[i] = w;
            a_occ[i] = occ;
        }

        set_b_utg_weight_flag_xor(bub, bs_ug, &b, v^1, vis, flag_pri, NULL);
    }


    for (v = 0; v < n_vx; v++)
    {
        av = asg_arc_a(bs_ug->g, v);
        nv = asg_arc_n(bs_ug->g, v);
        aw = (&e_w[bs_ug->g->idx[v]>>32]);
        a_occ = (&e_occ[bs_ug->g->idx[v]>>32]);
        if(nv <= 1 || get_real_length(bs_ug->g, v, NULL) <= 1) continue;

        for (i = rv = 0, max_i = (uint32_t)-1; i < nv; i++)
        {
            if(av[i].del) continue;
            if(max_i == (uint32_t)-1)
            {
                max_i = i;
                max_w = aw[i];
            }
            else if(max_w < aw[i])
            {
                max_i = i;
                max_w = aw[i];
            }
            rv++;
        }

        if(max_i == (uint32_t)-1) continue;
        ///if(max_w <= max_w_cutoff) continue; //must be <=
        if(a_occ[max_i] <= max_w_occ) continue; //must be <=
        if(rv < 2) continue;

        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            if(i == max_i) continue;
            ///if((av[i].v>>1) == (v>>1) && aw[i] <= max_w_cutoff) continue; ///might be not reasonable
            if((av[i].v>>1) == (v>>1) && a_occ[i] <= max_w_occ) continue; ///might be not reasonable
            if(aw[i]*cutoff < max_w && double_check_bub_branch(&av[i], bs_ug, e_w, e_occ, cutoff, max_w_occ))
            {
                av[i].del = 1; asg_arc_del(bs_ug->g, (av[i].v)^1, (av[i].ul>>32)^1, 1);
            }
        }
    }

    uint32_t rId_0, ori_0, rId_1, ori_1, root_0, root_1, new_bub;
    if(bub->num.n > 0) bub->num.n--;
    new_bub = bub->b_g->n_seq;

    for (v = 0; v < n_vx; v++)
    {
        av = asg_arc_a(bs_ug->g, v);
        nv = asg_arc_n(bs_ug->g, v);
        rv = get_real_length(bs_ug->g, v, NULL);
        if(nv == rv) continue;///no edge drop
        if(rv != 1 || nv <= 1) continue;
        get_real_length(bs_ug->g, v, &u);
        u ^= 1;
        if(get_real_length(bs_ug->g, u, NULL) != 1) continue;
        drop_g_edges_by_utg(bub, bub->b_g, bs_ug, NULL, v, u);
        if(is_used[v] || is_used[u]) continue;

        is_used[v] = is_used[u] = 1;
        root = get_utg_end_from_btg(bub, bs_ug, v);
        rId_0 = root>>1;
        ori_0 = root&1;
        get_bubbles(bub, rId_0, ori_0 == 1?&root_0:NULL, ori_0 == 0?&root_0:NULL, NULL, NULL, NULL);

        root = get_utg_end_from_btg(bub, bs_ug, u);
        rId_1 = root>>1;
        ori_1 = root&1;
        get_bubbles(bub, rId_1, ori_1 == 1?&root_1:NULL, ori_1 == 0?&root_1:NULL, NULL, NULL, NULL);

        res_utg.a.n = 0;
        set_b_utg_weight_flag_xor(bub, back_bs_ug, &b, v^1, vis, flag_pri, NULL);
        get_chain_weight_hic(bub, back_bs_ug, &b, u^1, v, ta, vis, is_vis, ug, &stack, &result, flag_pri, flag_ava, &res_utg, NULL);
        set_b_utg_weight_flag_xor(bub, back_bs_ug, &b, v^1, vis, flag_pri, NULL);
        for (i = 0; i < res_utg.a.n; i++) dedup[res_utg.a.a[i]>>1] |= 1;

        set_b_utg_weight_flag_xor(bub, back_bs_ug, &b, u^1, vis, flag_pri, NULL);
        get_chain_weight_hic(bub, back_bs_ug, &b, v^1, u, ta, vis, is_vis, ug, &stack, &result, flag_pri, flag_ava, &res_utg, NULL);
        set_b_utg_weight_flag_xor(bub, back_bs_ug, &b, u^1, vis, flag_pri, NULL);
        for (; i < res_utg.a.n; i++) dedup[res_utg.a.a[i]>>1] |= 2;

        for (i = m = 0; i < res_utg.a.n; i++)
        {
            if(dedup[res_utg.a.a[i]>>1] == 3)
            {
                res_utg.a.a[m] = res_utg.a.a[i];
                m++;
            }
            dedup[res_utg.a.a[i]>>1] = 0;
        }
        res_utg.a.n = m;

        if(!IF_HOM(root_0>>1, *bub)) kv_push(uint32_t, res_utg.a, root_0);
        if(!IF_HOM(root_1>>1, *bub)) kv_push(uint32_t, res_utg.a, root_1);

        update_bubble_graph(&res_utg, root_0^1, rId_0, root_1^1, rId_1, bub, &edges, bub->b_g, NULL, NULL, ug, NULL, 0);

        ///fprintf(stderr, "\n******src-btg%.6ul------>dest-btg%.6ul\n", (v>>1)+1, (u>>1)+1);
    }

    kv_push(uint32_t, bub->num, bub->list.n);
    new_bub = bub->b_g->n_seq - new_bub;
    bub->cross_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);
    
    ///debug_tangle_bubble(bub, bub->b_g->n_seq - bub->cross_bub, bub->b_g->n_seq - 1, "Cross-tangle");
    update_bsg(bub->b_g, &edges);

    ma_ug_destroy(bs_ug);
    bs_ug = ma_ug_gen(bub->b_g);
    bub->b_ug = bs_ug;
    kv_destroy(bub->chain_weight);
    ma_utg_t *u_x = NULL;
    bs_ug = bub->b_ug;
    kv_malloc(bub->chain_weight, bs_ug->u.n); bub->chain_weight.n = bs_ug->u.n;
    for (i = 0; i < bs_ug->u.n; i++)
    {
        u_x = &(bs_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_x, bub, ug, &(bub->chain_weight.a[i]));
        }
    }
    qsort(bub->chain_weight.a, bub->chain_weight.n, sizeof(chain_w_type), cmp_chain_weight);

    
    
    free(vis); free(is_vis); free(is_used); free(dedup); free(b.b.a); free(e_w); free(e_occ);
    kv_destroy(stack.a); kv_destroy(result.a); kv_destroy(res_utg.a); kv_destroy(edges.a);
    ma_ug_destroy(back_bs_ug);
    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
movq %rdx, %rbx
movq %rsi, 0xa8(%rsp)
movq %rdi, %r14
callq 0x1365ef
movq %xmm0, 0xb8(%rsp)
movq %rbx, 0x10(%rsp)
movq 0xc0(%rbx), %rbp
movq 0x18(%rbp), %rbx
movl 0x14(%rbx), %r13d
addl %r13d, %r13d
movq %r14, 0x28(%rsp)
movq 0x18(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %r15
pushq $0x1
popq %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, 0x18(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, 0x90(%rsp)
movq %r13, 0x60(%rsp)
movq %r13, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, %r12
pxor %xmm0, %xmm0
movdqa %xmm0, 0x150(%rsp)
movdqa %xmm0, 0x140(%rsp)
movdqa %xmm0, 0x130(%rsp)
movdqa %xmm0, 0x120(%rsp)
movdqa %xmm0, 0x110(%rsp)
movdqa %xmm0, 0x100(%rsp)
andq $0x0, 0x160(%rsp)
movdqa %xmm0, 0xe0(%rsp)
andq $0x0, 0xf0(%rsp)
movdqa %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movdqa %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movl 0x4(%rbx), %r15d
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %r15
leaq (,%r15,8), %rdi
callq 0x2280
movq %rax, %r13
pushq $0x4
popq %rsi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x88(%rsp)
pxor %xmm0, %xmm0
movdqa %xmm0, 0x170(%rsp)
andq $0x0, 0x180(%rsp)
movq %rbp, %rdi
callq 0xc8eab
movq %rbp, %r11
movq %rax, 0x50(%rsp)
movq 0x18(%rbp), %rax
movl 0x4(%rax), %edx
andq %rbx, %rdx
je 0x19229
leal 0x1(%rdx), %ecx
decq %rdx
movq %rdx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
andl $-0x2, %ecx
shlq $0x3, %rcx
movdqa 0x218123(%rip), %xmm1   # 0x2312d0
xorl %edx, %edx
movdqa 0x218129(%rip), %xmm2   # 0x2312e0
pxor %xmm2, %xmm0
movabsq $-0x4010000000000000, %rsi # imm = 0xBFF0000000000000
pcmpeqd %xmm3, %xmm3
movdqa 0x21832f(%rip), %xmm4   # 0x231500
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edi
notl %edi
testb $0x1, %dil
je 0x19208
movq %rsi, (%r13,%rdx)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edi
testb $0x1, %dil
je 0x1921c
movq %rsi, 0x8(%r13,%rdx)
paddq %xmm4, %xmm1
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x191d1
movq %r13, 0x58(%rsp)
movq %r12, 0x68(%rsp)
movq %r14, 0x98(%rsp)
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
movq 0x10(%rsp), %r12
movq %r11, 0x8(%rsp)
movq 0x18(%rsp), %r14
je 0x19295
xorl %r15d, %r15d
pushq $0x2
popq %r13
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %ebp, %ebp
movq %r12, %rdi
leaq 0x100(%rsp), %rsi
movl %r15d, %edx
movq %r14, %rcx
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0x14d241
movq 0x8(%rsp), %r11
incl %ebp
movq 0x18(%r11), %rax
movl 0x14(%rax), %eax
andl %ebx, %eax
addl $0x2, %r15d
cmpl %eax, %ebp
jb 0x19261
movq 0x60(%rsp), %rbp
testq %rbp, %rbp
movq 0x28(%rsp), %r15
je 0x19668
xorl %r15d, %r15d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq 0x18(%r11), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%r15,8), %rax
testl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0x19410
movq %rax, %r13
andq %rdi, %r13
je 0x19410
movq 0x8(%rcx), %rcx
shrq $0x20, %rax
movq 0x58(%rsp), %rdx
leaq (%rdx,%rax,8), %rbx
movq 0x88(%rsp), %rdx
leaq (%rdx,%rax,4), %r14
imulq $0x18, %rax, %rax
leaq (%rcx,%rax), %rbp
addq $0xc, %rbp
imulq $0x18, %r13, %rax
xorl %ecx, %ecx
xorl %edx, %edx
movl (%rbp,%rcx), %esi
notl %esi
shrl $0x1f, %esi
addl %esi, %edx
addq $0x18, %rcx
cmpq %rcx, %rax
jne 0x19304
cmpl $0x2, %edx
jl 0x19410
movl %r15d, %ecx
xorl $0x1, %ecx
subq $0x8, %rsp
movq %r12, %rdi
movq %r11, %rsi
leaq 0x108(%rsp), %rdx
movl %ecx, 0x28(%rsp)
movq 0x20(%rsp), %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x1500a5
addq $0x10, %rsp
xorl %r12d, %r12d
cmpl $0x0, (%rbp)
js 0x193c8
movl -0x4(%rbp), %ecx
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
leaq 0x108(%rsp), %rdx
movl %r15d, %r8d
movq 0xb0(%rsp), %r9
leaq 0xbc(%rsp), %rax
pushq %rax
pushq $0x0
pushq $0x4
pushq $0x1
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0x110(%rsp), %rax
pushq %rax
pushq 0x60(%rsp)
pushq 0xd0(%rsp)
pushq 0x60(%rsp)
callq 0x158a5c
addq $0x50, %rsp
movq %xmm0, (%rbx,%r12,8)
movl 0xb4(%rsp), %eax
movl %eax, (%r14,%r12,4)
incq %r12
addq $0x18, %rbp
cmpq %r12, %r13
jne 0x19354
subq $0x8, %rsp
movq 0x18(%rsp), %r12
movq %r12, %rdi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
leaq 0x108(%rsp), %rdx
movl 0x28(%rsp), %ecx
movq 0x20(%rsp), %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x1500a5
movq %rbx, %r11
addq $0x10, %rsp
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
incq %r15
movq 0x60(%rsp), %rbp
cmpq %rbp, %r15
jne 0x192b0
testl %ebp, %ebp
movq 0x28(%rsp), %r15
movq 0x58(%rsp), %r10
je 0x19668
pxor %xmm1, %xmm1
xorl %r13d, %r13d
movq 0x18(%r11), %rcx
movq 0x28(%rcx), %rax
movq (%rax,%r13,8), %rdx
testl $0xfffffffe, %edx       # imm = 0xFFFFFFFE
je 0x1965c
movq %rdx, %rax
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rax
je 0x1965c
movq 0x8(%rcx), %rcx
movq %rdx, %rsi
shrq $0x20, %rsi
imulq $0x18, %rsi, %rdi
leaq (%rcx,%rdi), %r8
movq %r8, 0x80(%rsp)
leaq (%r10,%rsi,8), %rbx
movq 0x88(%rsp), %r8
leaq (%r8,%rsi,4), %rsi
movq %rsi, 0x20(%rsp)
addq %rdi, %rcx
addq $0xc, %rcx
imulq $0x18, %rax, %rsi
xorl %edi, %edi
xorl %r8d, %r8d
movl (%rcx,%rdi), %r9d
notl %r9d
shrl $0x1f, %r9d
addl %r9d, %r8d
addq $0x18, %rdi
cmpq %rdi, %rsi
jne 0x194a3
cmpl $0x2, %r8d
jl 0x1965c
movl %edx, %r9d
xorl %esi, %esi
pushq $-0x1
popq %rdi
xorl %edx, %edx
cmpl $0x0, (%rcx)
js 0x194eb
movsd (%rbx,%rsi,8), %xmm0
cmpl $-0x1, %edi
je 0x194e3
ucomisd %xmm1, %xmm0
jbe 0x194e9
movapd %xmm0, %xmm1
movl %esi, %edi
incl %edx
incq %rsi
addq $0x18, %rcx
cmpq %rsi, %rax
jne 0x194ce
cmpl $-0x1, %edi
je 0x1965c
movl %edi, %ecx
movq 0x20(%rsp), %rax
movq %rcx, 0x78(%rsp)
cmpl $0x5, (%rax,%rcx,4)
setb %al
cmpl $0x2, %edx
setb %cl
orb %al, %cl
jne 0x1965c
xorl %ebp, %ebp
movq 0x80(%rsp), %r8
movq 0x78(%rsp), %r10
movsd %xmm1, 0x70(%rsp)
movq %rbx, 0xa0(%rsp)
imulq $0x18, %rbp, %r12
movl 0xc(%r8,%r12), %r14d
testl %r14d, %r14d
js 0x1963c
cmpq %r10, %rbp
je 0x1963c
addq %r8, %r12
movl 0x8(%r12), %r15d
movl %r15d, %eax
xorl %r13d, %eax
cmpl $0x1, %eax
ja 0x1957b
movq 0x20(%rsp), %rax
cmpl $0x5, (%rax,%rbp,4)
jb 0x1963c
movsd (%rbx,%rbp,8), %xmm0
addsd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x1963c
movq %r12, %rdi
movq %r11, %rsi
movq 0x58(%rsp), %rdx
movq 0x88(%rsp), %rcx
movsd 0x221cb7(%rip), %xmm0   # 0x23b260
pushq $0x4
popq %r8
movq %r9, %rbx
callq 0x150e71
movq 0x78(%rsp), %r10
movq %rbx, %r9
movq 0xa0(%rsp), %rbx
movq 0x80(%rsp), %r8
movsd 0x70(%rsp), %xmm1
movq 0x8(%rsp), %r11
testl %eax, %eax
je 0x1963c
orl $0x80000000, %r14d      # imm = 0x80000000
movl %r14d, 0xc(%r12)
movq 0x18(%r11), %rcx
xorq $0x1, %r15
movq 0x28(%rcx), %rax
movq (%rax,%r15,8), %rdx
movq %rdx, %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
andq %rax, %rsi
je 0x1963c
movl 0x4(%r12), %eax
movq 0x8(%rcx), %rdi
shrq $0x20, %rdx
imulq $0x18, %rsi, %rcx
imulq $0x18, %rdx, %rdx
addq %rdi, %rdx
addq $0xc, %rdx
xorl %esi, %esi
movl -0x4(%rdx,%rsi), %edi
xorl %eax, %edi
cmpl $0x1, %edi
jne 0x19633
orb $-0x80, 0x3(%rdx,%rsi)
addq $0x18, %rsi
cmpq %rsi, %rcx
jne 0x19623
incq %rbp
cmpq %r9, %rbp
jne 0x1953e
movq 0x10(%rsp), %r12
movq 0x28(%rsp), %r15
movq 0x58(%rsp), %r10
movq 0x60(%rsp), %rbp
incq %r13
cmpq %rbp, %r13
jne 0x1943a
movq 0x30(%r12), %rcx
testq %rcx, %rcx
jne 0x19676
xorl %ecx, %ecx
jmp 0x1967e
decq %rcx
movq %rcx, 0x30(%r12)
movq 0xb8(%r12), %rax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl 0x14(%rax), %edx
movl %edx, 0xb0(%rsp)
testl %ebp, %ebp
movq 0x98(%rsp), %rbx
movq 0x68(%rsp), %r14
je 0x19c0a
xorl %r15d, %r15d
movq 0x18(%r11), %rax
movq 0x28(%rax), %rcx
movq (%rcx,%r15,8), %rdx
movq %rdx, %rsi
movl $0x0, %edi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
andq %r8, %rsi
je 0x19702
movq 0x8(%rax), %rdi
movq %rdx, %r8
shrq $0x20, %r8
imulq $0x18, %r8, %r8
addq %rdi, %r8
addq $0xc, %r8
imulq $0x18, %rsi, %r9
xorl %r10d, %r10d
xorl %edi, %edi
movl (%r8,%r10), %r11d
notl %r11d
shrl $0x1f, %r11d
addl %r11d, %edi
addq $0x18, %r10
cmpq %r10, %r9
jne 0x196eb
cmpl %edx, %edi
jne 0x1971e
movl %r12d, %r13d
movq 0x8(%rsp), %r11
incq %r15
movl %r13d, %r12d
cmpq %rbp, %r15
jne 0x196ad
jmp 0x19bfb
cmpl $0x2, %edx
jb 0x19706
cmpl $0x1, %edi
jne 0x19706
testq %rsi, %rsi
movq 0x8(%rsp), %r11
je 0x1975f
movq 0x8(%rax), %rdi
shrq $0x20, %rdx
imulq $0x18, %rsi, %rsi
imulq $0x18, %rdx, %rdx
addq %rdi, %rdx
addq $0xc, %rdx
xorl %edi, %edi
cmpl $0x0, (%rdx,%rdi)
js 0x19756
movl -0x4(%rdx,%rdi), %r12d
addq $0x18, %rdi
cmpq %rdi, %rsi
jne 0x1974b
movl %r12d, %r13d
xorq $0x1, %r13
movq (%rcx,%r13,8), %rdx
movq %rdx, %rcx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rcx
je 0x1970e
movq 0x8(%rax), %rax
shrq $0x20, %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
addq $0xc, %rax
imulq $0x18, %rcx, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%rax,%rdx), %edi
notl %edi
shrl $0x1f, %edi
addl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rcx
jne 0x19792
cmpl $0x1, %esi
jne 0x1970e
movq 0x10(%rsp), %rax
movq 0xb8(%rax), %rsi
movq %r11, %rdx
xorl %ecx, %ecx
movl %r15d, %r8d
movl %r13d, %r9d
callq 0x14e373
cmpb $0x0, (%rbx,%r15)
jne 0x19709
cmpb $0x0, (%rbx,%r13)
jne 0x19709
movb $0x1, %al
movb %al, (%rbx,%r13)
movb %al, (%rbx,%r15)
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movl %r15d, %ecx
shrl %ecx
imulq $0x28, %rcx, %rdx
movq 0x18(%rax,%rdx), %rcx
testb $0x1, %r15b
jne 0x19815
addq %rax, %rdx
movl 0x10(%rdx), %edx
decl %edx
movl 0x4(%rcx,%rdx,8), %esi
jmp 0x1981b
movl 0x4(%rcx), %esi
xorl $0x1, %esi
movl %r12d, %ecx
shrl %ecx
imulq $0x28, %rcx, %rdx
movq 0x18(%rax,%rdx), %rcx
testb $0x1, %r12b
jne 0x19837
movl 0x4(%rcx), %edi
xorl $0x1, %edi
jmp 0x19843
addq %rdx, %rax
movl 0x10(%rax), %eax
decl %eax
movl 0x4(%rcx,%rax,8), %edi
movl %esi, %eax
notl %eax
shrl %esi
movq 0x10(%rsp), %r8
movq 0x40(%r8), %rcx
andl $0x1, %eax
movq %rsi, 0x80(%rsp)
addl (%rcx,%rsi,4), %eax
movq 0x28(%r8), %rdx
movl (%rdx,%rax,4), %eax
movq %rax, 0x70(%rsp)
movl %edi, %eax
notl %eax
shrl %edi
andl $0x1, %eax
movq %rdi, 0x78(%rsp)
addl (%rcx,%rdi,4), %eax
movl (%rdx,%rax,4), %eax
movq %rax, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movl %r15d, %ebp
xorl $0x1, %ebp
subq $0x8, %rsp
movq %r8, %rdi
movq 0x58(%rsp), %rbx
movq %rbx, %rsi
leaq 0x108(%rsp), %rdx
movl %ebp, %ecx
movq 0x20(%rsp), %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x1500a5
popq %rax
popq %rcx
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
leaq 0x108(%rsp), %rdx
movl %r12d, %ecx
movl %r15d, %r8d
movq 0xb0(%rsp), %r9
pushq $0x0
leaq 0x40(%rsp), %rax
pushq %rax
pushq $0x4
pushq $0x1
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0x110(%rsp), %rax
pushq %rax
pushq 0x60(%rsp)
pushq 0xd0(%rsp)
movq 0x60(%rsp), %rbx
pushq %rbx
callq 0x158a5c
addq $0x48, %rsp
movq 0x18(%rsp), %rdi
movq 0x58(%rsp), %rsi
leaq 0x108(%rsp), %rdx
movl %ebp, 0xa8(%rsp)
movl %ebp, %ecx
movq %rbx, %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x1500a5
addq $0x10, %rsp
movq 0x30(%rsp), %rax
testq %rax, %rax
je 0x1996a
movq 0x40(%rsp), %rcx
xorl %ebx, %ebx
movl (%rcx,%rbx,4), %edx
shrl %edx
orb $0x1, (%r14,%rdx)
incq %rbx
movl %ebx, %edx
cmpq %rdx, %rax
ja 0x19954
jmp 0x1996c
xorl %ebx, %ebx
subq $0x8, %rsp
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
movq 0x58(%rsp), %r14
movq %r14, %rsi
leaq 0x108(%rsp), %rdx
movl %r12d, %ecx
movq 0x20(%rsp), %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x1500a5
popq %rax
popq %rcx
subq $0x8, %rsp
movq %rbp, %rdi
movq %r14, %rsi
leaq 0x108(%rsp), %rdx
movl 0xa8(%rsp), %ecx
movl %r13d, %r8d
movq 0xb0(%rsp), %r9
pushq $0x0
leaq 0x40(%rsp), %rax
pushq %rax
pushq $0x4
pushq $0x1
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0x110(%rsp), %rax
pushq %rax
pushq 0x60(%rsp)
pushq 0xd0(%rsp)
movq 0x60(%rsp), %r14
pushq %r14
callq 0x158a5c
addq $0x48, %rsp
movq %rbp, %rdi
movq 0x58(%rsp), %rsi
leaq 0x108(%rsp), %rdx
movl %r12d, %ecx
movq %r14, %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x1500a5
popq %rax
popq %rcx
movq 0x30(%rsp), %rax
movl %ebx, %ecx
cmpq %rcx, %rax
jbe 0x19a5a
movq 0x40(%rsp), %rdx
leal 0x1(%rcx), %esi
movq 0x10(%rsp), %rbx
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %rbp
movq 0x70(%rsp), %r12
movl (%rdx,%rcx,4), %ecx
shrl %ecx
orb $0x2, (%r14,%rcx)
movl %esi, %ecx
incl %esi
cmpq %rcx, %rax
ja 0x19a45
jmp 0x19a77
testq %rax, %rax
movq 0x10(%rsp), %rbx
movq 0x68(%rsp), %r14
movq 0x60(%rsp), %rbp
movq 0x70(%rsp), %r12
je 0x19bf4
xorl %ecx, %ecx
movq 0x40(%rsp), %rdx
xorl %esi, %esi
movl (%rdx,%rcx,4), %r8d
movl %r8d, %edi
shrl %edi
cmpb $0x3, (%r14,%rdi)
jne 0x19a9d
movl %esi, %edi
movl %r8d, (%rdx,%rdi,4)
incl %esi
movl (%rdx,%rcx,4), %edi
shrl %edi
movb $0x0, (%r14,%rdi)
incq %rcx
movl %ecx, %edi
cmpq %rdi, %rax
ja 0x19a80
movl %esi, %ecx
movq %rcx, 0x30(%rsp)
movq (%rbx), %rsi
movq 0x80(%rbx), %rdx
movl %r12d, %eax
shrl %eax
movl (%rsi,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
movq 0x20(%rsp), %r8
jb 0x19b29
movq 0x40(%rsp), %rax
cmpq %rcx, 0x38(%rsp)
jne 0x19b19
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x20(%rsp), %r8
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
movq (%rbx), %rsi
movq 0x80(%rbx), %rdx
incq %rdx
leaq 0x1(%rcx), %rdi
movq %rdi, 0x30(%rsp)
movl %r12d, (%rax,%rcx,4)
movq %rdi, %rcx
movl %r8d, %eax
shrl %eax
movl (%rsi,%rax,4), %eax
cmpq %rax, %rdx
jb 0x19b7d
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rcx
jne 0x19b70
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq 0x20(%rsp), %r8
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movl %r8d, (%rax,%rcx,4)
xorl $0x1, %r12d
xorl $0x1, %r8d
movq 0xb8(%rbx), %rax
subq $0x40, %rsp
pxor %xmm0, %xmm0
movdqu %xmm0, 0x28(%rsp)
movq 0x68(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movdqu %xmm0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
leaq 0x1b0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %rdi
movl %r12d, %esi
movq 0xc0(%rsp), %rdx
movl %r8d, %ecx
movq 0xb8(%rsp), %r8
movq %rbx, %r9
callq 0x14c338
addq $0x40, %rsp
movq 0x8(%rsp), %r11
movq 0x98(%rsp), %rbx
jmp 0x1970e
xorl %ecx, %ecx
jmp 0x19aae
movq 0x10(%rsp), %r12
movq 0x30(%r12), %rcx
movq 0x28(%rsp), %r15
cmpq 0x38(%r12), %rcx
jne 0x19c3e
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x38(%r12)
movq 0x40(%r12), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%r12)
movq 0x30(%r12), %rcx
jmp 0x19c43
movq 0x40(%r12), %rax
movl 0x18(%r12), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r12)
movl %edx, (%rax,%rcx,4)
movq 0xb8(%r12), %rdi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x14(%rdi), %eax
movl %eax, %ecx
movl 0xb0(%rsp), %edx
subl %edx, %ecx
addq %rcx, 0xa0(%r12)
cmpl %edx, %eax
je 0x19c8b
movq %r12, %rdi
callq 0x13f2d9
movq 0xb8(%r12), %rdi
leaq 0x170(%rsp), %rsi
callq 0x14e73d
movq 0x8(%rsp), %rdi
callq 0xa0761
movq 0xb8(%r12), %rdi
callq 0xb10cd
movq %rax, 0xc0(%r12)
movq 0xd8(%r12), %rdi
callq 0x2220
movq 0xc0(%r12), %rbx
movq (%rbx), %r13
movq %r13, 0xd0(%r12)
movq %r13, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %rax, 0xd8(%r12)
movq %r13, 0xc8(%r12)
testq %r13, %r13
jne 0x19d01
xorl %esi, %esi
movq 0x18(%rsp), %r13
jmp 0x19d59
pushq $0x1
popq %rbp
xorl %eax, %eax
movq 0x18(%rsp), %r13
imulq $0x28, %rax, %rdi
addq 0x10(%rbx), %rdi
movq 0xd8(%r12), %rdx
movq %rax, %rsi
shlq $0x5, %rsi
leaq (%rdx,%rsi), %rcx
movq %rax, 0x10(%rdx,%rsi)
movb $0x0, 0x18(%rdx,%rsi)
movq %r12, %rsi
movq %r15, %rdx
callq 0x14cc0f
movl %ebp, %eax
incl %ebp
cmpq %rax, (%rbx)
ja 0x19d0b
movq 0xc8(%r12), %rsi
movq 0xd8(%r12), %rax
movq 0x68(%rsp), %r14
leaq 0x133032(%rip), %rcx    # 0x14cd92
pushq $0x20
popq %rdx
movq %rax, %rdi
callq 0x23f0
movq %r13, %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0x98(%rsp), %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2220
movq 0x148(%rsp), %rdi
callq 0x2220
movq 0x58(%rsp), %rdi
callq 0x2220
movq 0x88(%rsp), %rdi
callq 0x2220
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0xd0(%rsp), %rdi
callq 0x2220
movq 0x40(%rsp), %rdi
callq 0x2220
movq 0x180(%rsp), %rdi
callq 0x2220
movq 0x50(%rsp), %rdi
callq 0xa0761
movq 0x27b1e5(%rip), %rax    # 0x294fe0
movq (%rax), %rbx
callq 0x1365ef
subsd 0xb8(%rsp), %xmm0
leaq 0x221dd8(%rip), %rsi    # 0x23bbeb
leaq 0x222417(%rip), %rdx    # 0x23c231
movq %rbx, %rdi
movb $0x1, %al
callq 0x22b0
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq