// File: /workspace/github_cpp_makefile_star2_O2/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 $0x128, %rsp            # imm = 0x128
movq %rsi, %rbx
movq 0xb8(%rsi), %rdx
movq 0xc0(%rsi), %rbp
movq %rdi, 0x68(%rsp)
movq 0x18(%rdi), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
movq 0x18(%rbp), %rcx
movl 0x14(%rcx), %ecx
addl %ecx, %ecx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movq %rdx, 0x88(%rsp)
movl 0x14(%rdx), %r15d
addl %r15d, %r15d
cmpl %r15d, %ecx
cmovgl %ecx, %r15d
xorps %xmm0, %xmm0
leaq 0x100(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0xe0(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movaps %xmm0, (%rax)
movaps %xmm0, (%rcx)
leaq 0x90(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x30(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
pushq $0x1
popq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, 0x60(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, %r12
movq %r15, %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, %r13
movq %r15, 0x80(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x2120
movq %rax, 0x70(%rsp)
leaq 0xc0(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x28(%rsp)
movq $0x0, 0xb8(%rsp)
movq %rbx, 0x8(%rsp)
andq $0x0, 0xc0(%rsp)
movq 0x68(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %ecx
addl %ecx, %ecx
movq 0x18(%rbp), %rax
movl 0x14(%rax), %eax
addl %eax, %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
movq 0xb8(%rbx), %rcx
movl 0x14(%rcx), %ebx
addl %ebx, %ebx
cmpl %ebx, %eax
jge 0x1069cf
movq 0x80(%rsp), %rcx
cmpl %ebx, %ecx
jmp 0x1069db
movl %eax, %ebx
movq 0x80(%rsp), %rcx
cmpl %eax, %ecx
movq 0x60(%rsp), %rdi
jae 0x106a23
movl %ebx, %r14d
movq %r14, %rsi
callq 0x2370
movq %rax, %r15
movq %r12, %rdi
movq %r14, %rsi
callq 0x2370
movq %rax, %r12
movq %r13, %rdi
movq %r14, %rsi
callq 0x2370
movq %rax, %r13
movq 0x70(%rsp), %rdi
movq %r14, %rsi
callq 0x2370
movq %r15, %rdi
movq %rax, %r15
movl %ebx, %ecx
jmp 0x106a28
movq 0x70(%rsp), %r15
movq %rcx, 0x80(%rsp)
movl %ecx, %r14d
movq %rdi, 0x60(%rsp)
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movq %r12, 0x78(%rsp)
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movq 0x8(%rsp), %rcx
movq 0x30(%rcx), %rax
testq %rax, %rax
je 0x106a83
decq %rax
movq %rax, 0x30(%rcx)
movq 0xb8(%rcx), %rax
movl 0x14(%rax), %eax
movl %eax, 0x5c(%rsp)
pushq $-0x8
popq %r12
xorl %r14d, %r14d
movq %r15, 0x70(%rsp)
movq %rbp, 0xb0(%rsp)
movq 0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r14
jae 0x106b4f
movq 0xb8(%rsp), %rax
cmpq %rax, %r14
jne 0x106af4
leaq (%rax,%rax), %rbx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rsi
movq 0x28(%rsp), %rdi
callq 0x2370
movq %rax, %rbp
movq %rbx, 0xb8(%rsp)
jmp 0x106af9
movq 0x28(%rsp), %rbp
leaq 0x1(%r14), %rbx
movq 0x8(%rsp), %r15
movq %r15, %rdi
movl %r14d, %esi
callq 0x10535b
shlq $0x20, %rax
orq %r14, %rax
movq %rbp, 0x28(%rsp)
movq %rax, (%rbp,%r14,8)
leal (%r14,%r14), %edx
movq %r15, %rdi
xorl %esi, %esi
movq 0x70(%rsp), %r15
movq %r15, %rcx
pushq $0x1
popq %r8
xorl %r9d, %r9d
callq 0x10519d
addq $0x8, %r12
movq %rbx, %r14
movq 0xb0(%rsp), %rbp
jmp 0x106aa5
andl $0x7fffffff, 0x5c(%rsp) # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rbx
leaq (%rbx,%r14,8), %rsi
movq %rbx, %rdi
callq 0xf116c
movq %rbx, %rsi
shrq %r14
addq %rbx, %r12
xorl %eax, %eax
movq 0x8(%rsp), %rbx
cmpl %r14d, %eax
jae 0x106b96
movq (%rsi,%rax,8), %rcx
movq (%r12), %rdx
movq %rdx, (%rsi,%rax,8)
movq %rcx, (%r12)
incq %rax
addq $-0x8, %r12
jmp 0x106b78
xorl %r12d, %r12d
movq 0x18(%rbp), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %r12
jae 0x1070cd
movl (%rsi,%r12,8), %r14d
addl %r14d, %r14d
cmpb $0x0, (%r13,%r14)
je 0x106bcf
cmpb $0x0, 0x1(%r13,%r14)
je 0x106d85
incq %r12
jmp 0x106b99
movq 0x28(%rax), %rax
cmpl $0x0, (%rax,%r14,8)
je 0x106bbe
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x78(%rsp), %rcx
movl %r14d, %r8d
movsd 0xe1091(%rip), %xmm0    # 0x1e7c88
movsd 0xe6549(%rip), %xmm1    # 0x1ed148
leaq 0x100(%rsp), %r9
leaq 0x10(%rsp), %rax
pushq %rax
leaq 0x1c(%rsp), %rax
pushq %rax
leaq 0x28(%rsp), %rax
pushq %rax
leaq 0x34(%rsp), %rax
pushq %rax
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x4c(%rsp), %rax
pushq %rax
pushq %r15
leaq 0x68(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x128(%rsp), %rax
pushq %rax
callq 0x1058b4
movq 0x78(%rsp), %rsi
addq $0x50, %rsp
testl %eax, %eax
je 0x106bbe
movl 0x14(%rsp), %ebx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %rsi, %rbx
je 0x106cd2
movl %ebx, %eax
shrl %eax
movq 0x8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x106cd2
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rcx
jne 0x106cc6
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
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movl %ebx, (%rax,%rcx,4)
movl 0x10(%rsp), %ebx
cmpq %rsi, %rbx
je 0x106d44
movl %ebx, %eax
shrl %eax
movq 0x8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x106d44
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rcx
jne 0x106d38
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
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movl %ebx, (%rax,%rcx,4)
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movb $0x1, %dl
movl %eax, %eax
cmpq %rax, 0x90(%rsp)
jbe 0x106f47
movq 0xa0(%rsp), %rcx
movl (%rcx,%rax,4), %ecx
movb %dl, (%r13,%rcx)
movq 0xa0(%rsp), %rcx
movl (%rcx,%rax,4), %ecx
xorq $0x1, %rcx
movb %dl, (%r13,%rcx)
incl %eax
jmp 0x106d4d
orq $0x1, %r14
movq 0x18(%rbp), %rax
movq 0x28(%rax), %rax
cmpl $0x0, (%rax,%r14,8)
je 0x106bca
movq %rbx, %rdi
movq 0x68(%rsp), %rsi
movq 0x60(%rsp), %rdx
movq 0x78(%rsp), %rcx
movl %r14d, %r8d
movsd 0xe0ecf(%rip), %xmm0    # 0x1e7c88
movsd 0xe6387(%rip), %xmm1    # 0x1ed148
leaq 0x100(%rsp), %r9
leaq 0x10(%rsp), %rax
pushq %rax
leaq 0x1c(%rsp), %rax
pushq %rax
leaq 0x28(%rsp), %rax
pushq %rax
leaq 0x34(%rsp), %rax
pushq %rax
leaq 0x40(%rsp), %rax
pushq %rax
leaq 0x4c(%rsp), %rax
pushq %rax
pushq %r15
leaq 0x68(%rsp), %rax
pushq %rax
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x128(%rsp), %rax
pushq %rax
callq 0x1058b4
movq 0x78(%rsp), %rsi
addq $0x50, %rsp
testl %eax, %eax
je 0x106bca
movl 0x14(%rsp), %ebx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
cmpq %rsi, %rbx
je 0x106e94
movl %ebx, %eax
shrl %eax
movq 0x8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x106e94
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rcx
jne 0x106e88
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
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movl %ebx, (%rax,%rcx,4)
movl 0x10(%rsp), %ebx
cmpq %rsi, %rbx
je 0x106f06
movl %ebx, %eax
shrl %eax
movq 0x8(%rsp), %rdx
movq (%rdx), %rcx
movq 0x80(%rdx), %rdx
movl (%rcx,%rax,4), %eax
incq %rdx
cmpq %rax, %rdx
jb 0x106f06
movq 0x30(%rsp), %rcx
movq 0x40(%rsp), %rax
cmpq 0x38(%rsp), %rcx
jne 0x106efa
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
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rsp)
movl %ebx, (%rax,%rcx,4)
xorl %eax, %eax
movq 0x8(%rsp), %rbx
movb $0x1, %dl
movl %eax, %eax
cmpq %rax, 0x90(%rsp)
jbe 0x10700e
movq 0xa0(%rsp), %rcx
movl (%rcx,%rax,4), %ecx
movb %dl, (%r13,%rcx)
movq 0xa0(%rsp), %rcx
movl (%rcx,%rax,4), %ecx
xorq $0x1, %rcx
movb %dl, (%r13,%rcx)
incl %eax
jmp 0x106f0f
movl 0x24(%rsp), %eax
cmpq %rsi, %rax
je 0x106f56
movb $0x1, (%r13,%rax)
movl 0x20(%rsp), %eax
cmpq %rsi, %rax
je 0x106f65
movb $0x1, (%r13,%rax)
movl 0x1c(%rsp), %eax
pushq $-0x1
popq %rdx
cmpl $-0x1, %eax
je 0x106f79
shrl %eax
movl %eax, 0x1c(%rsp)
movl %eax, %edx
movl 0x18(%rsp), %eax
pushq $-0x1
popq %r8
cmpl $-0x1, %eax
je 0x106f8f
shrl %eax
movl %eax, 0x18(%rsp)
movl %eax, %r8d
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %ecx
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
movq 0xc8(%rsp), %rbp
movq %rbp, 0x8(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %rdi
movq %rbx, %r9
callq 0x10441e
addq $0x40, %rsp
movl 0x24(%rsp), %r8d
movl 0x20(%rsp), %r9d
movq %rbp, %rsi
movq 0xb0(%rsp), %rbp
movq %rbp, %rdx
leaq 0x90(%rsp), %rcx
callq 0x1062c5
movq 0x28(%rsp), %rsi
jmp 0x106bbe
movl 0x24(%rsp), %eax
cmpq %rsi, %rax
je 0x10701d
movb $0x1, (%r13,%rax)
movl 0x20(%rsp), %eax
cmpq %rsi, %rax
je 0x10702c
movb $0x1, (%r13,%rax)
movl 0x1c(%rsp), %eax
pushq $-0x1
popq %rdx
cmpl $-0x1, %eax
je 0x107040
shrl %eax
movl %eax, 0x1c(%rsp)
movl %eax, %edx
movl 0x18(%rsp), %eax
pushq $-0x1
popq %r8
cmpl $-0x1, %eax
je 0x107056
shrl %eax
movl %eax, 0x18(%rsp)
movl %eax, %r8d
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %ecx
subq $0x40, %rsp
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rsp)
movq 0xa8(%rsp), %rax
movq %rax, 0x20(%rsp)
movups %xmm0, 0x10(%rsp)
movq 0xc8(%rsp), %r14
movq %r14, 0x8(%rsp)
leaq 0x100(%rsp), %rax
movq %rax, (%rsp)
leaq 0x70(%rsp), %rdi
movq %rbx, %r9
callq 0x10441e
addq $0x40, %rsp
movl 0x24(%rsp), %r8d
movl 0x20(%rsp), %r9d
movq %r14, %rsi
movq %rbp, %rdx
leaq 0x90(%rsp), %rcx
callq 0x1062c5
movq 0x28(%rsp), %rsi
jmp 0x106bca
movq 0x30(%rbx), %rcx
movq 0x40(%rbx), %rax
cmpq 0x38(%rbx), %rcx
jne 0x107101
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rcx
movq 0x78(%rsp), %r12
movl 0x5c(%rsp), %r15d
movl 0x18(%rbx), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%rbx)
movl %edx, (%rax,%rcx,4)
movq 0xb8(%rbx), %rax
movq %rbx, %r14
movl 0x14(%rax), %ebx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ebx
movl %ebx, %eax
subl %r15d, %eax
addq %rax, 0x98(%r14)
cmpl %r15d, %ebx
je 0x107146
movq %r14, %rdi
callq 0xf7cab
movq 0x88(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x1066d7
movq %rbp, %rdi
callq 0x6921d
movq 0xb8(%r14), %rdi
callq 0x76d91
movq %rax, %rbp
movq %rax, 0xc0(%r14)
cmpl %r15d, %ebx
movq %r14, %rbx
jne 0x10698e
movq 0xd8(%rbx), %rdi
callq 0x2220
movq %rbx, %r14
movq 0xc0(%rbx), %rbx
movq (%rbx), %r12
movq %r12, 0xd0(%r14)
movq %r12, %rdi
shlq $0x5, %rdi
callq 0x2280
movq %rax, 0xd8(%r14)
movq %r12, 0xc8(%r14)
xorl %eax, %eax
movq 0x70(%rsp), %r15
movl %eax, %r14d
cmpq %r14, %r12
jbe 0x10720a
imulq $0x28, %r14, %rdi
addq 0x10(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0xd8(%rsi), %rax
movq %r14, %rdx
shlq $0x5, %rdx
leaq (%rax,%rdx), %rcx
movq %r14, 0x10(%rax,%rdx)
movb $0x0, 0x18(%rax,%rdx)
movq 0x68(%rsp), %rdx
callq 0x104bf5
leal 0x1(%r14), %eax
movq (%rbx), %r12
jmp 0x1071c6
movq 0x8(%rsp), %rax
movq 0xc8(%rax), %rsi
movq 0xd8(%rax), %rdi
leaq -0x24db(%rip), %rcx     # 0x104d49
pushq $0x20
popq %rdx
callq 0x23f0
movq 0x60(%rsp), %rdi
callq 0x2220
movq 0x78(%rsp), %rdi
callq 0x2220
movq %r13, %rdi
callq 0x2220
movq %r15, %rdi
callq 0x2220
movq 0x28(%rsp), %rdi
callq 0x2220
movq 0x110(%rsp), %rdi
callq 0x2220
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0xa0(%rsp), %rdi
callq 0x2220
movq 0x40(%rsp), %rdi
callq 0x2220
movq 0xd0(%rsp), %rdi
callq 0x2220
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq