// File: chhylp123[P]hifiasm/hic.cpp
// Function: identify_bubbles(ma_ug_t*, bubble_type*, unsigned char*, kv_u_trans_t*)
void identify_bubbles(ma_ug_t* ug, bubble_type* bub, uint8_t *r_het_flag, kv_u_trans_t *ref)
{
    asg_cleanup(ug->g);
    if (!ug->g->is_symm) asg_symm(ug->g);
    uint32_t v, n_vtx = ug->g->n_seq * 2, i, k, mode = (((uint32_t)-1)<<2);
    uint32_t beg, sink, n, *a, n_occ;
    uint64_t pathLen;
    bub->ug = ug; 
    bub->b_bub = bub->b_end_bub = bub->tangle_bub = bub->cross_bub = bub->mess_bub = 0;
    if(bub->round_id == 0)
    {
        buf_t b; memset(&b, 0, sizeof(buf_t)); b.a = (binfo_t*)calloc(n_vtx, sizeof(binfo_t));
        uint64_t tLen = get_bub_pop_max_dist_advance(ug->g, &b);
        kv_init(bub->list); kv_init(bub->num); kv_init(bub->pathLen);
        kv_init(bub->b_s_idx); kv_malloc(bub->b_s_idx, ug->g->n_seq); 
        bub->b_ug = NULL; kv_init(bub->chain_weight);
        bub->b_s_idx.n = ug->g->n_seq;
        memset(bub->b_s_idx.a, -1, bub->b_s_idx.n * sizeof(uint64_t));
        CALLOC(bub->index, n_vtx);
        for (i = 0; i < ug->g->n_seq; i++) ug->g->seq[i].c = 0;
        for (v = 0; v < n_vtx; ++v) 
        {
            if(ug->g->seq[v>>1].del) continue;
            if(asg_arc_n(ug->g, v) < 2) continue;
            if((bub->index[v]&(uint32_t)3) != 0) continue;
            if(asg_bub_pop1_primary_trio(ug->g, NULL, v, tLen, &b, (uint32_t)-1, (uint32_t)-1, 0, NULL, NULL, NULL, 0, 0, NULL))
            {
                //beg is v, end is b.S.a[0]
                //note b.b include end, does not include beg
                for (i = 0; i < b.b.n; i++)
                {
                    if(b.b.a[i]==v || b.b.a[i]==b.S.a[0]) continue;
                    bub->index[b.b.a[i]] &= mode; bub->index[b.b.a[i]] += 1;
                    bub->index[b.b.a[i]^1] &= mode; bub->index[b.b.a[i]^1] += 1;
                }
                bub->index[v] &= mode; bub->index[v] += 2;
                bub->index[b.S.a[0]^1] &= mode; bub->index[b.S.a[0]^1] += 3;
            }
        }

        kvec_t_u32_warp stack, result;
        kv_init(stack.a); kv_init(result.a);
        for (v = 0; v < n_vtx; ++v) 
        {
            if((bub->index[v]&(uint32_t)3) !=2) continue;
            if(asg_bub_pop1_primary_trio(ug->g, ug, v, tLen, &b, (uint32_t)-1, (uint32_t)-1, 0, &pathLen, NULL, NULL, 0, 0, NULL))
            {   
                //note b.b include end, does not include beg
                i = b.b.n + 1;
                if(b.b.n == 2 || b.b.n == 3 || b.b.n == 5)
                {
                    for (i = 0; i < b.b.n; i++)
                    {
                        if(b.b.a[i]==v || b.b.a[i]==b.S.a[0]) continue;
                        dfs_bubble(ug->g, &stack, &result, b.b.a[i]>>1, v>>1, b.S.a[0]>>1);
                        if((result.a.n + 3) != b.b.n && (result.a.n + 2) != b.b.n) break;
                    }
                }

                if(i == b.b.n)
                {
                    kv_push(uint32_t, bub->num, v);
                }
                else
                {
                    kv_push(uint32_t, bub->num, v + (1<<31));
                }
            }
        }
        kv_destroy(stack.a); kv_destroy(result.a);
        radix_sort_u32(bub->num.a, bub->num.a + bub->num.n);
        bub->s_bub = 0;
        for (k = 0; k < bub->num.n; k++)
        {
            if((bub->num.a[k]>>31) == 0) bub->s_bub++;
            v = (bub->num.a[k]<<1)>>1;
            bub->num.a[k] = bub->list.n;
            if(asg_bub_pop1_primary_trio(ug->g, ug, v, tLen, &b, (uint32_t)-1, (uint32_t)-1, 0, &pathLen, NULL, NULL, 0, 0, NULL))
            {
                kv_push(uint64_t, bub->pathLen, pathLen);
                //beg is v, end is b.S.a[0]
                kv_push(uint32_t, bub->list, v);
                kv_push(uint32_t, bub->list, b.S.a[0]^1);
                
                //note b.b include end, does not include beg
                for (i = 0; i < b.b.n; i++)
                {
                    if(b.b.a[i]==v || b.b.a[i]==b.S.a[0]) continue;
                    kv_push(uint32_t, bub->list, b.b.a[i]);
                }
            }
        }
        kv_push(uint32_t, bub->num, bub->list.n);
        free(b.a); free(b.S.a); free(b.T.a); free(b.b.a); free(b.e.a);
        bub->f_bub = bub->num.n - 1; ///bub->s_bub = bub->num.n - 1;
        
        for (i = 0; i < ug->g->n_seq; i++)
        {
            bub->index[i] = get_unitig_het_arb(ug, i, r_het_flag, ref, 20, M_het(*bub), P_het(*bub), (uint32_t)-1);
        }
        for (i = 0; i < bub->f_bub; i++)
        {
            get_bubbles(bub, i, &beg, &sink, &a, &n, &pathLen);
            for (v = n_occ = 0; v < n; v++)
            {
                bub->index[(a[v]>>1)] = i;
                n_occ += ug->u.a[a[v]>>1].n;
            }

            // if((pathLen*2) >= ug->g->seq[beg>>1].len && (pathLen*2) >= ug->g->seq[sink>>1].len)
            // {
            //     bub->index[(beg>>1)] = (uint32_t)-1;
            //     bub->index[(sink>>1)] = (uint32_t)-1;
            // }

            if(n_occ > 3)
            {
                if(bub->index[(beg>>1)] != M_het(*bub)) bub->index[(beg>>1)] = (uint32_t)-1;
                if(bub->index[(sink>>1)] != M_het(*bub)) bub->index[(sink>>1)] = (uint32_t)-1;
            }
            
            
            v = beg>>1;
            if(bub->b_s_idx.a[v] == (uint64_t)-1)
            {
                bub->b_s_idx.a[v] <<= 32;
                bub->b_s_idx.a[v] |= i;
            }
            else if((bub->b_s_idx.a[v] & 0xffffffff00000000) == 0xffffffff00000000)
            {
                bub->b_s_idx.a[v] <<= 32;
                bub->b_s_idx.a[v] |= i;
            }


            v = sink>>1;
            if(bub->b_s_idx.a[v] == (uint64_t)-1)
            {
                bub->b_s_idx.a[v] <<= 32;
                bub->b_s_idx.a[v] |= i;
            }
            else if((bub->b_s_idx.a[v] & 0xffffffff00000000) == 0xffffffff00000000)
            {
                bub->b_s_idx.a[v] <<= 32;
                bub->b_s_idx.a[v] |= i;
            }        
        }
        for (i = 0; i < ug->g->n_seq; i++)
        {
            if(bub->index[i] == M_het(*bub)) bub->index[i] = P_het(*bub);
        }
    }
    else
    {
        bub->num.n = bub->f_bub + 1; 
        bub->pathLen.n = bub->f_bub;
        bub->list.n = bub->num.a[bub->num.n-1];
        update_bub_b_s_idx(bub);
        bub->check_het = 0;
        asg_destroy(bub->b_g); bub->b_g = NULL;
        ma_ug_destroy(bub->b_ug); bub->b_ug = NULL;
        kv_destroy(bub->chain_weight); kv_init(bub->chain_weight);
    }
    bub->b_g = NULL;
    bub->b_ug = NULL;
    build_bub_graph(ug, bub);
    // fprintf(stderr, "-bub->index[18759]: %u, bub->num.n: %u\n",  (uint32_t)bub->index[18759], bub->num.n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xcdd10
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1c5bf8
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xce020
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shll %eax
movl %eax, -0x28(%rbp)
movl $0xfffffffc, -0x34(%rbp) # imm = 0xFFFFFFFC
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xa8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xa0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x98(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x90(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x88(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x1c6bd1
leaq -0xc0(%rbp), %rdi
xorl %esi, %esi
movl $0x68, %edx
callq 0x2100
movl -0x28(%rbp), %eax
movl %eax, %edi
movl $0x1c, %esi
callq 0x2140
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0xc0(%rbp), %rsi
callq 0xfde50
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x50(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x70(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edi
shlq $0x3, %rdi
callq 0x2270
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xd0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xc8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xd8(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rdx
shlq $0x3, %rdx
movl $0xff, %esi
callq 0x2100
movl -0x28(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x2140
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x1c5e6a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x2c(%rbp), %ecx
movb $0x0, 0x4(%rax,%rcx,8)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c5e33
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x1c607d
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x20(%rax), %rax
movl -0x24(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,8), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
je 0x1c5ea0
jmp 0x1c606f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rax
cmpl $0x2, %eax
jae 0x1c5ebd
jmp 0x1c606f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x3, %eax
cmpl $0x0, %eax
je 0x1c5ed7
jmp 0x1c606f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x24(%rbp), %edx
movq -0xc8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0xc0(%rbp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x1c606d
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpq -0x88(%rbp), %rax
jae 0x1c600b
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x24(%rbp), %eax
je 0x1c5f89
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x1c5f8b
jmp 0x1c5ffd
movl -0x34(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x78(%rbp), %rcx
movl -0x2c(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
andl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x78(%rbp), %rcx
movl -0x2c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x78(%rbp), %rcx
movl -0x2c(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
andl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x78(%rbp), %rcx
movl -0x2c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c5f55
movl -0x34(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
andl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %edx
addl $0x2, %edx
movl %edx, (%rax,%rcx,4)
movl -0x34(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0xa8(%rbp), %rcx
movl (%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
andl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0xa8(%rbp), %rcx
movl (%rcx), %ecx
xorl $0x1, %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %edx
addl $0x3, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1c606f
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1c5e71
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq $0x0, -0xd8(%rbp)
movq $0x0, -0x100(%rbp)
movq $0x0, -0x108(%rbp)
movq $0x0, -0xf8(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0x1c63a3
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %eax
andl $0x3, %eax
cmpl $0x2, %eax
je 0x1c60ec
jmp 0x1c6395
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0xc8(%rbp), %rcx
leaq -0xc0(%rbp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
leaq -0x58(%rbp), %rax
xorl %r10d, %r10d
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x1c6393
movq -0x88(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x2c(%rbp)
cmpq $0x2, -0x88(%rbp)
je 0x1c6196
cmpq $0x3, -0x88(%rbp)
je 0x1c6196
cmpq $0x5, -0x88(%rbp)
jne 0x1c624a
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpq -0x88(%rbp), %rax
jae 0x1c6248
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x24(%rbp), %eax
je 0x1c61d1
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x1c61d3
jmp 0x1c623a
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %ecx
shrl %ecx
movl -0x24(%rbp), %r8d
shrl %r8d
movq -0xa8(%rbp), %rax
movl (%rax), %r9d
shrl %r9d
leaq -0xe8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x1c54a0
movq -0x108(%rbp), %rax
addq $0x3, %rax
cmpq -0x88(%rbp), %rax
je 0x1c6238
movq -0x108(%rbp), %rax
addq $0x2, %rax
cmpq -0x88(%rbp), %rax
je 0x1c6238
jmp 0x1c6248
jmp 0x1c623a
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c619d
jmp 0x1c624a
movl -0x2c(%rbp), %eax
cmpq -0x88(%rbp), %rax
jne 0x1c62f4
jmp 0x1c625c
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x1c62ce
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1c628d
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
shlq %rax
movq %rax, -0x110(%rbp)
jmp 0x1c629b
movl $0x2, %eax
movq %rax, -0x110(%rbp)
jmp 0x1c629b
movq -0x110(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movl -0x24(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1c6391
jmp 0x1c62f6
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x1c6368
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1c6327
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
shlq %rax
movq %rax, -0x118(%rbp)
jmp 0x1c6335
movl $0x2, %eax
movq %rax, -0x118(%rbp)
jmp 0x1c6335
movq -0x118(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movl -0x24(%rbp), %edx
addl $0x80000000, %edx       # imm = 0x80000000
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1c6391
jmp 0x1c6393
jmp 0x1c6395
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1c60c6
movq -0xd8(%rbp), %rdi
callq 0x2210
movq -0xf8(%rbp), %rdi
callq 0x2210
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x1ba520
movq -0x10(%rbp), %rax
movq $0x0, 0x78(%rax)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0x1c6798
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x30(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x1c6429
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x30(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shll %eax
shrl %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x30(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x8(%rbp), %rsi
movl -0x24(%rbp), %edx
movq -0xc8(%rbp), %rcx
leaq -0xc0(%rbp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
xorl %eax, %eax
leaq -0x58(%rbp), %rax
xorl %r10d, %r10d
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x0, 0x28(%rsp)
movl $0x0, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
callq 0xfe040
cmpq $0x0, %rax
je 0x1c6788
jmp 0x1c64d2
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x50(%rcx), %rax
jne 0x1c6544
movq -0x10(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x1c6503
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
shlq %rax
movq %rax, -0x120(%rbp)
jmp 0x1c6511
movl $0x2, %eax
movq %rax, -0x120(%rbp)
jmp 0x1c6511
movq -0x120(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x58(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x48(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x48(%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x1c6569
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x1c65db
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1c659a
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
shlq %rax
movq %rax, -0x128(%rbp)
jmp 0x1c65a8
movl $0x2, %eax
movq %rax, -0x128(%rbp)
jmp 0x1c65a8
movq -0x128(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x24(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x18(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x18(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1c65fe
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x1c6670
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1c662f
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
shlq %rax
movq %rax, -0x130(%rbp)
jmp 0x1c663d
movl $0x2, %eax
movq %rax, -0x130(%rbp)
jmp 0x1c663d
movq -0x130(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0xa8(%rbp), %rax
movl (%rax), %edx
xorl $0x1, %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x18(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x18(%rsi)
movl %edx, (%rax,%rcx,4)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpq -0x88(%rbp), %rax
jae 0x1c6786
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
cmpl -0x24(%rbp), %eax
je 0x1c66d5
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0xa8(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x1c66da
jmp 0x1c6778
jmp 0x1c66dc
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x1c674e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1c670d
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
shlq %rax
movq %rax, -0x138(%rbp)
jmp 0x1c671b
movl $0x2, %eax
movq %rax, -0x138(%rbp)
jmp 0x1c671b
movq -0x138(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x78(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x18(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x18(%rsi)
movl %edx, (%rax,%rcx,4)
jmp 0x1c6778
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c66a1
jmp 0x1c6788
jmp 0x1c678a
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1c63f2
jmp 0x1c679a
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
jne 0x1c680c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1c67cb
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
shlq %rax
movq %rax, -0x140(%rbp)
jmp 0x1c67d9
movl $0x2, %eax
movq %rax, -0x140(%rbp)
jmp 0x1c67d9
movq -0x140(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
shlq $0x2, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rsi
movq 0x30(%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, 0x30(%rsi)
movl %edx, (%rax,%rcx,4)
movq -0xc0(%rbp), %rdi
callq 0x2210
movq -0xa8(%rbp), %rdi
callq 0x2210
movq -0x90(%rbp), %rdi
callq 0x2210
movq -0x78(%rbp), %rdi
callq 0x2210
movq -0x60(%rbp), %rdi
callq 0x2210
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
subq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x1c68f6
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
addq $0x1, %rax
movl %eax, %r9d
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl $0x14, %r8d
movl %eax, (%rsp)
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
callq 0x1c5a40
movl %eax, %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c6888
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x80(%rcx), %rax
jae 0x1c6b6b
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %esi
leaq -0x38(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
leaq -0x48(%rbp), %r8
leaq -0x40(%rbp), %r9
leaq -0x58(%rbp), %rax
movq %rax, (%rsp)
callq 0x1c4b20
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x40(%rbp), %eax
jae 0x1c6999
movl -0x2c(%rbp), %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movl -0x24(%rbp), %esi
movl (%rcx,%rsi,4), %ecx
shrl %ecx
movl %ecx, %ecx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x48(%rbp), %rcx
movl -0x24(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
shrl %ecx
movl %ecx, %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
addl -0x4c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1c6945
cmpl $0x3, -0x4c(%rbp)
jbe 0x1c6a0f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
je 0x1c69d6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x38(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
je 0x1c6a0d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x3c(%rbp), %ecx
shrl %ecx
movl %ecx, %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x1c6a0f
movl -0x38(%rbp), %eax
shrl %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
cmpq $-0x1, (%rax,%rcx,8)
jne 0x1c6a5a
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1c6ab5
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
movl -0x24(%rbp), %eax
movl %eax, %edx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq (%rcx,%rdx,8), %rax
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rax
jne 0x1c6ab3
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1c6ab5
movl -0x3c(%rbp), %eax
shrl %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
cmpq $-0x1, (%rax,%rcx,8)
jne 0x1c6b00
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1c6b5b
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
movl -0x24(%rbp), %eax
movl %eax, %edx
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq (%rcx,%rdx,8), %rax
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
cmpq %rcx, %rax
jne 0x1c6b59
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x2c(%rbp), %eax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movl -0x24(%rbp), %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1c6b5b
jmp 0x1c6b5d
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c68fd
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl %ecx, %eax
jae 0x1c6bcc
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movl (%rax,%rcx,4), %eax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jne 0x1c6bbf
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl -0x2c(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x1c6bc1
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1c6b72
jmp 0x1c6cae
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
addq $0x1, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x30(%rcx), %rcx
subq $0x1, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x1c6cf0
movq -0x10(%rbp), %rax
movl $0x0, 0xb0(%rax)
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rdi
callq 0xcd170
movq -0x10(%rbp), %rax
movq $0x0, 0xb8(%rax)
movq -0x10(%rbp), %rax
movq 0xc0(%rax), %rdi
callq 0xcd6f0
movq -0x10(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rdi
callq 0x2210
movq -0x10(%rbp), %rax
movq $0x0, 0xd0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xc8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xd8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xb8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1c6ee0
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)