// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: identify_bubbles_recal_poy(asg_t*, ma_ug_t*, bubble_type*, unsigned char*, ma_hit_t_alloc*, R_to_U*, kv_u_trans_t*)
void identify_bubbles_recal_poy(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 = het_cov + (het_cov*0.333333);///hom_cov - het_cov + (het_cov*0.333333);
    m_hom_cov = het_cov + (het_cov*0.6);///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);

    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(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);
    }
    
    bub->b_g = NULL;
    bub->b_ug = NULL;
    build_bub_graph(ug, bub);


    ///make het nodes to be hom
    ma_utg_t *u = NULL;
    for (i = 0; i < bub->b_ug->u.n; i++) {
        u = &(bub->b_ug->u.a[i]);
        if(u->n == 0) continue;
        for (k = 0; k < u->n; k++) {
            reset_inner_bub_het_poy(sg, ug, bub, u->a[k]>>33, tLen, &b, m_het_cov, m_hom_cov, r_het_flag, sources, ruIndex);   
        }
    }
    free(b.a); free(b.S.a); free(b.T.a); free(b.b.a); free(b.e.a);

    for (i = 0; i < ug->g->n_seq; i++) {
        if(IF_HOM(i, *bub)) continue;
        if(deter_unitig_het_fly(ug, i, sg, het_cov*1.15, sources, ruIndex, r_het_flag)) continue;
        bub->index[i] = (uint32_t)-1;
    }
    // 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 $0x148, %rsp            # imm = 0x148
movq %r9, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x18(%rsp)
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movq 0x18(%rsi), %rdi
callq 0x694eb
movq 0x18(%r13), %rbx
movl 0x14(%rbx), %ebp
testl %ebp, %ebp
js 0xf9129
movq %rbx, %rdi
callq 0x69638
movq 0x18(%r13), %rbx
movl 0x14(%rbx), %ebp
addl %ebp, %ebp
movq %r13, 0x10(%r12)
xorps %xmm2, %xmm2
movups %xmm2, 0x88(%r12)
movups %xmm2, 0x98(%r12)
andq $0x0, 0xa8(%r12)
leaq 0x15a603(%rip), %rcx    # 0x253758
movslq 0x144(%rcx), %rdx
cvtsi2sd %edx, %xmm0
divsd 0xeeaf8(%rip), %xmm0    # 0x1e7c60
cvttsd2si %xmm0, %rsi
movq %rsi, %rdi
sarq $0x3f, %rdi
subsd 0xea11c(%rip), %xmm0    # 0x1e3298
cvttsd2si %xmm0, %rax
andq %rdi, %rax
orq %rsi, %rax
cmpl $0x0, 0x148(%rcx)
cmovneq %rdx, %rax
movslq 0x1bc(%rcx), %rcx
xorl %r15d, %r15d
xorl %edx, %edx
divq %rcx
movq %rax, %xmm0
punpckldq 0xea0c2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xea0ca(%rip), %xmm0    # 0x1e3280
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xea3de(%rip), %xmm0    # 0x1e35a8
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, 0x50(%rsp)
movsd 0xea2f8(%rip), %xmm0    # 0x1e34d8
mulsd %xmm1, %xmm0
movapd %xmm1, 0xf0(%rsp)
addsd %xmm1, %xmm0
movapd %xmm0, 0xe0(%rsp)
leaq 0x78(%rsp), %r14
movups %xmm2, 0x58(%r14)
movups %xmm2, 0x48(%r14)
movups %xmm2, 0x38(%r14)
movups %xmm2, 0x28(%r14)
movups %xmm2, 0x18(%r14)
movups %xmm2, 0x8(%r14)
pushq $0x1c
popq %rsi
movq %rbp, %rdi
callq 0x2120
movq %rax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x84975
movq %rax, 0x20(%rsp)
leaq 0x18(%r12), %rax
movq %rax, (%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%r12)
movupd %xmm0, 0x28(%r12)
movupd %xmm0, 0x38(%r12)
movupd %xmm0, 0x48(%r12)
movupd %xmm0, 0x58(%r12)
movupd %xmm0, 0x68(%r12)
movq 0x18(%r13), %rbx
movl 0x14(%rbx), %eax
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rax
movq %rax, 0x68(%r12)
movl 0x14(%rbx), %edi
andq %r14, %rdi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x70(%r12)
leaq 0xc0(%r12), %rcx
movq %rcx, 0x68(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc0(%r12)
movupd %xmm0, 0xd0(%r12)
movl 0x14(%rbx), %edx
andq %r14, %rdx
movq %rdx, 0x60(%r12)
shlq $0x3, %rdx
movq %rax, %rdi
movl $0xff, %esi
callq 0x20e0
pushq $0x4
popq %rsi
movq %rbp, 0x28(%rsp)
movq %rbp, %rdi
callq 0x2120
movq %rax, (%r12)
movl 0x14(%rbx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r15
jae 0xf930c
movq 0x20(%rbx), %rax
movb $0x0, 0x4(%rax,%r15,8)
incq %r15
jmp 0xf92f0
movapd 0x50(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xe9f72(%rip), %xmm0    # 0x1e3298
cvttsd2si %xmm0, %rdx
andq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x50(%rsp)
xorl %r15d, %r15d
leaq 0x78(%rsp), %r14
pushq $-0x1
popq %rbp
movq 0x28(%rsp), %rbx
cmpq %rbx, %r15
je 0xf9464
movq 0x18(%r13), %rdi
movq 0x20(%rdi), %rax
movl %r15d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0xf945c
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%r15,8) # imm = 0xFFFFFFFE
je 0xf945c
movq (%r12), %rax
testb $0x3, (%rax,%r15,4)
jne 0xf945c
subq $0x40, %rsp
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 0x60(%rsp), %rcx
movq %r14, %r8
movl %ebp, %r9d
callq 0x84a86
addq $0x40, %rsp
testq %rax, %rax
je 0xf945c
movq 0x90(%rsp), %rax
movq 0xb0(%rsp), %rcx
movq 0xc0(%rsp), %rdx
xorl %esi, %esi
movl %esi, %esi
cmpq %rsi, %rcx
jbe 0xf942e
movl (%rdx,%rsi,4), %edi
cmpq %rdi, %r15
je 0xf942a
cmpl (%rax), %edi
je 0xf942a
movq (%r12), %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 0xf93f0
movq (%r12), %rax
movl (%rax,%r15,4), %ecx
andl $-0x4, %ecx
orl $0x2, %ecx
movl %ecx, (%rax,%r15,4)
movq 0x90(%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 0xf9346
xorpd %xmm0, %xmm0
leaq 0x120(%rsp), %rax
andq $0x0, 0x10(%rax)
leaq 0x100(%rsp), %rcx
andq $0x0, 0x10(%rcx)
movapd %xmm0, (%rax)
movapd %xmm0, (%rcx)
xorl %r15d, %r15d
leaq 0x78(%rsp), %rbp
pushq $-0x1
popq %r14
cmpq %rbx, %r15
je 0xf965d
movq (%r12), %rax
movl (%rax,%r15,4), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0xf9655
movq 0x18(%r13), %rdi
subq $0x40, %rsp
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 0x80(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %r13, %rsi
movl %r15d, %edx
movq 0x60(%rsp), %rcx
movq %rbp, %r8
movl %r14d, %r9d
callq 0x84a86
addq $0x40, %rsp
testq %rax, %rax
je 0xf9655
movq 0xb0(%rsp), %rdx
cmpq $0x5, %rdx
ja 0xf95b4
pushq $0x2c
popq %rax
btq %rdx, %rax
jae 0xf95b4
movq %rbp, %r14
movl %r15d, %ebp
shrl %ebp
xorl %ebx, %ebx
movl %ebx, %ebx
cmpq %rbx, %rdx
jbe 0xf95ab
movq 0xc0(%rsp), %rax
movl (%rax,%rbx,4), %ecx
cmpq %rcx, %r15
je 0xf95a7
movq 0x90(%rsp), %rax
movl (%rax), %r9d
cmpl %r9d, %ecx
je 0xf95a7
movq 0x18(%r13), %rdi
shrl %ecx
shrl %r9d
leaq 0x120(%rsp), %rsi
leaq 0x100(%rsp), %rdx
movl %ebp, %r8d
callq 0xf6fe5
movq 0x100(%rsp), %rax
leaq 0x3(%rax), %rcx
movq 0xb0(%rsp), %rdx
cmpq %rdx, %rcx
setne %cl
addq $0x2, %rax
cmpq %rdx, %rax
setne %al
testb %al, %cl
jne 0xf95ab
incl %ebx
jmp 0xf9537
movq %r14, %rbp
pushq $-0x1
popq %r14
jmp 0xf95b7
leal 0x1(%rdx), %ebx
movq 0x30(%r12), %rcx
movq 0x38(%r12), %rsi
movq 0x40(%r12), %rax
cmpq %rbx, %rdx
jne 0xf960d
cmpq %rsi, %rcx
movq 0x28(%rsp), %rbx
jne 0xf95fe
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%r12)
movq 0x30(%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%r12)
movl %r15d, (%rax,%rcx,4)
jmp 0xf9655
cmpq %rsi, %rcx
movq 0x28(%rsp), %rbx
jne 0xf9640
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%r12)
movq 0x30(%r12), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%r12)
movl %r15d, %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
incq %r15
jmp 0xf9496
movq 0x130(%rsp), %rdi
callq 0x2220
movq 0x110(%rsp), %rdi
callq 0x2220
movq 0x30(%r12), %rax
movq 0x40(%r12), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0xf1352
andq $0x0, 0x78(%r12)
xorl %ebp, %ebp
leaq 0x40(%rsp), %r14
movl %ebp, %ebp
movq 0x30(%r12), %rcx
cmpq %rbp, %rcx
jbe 0xf988a
movq 0x40(%r12), %rax
movl (%rax,%rbp,4), %r15d
testl %r15d, %r15d
js 0xf96ba
incq 0x78(%r12)
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movq (%rsp), %rcx
movl (%rcx), %ecx
movl %ecx, (%rax,%rbp,4)
movq 0x18(%r13), %rdi
subq $0x40, %rsp
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)
movq %r14, 0x10(%rsp)
movq %r13, %rsi
movl %r15d, %edx
movq 0x60(%rsp), %rcx
leaq 0xb8(%rsp), %r8
pushq $-0x1
popq %r9
callq 0x84a86
addq $0x40, %rsp
testq %rax, %rax
je 0xf9883
movq 0x48(%r12), %rcx
movq 0x58(%r12), %rax
cmpq 0x50(%r12), %rcx
jne 0xf975d
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x50(%r12)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x58(%r12)
movq 0x48(%r12), %rcx
movq 0x40(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x48(%r12)
movq %rdx, (%rax,%rcx,8)
movq 0x18(%r12), %rdx
movq 0x20(%r12), %rcx
movq 0x28(%r12), %rax
cmpq %rcx, %rdx
jne 0xf97b1
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%r12)
movq 0x18(%r12), %rdx
movq 0x20(%r12), %rcx
leaq 0x1(%rdx), %rsi
movq (%rsp), %rdi
movq %rsi, (%rdi)
movl %r15d, (%rax,%rdx,4)
cmpq %rcx, %rsi
jne 0xf97ee
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%r12)
movq 0x18(%r12), %rsi
movq 0x90(%rsp), %rcx
movl (%rcx), %edx
xorl $0x1, %edx
leaq 0x1(%rsi), %rcx
movq (%rsp), %rdi
movq %rcx, (%rdi)
movl %edx, (%rax,%rsi,4)
xorl %ebx, %ebx
movl %ebx, %ebx
cmpq %rbx, 0xb0(%rsp)
jbe 0xf9883
movq 0xc0(%rsp), %rdx
movl (%rdx,%rbx,4), %edx
cmpl %r15d, %edx
je 0xf987f
movq 0x90(%rsp), %rsi
cmpl (%rsi), %edx
je 0xf987f
cmpq 0x20(%r12), %rcx
jne 0xf986e
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%r12)
movq 0xc0(%rsp), %rcx
movl (%rcx,%rbx,4), %edx
movq 0x18(%r12), %rcx
leaq 0x1(%rcx), %rsi
movq (%rsp), %rdi
movq %rsi, (%rdi)
movl %edx, (%rax,%rcx,4)
movq %rsi, %rcx
incl %ebx
jmp 0xf980b
incl %ebp
jmp 0xf9697
movapd 0xe0(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, (%rsp)
sarq $0x3f, %rax
subsd 0xe99f0(%rip), %xmm0    # 0x1e3298
cvttsd2si %xmm0, %rbx
andq %rax, %rbx
movq 0x40(%r12), %rax
cmpq 0x38(%r12), %rcx
jne 0xf98e5
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%r12)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%r12)
movq 0x30(%r12), %rcx
orq %rbx, (%rsp)
movl 0x18(%r12), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r12)
movl %edx, (%rax,%rcx,4)
movq %rcx, 0x80(%r12)
movq 0x10(%rsp), %rax
movl 0x14(%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %ebp, %ebp
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x18(%r13), %rbx
movl 0x14(%rbx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %rbp
jae 0xf9976
movl 0x30(%r12), %eax
movq %r13, %rdi
movl %ebp, %esi
movq 0x10(%rsp), %rdx
movq 0x50(%rsp), %rcx
movq (%rsp), %r8
movq 0x30(%rsp), %r9
pushq $-0x1
movl %eax, %r10d
incl %r10d
pushq %rax
pushq %r10
pushq $0x14
pushq 0x38(%rsp)
pushq 0x60(%rsp)
callq 0xf7dd6
addq $0x30, %rsp
movq (%r12), %rcx
movl %eax, (%rcx,%rbp,4)
incq %rbp
jmp 0xf991e
xorl %r14d, %r14d
movabsq $-0x100000001, %r15     # imm = 0xFFFFFFFEFFFFFFFF
movl %r14d, %ebp
cmpq %rbp, 0x80(%r12)
jbe 0xf9a88
subq $0x8, %rsp
movq %r12, %rdi
movq %rbp, %rsi
leaq 0x14(%rsp), %rdx
leaq 0x10(%rsp), %rcx
leaq 0x78(%rsp), %r8
leaq 0x54(%rsp), %r9
leaq 0x48(%rsp), %rax
pushq %rax
callq 0xf6ab5
popq %rax
popq %rcx
xorl %eax, %eax
movq 0x70(%rsp), %rcx
xorl %edx, %edx
movl 0x4c(%rsp), %esi
cmpq %rsi, %rax
jae 0xf99f4
movq (%r12), %rsi
movl (%rcx,%rax,4), %edi
shrl %edi
movl %r14d, (%rsi,%rdi,4)
movq 0x10(%r13), %rsi
movl (%rcx,%rax,4), %edi
shrl %edi
imulq $0x28, %rdi, %rdi
addl 0x10(%rsi,%rdi), %edx
incq %rax
jmp 0xf99c8
cmpl $0x4, %edx
jb 0xf9a29
movq (%r12), %rax
movq 0x30(%r12), %rcx
movl 0xc(%rsp), %edx
shrl %edx
movl (%rax,%rdx,4), %esi
incq %rcx
cmpq %rsi, %rcx
je 0xf9a17
orl $-0x1, (%rax,%rdx,4)
movl 0x8(%rsp), %edx
shrl %edx
movl (%rax,%rdx,4), %esi
cmpq %rsi, %rcx
je 0xf9a29
orl $-0x1, (%rax,%rdx,4)
movl 0xc(%rsp), %ecx
shrl %ecx
movq 0x70(%r12), %rax
movq (%rax,%rcx,8), %rdx
cmpq $-0x1, %rdx
je 0xf9a4c
cmpq %r15, %rdx
jbe 0xf9a57
shlq $0x20, %rdx
orq %rbp, %rdx
jmp 0xf9a53
leaq (%r15,%rbp), %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
movl 0x8(%rsp), %ecx
shrl %ecx
movq (%rax,%rcx,8), %rdx
cmpq $-0x1, %rdx
je 0xf9a75
cmpq %r15, %rdx
jbe 0xf9a80
shlq $0x20, %rdx
orq %rbp, %rdx
jmp 0xf9a7c
leaq (%r15,%rbp), %rdx
incq %rdx
movq %rdx, (%rax,%rcx,8)
incl %r14d
jmp 0xf9983
xorl %eax, %eax
movl 0x14(%rbx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
jae 0xf9ab5
movq (%r12), %rcx
movq 0x30(%r12), %rdx
movl (%rcx,%rax,4), %esi
leaq 0x1(%rdx), %rdi
cmpq %rsi, %rdi
jne 0xf9ab0
movl %edx, (%rcx,%rax,4)
incq %rax
jmp 0xf9a8a
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb8(%r12)
movq %r13, %rdi
movq %r12, %rsi
callq 0xf7d63
xorl %ebx, %ebx
leaq 0x78(%rsp), %rbp
movl %ebx, %ebx
movq 0x68(%rsp), %rax
movq (%rax), %rax
cmpq %rbx, (%rax)
jbe 0xf9b55
movq %r13, %r15
movq 0x10(%rax), %r14
imulq $0x28, %rbx, %rcx
movl 0x10(%r14,%rcx), %eax
testl %eax, %eax
je 0xf9b4e
addq %rcx, %r14
xorl %r13d, %r13d
movl %eax, %eax
cmpq %rax, %r13
jae 0xf9b4e
movq 0x18(%r14), %rax
movq (%rax,%r13,8), %rcx
shrq $0x21, %rcx
subq $0x8, %rsp
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
movq 0x28(%rsp), %r8
movq %rbp, %r9
pushq 0x40(%rsp)
pushq 0x40(%rsp)
pushq 0x30(%rsp)
pushq 0x20(%rsp)
pushq 0x78(%rsp)
callq 0xf8b72
addq $0x30, %rsp
incq %r13
movl 0x10(%r14), %eax
jmp 0xf9afe
incl %ebx
movq %r15, %r13
jmp 0xf9ad5
movq 0x78(%rsp), %rdi
callq 0x2220
movq 0x90(%rsp), %rdi
callq 0x2220
movq 0xa8(%rsp), %rdi
callq 0x2220
movq 0xc0(%rsp), %rdi
callq 0x2220
movq 0xd8(%rsp), %rdi
callq 0x2220
movapd 0xf0(%rsp), %xmm0
mulsd 0xee104(%rip), %xmm0    # 0x1e7ca8
cvttsd2si %xmm0, %rbx
xorl %r14d, %r14d
movq 0x18(%r13), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r14
jae 0xf9c0e
movq (%r12), %rax
movq 0x80(%r12), %rcx
movl (%rax,%r14,4), %eax
incq %rcx
cmpq %rax, %rcx
jb 0xf9c09
subq $0x8, %rsp
movq %r13, %rdi
movl %r14d, %esi
movq 0x18(%rsp), %rdx
movq %rbx, %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
pushq 0x20(%rsp)
callq 0xf8e05
popq %rcx
popq %rdx
testl %eax, %eax
jne 0xf9c09
movq (%r12), %rax
orl $-0x1, (%rax,%r14,4)
incq %r14
jmp 0xf9bac
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq