// File: /workspace/github_cpp_makefile_star2_O3/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, 0x50(%rsp)
movq %r8, %r14
movq %rcx, 0x38(%rsp)
movq %rdx, (%rsp)
movq %rsi, %r15
movq %rdi, 0x40(%rsp)
movq 0x18(%rsi), %rdi
callq 0xa0a7d
movq 0x18(%r15), %rbx
movl 0x14(%rbx), %r13d
testl %r13d, %r13d
js 0x140a45
movq %rbx, %rdi
callq 0xa0c1e
movq 0x18(%r15), %rbx
movl 0x14(%rbx), %r13d
movq %r14, 0x48(%rsp)
addl %r13d, %r13d
movq (%rsp), %rbp
movq %r15, 0x10(%rbp)
xorps %xmm2, %xmm2
movups %xmm2, 0x88(%rbp)
movups %xmm2, 0x98(%rbp)
movq $0x0, 0xa8(%rbp)
leaq 0x154ce0(%rip), %rcx    # 0x295758
movslq 0x144(%rcx), %rdx
cvtsi2sd %edx, %xmm0
divsd 0xf52d5(%rip), %xmm0    # 0x235d60
cvttsd2si %xmm0, %rsi
subsd 0xf0870(%rip), %xmm0    # 0x231308
cvttsd2si %xmm0, %rdi
movq %rsi, %rax
sarq $0x3f, %rax
andq %rdi, %rax
orq %rsi, %rax
cmpl $0x0, 0x148(%rcx)
cmovneq %rdx, %rax
movslq 0x1bc(%rcx), %rcx
xorl %edx, %edx
divq %rcx
movq %rax, %xmm0
punpckldq 0xf07b2(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xf07ba(%rip), %xmm0    # 0x231290
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd 0xf0b6e(%rip), %xmm0    # 0x231658
mulsd %xmm1, %xmm0
addsd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
movsd 0xf0a88(%rip), %xmm0    # 0x231588
mulsd %xmm1, %xmm0
movapd %xmm1, 0x130(%rsp)
addsd %xmm1, %xmm0
movapd %xmm0, 0x60(%rsp)
leaq 0x88(%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)
movl $0x1c, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc0162
movq %rax, 0x18(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rbp)
movupd %xmm0, 0x28(%rbp)
movupd %xmm0, 0x38(%rbp)
movupd %xmm0, 0x48(%rbp)
movupd %xmm0, 0x58(%rbp)
movupd %xmm0, 0x68(%rbp)
movq %r15, 0x8(%rsp)
movq 0x18(%r15), %rbx
movl 0x14(%rbx), %eax
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rax
movq %rax, 0x68(%rbp)
movl 0x14(%rbx), %edi
andq %r14, %rdi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x70(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc0(%rbp)
movupd %xmm0, 0xd0(%rbp)
movl 0x14(%rbx), %edx
andq %r14, %rdx
movq %rdx, 0x60(%rbp)
shlq $0x3, %rdx
movq %rax, %rdi
movl $0xff, %esi
callq 0x20e0
movl $0x4, %esi
movq %r13, %r12
movq %r13, %rdi
callq 0x2120
movq %rbp, %r9
movq %rax, (%rbp)
testl $0x7fffffff, 0x14(%rbx) # imm = 0x7FFFFFFF
je 0x140c16
movq 0x20(%rbx), %rax
xorl %ecx, %ecx
movb $0x0, 0x4(%rax,%rcx,8)
incq %rcx
movl 0x14(%rbx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
jb 0x140c00
movapd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x10(%rsp)
movsd 0xf06da(%rip), %xmm1    # 0x231308
subsd %xmm1, %xmm0
movapd %xmm0, 0x20(%rsp)
movapd 0x60(%rsp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, 0x30(%rsp)
subsd %xmm1, %xmm0
movapd %xmm0, 0x60(%rsp)
testq %r12, %r12
je 0x140fa1
movq %r12, %rdx
xorl %ebx, %ebx
leaq 0x88(%rsp), %r13
xorl %ebp, %ebp
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %r14
movq 0x18(%r15), %rdi
movq 0x20(%rdi), %rax
movl %ebp, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x140d7e
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%rbp,8) # imm = 0xFFFFFFFE
je 0x140d7e
movq (%r9), %rax
testb $0x3, (%rax,%rbp,4)
jne 0x140d7e
subq $0x40, %rsp
movq %rbx, 0x38(%rsp)
movl %ebx, 0x30(%rsp)
movl %ebx, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rsp)
movl %ebx, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %ebp, %edx
movq %r14, %rcx
movq %r13, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
movq %r12, %rdx
movq 0x40(%rsp), %r9
addq $0x40, %rsp
testq %rax, %rax
je 0x140d7e
movq 0xa0(%rsp), %rax
movq 0xc0(%rsp), %rcx
testq %rcx, %rcx
je 0x140d58
movq 0xd0(%rsp), %rdx
xorl %esi, %esi
movl (%rdx,%rsi,4), %edi
cmpq %rdi, %rbp
je 0x140d4e
cmpl (%rax), %edi
je 0x140d4e
movq (%r9), %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)
incq %rsi
movl %esi, %edi
cmpq %rdi, %rcx
ja 0x140d1c
movq (%r9), %rcx
movl (%rcx,%rbp,4), %edx
andl $-0x4, %edx
orl $0x2, %edx
movl %edx, (%rcx,%rbp,4)
movl (%rax), %edx
xorq $0x1, %rdx
andl $-0x4, (%rcx,%rdx,4)
movl (%rax), %eax
xorq $0x1, %rax
addl $0x3, (%rcx,%rax,4)
movq %r12, %rdx
incq %rbp
cmpq %rdx, %rbp
jne 0x140c74
xorl %r13d, %r13d
xorpd %xmm0, %xmm0
movapd %xmm0, 0x110(%rsp)
movq %r13, 0x120(%rsp)
movapd %xmm0, 0xf0(%rsp)
movq %r13, 0x100(%rsp)
movl $0x0, %edi
testl %edx, %edx
je 0x140fd6
xorl %ebp, %ebp
movq (%r9), %rax
movl (%rax,%rbp,4), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x140f83
movq 0x18(%r15), %rdi
subq $0x40, %rsp
movl %r13d, 0x30(%rsp)
movl %r13d, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %r13d, 0x8(%rsp)
movq $0x0, 0x38(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq %r15, %rsi
movl %ebp, %edx
movq %r14, %rcx
leaq 0xc8(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
movq %r12, %rdx
movq 0x40(%rsp), %r9
addq $0x40, %rsp
testq %rax, %rax
je 0x140f83
movq 0xc0(%rsp), %rdx
leal 0x1(%rdx), %r14d
cmpq $0x5, %rdx
ja 0x140edc
movl $0x2c, %eax
btq %rdx, %rax
jae 0x140edc
movl %ebp, %ebx
shrl %ebx
xorl %r14d, %r14d
movq 0xd0(%rsp), %rax
movl (%rax,%r14,4), %ecx
cmpq %rcx, %rbp
je 0x140ed4
movq 0xa0(%rsp), %rax
movl (%rax), %r9d
cmpl %r9d, %ecx
je 0x140ed4
movq 0x18(%r15), %rdi
shrl %ecx
shrl %r9d
leaq 0x110(%rsp), %rsi
leaq 0xf0(%rsp), %rdx
movl %ebx, %r8d
callq 0x13e4b7
movq 0xf0(%rsp), %rax
leaq 0x3(%rax), %rcx
movq 0xc0(%rsp), %rdx
cmpq %rdx, %rcx
setne %cl
addq $0x2, %rax
cmpq %rdx, %rax
setne %al
testb %al, %cl
jne 0x140edc
incl %r14d
cmpq %r14, %rdx
ja 0x140e6a
movl %r14d, %edi
movq (%rsp), %r9
movq 0x30(%r9), %rcx
movq 0x38(%r9), %rsi
movq 0x40(%r9), %rax
cmpq %rdi, %rdx
jne 0x140f37
cmpq %rsi, %rcx
movq 0x18(%rsp), %r14
jne 0x140f2a
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%r9)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x40(%r9)
movq 0x30(%r9), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%r9)
movl %ebp, (%rax,%rcx,4)
jmp 0x140f80
cmpq %rsi, %rcx
movq 0x18(%rsp), %r14
jne 0x140f6d
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x38(%r9)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x40(%r9)
movq 0x30(%r9), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x30(%r9)
movl %ebp, %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
movq %r12, %rdx
incq %rbp
cmpq %rdx, %rbp
jne 0x140dc2
movq 0x120(%rsp), %rdi
movq 0x100(%rsp), %r13
jmp 0x140fd6
xorpd %xmm0, %xmm0
movapd %xmm0, 0x110(%rsp)
xorl %r13d, %r13d
movq %r13, 0x120(%rsp)
movapd %xmm0, 0xf0(%rsp)
movq %r13, 0x100(%rsp)
xorl %edi, %edi
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rax
sarq $0x3f, %rax
movq %rax, 0x80(%rsp)
cvttsd2si 0x20(%rsp), %r12
movq 0x30(%rsp), %rax
sarq $0x3f, %rax
movq %rax, 0x78(%rsp)
movq %r13, %rbx
cvttsd2si 0x60(%rsp), %r13
callq 0x2220
movq %rbx, %rdi
callq 0x2220
movq (%rsp), %rax
movq 0x30(%rax), %rax
movq (%rsp), %rcx
movq 0x40(%rcx), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0x137c5c
movq (%rsp), %r9
movq $0x0, 0x78(%r9)
cmpq $0x0, 0x30(%r9)
je 0x141279
leaq 0x18(%r9), %rax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
xorl %ebx, %ebx
movq 0x40(%r9), %rcx
movl (%rcx,%rax,4), %ebp
testl %ebp, %ebp
js 0x14105f
incq 0x78(%r9)
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x20(%rsp), %rdx
movl (%rdx), %edx
movl %edx, (%rcx,%rax,4)
movq 0x18(%r15), %rdi
subq $0x40, %rsp
xorl %eax, %eax
movl %eax, 0x30(%rsp)
movl %eax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
leaq 0x98(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
movq $0x0, 0x38(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq %r15, %rsi
movl %ebp, %edx
movq %r14, %rcx
leaq 0xc8(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
movq 0x40(%rsp), %r9
addq $0x40, %rsp
testq %rax, %rax
je 0x14125b
movq 0x48(%r9), %rcx
movq 0x58(%r9), %rax
cmpq 0x50(%r9), %rcx
jne 0x141113
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x50(%r9)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x58(%r9)
movq 0x48(%r9), %rcx
movq 0x58(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x48(%r9)
movq %rdx, (%rax,%rcx,8)
movq 0x18(%r9), %rdx
movq 0x20(%r9), %rcx
movq 0x28(%r9), %rax
cmpq %rcx, %rdx
jne 0x141165
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%r9)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x28(%r9)
movq 0x18(%r9), %rdx
movq 0x20(%r9), %rcx
leaq 0x1(%rdx), %rsi
movq 0x20(%rsp), %rdi
movq %rsi, (%rdi)
movl %ebp, (%rax,%rdx,4)
cmpq %rcx, %rsi
jne 0x1411a5
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%r9)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x28(%r9)
movq 0x18(%r9), %rsi
movq 0xa0(%rsp), %rcx
movl (%rcx), %ecx
xorl $0x1, %ecx
leaq 0x1(%rsi), %rdx
movq 0x20(%rsp), %rdi
movq %rdx, (%rdi)
movl %ecx, (%rax,%rsi,4)
movq 0xc0(%rsp), %rcx
testq %rcx, %rcx
je 0x14125b
movl $0x1, %r14d
movq 0xd0(%rsp), %rsi
xorl %r15d, %r15d
movl (%rsi,%r15,4), %edi
cmpl %ebp, %edi
je 0x141250
movq 0xa0(%rsp), %r8
cmpl (%r8), %edi
je 0x141250
cmpq 0x20(%r9), %rdx
jne 0x14123a
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%r9)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x28(%r9)
movq 0xc0(%rsp), %rcx
movq 0xd0(%rsp), %rsi
movq 0x18(%r9), %rdx
movl (%rsi,%r15,4), %edi
leaq 0x1(%rdx), %r8
movq 0x20(%rsp), %r10
movq %r8, (%r10)
movl %edi, (%rax,%rdx,4)
movq %r8, %rdx
movl %r14d, %r15d
incl %r14d
cmpq %r15, %rcx
ja 0x1411e3
incl %ebx
movq 0x30(%r9), %rcx
movq %rbx, %rax
cmpq %rbx, %rcx
movq 0x8(%rsp), %r15
movq 0x18(%rsp), %r14
ja 0x141050
jmp 0x14127b
xorl %ecx, %ecx
andq 0x80(%rsp), %r12
movq %r12, %rbp
andq 0x78(%rsp), %r13
movq 0x40(%r9), %rax
cmpq 0x38(%r9), %rcx
jne 0x1412c8
movq 0x38(%rsp), %rbx
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rdx, %rsi
movq %rsi, 0x38(%r9)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x40(%r9)
movq 0x30(%r9), %rcx
jmp 0x1412cd
movq 0x38(%rsp), %rbx
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x30(%rsp), %r12
orq %rbp, %rsi
movq %rsi, 0x10(%rsp)
orq %r13, %r12
movl 0x18(%r9), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%r9)
movl %edx, (%rax,%rcx,4)
movq %rcx, 0x80(%r9)
movl 0x14(%rdi), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %rbx, %r14
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20e0
movq (%rsp), %rsi
movq 0x18(%r15), %rax
movl 0x14(%rax), %ecx
testl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq 0x50(%rsp), %rbx
movq 0x48(%rsp), %r13
je 0x141385
xorl %ebp, %ebp
movl 0x30(%rsi), %eax
movq %r15, %rdi
movl %ebp, %esi
movq 0x40(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq %r12, %r8
movq %r13, %r9
pushq $-0x1
movl %eax, %r10d
incl %r10d
pushq %rax
pushq %r10
pushq $0x14
pushq %r14
pushq %rbx
callq 0x13f417
movq 0x30(%rsp), %rsi
addq $0x30, %rsp
movq (%rsi), %rcx
movl %eax, (%rcx,%rbp,4)
incq %rbp
movq 0x18(%r15), %rax
movl 0x14(%rax), %ecx
movl %ecx, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rbp
jb 0x141332
movq %r12, 0x30(%rsp)
cmpq $0x0, 0x80(%rsi)
movq %r14, %r12
je 0x1414cb
movabsq $-0x100000001, %r13     # imm = 0xFFFFFFFEFFFFFFFF
movq (%rsp), %rcx
movq 0x28(%rcx), %rdx
movq 0x40(%rcx), %r12
movq 0x58(%rcx), %rsi
movq %rsi, 0x20(%rsp)
movq 0x70(%rcx), %r8
xorl %r9d, %r9d
movl (%r12,%r9,4), %edi
movl 0x4(%r12,%r9,4), %ecx
subl %edi, %ecx
leal 0x1(%rdi), %r10d
movl (%rdx,%rdi,4), %r11d
movl (%rdx,%r10,4), %r10d
movq 0x20(%rsp), %rsi
movq (%rsi,%r9,8), %rbx
movq %rbx, 0x58(%rsp)
addl $-0x2, %ecx
je 0x141463
leaq (%rdx,%rdi,4), %rbx
movq (%rsp), %rsi
movq (%rsi), %r14
movq 0x10(%r15), %r15
movl %ecx, %ebp
xorl %ecx, %ecx
xorl %edi, %edi
movl 0x8(%rbx,%rcx,4), %esi
shrl %esi
movl %r9d, (%r14,%rsi,4)
movl 0x8(%rbx,%rcx,4), %esi
shrl %esi
leaq (%rsi,%rsi,4), %rsi
addl 0x10(%r15,%rsi,8), %edi
incq %rcx
cmpq %rcx, %rbp
jne 0x141400
cmpl $0x3, %edi
movq 0x8(%rsp), %r15
jbe 0x141463
movq (%rsp), %rsi
movq (%rsi), %rcx
movq 0x30(%rsi), %rdi
shrl %r11d
movl (%rcx,%r11,4), %esi
incq %rdi
cmpq %rsi, %rdi
je 0x14144d
movl $0xffffffff, (%rcx,%r11,4) # imm = 0xFFFFFFFF
movl %r10d, %ebx
shrl %ebx
movl (%rcx,%rbx,4), %esi
cmpq %rsi, %rdi
je 0x141466
movl $0xffffffff, (%rcx,%rbx,4) # imm = 0xFFFFFFFF
jmp 0x141466
shrl %r11d
movq (%r8,%r11,8), %rcx
cmpq $-0x1, %rcx
je 0x14147e
cmpq %r13, %rcx
jbe 0x141489
shlq $0x20, %rcx
orq %r9, %rcx
jmp 0x141485
leaq (%r9,%r13), %rcx
incq %rcx
movq %rcx, (%r8,%r11,8)
shrl %r10d
movq (%r8,%r10,8), %rcx
cmpq $-0x1, %rcx
je 0x1414a4
cmpq %r13, %rcx
jbe 0x1414af
shlq $0x20, %rcx
orq %r9, %rcx
jmp 0x1414ab
leaq (%r9,%r13), %rcx
incq %rcx
movq %rcx, (%r8,%r10,8)
incl %r9d
movq (%rsp), %rcx
cmpq %r9, 0x80(%rcx)
ja 0x1413c1
movl 0x14(%rax), %ecx
movq 0x38(%rsp), %r12
testl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
je 0x141507
movq (%rsp), %rsi
movq (%rsi), %rdx
movq 0x30(%rsi), %rsi
leaq 0x1(%rsi), %rdi
xorl %r8d, %r8d
movl (%rdx,%r8,4), %r9d
cmpq %r9, %rdi
jne 0x1414f5
movl %esi, (%rdx,%r8,4)
movl 0x14(%rax), %ecx
incq %r8
movl %ecx, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpq %r9, %r8
jb 0x1414e5
xorpd %xmm0, %xmm0
movq (%rsp), %rbx
movupd %xmm0, 0xb8(%rbx)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x13f39b
movq 0xc0(%rbx), %rax
movq (%rax), %rcx
testq %rcx, %rcx
movq 0x48(%rsp), %r13
je 0x1415f2
movq %rbx, %rdx
leaq 0xc0(%rbx), %rsi
movq %rsi, 0x60(%rsp)
xorl %r8d, %r8d
leaq 0x88(%rsp), %rbp
movq 0x18(%rsp), %r14
movq 0x10(%rax), %rdi
leaq (%r8,%r8,4), %rsi
cmpl $0x0, 0x10(%rdi,%rsi,8)
je 0x1415e6
movq %r8, 0x20(%rsp)
leaq (%rdi,%rsi,8), %r15
xorl %ebx, %ebx
movq 0x10(%rsp), %r12
movq 0x30(%rsp), %r13
movq 0x18(%r15), %rax
movq (%rax,%rbx,8), %rcx
shrq $0x21, %rcx
subq $0x8, %rsp
movq 0x48(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %r8
movq %rbp, %r9
pushq 0x58(%rsp)
pushq 0x58(%rsp)
pushq 0x50(%rsp)
pushq %r13
pushq %r12
callq 0x14035e
movq 0x30(%rsp), %rdx
addq $0x30, %rsp
incq %rbx
movl 0x10(%r15), %eax
cmpq %rax, %rbx
jb 0x14157d
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq 0x48(%rsp), %r13
movq 0x38(%rsp), %r12
movq 0x8(%rsp), %r15
movq 0x20(%rsp), %r8
incl %r8d
cmpq %r8, %rcx
ja 0x141559
movq 0x88(%rsp), %rdi
callq 0x2220
movq 0xa0(%rsp), %rdi
callq 0x2220
movq 0xb8(%rsp), %rdi
callq 0x2220
movq 0xd0(%rsp), %rdi
callq 0x2220
movq 0xe8(%rsp), %rdi
callq 0x2220
movq (%rsp), %rdx
movq 0x18(%r15), %rax
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
movq 0x50(%rsp), %r15
je 0x1416ce
movapd 0x130(%rsp), %xmm0
mulsd 0xf474a(%rip), %xmm0    # 0x235da8
cvttsd2si %xmm0, %rbx
xorl %r14d, %r14d
movq (%rdx), %rax
movq 0x80(%rdx), %rcx
movl (%rax,%r14,4), %eax
incq %rcx
cmpq %rax, %rcx
jb 0x1416b5
subq $0x8, %rsp
movq 0x10(%rsp), %rdi
movl %r14d, %esi
movq 0x48(%rsp), %rdx
movq %rbx, %rcx
movq %r13, %r8
movq %r15, %r9
pushq %r12
callq 0x1406b3
movq 0x10(%rsp), %rdx
addq $0x10, %rsp
testl %eax, %eax
jne 0x1416b5
movq (%rdx), %rax
movl $0xffffffff, (%rax,%r14,4) # imm = 0xFFFFFFFF
incq %r14
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, %r14
jb 0x141666
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq