// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: identify_bubbles_recal(asg_t*, ma_ug_t*, bubble_type*, unsigned char*, ma_hit_t_alloc*, R_to_U*, kv_u_trans_t*)
void identify_bubbles_recal(asg_t* sg, ma_ug_t* ug, bubble_type* bub, uint8_t *r_het_flag, ma_hit_t_alloc* sources, R_to_U* ruIndex,
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, hom_cov, het_cov, m_het_cov, m_hom_cov;
    bub->ug = ug; 
    bub->b_bub = bub->b_end_bub = bub->tangle_bub = bub->cross_bub = bub->mess_bub = 0;

    if(asm_opt.hom_global_coverage_set) {
        hom_cov = asm_opt.hom_global_coverage;
    } else {
        hom_cov = ((double)asm_opt.hom_global_coverage)/((double)HOM_PEAK_RATE);
    }
    het_cov = hom_cov/asm_opt.polyploidy;
    m_het_cov = hom_cov - het_cov + (het_cov*0.333333);
    m_hom_cov = hom_cov - het_cov + (het_cov*0.6);
    // fprintf(stderr, "hom_cov::%lu, het_cov::%lu, m_het_cov::%lu, m_hom_cov::%lu\n",  hom_cov, het_cov, m_het_cov, m_hom_cov);

    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;

        memset(r_het_flag, 0, sizeof((*r_het_flag))*sg->n_seq);
        for (i = 0; i < ug->g->n_seq; i++) {
            bub->index[i] = get_unitig_het_fly(ug, i, sg, m_het_cov, m_hom_cov,
            sources, ruIndex, r_het_flag, 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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %r9, %r12
movq %r8, %r13
movq %rcx, 0x88(%rsp)
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x80(%rsp)
movq 0x18(%rsi), %rdi
callq 0x694eb
movq 0x18(%r14), %r15
movl 0x14(%r15), %r8d
testl %r8d, %r8d
js 0xf8132
movq %r15, %rdi
callq 0x69638
movq 0x18(%r14), %r15
movl 0x14(%r15), %r8d
movq %r14, 0x10(%rbx)
xorps %xmm5, %xmm5
movups %xmm5, 0x88(%rbx)
movups %xmm5, 0x98(%rbx)
andq $0x0, 0xa8(%rbx)
leaq 0x15b602(%rip), %rax    # 0x253758
movslq 0x144(%rax), %rdx
cvtsi2sd %edx, %xmm1
divsd 0xefaf7(%rip), %xmm1    # 0x1e7c60
cvttsd2si %xmm1, %rsi
movsd 0xeb122(%rip), %xmm0    # 0x1e3298
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rdi
movq %rsi, %rcx
sarq $0x3f, %rcx
andq %rdi, %rcx
orq %rsi, %rcx
cmpl $0x0, 0x148(%rax)
cmovneq %rdx, %rcx
movslq 0x1bc(%rax), %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
cmpl $0x0, 0x8(%rbx)
je 0xf824e
movq 0x40(%rbx), %rax
movq 0x80(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rbx)
movq %rcx, 0x48(%rbx)
movl (%rax,%rcx,4), %eax
movq %rax, 0x18(%rbx)
movq %rbx, %rdi
callq 0xf7cab
andl $0x0, 0xb0(%rbx)
movq 0xb8(%rbx), %rdi
callq 0x68f68
andq $0x0, 0xb8(%rbx)
movq 0xc0(%rbx), %rdi
callq 0x6921d
andq $0x0, 0xc0(%rbx)
movq 0xd8(%rbx), %rdi
callq 0x2220
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc8(%rbx)
andq $0x0, 0xd8(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xf7d63
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, 0x68(%rsp)
movq %r12, 0x70(%rsp)
subq %rax, %rcx
movq %rcx, %xmm1
movq 0xeb008(%rip), %xmm2    # 0x1e3270
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xeb00c(%rip), %xmm3    # 0x1e3280
subpd %xmm3, %xmm1
movapd %xmm1, %xmm4
unpckhpd %xmm1, %xmm4            # xmm4 = xmm4[1],xmm1[1]
addsd %xmm1, %xmm4
movq %rax, %xmm1
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movsd 0xeb303(%rip), %xmm1    # 0x1e35a8
mulsd %xmm2, %xmm1
addsd %xmm4, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %rdx
mulsd 0xeb20e(%rip), %xmm2    # 0x1e34d8
andq %rcx, %rdx
addsd %xmm4, %xmm2
cvttsd2si %xmm2, %rcx
orq %rax, %rdx
movq %rdx, 0x98(%rsp)
movq %rcx, %rax
sarq $0x3f, %rax
subsd %xmm0, %xmm2
cvttsd2si %xmm2, %rdx
andq %rax, %rdx
orq %rcx, %rdx
movq %rdx, 0x90(%rsp)
movq %r8, %r12
addl %r12d, %r12d
leaq 0xa8(%rsp), %r13
movups %xmm5, 0x58(%r13)
movups %xmm5, 0x48(%r13)
movups %xmm5, 0x38(%r13)
movups %xmm5, 0x28(%r13)
movups %xmm5, 0x18(%r13)
movups %xmm5, 0x8(%r13)
pushq $0x1c
popq %rsi
movq %r12, %rdi
callq 0x2120
movq %rax, (%r13)
movq %r15, %rdi
movq %r13, %rsi
callq 0x84975
movq %rax, 0x50(%rsp)
leaq 0x18(%rbx), %rbp
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rbx)
movupd %xmm0, 0x28(%rbx)
movupd %xmm0, 0x38(%rbx)
movupd %xmm0, 0x48(%rbx)
movupd %xmm0, 0x58(%rbx)
movupd %xmm0, 0x68(%rbx)
movq 0x18(%r14), %r15
movl 0x14(%r15), %eax
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
andq %r13, %rax
movq %rax, 0x68(%rbx)
movl 0x14(%r15), %edi
andq %r13, %rdi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x70(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc0(%rbx)
movupd %xmm0, 0xd0(%rbx)
movl 0x14(%r15), %edx
andq %r13, %rdx
movq %rdx, 0x60(%rbx)
shlq $0x3, %rdx
movq %rax, %rdi
movl $0xff, %esi
callq 0x20e0
pushq $0x4
popq %rsi
movq %r12, %rdi
callq 0x2120
movq %rax, (%rbx)
xorl %eax, %eax
movl 0x14(%r15), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
jae 0xf83f6
movq 0x20(%r15), %rcx
movb $0x0, 0x4(%rcx,%rax,8)
incq %rax
jmp 0xf83d9
xorl %r15d, %r15d
pushq $-0x1
popq %r13
cmpq %r12, %r15
je 0xf8515
movq 0x18(%r14), %rdi
movq 0x20(%rdi), %rax
movl %r15d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xf850d
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%r15,8) # imm = 0xFFFFFFFE
je 0xf850d
movq (%rbx), %rax
testb $0x3, (%rax,%r15,4)
jne 0xf850d
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
andl $0x0, 0x28(%rsp)
andq $0x0, 0x20(%rsp)
andl $0x0, 0x8(%rsp)
orl $-0x1, (%rsp)
xorl %esi, %esi
movl %r15d, %edx
movq 0x50(%rsp), %rcx
leaq 0xa8(%rsp), %r8
movl %r13d, %r9d
callq 0x84a86
testq %rax, %rax
je 0xf850d
movq 0xc0(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq 0xf0(%rsp), %rdx
xorl %esi, %esi
movl %esi, %esi
cmpq %rsi, %rcx
jbe 0xf84e0
movl (%rdx,%rsi,4), %edi
cmpq %rdi, %r15
je 0xf84dc
cmpl (%rax), %edi
je 0xf84dc
movq (%rbx), %r8
andl $-0x4, (%r8,%rdi,4)
movl (%rdx,%rsi,4), %edi
incl (%r8,%rdi,4)
movl (%rdx,%rsi,4), %edi
xorq $0x1, %rdi
andl $-0x4, (%r8,%rdi,4)
movl (%rdx,%rsi,4), %edi
xorq $0x1, %rdi
incl (%r8,%rdi,4)
incl %esi
jmp 0xf84a3
movq (%rbx), %rax
movl (%rax,%r15,4), %ecx
andl $-0x4, %ecx
orl $0x2, %ecx
movl %ecx, (%rax,%r15,4)
movq 0xc0(%rsp), %rcx
movl (%rcx), %edx
xorq $0x1, %rdx
andl $-0x4, (%rax,%rdx,4)
movl (%rcx), %ecx
xorq $0x1, %rcx
addl $0x3, (%rax,%rcx,4)
incq %r15
jmp 0xf83fd
xorpd %xmm0, %xmm0
leaq 0x130(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x110(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movapd %xmm0, (%rax)
movapd %xmm0, (%rcx)
xorl %r13d, %r13d
leaq 0xa8(%rsp), %r15
movq %r12, 0x78(%rsp)
cmpq %r12, %r13
je 0xf8700
movq (%rbx), %rax
movl (%rax,%r13,4), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0xf86f8
movq 0x18(%r14), %rdi
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
andl $0x0, 0x28(%rsp)
andl $0x0, 0x8(%rsp)
orl $-0x1, (%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rsi
movl %r13d, %edx
movq 0x50(%rsp), %rcx
movq %r15, %r8
pushq $-0x1
popq %r9
callq 0x84a86
testq %rax, %rax
je 0xf86f8
movq 0xe0(%rsp), %rdx
cmpq $0x5, %rdx
ja 0xf8661
pushq $0x2c
popq %rax
btq %rdx, %rax
jae 0xf8661
movl %r13d, %r15d
shrl %r15d
xorl %r12d, %r12d
movl %r12d, %r12d
cmpq %r12, %rdx
jbe 0xf8657
movq 0xf0(%rsp), %rax
movl (%rax,%r12,4), %ecx
cmpq %rcx, %r13
je 0xf8652
movq 0xc0(%rsp), %rax
movl (%rax), %r9d
cmpl %r9d, %ecx
je 0xf8652
movq 0x18(%r14), %rdi
shrl %ecx
shrl %r9d
leaq 0x130(%rsp), %rsi
leaq 0x110(%rsp), %rdx
movl %r15d, %r8d
callq 0xf6fe5
movq 0x110(%rsp), %rax
leaq 0x3(%rax), %rcx
movq 0xe0(%rsp), %rdx
cmpq %rdx, %rcx
setne %cl
addq $0x2, %rax
cmpq %rdx, %rax
setne %al
testb %al, %cl
jne 0xf8657
incl %r12d
jmp 0xf85e0
leaq 0xa8(%rsp), %r15
jmp 0xf8665
leal 0x1(%rdx), %r12d
movq 0x30(%rbx), %rcx
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rax
cmpq %r12, %rdx
jne 0xf86b4
cmpq %rsi, %rcx
movq 0x78(%rsp), %r12
jne 0xf86a6
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
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rbx)
movl %r13d, (%rax,%rcx,4)
jmp 0xf86f8
cmpq %rsi, %rcx
movq 0x78(%rsp), %r12
jne 0xf86e4
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
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%rbx)
movl %r13d, %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
incq %r13
jmp 0xf854b
movq 0x140(%rsp), %rdi
callq 0x2220
movq 0x120(%rsp), %rdi
callq 0x2220
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0xf1352
andq $0x0, 0x78(%rbx)
xorl %r13d, %r13d
movl %r13d, %r13d
movq 0x30(%rbx), %rcx
cmpq %r13, %rcx
jbe 0xf8907
movq 0x40(%rbx), %rax
movl (%rax,%r13,4), %r12d
testl %r12d, %r12d
js 0xf8754
incq 0x78(%rbx)
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movl (%rbp), %ecx
movl %ecx, (%rax,%r13,4)
movq 0x18(%r14), %rdi
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
andq $0x0, 0x38(%rsp)
andl $0x0, 0x30(%rsp)
andl $0x0, 0x28(%rsp)
andl $0x0, 0x8(%rsp)
orl $-0x1, (%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rsi
movl %r12d, %edx
movq 0x50(%rsp), %rcx
leaq 0xa8(%rsp), %r8
pushq $-0x1
popq %r9
callq 0x84a86
testq %rax, %rax
je 0xf88ff
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rax
cmpq 0x50(%rbx), %rcx
jne 0xf87ec
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x50(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rcx
movq 0x58(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x48(%rbx)
movq %rdx, (%rax,%rcx,8)
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rcx
movq 0x28(%rbx), %rax
cmpq %rcx, %rdx
jne 0xf8838
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rdx
movq 0x20(%rbx), %rcx
leaq 0x1(%rdx), %rsi
movq %rsi, (%rbp)
movl %r12d, (%rax,%rdx,4)
cmpq %rcx, %rsi
jne 0xf886f
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rsi
movq 0xc0(%rsp), %rcx
movl (%rcx), %edx
xorl $0x1, %edx
leaq 0x1(%rsi), %rcx
movq %rcx, (%rbp)
movl %edx, (%rax,%rsi,4)
xorl %r15d, %r15d
movl %r15d, %r15d
cmpq %r15, 0xe0(%rsp)
jbe 0xf88ff
movq 0xf0(%rsp), %rdx
movl (%rdx,%r15,4), %edx
cmpl %r12d, %edx
je 0xf88fa
movq 0xc0(%rsp), %rsi
cmpl (%rsi), %edx
je 0xf88fa
cmpq 0x20(%rbx), %rcx
jne 0xf88ec
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0xf0(%rsp), %rcx
movl (%rcx,%r15,4), %edx
movq 0x18(%rbx), %rcx
leaq 0x1(%rcx), %rsi
movq %rsi, (%rbp)
movl %edx, (%rax,%rcx,4)
movq %rsi, %rcx
incl %r15d
jmp 0xf888a
incl %r13d
jmp 0xf8733
movq 0x40(%rbx), %rax
cmpq 0x38(%rbx), %rcx
jne 0xf8937
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 0x70(%rsp), %r13
movq 0x68(%rsp), %rbp
movl 0x18(%rbx), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%rbx)
movl %edx, (%rax,%rcx,4)
movq 0xa8(%rsp), %rdi
callq 0x2220
movq 0xc0(%rsp), %rdi
callq 0x2220
movq 0xd8(%rsp), %rdi
callq 0x2220
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0x108(%rsp), %rdi
callq 0x2220
movq 0x30(%rbx), %rax
decq %rax
movq %rax, 0x80(%rbx)
movq 0x80(%rsp), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movq 0x88(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x18(%r14), %r12
movl 0x14(%r12), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r15
jae 0xf8a31
movl 0x30(%rbx), %eax
movl %eax, 0x20(%rsp)
incl %eax
movl %eax, 0x18(%rsp)
movq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
orl $-0x1, 0x28(%rsp)
movq %r13, (%rsp)
movl $0x14, 0x10(%rsp)
movq %r14, %rdi
movl %r15d, %esi
movq 0x80(%rsp), %rdx
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %r8
movq %rbp, %r9
callq 0xf7dd6
movq (%rbx), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
jmp 0xf89c1
xorl %r13d, %r13d
movabsq $-0x100000001, %rbp     # imm = 0xFFFFFFFEFFFFFFFF
movl %r13d, %r15d
cmpq %r15, 0x80(%rbx)
jbe 0xf8b41
leaq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
leaq 0x4c(%rsp), %rdx
leaq 0x48(%rsp), %rcx
leaq 0xa0(%rsp), %r8
leaq 0x64(%rsp), %r9
callq 0xf6ab5
xorl %eax, %eax
movq 0xa0(%rsp), %rcx
xorl %edx, %edx
movl 0x64(%rsp), %esi
cmpq %rsi, %rax
jae 0xf8ab0
movq (%rbx), %rsi
movl (%rcx,%rax,4), %edi
shrl %edi
movl %r13d, (%rsi,%rdi,4)
movq 0x10(%r14), %rsi
movl (%rcx,%rax,4), %edi
shrl %edi
imulq $0x28, %rdi, %rdi
addl 0x10(%rsi,%rdi), %edx
incq %rax
jmp 0xf8a85
cmpl $0x4, %edx
jb 0xf8ae3
movq (%rbx), %rax
movq 0x30(%rbx), %rcx
movl 0x4c(%rsp), %edx
shrl %edx
movl (%rax,%rdx,4), %esi
incq %rcx
cmpq %rsi, %rcx
je 0xf8ad1
orl $-0x1, (%rax,%rdx,4)
movl 0x48(%rsp), %edx
shrl %edx
movl (%rax,%rdx,4), %esi
cmpq %rsi, %rcx
je 0xf8ae3
orl $-0x1, (%rax,%rdx,4)
movl 0x4c(%rsp), %ecx
shrl %ecx
movq 0x70(%rbx), %rax
movq (%rax,%rcx,8), %rdx
cmpq $-0x1, %rdx
je 0xf8b05
cmpq %rbp, %rdx
jbe 0xf8b10
shlq $0x20, %rdx
orq %r15, %rdx
jmp 0xf8b0c
leaq (%r15,%rbp), %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x48(%rsp), %ecx
shrl %ecx
movq (%rax,%rcx,8), %rdx
cmpq $-0x1, %rdx
je 0xf8b2e
cmpq %rbp, %rdx
jbe 0xf8b39
shlq $0x20, %rdx
orq %r15, %rdx
jmp 0xf8b35
leaq (%r15,%rbp), %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
incl %r13d
jmp 0xf8a3e
xorl %eax, %eax
movl 0x14(%r12), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
jae 0xf8225
movq (%rbx), %rcx
movq 0x30(%rbx), %rdx
movl (%rcx,%rax,4), %esi
leaq 0x1(%rdx), %rdi
cmpq %rsi, %rdi
jne 0xf8b6d
movl %edx, (%rcx,%rax,4)
incq %rax
jmp 0xf8b43