// File: /workspace/github_cpp_makefile_star2_O1/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 $0x148, %rsp            # imm = 0x148
movq %r9, %r12
movq %r8, %r13
movq %rcx, %rbp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0xf8(%rsp)
movq 0x18(%rsi), %rdi
callq 0xa02fa
movq 0x18(%r14), %rdi
cmpl $0x0, 0x14(%rdi)
js 0x1399c2
callq 0xa047e
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 0x150d64(%rip), %rax    # 0x28a758
movslq 0x144(%rax), %rcx
cvtsi2sd %ecx, %xmm0
divsd 0xf0161(%rip), %xmm0    # 0x229b68
cvttsd2si %xmm0, %rdx
subsd 0xeb854(%rip), %xmm0    # 0x225268
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, 0x60(%rsp)
je 0x139ad1
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 0x1394bc
movl $0x0, 0xb0(%rbx)
movq 0xb8(%rbx), %rdi
callq 0x9fcdb
xorl %r14d, %r14d
movq %r14, 0xb8(%rbx)
movq 0xc0(%rbx), %rdi
callq 0xa0004
movq %r14, 0xc0(%rbx)
movq 0xd8(%rbx), %rdi
callq 0x2220
movq %r14, 0xd8(%rbx)
movq 0x60(%rsp), %r14
xorpd %xmm0, %xmm0
movupd %xmm0, 0xc8(%rbx)
jmp 0x13a4f8
movq %rax, 0xd8(%rsp)
movq %rdi, 0xe0(%rsp)
movq %r13, 0xe8(%rsp)
movq %r12, 0xf0(%rsp)
addl %r8d, %r8d
leaq 0x70(%rsp), %r12
movapd %xmm1, 0x50(%r12)
movapd %xmm1, 0x40(%r12)
movapd %xmm1, 0x30(%r12)
movapd %xmm1, 0x20(%r12)
movapd %xmm1, 0x10(%r12)
movapd %xmm1, (%r12)
movq $0x0, 0x60(%r12)
movl %r8d, 0x50(%rsp)
movl %r8d, %r13d
movl $0x1c, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, (%r12)
movq %r15, %rdi
movq %r12, %rsi
callq 0xbf22d
movq %rax, 0x48(%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), %r15
movl 0x14(%r15), %eax
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
andq %r12, %rax
movq %rax, 0x68(%rbx)
movl 0x14(%r15), %edi
andq %r12, %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 %r12, %rdx
movq %rdx, 0x60(%rbx)
shlq $0x3, %rdx
movq %rax, %rdi
movl $0xff, %esi
callq 0x20e0
movl $0x4, %esi
movq %r13, %rdi
callq 0x2120
movq %rax, (%rbx)
testl $0x7fffffff, 0x14(%r15) # imm = 0x7FFFFFFF
je 0x139c06
movq 0x20(%r15), %rax
xorl %ecx, %ecx
movb $0x0, 0x4(%rax,%rcx,8)
incq %rcx
movl 0x14(%r15), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %rcx
jb 0x139bef
movq %rbp, 0x58(%rsp)
movl 0x50(%rsp), %r9d
testl %r9d, %r9d
je 0x139d38
xorl %r12d, %r12d
leaq 0x70(%rsp), %r15
xorl %ebp, %ebp
movq 0x18(%r14), %rdi
movq 0x20(%rdi), %rax
movl %ebp, %ecx
shrl %ecx
cmpl $0x0, (%rax,%rcx,8)
js 0x139d2c
movq 0x28(%rdi), %rax
testl $0xfffffffe, (%rax,%rbp,8) # imm = 0xFFFFFFFE
je 0x139d2c
movq (%rbx), %rax
testb $0x3, (%rax,%rbp,4)
jne 0x139d2c
movq %r12, 0x38(%rsp)
movl %r12d, 0x30(%rsp)
movl %r12d, 0x28(%rsp)
movq %r12, 0x20(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rsp)
movl %r12d, 0x8(%rsp)
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
xorl %esi, %esi
movl %ebp, %edx
movq 0x48(%rsp), %rcx
movq %r15, %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xbf39f
movl 0x50(%rsp), %r9d
testq %rax, %rax
je 0x139d2c
movq 0xa8(%rsp), %rax
testq %rax, %rax
je 0x139d01
movq 0x88(%rsp), %rcx
movq 0xb8(%rsp), %rdx
xorl %esi, %esi
movl (%rdx,%rsi,4), %edi
cmpq %rdi, %rbp
je 0x139cf7
cmpl (%rcx), %edi
je 0x139cf7
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, %rax
ja 0x139cc5
movq (%rbx), %rax
movl (%rax,%rbp,4), %ecx
andl $-0x4, %ecx
orl $0x2, %ecx
movl %ecx, (%rax,%rbp,4)
movq 0x88(%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 %rbp
cmpq %r13, %rbp
jne 0x139c23
xorpd %xmm0, %xmm0
movapd %xmm0, 0x120(%rsp)
xorl %eax, %eax
movq %rax, 0x130(%rsp)
movapd %xmm0, 0x100(%rsp)
movq %rax, 0x110(%rsp)
testl %r9d, %r9d
je 0x139f34
xorl %ebp, %ebp
movq (%rbx), %rax
movl (%rax,%rbp,4), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x139f28
movq 0x18(%r14), %rdi
xorl %eax, %eax
movl %eax, 0x30(%rsp)
movl %eax, 0x28(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x18(%rsp)
leaq 0x68(%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 0x48(%rsp), %rcx
leaq 0x70(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xbf39f
testq %rax, %rax
je 0x139f28
movq 0xa8(%rsp), %rax
leal 0x1(%rax), %r12d
cmpq $0x5, %rax
ja 0x139e8f
movl $0x2c, %ecx
btq %rax, %rcx
jae 0x139e8f
cmpq $0x0, 0xa8(%rsp)
je 0x139e8c
movl %ebp, %r15d
shrl %r15d
xorl %r12d, %r12d
movq 0xb8(%rsp), %rax
movl (%rax,%r12,4), %ecx
cmpq %rcx, %rbp
je 0x139e7d
movq 0x88(%rsp), %rax
movl (%rax), %r9d
cmpl %r9d, %ecx
je 0x139e7d
movq 0x18(%r14), %rdi
shrl %ecx
shrl %r9d
leaq 0x120(%rsp), %rsi
leaq 0x100(%rsp), %rdx
movl %r15d, %r8d
callq 0x1386d7
movq 0x100(%rsp), %rax
leaq 0x3(%rax), %rcx
movq 0xa8(%rsp), %rdx
cmpq %rdx, %rcx
setne %cl
addq $0x2, %rax
cmpq %rdx, %rax
setne %al
testb %al, %cl
jne 0x139e8f
incl %r12d
cmpq %r12, 0xa8(%rsp)
ja 0x139e13
jmp 0x139e8f
xorl %r12d, %r12d
movl %r12d, %edx
movq 0x30(%rbx), %rcx
movq 0x38(%rbx), %rax
cmpq %rdx, 0xa8(%rsp)
jne 0x139ee3
cmpq %rax, %rcx
jne 0x139ece
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movl %ebp, (%rcx,%rax,4)
jmp 0x139f28
cmpq %rax, %rcx
jne 0x139f0d
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%rbx)
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x30(%rbx)
movl %ebp, %edx
orl $0x80000000, %edx       # imm = 0x80000000
movl %edx, (%rcx,%rax,4)
incq %rbp
cmpq %r13, %rbp
jne 0x139d6b
movq 0x130(%rsp), %rdi
callq 0x2220
movq 0x110(%rsp), %rdi
callq 0x2220
movq 0x30(%rbx), %rax
movq 0x40(%rbx), %rdi
leaq (%rdi,%rax,4), %rsi
callq 0x131a70
movq $0x0, 0x78(%rbx)
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
je 0x13a173
leaq 0x18(%rbx), %rax
movq %rax, 0x50(%rsp)
xorl %eax, %eax
xorl %r15d, %r15d
movq 0x40(%rbx), %rcx
movl (%rcx,%rax,4), %ebp
testl %ebp, %ebp
js 0x139f91
incq 0x78(%rbx)
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq 0x50(%rsp), %rdx
movl (%rdx), %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 0x68(%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 0x48(%rsp), %rcx
leaq 0x70(%rsp), %r8
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
callq 0xbf39f
testq %rax, %rax
je 0x13a160
movq 0x50(%rbx), %rax
cmpq %rax, 0x48(%rbx)
jne 0x13a029
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x50(%rbx)
movq 0x58(%rbx), %rdi
shlq $0x3, %rsi
callq 0x2370
movq %rax, 0x58(%rbx)
movq 0x68(%rsp), %rax
movq 0x48(%rbx), %rcx
movq 0x58(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x48(%rbx)
movq %rax, (%rdx,%rcx,8)
movq 0x20(%rbx), %rax
cmpq %rax, 0x18(%rbx)
jne 0x13a071
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x20(%rbx)
movq 0x28(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x18(%rbx), %rax
movq 0x28(%rbx), %rdi
leaq 0x1(%rax), %rcx
movq %rcx, 0x18(%rbx)
movl %ebp, (%rdi,%rax,4)
movq 0x20(%rbx), %rax
cmpq %rax, %rcx
jne 0x13a0ae
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x20(%rbx)
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0x88(%rsp), %rax
movl (%rax), %eax
xorl $0x1, %eax
movq 0x18(%rbx), %rcx
movq 0x28(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x18(%rbx)
movl %eax, (%rdx,%rcx,4)
cmpq $0x0, 0xa8(%rsp)
je 0x13a160
movl $0x1, %r13d
xorl %r12d, %r12d
movq 0xb8(%rsp), %rax
movl (%rax,%r12,4), %eax
cmpl %ebp, %eax
je 0x13a150
movq 0x88(%rsp), %rcx
cmpl (%rcx), %eax
je 0x13a150
movq 0x20(%rbx), %rax
cmpq %rax, 0x18(%rbx)
jne 0x13a131
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x20(%rbx)
movq 0x28(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x28(%rbx)
movq 0xb8(%rsp), %rax
movl (%rax,%r12,4), %eax
movq 0x18(%rbx), %rcx
movq 0x28(%rbx), %rdx
leaq 0x1(%rcx), %rsi
movq %rsi, 0x18(%rbx)
movl %eax, (%rdx,%rcx,4)
movl %r13d, %r12d
incl %r13d
cmpq %r12, 0xa8(%rsp)
ja 0x13a0e6
incl %r15d
movq 0x30(%rbx), %rcx
movq %r15, %rax
cmpq %r15, %rcx
ja 0x139f82
movq 0x38(%rbx), %rax
cmpq %rax, %rcx
movq 0xf0(%rsp), %r12
movq 0x58(%rsp), %r15
movq 0xf8(%rsp), %rbp
jne 0x13a1b6
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %esi
cmovneq %rcx, %rsi
movq %rsi, 0x38(%rbx)
movq 0x40(%rbx), %rdi
shlq $0x2, %rsi
callq 0x2370
movq %rax, 0x40(%rbx)
movl 0x18(%rbx), %eax
movq 0x40(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x30(%rbx)
movl %eax, (%rcx,%rdx,4)
movq 0x70(%rsp), %rdi
callq 0x2220
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 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
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
movq 0xe8(%rsp), %r9
je 0x13a37e
movq %rbp, %rdx
movq 0xe0(%rsp), %rax
movq 0xd8(%rsp), %rcx
subq %rcx, %rax
movq 0xeafde(%rip), %xmm0    # 0x225240
movq %rcx, %xmm1
movq %rax, %xmm2
movapd 0xeafdc(%rip), %xmm3    # 0x225250
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 0xeb2b4(%rip), %xmm1    # 0x225558
mulsd %xmm0, %xmm1
mulsd 0xeb1d8(%rip), %xmm0    # 0x225488
addsd %xmm3, %xmm1
addsd %xmm3, %xmm0
cvttsd2si %xmm1, %rax
movsd 0xeafa3(%rip), %xmm2    # 0x225268
subsd %xmm2, %xmm1
cvttsd2si %xmm0, %rcx
subsd %xmm2, %xmm0
movq %rax, %rdi
sarq $0x3f, %rdi
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
movq %rcx, %rdi
sarq $0x3f, %rdi
cvttsd2si %xmm0, %r8
andq %rdi, %r8
orq %rax, %rsi
movq %rsi, 0x48(%rsp)
orq %rcx, %r8
movq %r8, 0x50(%rsp)
xorl %r13d, %r13d
movl 0x30(%rbx), %eax
movl %eax, 0x20(%rsp)
incl %eax
movl %eax, 0x18(%rsp)
movq %r15, 0x8(%rsp)
movq %r12, (%rsp)
movl $0xffffffff, 0x28(%rsp) # imm = 0xFFFFFFFF
movl $0x14, 0x10(%rsp)
movq %r14, %rdi
movl %r13d, %esi
movq 0x48(%rsp), %rcx
movq %r14, %r15
movq %rdx, %r14
movq 0x50(%rsp), %r8
movq %rbx, %rbp
movq %r12, %rbx
movq %r9, %r12
callq 0x1395fa
movq %r12, %r9
movq %rbx, %r12
movq %rbp, %rbx
movq %r14, %rdx
movq %r15, %r14
movq 0x58(%rsp), %r15
movq (%rbp), %rcx
movl %eax, (%rcx,%r13,4)
incq %r13
movq 0x18(%r14), %rax
movl 0x14(%rax), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %r13
jb 0x13a303
cmpq $0x0, 0x80(%rbx)
je 0x13a4c3
movabsq $-0x100000001, %r12     # imm = 0xFFFFFFFEFFFFFFFF
movq 0x28(%rbx), %rdx
movq 0x40(%rbx), %rcx
movq %rcx, 0x48(%rsp)
movq 0x58(%rbx), %rcx
movq %rcx, 0x58(%rsp)
movq 0x70(%rbx), %r8
xorl %r9d, %r9d
movq 0x48(%rsp), %rcx
movl (%rcx,%r9,4), %edi
movl 0x4(%rcx,%r9,4), %ecx
subl %edi, %ecx
leal 0x1(%rdi), %r10d
movl (%rdx,%rdi,4), %r11d
movl (%rdx,%r10,4), %r10d
movq 0x58(%rsp), %rsi
movq (%rsi,%r9,8), %r15
movq %r15, 0x68(%rsp)
addl $-0x2, %ecx
je 0x13a467
movq %r12, %rsi
leaq (%rdx,%rdi,4), %r15
movq (%rbx), %r12
movq 0x10(%r14), %r13
movl %ecx, %ebp
xorl %ecx, %ecx
xorl %edi, %edi
movl 0x8(%r15,%rcx,4), %r14d
shrl %r14d
movl %r9d, (%r12,%r14,4)
movl 0x8(%r15,%rcx,4), %r14d
shrl %r14d
leaq (%r14,%r14,4), %r14
addl 0x10(%r13,%r14,8), %edi
incq %rcx
cmpq %rcx, %rbp
jne 0x13a3fa
cmpl $0x4, %edi
movq 0x60(%rsp), %r14
movq %rsi, %r12
jb 0x13a467
movq (%rbx), %r15
movq 0x30(%rbx), %rcx
movl %r11d, %edi
shrl %edi
movl (%r15,%rdi,4), %r14d
incq %rcx
cmpq %r14, %rcx
je 0x13a44c
movl $0xffffffff, (%r15,%rdi,4) # imm = 0xFFFFFFFF
movl %r10d, %edi
shrl %edi
movl (%r15,%rdi,4), %r14d
cmpq %r14, %rcx
movq 0x60(%rsp), %r14
je 0x13a467
movl $0xffffffff, (%r15,%rdi,4) # imm = 0xFFFFFFFF
shrl %r11d
movq (%r8,%r11,8), %rcx
cmpq $-0x1, %rcx
je 0x13a482
cmpq %r12, %rcx
jbe 0x13a48d
shlq $0x20, %rcx
orq %r9, %rcx
jmp 0x13a489
leaq (%r12,%r9), %rcx
incq %rcx
movq %rcx, (%r8,%r11,8)
shrl %r10d
movq (%r8,%r10,8), %rcx
cmpq $-0x1, %rcx
je 0x13a4a8
cmpq %r12, %rcx
jbe 0x13a4b3
shlq $0x20, %rcx
orq %r9, %rcx
jmp 0x13a4af
leaq (%r12,%r9), %rcx
incq %rcx
movq %rcx, (%r8,%r10,8)
incl %r9d
cmpq %r9, 0x80(%rbx)
ja 0x13a3b3
testl $0x7fffffff, 0x14(%rax) # imm = 0x7FFFFFFF
je 0x13a4f8
movq (%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq 0x1(%rdx), %rsi
xorl %edi, %edi
movl (%rcx,%rdi,4), %r8d
cmpq %r8, %rsi
jne 0x13a4e5
movl %edx, (%rcx,%rdi,4)
incq %rdi
movl 0x14(%rax), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
cmpq %r8, %rdi
jb 0x13a4d9
xorpd %xmm0, %xmm0
movupd %xmm0, 0xb8(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x13957e
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq