// File: /workspace/github_cpp_makefile_star2_O3/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, %r13
movq %r8, %r12
movq %rcx, %rbp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x80(%rsp)
movq 0x18(%rsi), %rdi
callq 0xa0a7d
movq 0x18(%r14), %r15
movl 0x14(%r15), %r8d
testl %r8d, %r8d
js 0x13f7e2
movq %r15, %rdi
callq 0xa0c1e
movq 0x18(%r14), %r15
movl 0x14(%r15), %r8d
movq %r14, 0x10(%rbx)
xorpd %xmm1, %xmm1
movupd %xmm1, 0x88(%rbx)
movupd %xmm1, 0x98(%rbx)
movq $0x0, 0xa8(%rbx)
leaq 0x155f4c(%rip), %rax    # 0x295758
movslq 0x144(%rax), %rcx
cvtsi2sd %ecx, %xmm0
divsd 0xf6541(%rip), %xmm0    # 0x235d60
cvttsd2si %xmm0, %rdx
subsd 0xf1adc(%rip), %xmm0    # 0x231308
cvttsd2si %xmm0, %rsi
movq %rdx, %rdi
sarq $0x3f, %rdi
andq %rsi, %rdi
orq %rdx, %rdi
cmpl $0x0, 0x148(%rax)
cmovneq %rcx, %rdi
movslq 0x1bc(%rax), %rcx
movq %rdi, %rax
xorl %edx, %edx
divq %rcx
cmpl $0x0, 0x8(%rbx)
movq %r14, 0x48(%rsp)
je 0x13f8e9
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 0x13f2d9
movl $0x0, 0xb0(%rbx)
movq 0xb8(%rbx), %rdi
callq 0xa0494
xorl %r14d, %r14d
movq %r14, 0xb8(%rbx)
movq 0xc0(%rbx), %rdi
callq 0xa0761
movq %r14, 0xc0(%rbx)
movq 0xd8(%rbx), %rdi
callq 0x2220
movq %r14, 0xd8(%rbx)
movq 0x48(%rsp), %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc8(%rbx)
jmp 0x140335
movq %r13, 0x78(%rsp)
movq %rax, 0x88(%rsp)
movq %rdi, 0x90(%rsp)
movq %r12, 0x98(%rsp)
addl %r8d, %r8d
leaq 0xc8(%rsp), %r12
movupd %xmm1, 0x58(%r12)
movupd %xmm1, 0x48(%r12)
movupd %xmm1, 0x38(%r12)
movupd %xmm1, 0x28(%r12)
movupd %xmm1, 0x18(%r12)
movupd %xmm1, 0x8(%r12)
movl %r8d, 0x6c(%rsp)
movl %r8d, %r13d
movl $0x1c, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, (%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0xc0162
movq %rax, 0x50(%rsp)
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), %r14
movl 0x14(%r14), %eax
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
andq %r15, %rax
movq %rax, 0x68(%rbx)
movl 0x14(%r14), %edi
andq %r15, %rdi
shlq $0x3, %rdi
callq 0x2280
movq %rax, 0x70(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc0(%rbx)
movupd %xmm0, 0xd0(%rbx)
movl 0x14(%r14), %edx
andq %r15, %rdx
movq %rdx, 0x60(%rbx)
shlq $0x3, %rdx
movq %rax, %rdi
movl $0xff, %esi
callq 0x20e0
movl $0x4, %esi
movq %r13, 0x58(%rsp)
movq %r13, %rdi
callq 0x2120
movq %rax, (%rbx)
testl $0x7fffffff, 0x14(%r14) # imm = 0x7FFFFFFF
je 0x13fa1b
movq 0x20(%r14), %rax
xorl %ecx, %ecx
movb $0x0, 0x4(%rax,%rcx,8)
incq %rcx
movl 0x14(%r14), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
jb 0x13fa04
movq %rbp, 0x60(%rsp)
cmpl $0x0, 0x6c(%rsp)
je 0x13fd4a
xorl %ebp, %ebp
leaq 0xc8(%rsp), %r15
xorl %r12d, %r12d
movq 0x48(%rsp), %r14
movq 0x58(%rsp), %r13
movq 0x18(%r14), %rdi
movq 0x20(%rdi), %rax
movl %r12d, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x13fb41
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%r12,8) # imm = 0xFFFFFFFE
je 0x13fb41
movq (%rbx), %rax
testb $0x3, (%rax,%r12,4)
jne 0x13fb41
movq %rbp, 0x38(%rsp)
movl %ebp, 0x30(%rsp)
movl %ebp, 0x28(%rsp)
movq %rbp, 0x20(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %r12d, %edx
movq 0x50(%rsp), %rcx
movq %r15, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
testq %rax, %rax
je 0x13fb41
movq 0xe0(%rsp), %rax
movq 0x100(%rsp), %rcx
testq %rcx, %rcx
je 0x13fb1c
movq 0x110(%rsp), %rdx
xorl %esi, %esi
movl (%rdx,%rsi,4), %edi
cmpq %rdi, %r12
je 0x13fb12
cmpl (%rax), %edi
je 0x13fb12
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)
incq %rsi
movl %esi, %edi
cmpq %rdi, %rcx
ja 0x13fae0
movq (%rbx), %rcx
movl (%rcx,%r12,4), %edx
andl $-0x4, %edx
orl $0x2, %edx
movl %edx, (%rcx,%r12,4)
movl (%rax), %edx
xorq $0x1, %rdx
andl $-0x4, (%rcx,%rdx,4)
movl (%rax), %eax
xorq $0x1, %rax
addl $0x3, (%rcx,%rax,4)
incq %r12
cmpq %r13, %r12
jne 0x13fa42
xorl %ebp, %ebp
xorpd %xmm0, %xmm0
movapd %xmm0, 0x130(%rsp)
movq %rbp, 0x140(%rsp)
movapd %xmm0, 0xa0(%rsp)
movq %rbp, 0xb0(%rsp)
movl $0x0, %edi
cmpl $0x0, 0x6c(%rsp)
je 0x13fd79
xorl %r15d, %r15d
movq (%rbx), %rax
movl (%rax,%r15,4), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x13fd2c
movq 0x18(%r14), %rdi
movl %ebp, 0x30(%rsp)
movl %ebp, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x10(%rsp)
movl %ebp, 0x8(%rsp)
movq $0x0, 0x38(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq %r14, %rsi
movl %r15d, %edx
movq 0x50(%rsp), %rcx
leaq 0xc8(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
testq %rax, %rax
je 0x13fd2c
movq 0x100(%rsp), %rdx
leal 0x1(%rdx), %r13d
cmpq $0x5, %rdx
ja 0x13fc92
movl $0x2c, %eax
btq %rdx, %rax
jae 0x13fc92
movl %r15d, %r12d
shrl %r12d
xorl %r13d, %r13d
movq 0x110(%rsp), %rax
movl (%rax,%r13,4), %ecx
cmpq %rcx, %r15
je 0x13fc8a
movq 0xe0(%rsp), %rax
movl (%rax), %r9d
cmpl %r9d, %ecx
je 0x13fc8a
movq 0x18(%r14), %rdi
shrl %ecx
shrl %r9d
leaq 0x130(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
movl %r12d, %r8d
callq 0x13e4b7
movq 0xa0(%rsp), %rax
leaq 0x3(%rax), %rcx
movq 0x100(%rsp), %rdx
cmpq %rdx, %rcx
setne %cl
addq $0x2, %rax
cmpq %rdx, %rax
setne %al
testb %al, %cl
jne 0x13fc92
incl %r13d
cmpq %r13, %rdx
ja 0x13fc20
movl %r13d, %edi
movq 0x30(%rbx), %rcx
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rax
cmpq %rdi, %rdx
jne 0x13fce6
cmpq %rsi, %rcx
movq 0x58(%rsp), %r13
jne 0x13fcd8
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
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 %r15d, (%rax,%rcx,4)
jmp 0x13fd2c
cmpq %rsi, %rcx
movq 0x58(%rsp), %r13
jne 0x13fd18
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
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 %r15d, %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rax,%rcx,4)
incq %r15
cmpq %r13, %r15
jne 0x13fb88
movq 0x140(%rsp), %rdi
movq 0xb0(%rsp), %rbp
jmp 0x13fd79
xorpd %xmm0, %xmm0
movapd %xmm0, 0x130(%rsp)
xorl %ebp, %ebp
movq %rbp, 0x140(%rsp)
movapd %xmm0, 0xa0(%rsp)
movq %rbp, 0xb0(%rsp)
xorl %edi, %edi
movq 0x48(%rsp), %r14
callq 0x2220
movq %rbp, %rdi
callq 0x2220
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0x137c5c
movq $0x0, 0x78(%rbx)
cmpq $0x0, 0x30(%rbx)
je 0x13ffab
leaq 0x18(%rbx), %r12
xorl %eax, %eax
xorl %r13d, %r13d
movq 0x40(%rbx), %rcx
movl (%rcx,%rax,4), %ebp
testl %ebp, %ebp
js 0x13fdc2
incq 0x78(%rbx)
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movl (%r12), %edx
movl %edx, (%rcx,%rax,4)
movq 0x18(%r14), %rdi
xorl %eax, %eax
movl %eax, 0x30(%rsp)
movl %eax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
leaq 0x70(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
movq $0x0, 0x38(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
movq %r14, %rsi
movl %ebp, %edx
movq 0x50(%rsp), %rcx
leaq 0xc8(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xc02d6
testq %rax, %rax
je 0x13ff91
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rax
cmpq 0x50(%rbx), %rcx
jne 0x13fe61
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x50(%rbx)
shlq $0x3, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x48(%rbx), %rcx
movq 0x70(%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 0x13feaf
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
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, (%r12)
movl %ebp, (%rax,%rdx,4)
cmpq %rcx, %rsi
jne 0x13fee7
leaq (%rcx,%rcx), %rsi
testq %rcx, %rcx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rsi
movq 0xe0(%rsp), %rcx
movl (%rcx), %ecx
xorl $0x1, %ecx
leaq 0x1(%rsi), %rdx
movq %rdx, (%r12)
movl %ecx, (%rax,%rsi,4)
movq 0x100(%rsp), %rcx
testq %rcx, %rcx
je 0x13ff91
movl $0x1, %r15d
movq 0x110(%rsp), %rsi
xorl %r14d, %r14d
movl (%rsi,%r14,4), %edi
cmpl %ebp, %edi
je 0x13ff86
movq 0xe0(%rsp), %r8
cmpl (%r8), %edi
je 0x13ff86
cmpq 0x20(%rbx), %rdx
jne 0x13ff74
leaq (%rdx,%rdx), %rsi
testq %rdx, %rdx
movl $0x2, %ecx
cmoveq %rcx, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x100(%rsp), %rcx
movq 0x110(%rsp), %rsi
movq 0x18(%rbx), %rdx
movl (%rsi,%r14,4), %edi
leaq 0x1(%rdx), %r8
movq %r8, (%r12)
movl %edi, (%rax,%rdx,4)
movq %r8, %rdx
movl %r15d, %r14d
incl %r15d
cmpq %r14, %rcx
ja 0x13ff21
incl %r13d
movq 0x30(%rbx), %rcx
movq %r13, %rax
cmpq %r13, %rcx
movq 0x48(%rsp), %r14
ja 0x13fdb3
jmp 0x13ffad
xorl %ecx, %ecx
movq 0x40(%rbx), %rax
cmpq 0x38(%rbx), %rcx
jne 0x13ffdf
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
movl $0x2, %esi
cmovneq %rdx, %rsi
movq %rsi, 0x38(%rbx)
shlq $0x2, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rcx
movq 0x78(%rsp), %r12
movq 0x60(%rsp), %r15
movq 0x80(%rsp), %rbp
movl 0x18(%rbx), %edx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x30(%rbx)
movl %edx, (%rax,%rcx,4)
movq 0xc8(%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
movq 0xf8(%rsp), %rdi
callq 0x2220
movq 0x110(%rsp), %rdi
callq 0x2220
movq 0x128(%rsp), %rdi
callq 0x2220
movq 0x30(%rbx), %rax
decq %rax
movq %rax, 0x80(%rbx)
movl 0x14(%rbp), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq %r15, %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x18(%r14), %rax
movl 0x14(%rax), %ecx
testl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq %r15, %rsi
movq 0x98(%rsp), %r15
je 0x1401b8
movq %rbp, %rdx
movq 0x90(%rsp), %rax
movq 0x88(%rsp), %rcx
subq %rcx, %rax
movq 0xf11e3(%rip), %xmm0    # 0x231280
movq %rcx, %xmm1
movq %rax, %xmm2
movapd 0xf11e1(%rip), %xmm3    # 0x231290
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
punpckldq %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
subpd %xmm3, %xmm1
subpd %xmm3, %xmm2
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm1, %xmm0
addsd %xmm2, %xmm3
movsd 0xf1579(%rip), %xmm1    # 0x231658
mulsd %xmm0, %xmm1
mulsd 0xf149d(%rip), %xmm0    # 0x231588
addsd %xmm3, %xmm1
addsd %xmm3, %xmm0
cvttsd2si %xmm1, %rax
movsd 0xf1208(%rip), %xmm2    # 0x231308
subsd %xmm2, %xmm1
cvttsd2si %xmm0, %rcx
subsd %xmm2, %xmm0
movq %rax, %rdi
sarq $0x3f, %rdi
cvttsd2si %xmm1, %r8
andq %rdi, %r8
movq %rcx, %rdi
sarq $0x3f, %rdi
cvttsd2si %xmm0, %r9
andq %rdi, %r9
orq %rax, %r8
movq %r8, 0x50(%rsp)
orq %rcx, %r9
movq %r9, 0x58(%rsp)
xorl %r13d, %r13d
movl 0x30(%rbx), %eax
movl %eax, 0x20(%rsp)
incl %eax
movl %eax, 0x18(%rsp)
movq %rsi, 0x8(%rsp)
movq %r12, (%rsp)
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movl $0x14, 0x10(%rsp)
movq %r14, %rdi
movl %r13d, %esi
movq 0x50(%rsp), %rcx
movq %rbx, %rbp
movq %r12, %rbx
movq %r14, %r12
movq %rdx, %r14
movq 0x58(%rsp), %r8
movq %r15, %r9
callq 0x13f417
movq %r14, %rdx
movq %r12, %r14
movq %rbx, %r12
movq %rbp, %rbx
movq 0x60(%rsp), %rsi
movq (%rbp), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
movq 0x18(%r14), %rax
movl 0x14(%rax), %ecx
movl %ecx, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
cmpq %rdi, %r13
jb 0x14013e
cmpq $0x0, 0x80(%rbx)
je 0x1402fd
movabsq $-0x100000001, %r12     # imm = 0xFFFFFFFEFFFFFFFF
movq 0x28(%rbx), %rdx
movq 0x40(%rbx), %rcx
movq %rcx, 0x50(%rsp)
movq 0x58(%rbx), %rcx
movq %rcx, 0x60(%rsp)
movq 0x70(%rbx), %r8
xorl %r9d, %r9d
movq 0x50(%rsp), %rcx
movl (%rcx,%r9,4), %r14d
movl 0x4(%rcx,%r9,4), %ecx
subl %r14d, %ecx
leal 0x1(%r14), %r10d
movl (%rdx,%r14,4), %r11d
movl (%rdx,%r10,4), %r10d
movq 0x60(%rsp), %rsi
movq (%rsi,%r9,8), %r15
movq %r15, 0x70(%rsp)
addl $-0x2, %ecx
je 0x140299
movq %r12, %rsi
leaq (%rdx,%r14,4), %r14
movq (%rbx), %r15
movq 0x48(%rsp), %rdi
movq 0x10(%rdi), %r12
movl %ecx, %r13d
xorl %ebp, %ebp
xorl %ecx, %ecx
movl 0x8(%r14,%rbp,4), %edi
shrl %edi
movl %r9d, (%r15,%rdi,4)
movl 0x8(%r14,%rbp,4), %edi
shrl %edi
leaq (%rdi,%rdi,4), %rdi
addl 0x10(%r12,%rdi,8), %ecx
incq %rbp
cmpq %rbp, %r13
jne 0x140237
cmpl $0x3, %ecx
movq %rsi, %r12
jbe 0x140299
movq (%rbx), %r14
movq 0x30(%rbx), %rcx
shrl %r11d
movl (%r14,%r11,4), %edi
incq %rcx
cmpq %rdi, %rcx
je 0x140280
movl $0xffffffff, (%r14,%r11,4) # imm = 0xFFFFFFFF
movl %r10d, %r15d
shrl %r15d
movl (%r14,%r15,4), %edi
cmpq %rdi, %rcx
je 0x14029c
movl $0xffffffff, (%r14,%r15,4) # imm = 0xFFFFFFFF
jmp 0x14029c
shrl %r11d
movq 0x48(%rsp), %r14
movq (%r8,%r11,8), %rcx
cmpq $-0x1, %rcx
je 0x1402b9
cmpq %r12, %rcx
jbe 0x1402c4
shlq $0x20, %rcx
orq %r9, %rcx
jmp 0x1402c0
leaq (%r12,%r9), %rcx
incq %rcx
movq %rcx, (%r8,%r11,8)
shrl %r10d
movq (%r8,%r10,8), %rcx
cmpq $-0x1, %rcx
je 0x1402df
cmpq %r12, %rcx
jbe 0x1402ea
shlq $0x20, %rcx
orq %r9, %rcx
jmp 0x1402e6
leaq (%r12,%r9), %rcx
incq %rcx
movq %rcx, (%r8,%r10,8)
incl %r9d
cmpq %r9, 0x80(%rbx)
ja 0x1401ed
movl 0x14(%rax), %ecx
testl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
je 0x140335
movq (%rbx), %rdx
movq 0x30(%rbx), %rsi
leaq 0x1(%rsi), %rdi
xorl %r8d, %r8d
movl (%rdx,%r8,4), %r9d
cmpq %r9, %rdi
jne 0x140323
movl %esi, (%rdx,%r8,4)
movl 0x14(%rax), %ecx
incq %r8
movl %ecx, %r9d
andl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
cmpq %r9, %r8
jb 0x140313
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x13f39b
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq