// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: clean_bubble_chain_by_HiC(ma_ug_t*, hc_links*, bubble_type*)
void clean_bubble_chain_by_HiC(ma_ug_t* ug, hc_links* link, 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/**, max_w_cutoff = MAX(MIN(100*OFFSET_RATE_MIN_W, OFFSET_RATE_MAX_W/100), OFFSET_RATE_MIN_W)**/;
    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);

        ///fprintf(stderr, "\n******pri>btg%.6dl\n", (v>>1)+1);
        for (i = 0; i < nv; i++)
        {
            if(av[i].del) continue;
            //fprintf(stderr, "aux>btg%.6dl\n", (av[i].v>>1)+1);
            w = get_chain_weight(bub, bs_ug, &b, av[i].v, v, link, vis, is_vis, ug, &stack, &result, flag_pri, flag_ava, NULL, &occ);
            ///fprintf(stderr, "aux>btg%.6dl, w: %f\n", (av[i].v>>1)+1, w);
            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;
        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(bub, back_bs_ug, &b, u^1, v, link, 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(bub, back_bs_ug, &b, v^1, u, link, 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;

        // fprintf(stderr, "res_utg.a.n: %u, m: %u, beg-utg%.6ul, sink-utg%.6ul\n", 
        //             res_utg.a.n, m, (root_0>>1)+1, (root_1>>1)+1);
        
        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, %r15
movq %rsi, 0xa0(%rsp)
movq %rdi, %r14
callq 0xefea7
movsd %xmm0, 0xb8(%rsp)
movq 0xc0(%r15), %r13
movq 0x18(%r13), %rbx
movl 0x14(%rbx), %ebp
addl %ebp, %ebp
movq %r14, 0x58(%rsp)
movq 0x18(%r14), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movslq %eax, %r14
pushq $0x1
popq %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, 0x30(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, 0x88(%rsp)
movq %rbp, 0x40(%rsp)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, 0x80(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2120
movq %rax, 0x98(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x150(%rsp)
movapd %xmm0, 0x140(%rsp)
movapd %xmm0, 0x130(%rsp)
movapd %xmm0, 0x120(%rsp)
movapd %xmm0, 0x110(%rsp)
movapd %xmm0, 0x100(%rsp)
andq $0x0, 0x160(%rsp)
movapd %xmm0, 0xe0(%rsp)
andq $0x0, 0xf0(%rsp)
movapd %xmm0, 0xc0(%rsp)
andq $0x0, 0xd0(%rsp)
movapd %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movl 0x4(%rbx), %r14d
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
andq %rbx, %r14
leaq (,%r14,8), %rdi
callq 0x2280
movq %rax, 0x48(%rsp)
pushq $0x4
popq %rsi
movq %r14, %rdi
callq 0x2120
movq %rax, 0x50(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x170(%rsp)
andq $0x0, 0x180(%rsp)
movq %r13, %rdi
callq 0x8c99a
movq %rax, 0x90(%rsp)
movq %r13, 0x10(%rsp)
movq 0x18(%r13), %rax
movl 0x4(%rax), %ecx
andq %rbx, %rcx
xorl %edx, %edx
movabsq $-0x4010000000000000, %rsi # imm = 0xBFF0000000000000
movq 0x48(%rsp), %rdi
cmpq %rdx, %rcx
je 0x108d56
movq %rsi, (%rdi,%rdx,8)
incq %rdx
jmp 0x108d48
movq %r15, 0x28(%rsp)
xorl %r14d, %r14d
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
leaq 0x100(%rsp), %r12
pushq $0x2
popq %r13
xorl %ebp, %ebp
movl 0x14(%rax), %eax
andl %ebx, %eax
cmpl %eax, %ebp
jae 0x108da6
movq 0x28(%rsp), %rdi
movq %r12, %rsi
movl %r14d, %edx
movq 0x30(%rsp), %rcx
movl %r13d, %r8d
xorl %r9d, %r9d
callq 0x10519d
incl %ebp
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rax
addl $0x2, %r14d
jmp 0x108d71
xorl %r12d, %r12d
movq 0x28(%rsp), %rbp
movq 0x40(%rsp), %r13
cmpq %r13, %r12
je 0x108f17
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rdi), %rax
movq (%rax,%r12,8), %r14
testl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
je 0x108f0f
movq 0x8(%rdi), %r15
movl %r12d, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x2, %eax
jl 0x108f0f
movq %r14, %r13
shrq $0x20, %r13
movq 0x48(%rsp), %rax
leaq (%rax,%r13,8), %rbx
movq %rbp, %rdi
movq 0x50(%rsp), %rax
leaq (%rax,%r13,4), %rbp
movl %r12d, %ecx
xorl $0x1, %ecx
subq $0x8, %rsp
movq 0x18(%rsp), %rsi
leaq 0x108(%rsp), %rdx
movl %ecx, 0x20(%rsp)
movq 0x38(%rsp), %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x107d53
addq $0x10, %rsp
movl %r14d, %r14d
imulq $0x18, %r13, %rax
addq %rax, %r15
addq $0xc, %r15
xorl %r13d, %r13d
cmpq %r13, %r14
je 0x108edb
cmpl $0x0, (%r15)
js 0x108ecf
movl -0x4(%r15), %ecx
subq $0x8, %rsp
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rsi
leaq 0x108(%rsp), %rdx
movl %r12d, %r8d
movq 0xa8(%rsp), %r9
leaq 0xb4(%rsp), %rax
pushq %rax
pushq $0x0
pushq $0x4
pushq $0x1
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0x110(%rsp), %rax
pushq %rax
pushq 0x90(%rsp)
pushq 0xc8(%rsp)
pushq 0x78(%rsp)
callq 0x108273
addq $0x50, %rsp
movsd %xmm0, (%rbx,%r13,8)
movl 0xac(%rsp), %eax
movl %eax, (%rbp,%r13,4)
incq %r13
addq $0x18, %r15
jmp 0x108e4d
subq $0x8, %rsp
movq 0x30(%rsp), %rbp
movq %rbp, %rdi
movq 0x18(%rsp), %rsi
leaq 0x108(%rsp), %rdx
movl 0x20(%rsp), %ecx
movq 0x38(%rsp), %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x107d53
popq %rax
popq %rcx
movq 0x40(%rsp), %r13
incq %r12
jmp 0x108db3
xorpd %xmm1, %xmm1
xorl %esi, %esi
cmpq %r13, %rsi
je 0x109107
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rdi), %rax
movq (%rax,%rsi,8), %rbx
testl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
je 0x1090ff
movsd %xmm1, 0x18(%rsp)
movq 0x8(%rdi), %r14
movq %rsi, 0x20(%rsp)
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x2, %eax
jge 0x108f6e
movq 0x20(%rsp), %rsi
movsd 0x18(%rsp), %xmm1
jmp 0x1090ff
movq %rbx, %r13
shrq $0x20, %r13
imulq $0x18, %r13, %rsi
leaq (%r14,%rsi), %r15
movq 0x48(%rsp), %rax
leaq (%rax,%r13,8), %rdx
movq 0x50(%rsp), %rax
leaq (%rax,%r13,4), %rcx
movl %ebx, %eax
leaq (%r14,%rsi), %rdi
addq $0xc, %rdi
xorl %r8d, %r8d
xorl %esi, %esi
pushq $-0x1
popq %r9
movsd 0x18(%rsp), %xmm1
cmpq %r8, %rax
je 0x108fd6
cmpl $0x0, (%rdi)
js 0x108fcd
movsd (%rdx,%r8,8), %xmm0
cmpl $-0x1, %r9d
je 0x108fc4
ucomisd %xmm1, %xmm0
jbe 0x108fcb
movapd %xmm0, %xmm1
movl %r8d, %r9d
incl %esi
incq %r8
addq $0x18, %rdi
jmp 0x108fa8
cmpl $-0x1, %r9d
je 0x108ff2
movl %r9d, %edx
cmpl $0x5, (%rcx,%rdx,4)
setb %cl
cmpl $0x2, %esi
setb %sil
orb %cl, %sil
je 0x109001
movq 0x40(%rsp), %r13
movq 0x20(%rsp), %rsi
jmp 0x1090ff
imulq $0x18, %rax, %rbx
imulq $0x18, %rdx, %rcx
xorl %ebp, %ebp
movq 0x20(%rsp), %rsi
movsd %xmm1, 0x18(%rsp)
movq %rcx, 0xb0(%rsp)
cmpq %rbp, %rbx
je 0x1090f5
movl 0xc(%r15,%rbp), %r12d
testl %r12d, %r12d
js 0x1090e9
cmpq %rbp, %rcx
je 0x1090e9
movl 0x8(%r15,%rbp), %r14d
movl %r14d, %eax
xorl %esi, %eax
cmpl $0x1, %eax
ja 0x10905d
movq 0x50(%rsp), %rax
cmpl $0x5, (%rax,%r13,4)
jb 0x1090e9
movq 0x48(%rsp), %rax
movsd (%rax,%r13,8), %xmm0
addsd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jbe 0x1090e9
leaq (%r15,%rbp), %rdi
movq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x50(%rsp), %rcx
movsd 0xe40c3(%rip), %xmm0    # 0x1ed150
pushq $0x4
popq %r8
callq 0x108adb
movq 0xb0(%rsp), %rcx
movsd 0x18(%rsp), %xmm1
movq 0x20(%rsp), %rsi
testl %eax, %eax
je 0x1090e9
orl $0x80000000, %r12d      # imm = 0x80000000
movl %r12d, 0xc(%r15,%rbp)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
xorl $0x1, %r14d
movl 0x4(%r15,%rbp), %edx
xorl $0x1, %edx
movl %r14d, %esi
callq 0x10433c
movq 0xb0(%rsp), %rcx
movsd 0x18(%rsp), %xmm1
movq 0x20(%rsp), %rsi
addq $0x18, %rbp
incq %r13
jmp 0x10901e
movq 0x28(%rsp), %rbp
movq 0x40(%rsp), %r13
incq %rsi
jmp 0x108f1d
movq 0x30(%rbp), %rax
testq %rax, %rax
je 0x109117
decq %rax
movq %rax, 0x30(%rbp)
movq 0xb8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x20(%rsp)
xorl %r12d, %r12d
leaq 0xc(%rsp), %r15
cmpq %r13, %r12
je 0x1095a2
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
movq 0x28(%rdi), %rax
movl (%rax,%r12,8), %ebx
movl %r12d, %esi
xorl %edx, %edx
callq 0xc2e7a
cmpl %ebx, %eax
jne 0x10915a
incq %r12
jmp 0x10912d
cmpl $0x1, %eax
jne 0x109155
cmpl $0x2, %ebx
jb 0x109155
movq 0x10(%rsp), %rbx
movq 0x18(%rbx), %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0xc2e7a
movl 0xc(%rsp), %esi
xorl $0x1, %esi
movl %esi, 0xc(%rsp)
movq 0x18(%rbx), %rdi
xorl %edx, %edx
callq 0xc2e7a
cmpl $0x1, %eax
jne 0x109155
movq 0xb8(%rbp), %rsi
movl 0xc(%rsp), %r9d
movq 0x10(%rsp), %rdx
xorl %ecx, %ecx
movl %r12d, %r8d
callq 0x1062c5
movq 0x80(%rsp), %rax
cmpb $0x0, (%rax,%r12)
jne 0x109155
movl 0xc(%rsp), %r14d
movq 0x80(%rsp), %rax
cmpb $0x0, (%rax,%r14)
jne 0x109155
movq 0x80(%rsp), %rax
movb $0x1, %cl
movb %cl, (%rax,%r14)
movb %cl, (%rax,%r12)
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
movl %r12d, %edx
callq 0x10629b
movl %eax, %esi
shrl %esi
xorl %r13d, %r13d
testb $0x1, %al
leaq 0x3c(%rsp), %rax
movq %rax, %rdx
cmoveq %r13, %rdx
movl $0x0, %ecx
cmoveq %rax, %rcx
subq $0x8, %rsp
movq %rbp, %rdi
movq %rsi, 0x30(%rsp)
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
callq 0xf6ab5
popq %rax
popq %rcx
movq %rbx, %rsi
movl %r14d, %edx
callq 0x10629b
movl %eax, %esi
shrl %esi
testb $0x1, %al
leaq 0x38(%rsp), %rax
movq %rax, %rdx
cmoveq %r13, %rdx
movl $0x0, %ecx
cmoveq %rax, %rcx
subq $0x8, %rsp
movq %rbp, %rdi
movq %rsi, 0x20(%rsp)
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
callq 0xf6ab5
popq %rax
popq %rcx
andq $0x0, 0x60(%rsp)
movl %r12d, %r14d
xorl $0x1, %r14d
subq $0x8, %rsp
movq %rbp, %rdi
movq 0x98(%rsp), %r15
movq %r15, %rsi
leaq 0x108(%rsp), %rdx
movl %r14d, %ecx
movq 0x38(%rsp), %rbx
movq %rbx, %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x107d53
popq %rax
popq %rcx
movl 0xc(%rsp), %ecx
xorl $0x1, %ecx
subq $0x8, %rsp
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x108(%rsp), %rdx
movl %r12d, %r8d
movq 0xa8(%rsp), %r9
pushq $0x0
leaq 0x70(%rsp), %rax
pushq %rax
pushq $0x4
pushq $0x1
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0x110(%rsp), %rax
pushq %rax
pushq 0x90(%rsp)
pushq 0xc8(%rsp)
pushq %rbx
callq 0x108273
addq $0x48, %rsp
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x108(%rsp), %rdx
movl %r14d, %ecx
movq %rbx, %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x107d53
addq $0x10, %rsp
movq 0x60(%rsp), %rax
movq 0x70(%rsp), %rcx
movq 0x98(%rsp), %rsi
movl %r13d, %edx
cmpq %rdx, %rax
jbe 0x109351
movl (%rcx,%rdx,4), %edx
shrl %edx
orb $0x1, (%rsi,%rdx)
incl %r13d
jmp 0x10933b
movl 0xc(%rsp), %ecx
xorl $0x1, %ecx
subq $0x8, %rsp
movq %rbp, %rdi
movq 0x98(%rsp), %r15
movq %r15, %rsi
leaq 0x108(%rsp), %rdx
movq 0x38(%rsp), %rbx
movq %rbx, %r8
pushq $0x1
popq %r9
pushq $0x0
callq 0x107d53
popq %rax
popq %rcx
movl 0xc(%rsp), %r8d
subq $0x8, %rsp
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x108(%rsp), %rdx
movl %r14d, %ecx
movq 0xa8(%rsp), %r9
pushq $0x0
leaq 0x70(%rsp), %rax
pushq %rax
pushq $0x4
pushq $0x1
leaq 0xe8(%rsp), %rax
pushq %rax
leaq 0x110(%rsp), %rax
pushq %rax
pushq 0x90(%rsp)
pushq 0xc8(%rsp)
pushq %rbx
callq 0x108273
addq $0x50, %rsp
movl 0xc(%rsp), %ecx
xorl $0x1, %ecx
subq $0x8, %rsp
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x108(%rsp), %rdx
movq %rbx, %r8
movq 0xa0(%rsp), %rbx
pushq $0x1
popq %r9
pushq $0x0
callq 0x107d53
popq %rax
popq %rcx
movq 0x60(%rsp), %rcx
movq 0x70(%rsp), %rax
leaq 0xc(%rsp), %r15
movl %r13d, %edx
cmpq %rdx, %rcx
jbe 0x109436
movl (%rax,%rdx,4), %esi
shrl %esi
orb $0x2, (%rbx,%rsi)
leal 0x1(%rdx), %r13d
jmp 0x10941f
xorl %edx, %edx
xorl %edi, %edi
movq 0x40(%rsp), %r13
movl %edi, %edi
movl %edx, %esi
cmpq %rdi, %rcx
jbe 0x10946f
movl (%rax,%rdi,4), %r9d
movl %r9d, %r8d
shrl %r8d
cmpb $0x3, (%rbx,%r8)
jne 0x109466
movl %r9d, (%rax,%rsi,4)
incl %edx
movl (%rax,%rdi,4), %r8d
shrl %r8d
movb $0x0, (%rbx,%r8)
incl %edi
jmp 0x10943f
movq %rsi, 0x60(%rsp)
movq (%rbp), %r8
movq 0x80(%rbp), %rdi
movl 0x3c(%rsp), %ecx
movl %ecx, %r9d
shrl %r9d
movl (%r8,%r9,4), %r9d
incq %rdi
cmpq %r9, %rdi
jb 0x1094e4
cmpq %rsi, 0x68(%rsp)
jne 0x1094d5
addq %rsi, %rsi
testl %edx, %edx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x68(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x70(%rsp)
movl 0x3c(%rsp), %ecx
movq 0x60(%rsp), %rsi
movq (%rbp), %r8
movq 0x80(%rbp), %rdi
incq %rdi
leaq 0x1(%rsi), %rdx
movq %rdx, 0x60(%rsp)
movl %ecx, (%rax,%rsi,4)
movq %rdx, %rsi
movl 0x38(%rsp), %ecx
movl %ecx, %edx
shrl %edx
movl (%r8,%rdx,4), %edx
cmpq %rdx, %rdi
jb 0x10953c
cmpq 0x68(%rsp), %rsi
jne 0x10952c
leaq (%rsi,%rsi), %rcx
testq %rsi, %rsi
pushq $0x2
popq %rdx
cmoveq %rdx, %rcx
movq %rcx, 0x68(%rsp)
shlq $0x2, %rcx
movq %rax, %rdi
movq %rcx, %rsi
callq 0x2370
movq %rax, 0x70(%rsp)
movl 0x38(%rsp), %ecx
movq 0x60(%rsp), %rsi
leaq 0x1(%rsi), %rdx
movq %rdx, 0x60(%rsp)
movl %ecx, (%rax,%rsi,4)
movl 0x38(%rsp), %ecx
movl 0x3c(%rsp), %esi
xorl $0x1, %esi
xorl $0x1, %ecx
movq 0xb8(%rbp), %rax
subq $0x40, %rsp
xorpd %xmm0, %xmm0
movupd %xmm0, 0x28(%rsp)
movq 0x98(%rsp), %rdx
movq %rdx, 0x20(%rsp)
movupd %xmm0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
leaq 0x1b0(%rsp), %rax
movq %rax, (%rsp)
leaq 0xa0(%rsp), %rdi
movq 0x68(%rsp), %rdx
movq 0x58(%rsp), %r8
movq %rbp, %r9
callq 0x10441e
addq $0x40, %rsp
jmp 0x109155
movl 0x20(%rsp), %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq 0x30(%rbp), %rcx
cmpq 0x38(%rbp), %rcx
jne 0x1095df
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rax
cmoveq %rax, %rsi
movq %rsi, 0x38(%rbp)
movq 0x40(%rbp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%rbp)
movq 0x30(%rbp), %rcx
jmp 0x1095e3
movq 0x40(%rbp), %rax
movl 0x18(%rbp), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%rbp)
movl %edx, (%rax,%rcx,4)
movq 0xb8(%rbp), %rdi
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl 0x14(%rdi), %eax
movl %eax, %ecx
subl %ebx, %ecx
addq %rcx, 0xa0(%rbp)
cmpl %ebx, %eax
je 0x10961e
movq %rbp, %rdi
callq 0xf7cab
movq 0xb8(%rbp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x1066d7
movq 0x10(%rsp), %rdi
callq 0x6921d
movq 0xb8(%rbp), %rdi
callq 0x76d91
movq %rax, 0xc0(%rbp)
movq 0xd8(%rbp), %rdi
callq 0x2220
movq 0xc0(%rbp), %rbx
movq (%rbx), %r15
movq %r15, 0xd0(%rbp)
movq %r15, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %rax, 0xd8(%rbp)
movq %r15, 0xc8(%rbp)
xorl %eax, %eax
movl %eax, %r14d
cmpq %r14, %r15
jbe 0x1096c3
imulq $0x28, %r14, %rdi
addq 0x10(%rbx), %rdi
movq 0xd8(%rbp), %rax
movq %r14, %rdx
shlq $0x5, %rdx
leaq (%rax,%rdx), %rcx
movq %r14, 0x10(%rax,%rdx)
movb $0x0, 0x18(%rax,%rdx)
movq %rbp, %rsi
movq 0x58(%rsp), %rdx
callq 0x104bf5
leal 0x1(%r14), %eax
movq (%rbx), %r15
jmp 0x109681
movq 0xc8(%rbp), %rsi
movq 0xd8(%rbp), %rdi
leaq -0x498f(%rip), %rcx     # 0x104d49
pushq $0x20
popq %rdx
callq 0x23f0
movq 0x30(%rsp), %rdi
callq 0x2220
movq 0x88(%rsp), %rdi
callq 0x2220
movq 0x80(%rsp), %rdi
callq 0x2220
movq 0x98(%rsp), %rdi
callq 0x2220
movq 0x148(%rsp), %rdi
callq 0x2220
movq 0x48(%rsp), %rdi
callq 0x2220
movq 0x50(%rsp), %rdi
callq 0x2220
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0xd0(%rsp), %rdi
callq 0x2220
movq 0x70(%rsp), %rdi
callq 0x2220
movq 0x180(%rsp), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x6921d
movq 0x149869(%rip), %rax    # 0x252fe0
movq (%rax), %rbx
callq 0xefea7
subsd 0xb8(%rsp), %xmm0
leaq 0xe434c(%rip), %rsi     # 0x1edadb
leaq 0xe464d(%rip), %rdx     # 0x1edde3
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