// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, %r14
movq 0xc0(%rsi), %rbx
movq %rdi, 0x68(%rsp)
movq 0x18(%rdi), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movq 0x18(%rbx), %rcx
movl 0x14(%rcx), %ecx
addl %ecx, %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movq 0xb8(%rsi), %rax
movq %rax, 0x88(%rsp)
movl 0x14(%rax), %r15d
addl %r15d, %r15d
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
xorps %xmm0, %xmm0
leaq 0x110(%rsp), %rcx
movaps %xmm0, (%rcx)
xorl %eax, %eax
movq %rax, 0x10(%rcx)
leaq 0xf0(%rsp), %rcx
movaps %xmm0, (%rcx)
movq %rax, 0x10(%rcx)
leaq 0x90(%rsp), %rcx
movaps %xmm0, (%rcx)
movq %rax, 0x10(%rcx)
leaq 0x40(%rsp), %rcx
movaps %xmm0, (%rcx)
movq $0x0, 0x8(%rsp)
movq %rax, 0x10(%rcx)
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x10(%rsp)
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, %r12
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, %rbp
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rbx, %rdx
movq %rax, 0x30(%rsp)
leaq 0xd0(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0xc0(%rsp)
movq %r14, 0x80(%rsp)
movq %rdx, 0x38(%rsp)
movq %rbp, 0x60(%rsp)
movq $0x0, 0xd0(%rsp)
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
addl %ecx, %ecx
movq 0x18(%rdx), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq 0xb8(%r14), %rcx
movl 0x14(%rcx), %ebx
addl %ebx, %ebx
cmpl %ebx, %eax
jge 0x14ebcc
cmpl %ebx, %r15d
jb 0x14ebd3
movq 0x10(%rsp), %rbx
movq %r12, %rbp
movq 0x60(%rsp), %r13
movq 0x30(%rsp), %r12
jmp 0x14ec1e
movl %eax, %ebx
cmpl %eax, %r15d
jae 0x14ebb8
movl %ebx, %r15d
movq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, 0x10(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, %rbp
movq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, %r13
movq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, %r12
movl %ebx, %r15d
movq 0x10(%rsp), %rbx
movq %r15, 0xb8(%rsp)
movl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq %rbp, 0x78(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq %r13, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq %r12, 0x30(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x30(%r14), %rax
testq %rax, %rax
movq %r13, %rbp
je 0x14ec7a
decq %rax
movq %rax, 0x30(%r14)
movq 0xb8(%r14), %rax
movl 0x14(%rax), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl %ecx, 0x74(%rsp)
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
movq %rbx, 0x10(%rsp)
movq 0x8(%rsp), %rdi
je 0x14edd9
movq %rbp, 0x60(%rsp)
movq %rdi, %rbx
movl $0x1, %eax
xorl %ecx, %ecx
xorl %r13d, %r13d
movq %r13, %r15
movq %rcx, %r14
movq %rax, 0x8(%rsp)
cmpq 0xc0(%rsp), %r13
jne 0x14ed0b
leaq (%r15,%r15), %rcx
testq %r15, %r15
movq %rcx, 0xc8(%rsp)
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0xc0(%rsp)
leaq (,%rcx,8), %rsi
movq %rbx, %rdi
callq 0x2370
movq %rax, %rbp
jmp 0x14ed1a
leaq (%r15,%r15), %rax
movq %rax, 0xc8(%rsp)
movq %rbx, %rbp
leaq 0x1(%r15), %r13
movq 0x80(%rsp), %r12
movq %r12, %rdi
movl %r15d, %esi
callq 0x14d3d2
shlq $0x20, %rax
orq %r15, %rax
movq %rbp, %rbx
movq %rax, (%rbp,%r15,8)
movq %r12, %rdi
xorl %esi, %esi
movq 0xc8(%rsp), %rdx
movq 0x30(%rsp), %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x14d241
movq 0x38(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq 0x8(%r14), %rcx
movq 0x8(%rsp), %rax
incq %rax
cmpq %rdx, %r13
jb 0x14ecc1
movq %rbx, %r12
leaq (%rbx,%r13,8), %rsi
movq %rbx, %rdi
callq 0x1379f9
testq %r15, %r15
je 0x14edea
addq %r12, %r14
movq 0x8(%rsp), %r8
shrq %r8
xorl %eax, %eax
movq 0x10(%rsp), %rbx
movq 0x60(%rsp), %rbp
movq %r12, %rsi
movq (%rsi,%rax,8), %rcx
movq (%r14), %rdx
movq %rdx, (%rsi,%rax,8)
movq %rcx, (%r14)
incq %rax
addq $-0x8, %r14
cmpq %rax, %r8
jne 0x14edb5
movq 0x80(%rsp), %r14
jmp 0x14edff
movq 0x8(%rsp), %rsi
callq 0x1379f9
movq 0x8(%rsp), %rsi
jmp 0x14edff
movq 0x80(%rsp), %r14
movq 0x10(%rsp), %rbx
movq 0x60(%rsp), %rbp
movq %r12, %rsi
movq 0x38(%rsp), %r13
movq 0x18(%r13), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
movq %rsi, 0x8(%rsp)
je 0x14f370
xorl %r12d, %r12d
movl (%rsi,%r12,8), %r15d
addl %r15d, %r15d
cmpb $0x0, (%rbp,%r15)
je 0x14ee52
cmpb $0x0, 0x1(%rbp,%r15)
je 0x14f0db
incq %r12
movq 0x18(%r13), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %r12
jb 0x14ee1d
jmp 0x14f370
movq 0x28(%rax), %rax
cmpl $0x0, (%rax,%r15,8)
je 0x14ee2c
movq %r14, %rdi
movq 0x68(%rsp), %rsi
movq %rbx, %rdx
movq 0x78(%rsp), %rcx
movl %r15d, %r8d
movsd 0xe6f10(%rip), %xmm0    # 0x235d88
movsd 0xec3d8(%rip), %xmm1    # 0x23b258
leaq 0x110(%rsp), %r9
leaq 0x18(%rsp), %rax
pushq %rax
leaq 0x24(%rsp), %rax
pushq %rax
leaq 0x30(%rsp), %rax
pushq %rax
leaq 0x3c(%rsp), %rax
pushq %rax
leaq 0x48(%rsp), %rax
pushq %rax
leaq 0x54(%rsp), %rax
pushq %rax
pushq 0x60(%rsp)
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x138(%rsp), %rax
pushq %rax
callq 0x14d9b6
movq 0x58(%rsp), %rsi
movq 0x88(%rsp), %r13
addq $0x50, %rsp
testl %eax, %eax
je 0x14ee2c
movl 0x1c(%rsp), %ebx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %rsi, %rbx
movq 0x68(%rsp), %r13
je 0x14ef5f
movl %ebx, %eax
shrl %eax
movq (%r14), %rcx
movq 0x80(%r14), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x14ef5f
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rcx
jne 0x14ef53
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rsp)
movl %ebx, (%rax,%rcx,4)
movl 0x18(%rsp), %ebx
cmpq %rsi, %rbx
je 0x14efce
movl %ebx, %eax
shrl %eax
movq (%r14), %rcx
movq 0x80(%r14), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x14efce
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rcx
jne 0x14efc2
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rsp)
movl %ebx, (%rax,%rcx,4)
cmpq $0x0, 0x90(%rsp)
movb $0x1, %dil
je 0x14f015
movl $0x1, %eax
xorl %ecx, %ecx
movq 0xa0(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
movb %dil, (%rbp,%rdx)
movq 0xa0(%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
xorq $0x1, %rcx
movb %dil, (%rbp,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x90(%rsp)
ja 0x14efe3
movl 0x2c(%rsp), %eax
cmpq %rsi, %rax
movq 0x10(%rsp), %rbx
je 0x14f028
movb $0x1, (%rbp,%rax)
movl 0x28(%rsp), %eax
cmpq %rsi, %rax
je 0x14f036
movb $0x1, (%rbp,%rax)
movl 0x24(%rsp), %eax
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x14f052
shrl %eax
movl %eax, 0x24(%rsp)
movl %eax, %edx
movl 0x20(%rsp), %eax
cmpl $-0x1, %eax
je 0x14f064
shrl %eax
movl %eax, 0x20(%rsp)
movl %eax, %r8d
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %ecx
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %r13, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
movq 0xc8(%rsp), %r13
movq %r13, 0x8(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
movq %r14, %r9
callq 0x14c338
addq $0x40, %rsp
movl 0x2c(%rsp), %r8d
movl 0x28(%rsp), %r9d
movq %r13, %rsi
movq 0x38(%rsp), %r13
movq %r13, %rdx
leaq 0x90(%rsp), %rcx
callq 0x14e373
movq 0x8(%rsp), %rsi
jmp 0x14ee2c
orq $0x1, %r15
movq 0x18(%r13), %rax
movq 0x28(%rax), %rax
cmpl $0x0, (%rax,%r15,8)
je 0x14ee38
movq %r14, %rdi
movq 0x68(%rsp), %rsi
movq %rbx, %rdx
movq 0x78(%rsp), %rcx
movl %r15d, %r8d
movsd 0xe6c7b(%rip), %xmm0    # 0x235d88
movsd 0xec143(%rip), %xmm1    # 0x23b258
leaq 0x110(%rsp), %r9
leaq 0x18(%rsp), %rax
pushq %rax
leaq 0x24(%rsp), %rax
pushq %rax
leaq 0x30(%rsp), %rax
pushq %rax
leaq 0x3c(%rsp), %rax
pushq %rax
leaq 0x48(%rsp), %rax
pushq %rax
leaq 0x54(%rsp), %rax
pushq %rax
pushq 0x60(%rsp)
leaq 0x78(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x138(%rsp), %rax
pushq %rax
callq 0x14d9b6
movq 0x58(%rsp), %rsi
movq 0x88(%rsp), %r13
addq $0x50, %rsp
testl %eax, %eax
je 0x14ee38
movl 0x1c(%rsp), %ebx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %rsi, %rbx
movq 0x68(%rsp), %r15
je 0x14f1f4
movl %ebx, %eax
shrl %eax
movq (%r14), %rcx
movq 0x80(%r14), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x14f1f4
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rcx
jne 0x14f1e8
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rsp)
movl %ebx, (%rax,%rcx,4)
movl 0x18(%rsp), %ebx
cmpq %rsi, %rbx
je 0x14f263
movl %ebx, %eax
shrl %eax
movq (%r14), %rcx
movq 0x80(%r14), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x14f263
movq 0x40(%rsp), %rcx
movq 0x50(%rsp), %rax
cmpq 0x48(%rsp), %rcx
jne 0x14f257
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x48(%rsp)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x50(%rsp)
movq 0x40(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x40(%rsp)
movl %ebx, (%rax,%rcx,4)
cmpq $0x0, 0x90(%rsp)
movb $0x1, %dil
je 0x14f2aa
movl $0x1, %eax
xorl %ecx, %ecx
movq 0xa0(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
movb %dil, (%rbp,%rdx)
movq 0xa0(%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
xorq $0x1, %rcx
movb %dil, (%rbp,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x90(%rsp)
ja 0x14f278
movl 0x2c(%rsp), %eax
cmpq %rsi, %rax
movq 0x10(%rsp), %rbx
je 0x14f2bd
movb $0x1, (%rbp,%rax)
movl 0x28(%rsp), %eax
cmpq %rsi, %rax
je 0x14f2cb
movb $0x1, (%rbp,%rax)
movl 0x24(%rsp), %eax
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x14f2e7
shrl %eax
movl %eax, 0x24(%rsp)
movl %eax, %edx
movl 0x20(%rsp), %eax
cmpl $-0x1, %eax
je 0x14f2f9
shrl %eax
movl %eax, 0x20(%rsp)
movl %eax, %r8d
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %ecx
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
movq 0xc8(%rsp), %r15
movq %r15, 0x8(%rsp)
leaq 0x110(%rsp), %rax
movq %rax, (%rsp)
leaq 0x80(%rsp), %rdi
movq %r14, %r9
callq 0x14c338
addq $0x40, %rsp
movl 0x2c(%rsp), %r8d
movl 0x28(%rsp), %r9d
movq %r15, %rsi
movq 0x38(%rsp), %r13
movq %r13, %rdx
leaq 0x90(%rsp), %rcx
callq 0x14e373
movq 0x8(%rsp), %rsi
jmp 0x14ee38
movq 0x30(%r14), %rcx
movq 0x40(%r14), %rax
cmpq 0x38(%r14), %rcx
jne 0x14f3a6
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%r14)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%r14)
movq 0x30(%r14), %rcx
movq 0x78(%rsp), %r12
movq 0xb8(%rsp), %r15
movl 0x18(%r14), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r14)
movl %edx, (%rax,%rcx,4)
movq 0xb8(%r14), %rax
movl 0x14(%rax), %ebx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ebx
movl %ebx, %eax
movl 0x74(%rsp), %ecx
subl %ecx, %eax
addq %rax, 0x98(%r14)
cmpl %ecx, %ebx
je 0x14f3ee
movq %r14, %rdi
callq 0x13f2d9
movq 0x88(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x14e73d
movq 0x38(%rsp), %rdi
callq 0xa0761
movq 0xb8(%r14), %rdi
callq 0xb10cd
movq %rax, %rdx
movq %rax, 0xc0(%r14)
cmpl 0x74(%rsp), %ebx
jne 0x14eb71
movq 0xd8(%r14), %rdi
callq 0x2220
movq 0xc0(%r14), %rbx
movq %r14, %r15
movq (%rbx), %r14
movq %r14, 0xd0(%r15)
movq %r14, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %rax, 0xd8(%r15)
movq %r14, 0xc8(%r15)
testq %r14, %r14
je 0x14f4cc
movl $0x1, %r14d
xorl %eax, %eax
movq 0x80(%rsp), %r15
leaq (%rax,%rax,4), %rdi
shlq $0x3, %rdi
addq 0x10(%rbx), %rdi
movq 0xd8(%r15), %rdx
movq %rax, %rsi
shlq $0x5, %rsi
leaq (%rdx,%rsi), %rcx
movq %rax, 0x10(%rdx,%rsi)
movb $0x0, 0x18(%rdx,%rsi)
movq %r15, %rsi
movq 0x68(%rsp), %rdx
callq 0x14cc0f
movl %r14d, %eax
incl %r14d
cmpq %rax, (%rbx)
ja 0x14f47c
movq 0xc8(%r15), %rsi
movq 0xd8(%r15), %rax
jmp 0x14f4ce
xorl %esi, %esi
leaq -0x2743(%rip), %rcx     # 0x14cd92
movl $0x20, %edx
movq %rax, %rdi
callq 0x23f0
movq 0x10(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
callq 0x2220
movq %rbp, %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
callq 0x2220
movq 0x8(%rsp), %rdi
callq 0x2220
movq 0x120(%rsp), %rdi
callq 0x2220
movq 0x100(%rsp), %rdi
callq 0x2220
movq 0xa0(%rsp), %rdi
callq 0x2220
movq 0x50(%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq