// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/horder.cpp
// Function: break_phasing_utg(ma_ug_t*, asg_t*, kvec_pe_hit*, kv_u_trans_t*, h_covs*)
void break_phasing_utg(ma_ug_t *ug, asg_t *rg, kvec_pe_hit *hits, kv_u_trans_t *k_trans, h_covs *b_points)
{
    if(b_points->n == 0) return;
    kv_u_trans_hit_t kv; kv_init(kv);
    asg_arc_t *rt = NULL, *ut = NULL;
    asg_t *utg = NULL;
    h_cov_t *p = NULL;
    h_covs join; kv_init(join);
    uint64_t k, l, i, idx, m, pidx, de_u, u_n, oug_n = ug->u.n, dug_n = 0, puid, pn, rsi, prid, nrid, x, y, *index = NULL;
    kv_u_trans_t *n_trans = NULL; CALLOC(n_trans, 1);
    kvec_t(uint64_t) dbg_N50; kv_init(dbg_N50);
    /*******************************for debug************************************/
    // debug_phasing_t *dbp = init_debug_phasing(ug, hits, k_trans, b_points);
    /*******************************for debug************************************/
    radix_sort_h_cov_s(b_points->a, b_points->a+b_points->n);
    for (k = 1, l = 0; k <= b_points->n; ++k) 
    {
        if (k == b_points->n || b_points->a[k].s != b_points->a[l].s)
        {
            de_u = 0; pn = join.n;
            radix_sort_h_cov_e(b_points->a+l, b_points->a+k);
            u_n = ug->u.a[b_points->a[l].s].n;
            for (i = l, pidx = 0; i < k; i++)
            {
                idx = b_points->a[i].e + 1;
                if(idx > pidx && idx - pidx < u_n)
                {
                    // fprintf(stderr, "sa-utg%.6lul, pidx: %lu, idx: %lu\n", b_points->a[l].s+1, pidx, idx);
                    if(append_sub_utg(ug, rg, b_points->a[l].s, pidx, idx, &rsi, NULL))
                    {
                        de_u++;
                        kv_pushp(h_cov_t, join, &p);
                        p->dp = (b_points->a[l].s<<32)|(ug->u.n-1);
                        p->s = rsi; p->e = ug->u.a[ug->u.n-1].len;
                        kv_push(uint64_t, dbg_N50, (uint64_t)(ug->u.a[ug->u.n-1].len)+((uint64_t)(1)<<63));///new nodes
                    }
                }
                pidx = idx;
            }

            idx = u_n;
            if(idx > pidx && idx - pidx < u_n)
            {
                // fprintf(stderr, "sa-utg%.6lul, pidx: %lu, idx: %lu\n", b_points->a[l].s+1, pidx, idx);
                if(append_sub_utg(ug, rg, b_points->a[l].s, pidx, idx, &rsi, NULL))
                {
                    de_u++;
                    kv_pushp(h_cov_t, join, &p);
                    p->dp = (b_points->a[l].s<<32)|(ug->u.n-1);
                    p->s = rsi; p->e = ug->u.a[ug->u.n-1].len;
                    kv_push(uint64_t, dbg_N50, (uint64_t)(ug->u.a[ug->u.n-1].len)+((uint64_t)(1)<<63));///new nodes
                }
            }

            if(de_u)
            {
                kv_push(uint64_t, dbg_N50, ug->u.a[b_points->a[l].s].len);///old nodes
                update_nus(&(ug->u.a[b_points->a[l].s]), ug, join.a + pn, join.n - pn);
                free(ug->u.a[b_points->a[l].s].a); free(ug->u.a[b_points->a[l].s].s);
                memset(&(ug->u.a[b_points->a[l].s]), 0, sizeof(ug->u.a[b_points->a[l].s]));
                dug_n++;
            }

            l = k;
        }
    }
    // fprintf(stderr, "oug_n-%lu, dug_n-%lu\n", oug_n, dug_n);
    // for (i = 0; i < join.n; i++)
    // {
    //     fprintf(stderr, "+p-utg%.6lul, n-utg%.6ul\n", (join.a[i].dp>>32)+1, ((uint32_t)join.a[i].dp)+1);
    // }

    for (i = 0; i < join.n; i++)
    {
        join.a[i].dp -= dug_n;
    }
    for (i = m = 0; i < ug->u.n; i++)
    {
        if(!ug->u.a[i].a) continue;
        if(i < oug_n)
        {
            kv_pushp(h_cov_t, join, &p);
            p->dp = (i<<32)|(m);///current id | updated id
            p->s = 0; p->e = ug->u.a[i].len;
        }

        ug->u.a[m] = ug->u.a[i];
        m++;
    }
    if(m < ug->u.n)
    {
        for (i = m; i < ug->u.n; i++)
        {
            memset(&(ug->u.a[i]), 0, sizeof(ug->u.a[i]));
        }
        ug->u.n = m;
    }
    radix_sort_h_cov_dp(join.a, join.a+join.n);
    CALLOC(index, ug->u.n);
    // for (i = 0; i < join.n; i++)
    // {
    //     fprintf(stderr, "+p-utg%.6lul (len: %u), n-utg%.6ul, s-%lu, e-%lu\n", 
    //             (join.a[i].dp>>32)+1, ug->g->seq[(join.a[i].dp>>32)].len, ((uint32_t)join.a[i].dp)+1, join.a[i].s, join.a[i].e);
    // }
    utg = asg_init();
    utg->n_arc = utg->m_arc = ug->g->n_arc;
    MALLOC(utg->arc, utg->n_arc);
    memcpy(utg->arc, ug->g->arc, utg->n_arc*sizeof(asg_arc_t));
    for (k = 1, l = 0; k <= join.n; ++k) 
    {
        if (k == join.n || ((join.a[k].dp>>32) != (join.a[l].dp>>32))) 
        {
            puid = (join.a[l].dp>>32);
            index[puid] = (l<<32) | (k-l);

            for (i = l; i < k; i++)
            {
                asg_seq_set(utg, (uint32_t)join.a[i].dp, ug->u.a[(uint32_t)join.a[i].dp].len, 0);
                utg->seq[(uint32_t)join.a[i].dp].c = ug->g->seq[puid].c;

                if(i + 1 >= k) continue;
                prid = ug->u.a[(uint32_t)join.a[i].dp].a[ug->u.a[(uint32_t)join.a[i].dp].n-1]>>32;
                nrid = ug->u.a[(uint32_t)join.a[i+1].dp].a[0]>>32;

                rt = get_r_edge(rg, prid, nrid, NULL);
                ut = asg_arc_pushp(utg); 
                x = (uint32_t)join.a[i].dp; x <<= 1;
                y = (uint32_t)join.a[i+1].dp; y <<= 1;
			    ut->ol = rt->ol, ut->del = 0;
			    ut->ul = (uint64_t)x<<32 | (ug->u.a[x>>1].len - ut->ol);
			    ut->v = y;

                rt = get_r_edge(rg, nrid^1, prid^1, NULL);
                ut = asg_arc_pushp(utg); 
                x = (uint32_t)join.a[i+1].dp; x <<= 1; x++;
                y = (uint32_t)join.a[i].dp; y <<= 1; y++;
                ut->ol = rt->ol, ut->del = 0;
                ut->ul = (uint64_t)x<<32 | (ug->u.a[x>>1].len - ut->ol);
			    ut->v = y;
            }
            update_unitig_ends(ug->g, utg->arc, puid, ((uint32_t)join.a[k-1].dp)<<1, (((uint32_t)join.a[l].dp)<<1)+1);
            l = k;
        }
    }
    asg_cleanup(utg);
    asg_destroy(ug->g);
    ug->g = utg;

    for (k = 0; k < k_trans->n; k++)
    {
        extract_novlp(&(k_trans->a[k]), &join, index, &kv, n_trans);
    }
    free(k_trans->a); free(k_trans->idx.a); memset(k_trans, 0, sizeof(*k_trans));
    k_trans->a = n_trans->a; k_trans->n = n_trans->n; k_trans->m = n_trans->m; 
    free(n_trans);

    clean_u_trans_t_idx_adv(k_trans, ug, rg);
    // clean_u_trans_t_idx(k_trans, ug, rg);

    
    uint64_t uID_bits, pos_mode;
    for (uID_bits=1; (uint64_t)(1<<uID_bits)<(uint64_t)ug->u.n; uID_bits++);
    pos_mode = ((uint64_t)-1)>>(uID_bits+1);
    
    for (k = m = 0; k < hits->a.n; k++)
    {
        if(get_new_offset(hits, k, index, &join, uID_bits))
        {
            hits->a.a[m] = hits->a.a[k];
            m++;
        }
    }
    // fprintf(stderr, "hits->a.n: %u, m: %lu\n", (uint32_t)hits->a.n, m);
    hits->a.n = m;  

    dedup_hits(hits, 0); 
    hits->uID_bits = uID_bits; hits->pos_mode = pos_mode;
    free(hits->idx.a); hits->idx.a = NULL; hits->idx.n = hits->idx.m = 0;
    free(hits->occ.a); hits->occ.a = NULL; hits->occ.n = hits->occ.m = 0;

    /*******************************for debug************************************/
    // debug_debug_phasing_t(dbp, ug, hits, k_trans, &join, index);
    // destory_debug_phasing_t(&dbp);
    /*******************************for debug************************************/
    verbose_misjoin(dbg_N50.a, dbg_N50.n);
    kv_destroy(join); kv_destroy(kv); free(index); kv_destroy(dbg_N50);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rcx, 0x90(%rsp)
movq %rsi, 0x70(%rsp)
movq 0x8(%r8), %rbx
testq %rbx, %rbx
je 0x13610b
movq %rdi, %r13
movq %rdx, 0x98(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xb0(%rsp)
andq $0x0, 0xc0(%rsp)
movaps %xmm0, 0x40(%rsp)
andq $0x0, 0x50(%rsp)
movq (%rdi), %rax
movq %rax, 0x60(%rsp)
pushq $0x1
popq %r14
pushq $0x30
popq %rsi
movq %r14, %rdi
movq %r8, 0x10(%rsp)
callq 0x2120
movq %rax, 0x88(%rsp)
movq 0x10(%rsp), %rax
movq (%rax), %rdi
imulq $0x18, %rbx, %rsi
addq %rdi, %rsi
callq 0x130013
movq %r14, %rsi
movq 0x10(%rsp), %r8
movq $0x0, 0x68(%rsp)
xorl %ebx, %ebx
xorl %r14d, %r14d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x28(%rsp)
movq %r13, 0x58(%rsp)
cmpq 0x8(%r8), %rsi
ja 0x135b52
movq (%r8), %rax
je 0x135714
imulq $0x18, %rsi, %rcx
movq (%rax,%rcx), %rcx
imulq $0x18, %rbx, %rdx
cmpq (%rax,%rdx), %rcx
je 0x135b4a
movq %r14, 0x30(%rsp)
movq 0x48(%rsp), %rcx
movq %rcx, 0x78(%rsp)
imulq $0x18, %rbx, %r15
leaq (%rax,%r15), %rdi
movq %rsi, 0x20(%rsp)
imulq $0x18, 0x20(%rsp), %rsi
addq %rax, %rsi
callq 0x130273
movq 0x20(%rsp), %rsi
movq 0x10(%rsp), %r8
movq 0x10(%r13), %rax
movq (%r8), %rcx
imulq $0x28, (%rcx,%r15), %rcx
movl 0x10(%rax,%rcx), %r14d
movq %r15, 0x38(%rsp)
leaq 0x8(%r15), %r12
xorl %r15d, %r15d
xorl %ebp, %ebp
movq %r15, %rcx
cmpq %rsi, %rbx
jae 0x1358f7
movq (%r8), %rax
movq (%rax,%r12), %r15
incq %r15
movq %r15, %rdx
subq %rcx, %rdx
jbe 0x1358eb
cmpq %r14, %rdx
jae 0x1358eb
movq 0x38(%rsp), %rdx
movq (%rax,%rdx), %rdx
andq $0x0, (%rsp)
movq %r13, %rdi
movq 0x70(%rsp), %rsi
movq %r15, %r8
leaq 0x80(%rsp), %r9
callq 0x133df8
testl %eax, %eax
je 0x1358a1
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %r13
cmpq 0x50(%rsp), %r13
jne 0x1357f9
leaq (,%r13,2), %rcx
testq %r13, %r13
pushq $0x2
popq %rdx
cmoveq %rdx, %rcx
movq %rcx, 0x50(%rsp)
imulq $0x18, %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %r8
leaq 0x1(%r13), %rcx
movq %rcx, 0x48(%rsp)
imulq $0x18, %r13, %rsi
movq (%r8), %rcx
movq 0x38(%rsp), %rdx
movq (%rcx,%rdx), %rdx
shlq $0x20, %rdx
movq 0x58(%rsp), %r13
movq (%r13), %rcx
leaq -0x1(%rcx), %rdi
orq %rdx, %rdi
movq %rdi, 0x10(%rax,%rsi)
movq 0x80(%rsp), %rdx
movq %rdx, (%rax,%rsi)
movq 0x10(%r13), %rdx
imulq $0x28, %rcx, %rdi
movl -0x28(%rdx,%rdi), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq %rdi, 0x8(%rax,%rsi)
movq 0x18(%rsp), %rax
cmpq %rax, 0x28(%rsp)
jne 0x1358ad
leaq (%rax,%rax), %r13
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r13
leaq (,%r13,8), %rsi
movq 0x30(%rsp), %rdi
callq 0x2370
movq 0x10(%rsp), %r8
movq 0x58(%rsp), %rcx
movq (%rcx), %rcx
movq 0x58(%rsp), %rdx
movq 0x10(%rdx), %rdx
movq %r13, 0x18(%rsp)
movq 0x58(%rsp), %r13
jmp 0x1358b2
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %rsi
jmp 0x1358eb
movq 0x30(%rsp), %rax
movq 0x20(%rsp), %rsi
incq %rbp
imulq $0x28, %rcx, %rcx
movl -0x28(%rdx,%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
orq %rdx, %rcx
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rdx
movq %rcx, (%rax,%rdx,8)
incq %rdx
movq %rdx, 0x28(%rsp)
incq %rbx
addq $0x18, %r12
jmp 0x135767
movq %r14, %rax
subq %rcx, %rax
jbe 0x135a40
cmpq %r14, %rax
jae 0x135a40
movq (%r8), %rax
movq 0x38(%rsp), %rdx
movq (%rax,%rdx), %rdx
andq $0x0, (%rsp)
movq %r13, %rdi
movq 0x70(%rsp), %rsi
movq %r14, %r8
leaq 0x80(%rsp), %r9
callq 0x133df8
testl %eax, %eax
je 0x135a47
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rbx
cmpq 0x50(%rsp), %rbx
movq 0x30(%rsp), %r14
jne 0x135977
leaq (%rbx,%rbx), %rcx
testq %rbx, %rbx
pushq $0x2
popq %rdx
cmoveq %rdx, %rcx
movq %rcx, 0x50(%rsp)
imulq $0x18, %rcx, %rsi
movq %rax, %rdi
callq 0x2370
movq %rax, 0x40(%rsp)
movq 0x10(%rsp), %r8
leaq 0x1(%rbx), %rcx
movq %rcx, 0x48(%rsp)
imulq $0x18, %rbx, %rsi
movq (%r8), %rcx
movq 0x38(%rsp), %rdx
movq (%rcx,%rdx), %rdx
shlq $0x20, %rdx
movq (%r13), %rcx
leaq -0x1(%rcx), %rdi
orq %rdx, %rdi
movq %rdi, 0x10(%rax,%rsi)
movq 0x80(%rsp), %rdx
movq %rdx, (%rax,%rsi)
movq 0x10(%r13), %rdx
imulq $0x28, %rcx, %rdi
movl -0x28(%rdx,%rdi), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movq %rdi, 0x8(%rax,%rsi)
movq 0x18(%rsp), %rax
cmpq %rax, 0x28(%rsp)
jne 0x135a0b
leaq (%rax,%rax), %rbx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rsi
movq %r14, %rdi
callq 0x2370
movq 0x10(%rsp), %r8
movq %rax, %r14
movq (%r13), %rcx
movq 0x10(%r13), %rdx
movq %rbx, 0x18(%rsp)
movq 0x20(%rsp), %rsi
incq %rbp
imulq $0x28, %rcx, %rax
movl -0x28(%rdx,%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
orq %rcx, %rax
movq 0x28(%rsp), %rcx
movq %rax, (%r14,%rcx,8)
incq %rcx
movq %rcx, 0x28(%rsp)
jmp 0x135a56
movq 0x30(%rsp), %r14
jmp 0x135a56
movq 0x30(%rsp), %r14
movq 0x10(%rsp), %r8
movq 0x20(%rsp), %rsi
testq %rbp, %rbp
je 0x135b47
movq 0x18(%rsp), %rax
cmpq %rax, 0x28(%rsp)
jne 0x135a96
leaq (%rax,%rax), %rbx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rsi
movq %r14, %rdi
callq 0x2370
movq 0x10(%rsp), %r8
movq %rax, %r14
movq %rbx, 0x18(%rsp)
movq 0x10(%r13), %rax
movq (%r8), %rcx
movq 0x38(%rsp), %rbx
imulq $0x28, (%rcx,%rbx), %rdx
movl (%rax,%rdx), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq 0x28(%rsp), %rsi
movq %rdx, (%r14,%rsi,8)
incq %rsi
movq %rsi, 0x28(%rsp)
imulq $0x28, (%rcx,%rbx), %rdi
addq %rax, %rdi
movq 0x78(%rsp), %rax
imulq $0x18, %rax, %rdx
addq 0x40(%rsp), %rdx
movq 0x48(%rsp), %rcx
subq %rax, %rcx
callq 0x1345c9
movq 0x10(%r13), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x28, (%rcx,%rbx), %rcx
movq 0x18(%rax,%rcx), %rdi
callq 0x2220
movq 0x10(%r13), %rax
movq 0x10(%rsp), %rcx
movq (%rcx), %rcx
imulq $0x28, (%rcx,%rbx), %rcx
movq 0x20(%rax,%rcx), %rdi
callq 0x2220
movq 0x10(%rsp), %r8
movq (%r8), %rax
imulq $0x28, (%rax,%rbx), %rax
movq 0x10(%r13), %rcx
andq $0x0, 0x20(%rcx,%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
incq 0x68(%rsp)
movq 0x20(%rsp), %rsi
movq %rsi, %rbx
incq %rsi
jmp 0x1356ef
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %r8
leaq 0x10(%rdi), %rax
movq %r8, %rcx
movq 0x60(%rsp), %r9
movq 0x68(%rsp), %rdx
subq $0x1, %rcx
jb 0x135b7c
subq %rdx, (%rax)
addq $0x18, %rax
jmp 0x135b6d
movq %r14, 0x30(%rsp)
movq 0x50(%rsp), %rax
xorl %r14d, %r14d
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r12d, %r12d
movq (%r13), %rcx
cmpq %rcx, %r12
jae 0x135c52
movq 0x10(%r13), %rcx
cmpq $0x0, 0x18(%rcx,%r15)
je 0x135c39
cmpq %r9, %r12
jae 0x135c14
cmpq %rax, %r8
jne 0x135bee
leaq (%rax,%rax), %r13
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %r13
imulq $0x18, %r13, %rsi
movq %r8, %rbp
callq 0x2370
movq %rbp, %r8
movq 0x60(%rsp), %r9
movq %rax, %rdi
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rcx
movq %r13, %rax
movq 0x58(%rsp), %r13
imulq $0x18, %r8, %rdx
movq %r14, %rsi
orq %rbx, %rsi
movq %rsi, 0x10(%rdi,%rdx)
andq $0x0, (%rdi,%rdx)
incq %r8
movl (%rcx,%r15), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rsi, 0x8(%rdi,%rdx)
imulq $0x28, %rbx, %rdx
movq 0x20(%rcx,%r15), %rsi
movq %rsi, 0x20(%rcx,%rdx)
movups (%rcx,%r15), %xmm0
movups 0x10(%rcx,%r15), %xmm1
movups %xmm1, 0x10(%rcx,%rdx)
movups %xmm0, (%rcx,%rdx)
incq %rbx
incq %r12
addq $0x28, %r15
movabsq $0x100000000, %rcx      # imm = 0x100000000
addq %rcx, %r14
jmp 0x135b91
movq %r8, 0x48(%rsp)
movq %rax, 0x50(%rsp)
movq %rdi, 0x40(%rsp)
cmpq %rcx, %rbx
jae 0x135c99
imulq $0x28, %rbx, %rax
xorps %xmm0, %xmm0
movq %rbx, %rdx
cmpq %rcx, %rdx
jae 0x135c95
movq 0x10(%r13), %rcx
movups %xmm0, 0x10(%rcx,%rax)
andq $0x0, 0x20(%rcx,%rax)
movups %xmm0, (%rcx,%rax)
incq %rdx
movq (%r13), %rcx
addq $0x28, %rax
jmp 0x135c70
movq %rbx, (%r13)
imulq $0x18, %r8, %rsi
addq %rdi, %rsi
movq %r8, 0x68(%rsp)
movq %rdi, 0x60(%rsp)
callq 0x1304b6
movq (%r13), %rdi
pushq $0x8
popq %rsi
callq 0x2120
movq %rax, 0x18(%rsp)
callq 0x68f5d
movq %rax, %r15
movq 0x18(%r13), %rax
movl 0x4(%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, (%r15)
movl $0x80000000, %ecx       # imm = 0x80000000
andl 0x4(%r15), %ecx
orl %eax, %ecx
movl %ecx, 0x4(%r15)
imulq $0x18, %rax, %rbx
movq %rbx, %rdi
callq 0x2280
movq %rax, 0x8(%r15)
movq 0x18(%r13), %rcx
movq 0x8(%rcx), %rsi
movq %rax, %rdi
movq %rbx, %rdx
callq 0x2160
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq -0x8(%rsi), %rax
movq %rax, 0xa8(%rsp)
leaq 0x10(%rsi), %rax
movq %rax, 0xa0(%rsp)
pushq $0x1
popq %rbx
xorl %r12d, %r12d
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %r15, 0x10(%rsp)
cmpq %rdx, %rbx
ja 0x135f62
jne 0x135d51
imulq $0x18, %r12, %rax
movq 0x10(%rsi,%rax), %rcx
jmp 0x135d70
imulq $0x18, %rbx, %rax
imulq $0x18, %r12, %rcx
movq 0x10(%rsi,%rcx), %rcx
movq 0x10(%rsi,%rax), %rax
xorq %rcx, %rax
shrq $0x20, %rax
je 0x135f5a
movq %rcx, %rdx
imulq $0x18, %r12, %r14
leaq (%rsi,%r14), %rax
addq $0x10, %rax
movq %rax, 0x78(%rsp)
shrq $0x20, %rdx
movq %r12, %rax
shlq $0x20, %rax
movq %rbx, %rcx
subq %r12, %rcx
orq %rax, %rcx
movq 0x18(%rsp), %rax
movq %rdx, 0x38(%rsp)
movq %rcx, (%rax,%rdx,8)
addq 0xa0(%rsp), %r14
movq %rbx, 0x20(%rsp)
cmpq %rbx, %r12
jae 0x135f1c
movq (%r14), %rsi
movl %esi, %eax
movq 0x10(%r13), %rcx
imulq $0x28, %rax, %rax
movl (%rcx,%rax), %edx
andl %ebp, %edx
movq %r15, %rdi
xorl %ecx, %ecx
callq 0x69316
movq 0x18(%r13), %rax
movq 0x20(%rax), %rax
movq 0x38(%rsp), %rcx
movb 0x4(%rax,%rcx,8), %cl
movq 0x20(%r15), %rdx
movl (%r14), %eax
movb %cl, 0x4(%rdx,%rax,8)
incq %r12
cmpq %rbx, %r12
jae 0x135f13
movq 0x10(%r13), %rcx
imulq $0x28, %rax, %rax
movq 0x18(%rcx,%rax), %rdx
movl 0x10(%rcx,%rax), %eax
decl %eax
movq (%rdx,%rax,8), %r15
shrq $0x20, %r15
movl 0x18(%r14), %eax
imulq $0x28, %rax, %rax
movq 0x18(%rcx,%rax), %rax
movq (%rax), %rbx
shrq $0x20, %rbx
movq 0x70(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x134c8f
movq %rax, %r13
movq 0x10(%rsp), %rdi
callq 0x13611d
movq (%r14), %rcx
movl %ecx, %edx
movl 0x18(%r14), %esi
movl 0xc(%r13), %edi
movq 0x58(%rsp), %r13
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andq %r8, %rdi
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
movl %edi, 0xc(%rax)
shlq $0x21, %rcx
movq 0x10(%r13), %r8
imulq $0x28, %rdx, %rdx
movl (%r8,%rdx), %edx
andq %r9, %rdx
subq %rdi, %rdx
orq %rcx, %rdx
movq %rdx, (%rax)
addl %esi, %esi
movl %esi, 0x8(%rax)
xorq $0x1, %rbx
xorq $0x1, %r15
movq %rbp, %rdi
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
movq %rbx, %rsi
movq %r15, %rdx
movq 0x10(%rsp), %r15
xorl %ecx, %ecx
callq 0x134c8f
movq %rax, %rbx
movq %r15, %rdi
callq 0x13611d
movq 0x18(%r14), %rcx
movl %ecx, %edx
movl (%r14), %esi
movl 0xc(%rbx), %edi
movq 0x20(%rsp), %rbx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andq %r9, %rdi
movl %edi, 0xc(%rax)
shlq $0x21, %rcx
movq 0x10(%r13), %r8
imulq $0x28, %rdx, %rdx
movl (%r8,%rdx), %edx
andq %r9, %rdx
subq %rdi, %rdx
movabsq $0x100000000, %rdi      # imm = 0x100000000
orq %rdi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
leal 0x1(,%rsi,2), %ecx
movl %ecx, 0x8(%rax)
addq $0x18, %r14
jmp 0x135db3
movq 0x18(%r13), %rdi
movq 0x8(%r15), %rsi
imulq $0x18, %rbx, %rax
movq 0xa8(%rsp), %rcx
movl (%rcx,%rax), %ecx
addl %ecx, %ecx
movq 0x78(%rsp), %rax
movl (%rax), %r8d
addl %r8d, %r8d
incq %r8
movq 0x38(%rsp), %rdx
callq 0x134ce5
movq %rbx, %r12
movq 0x68(%rsp), %rdx
movq 0x60(%rsp), %rsi
incq %rbx
jmp 0x135d3b
movq %r15, %rdi
callq 0x694eb
movq 0x18(%r13), %rdi
callq 0x68f68
movq %r15, 0x18(%r13)
xorl %r15d, %r15d
leaq 0x40(%rsp), %rbx
leaq 0xb0(%rsp), %r14
xorl %r12d, %r12d
movq 0x90(%rsp), %rax
movq 0x10(%rax), %rdi
cmpq (%rax), %r12
jae 0x135fbf
addq %r15, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rdx
movq %r14, %rcx
movq 0x88(%rsp), %r8
callq 0x135087
incq %r12
addq $0x30, %r15
jmp 0x135f8a
callq 0x2220
movq 0x90(%rsp), %rbx
movq 0x28(%rbx), %rdi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
andq $0x0, 0x28(%rbx)
movq 0x88(%rsp), %rdi
movq 0x10(%rdi), %rax
movq %rax, 0x10(%rbx)
movups (%rdi), %xmm0
movups %xmm0, (%rbx)
callq 0x2220
movq %rbx, %rdi
movq %r13, %rsi
movq 0x70(%rsp), %rdx
callq 0x885ac
movq (%r13), %rax
pushq $0x1
popq %rbx
pushq $0x1
popq %rdx
movl %edx, %esi
movl %ebx, %ecx
shll %cl, %esi
movslq %esi, %rcx
incq %rbx
cmpq %rcx, %rax
ja 0x136016
leaq -0x1(%rbx), %r14
xorl %ebp, %ebp
xorl %r13d, %r13d
xorl %r12d, %r12d
movq 0x98(%rsp), %rdi
cmpq (%rdi), %r12
jae 0x136088
movq %r12, %rsi
movq %rdi, %r15
movq 0x18(%rsp), %rdx
leaq 0x40(%rsp), %rcx
movq %r14, %r8
callq 0x13537e
testl %eax, %eax
je 0x13607c
movq 0x10(%r15), %rax
movq %r13, %rcx
shlq $0x5, %rcx
movups (%rax,%rbp), %xmm0
movups 0x10(%rax,%rbp), %xmm1
movups %xmm1, 0x10(%rax,%rcx)
movups %xmm0, (%rax,%rcx)
incq %r13
movq %r15, %rdi
incq %r12
addq $0x20, %rbp
jmp 0x13603b
pushq $-0x1
popq %r15
movl %ebx, %ecx
shrq %cl, %r15
movq %r13, (%rdi)
xorl %esi, %esi
movq %rdi, %rbx
callq 0xf6869
movq %r14, 0x48(%rbx)
movq %r15, 0x50(%rbx)
movq 0x28(%rbx), %rdi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
andq $0x0, 0x28(%rbx)
movq 0x40(%rbx), %rdi
callq 0x2220
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
andq $0x0, 0x40(%rbx)
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0x135561
movq 0x40(%rsp), %rdi
callq 0x2220
movq 0xc0(%rsp), %rdi
callq 0x2220
movq 0x18(%rsp), %rdi
callq 0x2220
movq %rbx, %rdi
callq 0x2220
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq