// File: /workspace/github_cpp_makefile_star2_O1/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 $0x118, %rsp            # imm = 0x118
movq %rsi, %rbx
movq 0xc0(%rsi), %r13
movq %rdi, 0x68(%rsp)
movq 0x18(%rdi), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movq 0x18(%r13), %rcx
movl 0x14(%rcx), %ecx
addl %ecx, %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movq 0xb8(%rsi), %rax
movq %rax, 0x78(%rsp)
movl 0x14(%rax), %r15d
addl %r15d, %r15d
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
xorps %xmm0, %xmm0
leaq 0xf0(%rsp), %rax
movaps %xmm0, (%rax)
xorl %r14d, %r14d
movq %r14, 0x10(%rax)
leaq 0xd0(%rsp), %rax
movaps %xmm0, (%rax)
movq %r14, 0x10(%rax)
leaq 0x80(%rsp), %rax
movaps %xmm0, (%rax)
movq %r14, 0x10(%rax)
leaq 0x20(%rsp), %rax
movaps %xmm0, (%rax)
movq %r14, 0x10(%rax)
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x60(%rsp)
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, 0x58(%rsp)
movl $0x1, %esi
movq %r15, %rdi
callq 0x2120
movq %rax, %rbp
movl $0x1, %esi
movq %r15, 0xa0(%rsp)
movq %r15, %rdi
callq 0x2120
movq %rax, %r12
leaq 0xb0(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
movq %r14, 0x10(%rax)
movq $0x0, 0xa8(%rsp)
movq %rbx, 0x48(%rsp)
movq %r12, 0x40(%rsp)
movq %r13, 0x50(%rsp)
movq $0x0, 0xb0(%rsp)
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
addl %ecx, %ecx
movq 0xc0(%rbx), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq 0xb8(%rbx), %rcx
movl 0x14(%rcx), %r15d
addl %r15d, %r15d
cmpl %r15d, %eax
movl %r15d, %ecx
cmovgl %eax, %ecx
movq 0xa0(%rsp), %rdx
cmpl %ecx, %edx
jae 0x148679
cmpl %r15d, %eax
cmovgl %eax, %r15d
movq 0x60(%rsp), %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, %r13
movq 0x58(%rsp), %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, %r12
movq %rbp, %rdi
movq %r15, %rsi
callq 0x2370
movq %rax, %rbp
movq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x2370
movq %r13, %rdi
movq %rax, %r13
movl %r15d, %edx
jmp 0x148688
movq 0x58(%rsp), %r12
movq 0x40(%rsp), %r13
movq 0x60(%rsp), %rdi
movq %rdx, 0xa0(%rsp)
movl %edx, %r15d
movq %rdi, 0x60(%rsp)
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq %r12, 0x58(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq %r13, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x20e0
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x1486de
decq %rax
movq %rax, 0x30(%rbx)
movq %r13, 0x40(%rsp)
movq 0xb8(%rbx), %rax
movl 0x14(%rax), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl %ecx, 0x74(%rsp)
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
je 0x1487b3
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0xa8(%rsp), %rax
cmpq %rax, %r12
jne 0x14874e
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rsi
movq %r14, %rdi
callq 0x2370
movq %rax, %r13
movq %rbx, 0xa8(%rsp)
jmp 0x148751
movq %r14, %r13
leaq 0x1(%r12), %rbx
movq 0x48(%rsp), %r14
movq %r14, %rdi
movl %r12d, %esi
callq 0x146d7f
shlq $0x20, %rax
addq %r12, %rax
movq %rax, (%r13,%r12,8)
movq %r14, %rdi
xorl %esi, %esi
movl %r15d, %edx
movq 0x40(%rsp), %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x146be0
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addl $0x2, %r15d
movq %rbx, %r12
cmpq %rax, %rbx
movq %r13, %r14
jb 0x148714
jmp 0x1487b5
xorl %ebx, %ebx
leaq (%r14,%rbx,8), %rsi
movq %r14, %rdi
callq 0x13180d
cmpq $0x2, %rbx
jb 0x1487ee
leaq (%r14,%rbx,8), %rax
addq $-0x8, %rax
shrq %rbx
xorl %ecx, %ecx
movq (%r14,%rcx,8), %rdx
movq (%rax), %rsi
movq %rsi, (%r14,%rcx,8)
movq %rdx, (%rax)
incq %rcx
addq $-0x8, %rax
cmpq %rcx, %rbx
jne 0x1487d4
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
movq 0x48(%rsp), %rbx
leaq 0xf0(%rsp), %r13
je 0x148d54
xorl %r12d, %r12d
movl (%r14,%r12,8), %r15d
addl %r15d, %r15d
cmpb $0x0, (%rbp,%r15)
je 0x14884e
cmpb $0x0, 0x1(%rbp,%r15)
je 0x148acb
incq %r12
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %r12
jb 0x148814
jmp 0x148d54
movq 0x28(%rax), %rax
cmpl $0x0, (%rax,%r15,8)
je 0x148823
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x58(%rsp), %rcx
movl %r15d, %r8d
movsd 0xe131a(%rip), %xmm0    # 0x229b90
movsd 0xe678a(%rip), %xmm1    # 0x22f008
movq %r13, %r9
leaq 0x10(%rsp), %rax
pushq %rax
leaq 0x1c(%rsp), %rax
pushq %rax
leaq 0x18(%rsp), %rax
pushq %rax
leaq 0x24(%rsp), %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
leaq 0x44(%rsp), %rax
pushq %rax
pushq 0x70(%rsp)
leaq 0x58(%rsp), %rax
pushq %rax
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0x118(%rsp), %rax
pushq %rax
callq 0x14736a
addq $0x50, %rsp
testl %eax, %eax
je 0x148823
movl 0x14(%rsp), %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbx
movq 0x68(%rsp), %r13
je 0x14894d
movl %ebx, %eax
shrl %eax
movq 0x48(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x14894d
movq 0x28(%rsp), %rax
cmpq %rax, 0x20(%rsp)
jne 0x148937
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x28(%rsp)
movq 0x30(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x20(%rsp)
movl %ebx, (%rcx,%rax,4)
movl 0x10(%rsp), %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbx
je 0x1489c3
movl %ebx, %eax
shrl %eax
movq 0x48(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x1489c3
movq 0x28(%rsp), %rax
cmpq %rax, 0x20(%rsp)
jne 0x1489ad
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x28(%rsp)
movq 0x30(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x20(%rsp)
movl %ebx, (%rcx,%rax,4)
cmpq $0x0, 0x80(%rsp)
movb $0x1, %sil
je 0x148a0a
movl $0x1, %eax
xorl %ecx, %ecx
movq 0x90(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
movb %sil, (%rbp,%rdx)
movq 0x90(%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
xorq $0x1, %rcx
movb %sil, (%rbp,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x80(%rsp)
ja 0x1489d8
movl 0x1c(%rsp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
movq 0x48(%rsp), %rbx
je 0x148a22
movb $0x1, (%rbp,%rax)
movl 0x18(%rsp), %eax
cmpq %rcx, %rax
je 0x148a30
movb $0x1, (%rbp,%rax)
movl 0xc(%rsp), %eax
cmpl $-0x1, %eax
je 0x148a3f
shrl %eax
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %eax
cmpl $-0x1, %eax
je 0x148a4e
shrl %eax
movl %eax, 0x8(%rsp)
movl 0x14(%rsp), %esi
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq %r13, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
movq 0xb8(%rsp), %r13
movq %r13, 0x8(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x60(%rsp), %rdi
movq %rbx, %r9
callq 0x145cd9
addq $0x40, %rsp
movl 0x1c(%rsp), %r8d
movl 0x18(%rsp), %r9d
movq %r13, %rsi
movq 0x50(%rsp), %rdx
leaq 0x80(%rsp), %rcx
callq 0x147dea
leaq 0xf0(%rsp), %r13
jmp 0x148823
orq $0x1, %r15
movq 0x50(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
cmpl $0x0, (%rax,%r15,8)
je 0x14882f
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x58(%rsp), %rcx
movl %r15d, %r8d
movsd 0xe108c(%rip), %xmm0    # 0x229b90
movsd 0xe64fc(%rip), %xmm1    # 0x22f008
movq %r13, %r9
leaq 0x10(%rsp), %rax
pushq %rax
leaq 0x1c(%rsp), %rax
pushq %rax
leaq 0x18(%rsp), %rax
pushq %rax
leaq 0x24(%rsp), %rax
pushq %rax
leaq 0x38(%rsp), %rax
pushq %rax
leaq 0x44(%rsp), %rax
pushq %rax
pushq 0x70(%rsp)
leaq 0x58(%rsp), %rax
pushq %rax
leaq 0xc0(%rsp), %rax
pushq %rax
leaq 0x118(%rsp), %rax
pushq %rax
callq 0x14736a
addq $0x50, %rsp
testl %eax, %eax
je 0x14882f
movl 0x14(%rsp), %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbx
je 0x148bd6
movl %ebx, %eax
shrl %eax
movq 0x48(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x148bd6
movq 0x28(%rsp), %rax
cmpq %rax, 0x20(%rsp)
jne 0x148bc0
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x28(%rsp)
movq 0x30(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x20(%rsp)
movl %ebx, (%rcx,%rax,4)
movl 0x10(%rsp), %ebx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, %rbx
je 0x148c4c
movl %ebx, %eax
shrl %eax
movq 0x48(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x148c4c
movq 0x28(%rsp), %rax
cmpq %rax, 0x20(%rsp)
jne 0x148c36
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x28(%rsp)
movq 0x30(%rsp), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x30(%rsp)
movq 0x20(%rsp), %rax
movq 0x30(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x20(%rsp)
movl %ebx, (%rcx,%rax,4)
cmpq $0x0, 0x80(%rsp)
movb $0x1, %sil
je 0x148c93
movl $0x1, %eax
xorl %ecx, %ecx
movq 0x90(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
movb %sil, (%rbp,%rdx)
movq 0x90(%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
xorq $0x1, %rcx
movb %sil, (%rbp,%rcx)
movl %eax, %ecx
incl %eax
cmpq %rcx, 0x80(%rsp)
ja 0x148c61
movl 0x1c(%rsp), %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
movq 0x48(%rsp), %rbx
je 0x148cab
movb $0x1, (%rbp,%rax)
movl 0x18(%rsp), %eax
cmpq %rcx, %rax
je 0x148cb9
movb $0x1, (%rbp,%rax)
movl 0xc(%rsp), %eax
cmpl $-0x1, %eax
je 0x148cc8
shrl %eax
movl %eax, 0xc(%rsp)
movl 0x8(%rsp), %eax
cmpl $-0x1, %eax
je 0x148cd7
shrl %eax
movl %eax, 0x8(%rsp)
movl 0x14(%rsp), %esi
movl 0xc(%rsp), %edx
movl 0x10(%rsp), %ecx
movl 0x8(%rsp), %r8d
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
movq 0xb8(%rsp), %r15
movq %r15, 0x8(%rsp)
leaq 0xf0(%rsp), %rax
movq %rax, (%rsp)
leaq 0x60(%rsp), %rdi
movq %rbx, %r9
callq 0x145cd9
addq $0x40, %rsp
movl 0x1c(%rsp), %r8d
movl 0x18(%rsp), %r9d
movq %r15, %rsi
movq 0x50(%rsp), %rdx
leaq 0x80(%rsp), %rcx
callq 0x147dea
jmp 0x14882f
movq 0x38(%rbx), %rax
cmpq %rax, 0x30(%rbx)
jne 0x148d83
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%rbx)
movl 0x18(%rbx), %eax
movq 0x40(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x30(%rbx)
movl %eax, (%rcx,%rdx,4)
movq 0xb8(%rbx), %rax
movq %rbx, %r15
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(%r15)
cmpl %ecx, %ebx
movq 0x40(%rsp), %r12
je 0x148dcd
movq %r15, %rdi
callq 0x1394bc
movq 0x78(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1481b6
movq 0x50(%rsp), %rdi
callq 0xa0004
movq 0xb8(%r15), %rdi
callq 0xb0285
movq %rax, %r13
movq %rax, 0xc0(%r15)
cmpl 0x74(%rsp), %ebx
movq %r15, %rbx
jne 0x1485d0
movq 0xd8(%rbx), %rdi
callq 0x2220
movq %rbx, %r12
movq 0xc0(%rbx), %rbx
movq $0x0, 0xc8(%r12)
movq (%rbx), %r15
movq %r15, 0xd0(%r12)
movq %r15, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %rax, 0xd8(%r12)
movq %r15, 0xc8(%r12)
cmpq $0x0, (%rbx)
movq 0x68(%rsp), %r13
je 0x148ea7
movl $0x1, %r15d
xorl %eax, %eax
leaq (%rax,%rax,4), %rdi
shlq $0x3, %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 %r13, %rdx
callq 0x14655c
movl %r15d, %eax
incl %r15d
cmpq %rax, (%rbx)
ja 0x148e68
movq 0xc8(%r12), %rsi
movq 0xd8(%r12), %rdi
leaq -0x2800(%rip), %rcx     # 0x1466be
movl $0x20, %edx
callq 0x23f0
movq 0x60(%rsp), %rdi
callq 0x2220
movq 0x58(%rsp), %rdi
callq 0x2220
movq %rbp, %rdi
callq 0x2220
movq 0x40(%rsp), %rdi
callq 0x2220
movq %r14, %rdi
callq 0x2220
movq 0x100(%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0x30(%rsp), %rdi
callq 0x2220
movq 0xc0(%rsp), %rdi
callq 0x2220
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq