// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/hic.cpp
// Function: trio_phasing_refine(ma_ug_t*, asg_t*, kv_u_trans_t*, ug_opt_t*)
void trio_phasing_refine(ma_ug_t *iug, asg_t* sg, kv_u_trans_t *ref, ug_opt_t *opt)
{
    ma_ug_t *ug = copy_untig_graph(iug); uint8_t *bf = NULL; 
    uint64_t ug_n0 = ug->g->n_seq, k, i, ul, cis_n, trans_n, w_n, tot_hap, tot_r, frid, mrid, flag; 
    kv_u_trans_t in; memset(&in, 0, sizeof(in)); ma_utg_t *p; u_trans_t *z; int64_t fh, mh;
    bubble_type *bub = gen_bubble_chain(sg, ug, opt, &bf, 0); free(bf);
    clean_u_trans_t_idx_filter_adv(ref, ug, sg, 0.95, 0);
    
    ///update ug itself
    ul = FATHER; frid = ug->g->n_seq; asg_seq_set(ug->g, frid, ul, 0); 
    kv_pushp(ma_utg_t, ug->u, &p); memset(p, 0, sizeof((*p)));
    p->s = 0; p->start = UINT32_MAX; p->end = UINT32_MAX; p->len = ul, p->n = p->m = 1; p->circ = 1;
    kv_roundup32(p->m); p->a = (uint64_t*)malloc(8 * p->m); 
    p->a[0] = UINT32_MAX; p->a[0] <<= 32; p->a[0] |= ul;
    
    ul = MOTHER; mrid = ug->g->n_seq; asg_seq_set(ug->g, mrid, ul, 0); 
    kv_pushp(ma_utg_t, ug->u, &p); memset(p, 0, sizeof((*p)));
    p->s = 0; p->start = UINT32_MAX; p->end = UINT32_MAX; p->len = ul, p->n = p->m = 1; p->circ = 1;
    kv_roundup32(p->m); p->a = (uint64_t*)malloc(8 * p->m); 
    p->a[0] = UINT32_MAX; p->a[0] <<= 32; p->a[0] |= ul;

    free(ug->g->idx); ug->g->idx = 0; ug->g->is_srt = 0; asg_cleanup(ug->g);

    ///update bubble
    REALLOC(bub->index, ug->g->n_seq);
    for (k = ug_n0; k < ug->g->n_seq; k++) bub->index[k] = bub->f_bub+1;
    
    bub->b_s_idx.n = ug->g->n_seq; kv_resize(uint64_t, bub->b_s_idx, ug->g->n_seq);
    for (k = ug_n0; k < bub->b_s_idx.m; k++) bub->b_s_idx.a[k] = (uint64_t)-1;

    ///check if a node has haplotype markers
    CALLOC(bf, ug->g->n_seq);
    for (k = cis_n = tot_hap = tot_r = 0; k < ug_n0; k++) {
        if(ug->g->seq[k].del) continue;
        p = &(ug->u.a[k]); tot_r += p->n;
        if(p->n == 0 || p->m == 0) continue;
        for (i = fh = mh = 0; i < p->n; i++) {
            if(R_INF.trio_flag[p->a[i]>>33] == FATHER) {
                tot_hap++; fh = 1;
            } else if(R_INF.trio_flag[p->a[i]>>33] == MOTHER) {
                tot_hap++; mh = 1;
            }
            if((R_INF.trio_flag[p->a[i]>>33] == FATHER) || (R_INF.trio_flag[p->a[i]>>33] == MOTHER)) {
                tot_hap++; bf[k] = 1; 
            }
        }
        if(fh > 0) {
            bf[k] = 1; cis_n+=2;
        }
        if(mh > 0) {
            bf[k] = 1; cis_n+=2;
        }
    }
    for (; k < ug->g->n_seq; k++) bf[k] = 1;///for father/mother nodes
    

    ///update trans overlaps
    kv_pushp(u_trans_t, *ref, &z); memset(z, 0, sizeof((*z)));
    z->f = RC_2; z->nw = (DBL_MAX/2); z->rev = 0;
    z->qn = ug_n0; z->tn = ug_n0+1; z->del = 0;
    z->qs = 0; z->qe = ug->g->seq[z->qn].len;
    z->ts = 0; z->te = ug->g->seq[z->tn].len;

    kv_pushp(u_trans_t, *ref, &z); memset(z, 0, sizeof((*z)));
    z->f = RC_2; z->nw = (DBL_MAX/2); z->rev = 0;
    z->qn = ug_n0+1; z->tn = ug_n0; z->del = 0;
    z->qs = 0; z->qe = ug->g->seq[z->qn].len;
    z->ts = 0; z->te = ug->g->seq[z->tn].len;

    kt_u_trans_t_idx(ref, ug->g->n_seq);
    // clean_u_trans_t_idx_adv(ref, ug, sg);
    // clean_u_trans_t_idx_filter_adv(ref, ug, sg);

    ///gen all links
    for (k = trans_n = 0; k < ref->n; k++) {
        if(ref->a[k].del) continue;
        if((IF_HOM(ref->a[k].qn, (*bub))) || (IF_HOM(ref->a[k].tn, (*bub)))) continue;
        ///disable bf
        // if((!bf[ref->a[k].qn]) || (!bf[ref->a[k].tn])) continue;
        trans_n++;
    }
    kv_resize(u_trans_t, in, (trans_n+cis_n)); 

    for (k = in.n = 0; k < ref->n; k++) {
        if(ref->a[k].del) continue;
        if((IF_HOM(ref->a[k].qn, (*bub))) || (IF_HOM(ref->a[k].tn, (*bub)))) continue;
        ///disable bf
        // if((!bf[ref->a[k].qn]) || (!bf[ref->a[k].tn])) continue;

        kv_pushp(u_trans_t, in, &z); memset(z, 0, sizeof((*z))); w_n = 0;
        if((ref->a[k].qn < ug_n0) && (ref->a[k].tn < ug_n0)) {
            w_n += ug_occ_hap_w(ref->a[k].qs, ref->a[k].qe, &(ug->u.a[ref->a[k].qn])) + 
            ug_occ_hap_w(ref->a[k].ts, ref->a[k].te, &(ug->u.a[ref->a[k].tn]));
            w_n += ug_occ_w(ref->a[k].qs, ref->a[k].qe, &(ug->u.a[ref->a[k].qn])) + 
            ug_occ_w(ref->a[k].ts, ref->a[k].te, &(ug->u.a[ref->a[k].tn]));
        } else {
            w_n += tot_hap + tot_r;
        }
        w_n >>= 1;///wn/4
        (*z) = ref->a[k]; z->nw = ((w_n)?(w_n):(1));
    }

    for (k = 0; k < ug_n0; k++) {
        if(!bf[k]) continue;
        p = &(ug->u.a[k]);
        if(p->n == 0 || p->m == 0) continue;
        fh = mh = 0;
        for (i = 0; i < p->n; i++) {
            if(R_INF.trio_flag[p->a[i]>>33] == FATHER) fh--;
            if(R_INF.trio_flag[p->a[i]>>33] == MOTHER) mh--;
        }
        if(fh != 0) {
            w_n = frid;

            kv_pushp(u_trans_t, in, &z); memset(z, 0, sizeof((*z)));
            z->f = RC_2; z->nw = fh; z->rev = 0;
            z->qn = w_n; z->tn = k; z->del = 0;
            z->qs = 0; z->qe = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);
            z->ts = 0; z->te = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);

            kv_pushp(u_trans_t, in, &z); memset(z, 0, sizeof((*z)));
            z->f = RC_2; z->nw = fh; z->rev = 0;
            z->qn = k; z->tn = w_n; z->del = 0;
            z->qs = 0; z->qe = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);
            z->ts = 0; z->te = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);
        }

        if(mh != 0) {
            w_n = mrid;

            kv_pushp(u_trans_t, in, &z); memset(z, 0, sizeof((*z)));
            z->f = RC_2; z->nw = mh; z->rev = 0;
            z->qn = w_n; z->tn = k; z->del = 0;
            z->qs = 0; z->qe = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);
            z->ts = 0; z->te = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);

            kv_pushp(u_trans_t, in, &z); memset(z, 0, sizeof((*z)));
            z->f = RC_2; z->nw = mh; z->rev = 0;
            z->qn = k; z->tn = w_n; z->del = 0;
            z->qs = 0; z->qe = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);
            z->ts = 0; z->te = MIN(ug->g->seq[z->qn].len, ug->g->seq[z->tn].len);
        }
    }
    free(bf);
    assert(in.n == (trans_n+cis_n));
    kt_u_trans_t_idx(&in, ug->g->n_seq);
    // clean_u_trans_t_idx_adv(&in, ug, sg);

    ps_t *s = init_ps_t(11, ug->g->n_seq); s->s[frid] = 1; s->s[mrid] = -1; 
    mc_solve(NULL, NULL, &in, ug, sg, 0.8, NULL, 0, s->s, 1, bub, ref, 0, 0);
    // fprintf(stderr, "[M::%s::] s[frid]::%d, s->s[mrid]::%d\n", __func__, s->s[frid], s->s[mrid]);
    if((s->s[frid] != 0) && (s->s[mrid] != 0) && (s->s[frid] != s->s[mrid])) {
        memset(R_INF.trio_flag, AMBIGU, R_INF.total_reads * sizeof(uint8_t));
        for (i = 0; i < ug_n0; i++) {
            if(ug->g->seq[i].del) continue;
            flag = AMBIGU;
            if(s->s[i] == 0) continue;
            flag = (s->s[i] == s->s[frid]? FATHER:MOTHER);
            p = &ug->u.a[i];
            if(p->m == 0) continue;
            for (k = 0; k < p->n; k++) R_INF.trio_flag[p->a[k]>>33] = flag;
        }
    }

    destory_bubbles(bub); free(bub); ma_ug_destroy(ug);
    destory_ps_t(&s); kv_destroy(in); kv_destroy(in.idx);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, %r14
movq %rdx, %rbx
movq %rsi, %r12
callq 0x8c99a
leaq 0x50(%rsp), %r15
andq $0x0, (%r15)
movq %rax, %r13
movq 0x18(%rax), %rax
movl 0x14(%rax), %ebp
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x1afe25
movq %rax, 0x40(%rsp)
movq (%r15), %rdi
callq 0x2220
movsd 0xc4f03(%rip), %xmm0    # 0x1e34e8
movq %rbx, 0x60(%rsp)
movq %rbx, %rdi
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq %r13, %rsi
movq %r12, 0xc0(%rsp)
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x8922a
movq 0x18(%r13), %rdi
movl 0x14(%rdi), %esi
andq %rbx, %rsi
pushq $0x1
popq %rdx
movq %rsi, 0xa8(%rsp)
xorl %ecx, %ecx
callq 0x69316
movq (%r13), %rax
pushq $0x2
popq %rdx
cmpq 0x8(%r13), %rax
jne 0x11e659
leaq (%rax,%rax), %rcx
testq %rax, %rax
cmoveq %rdx, %rcx
movq %rcx, 0x8(%r13)
movq 0x10(%r13), %rdi
imulq $0x28, %rcx, %rsi
callq 0x2370
movq %rax, %r15
movq %rax, 0x10(%r13)
movq (%r13), %rax
jmp 0x11e65d
movq 0x10(%r13), %r15
andq %rbx, %rbp
movabsq $-0xffffffff, %rbx      # imm = 0xFFFFFFFF00000001
leaq 0x1(%rax), %rcx
movq %rcx, (%r13)
imulq $0x28, %rax, %r14
xorps %xmm0, %xmm0
andq $0x0, 0x20(%r15,%r14)
movups %xmm0, 0x10(%r15,%r14)
movl $0x1, 0x10(%r15,%r14)
movaps 0xcea5b(%rip), %xmm0    # 0x1ed0f0
movups %xmm0, (%r15,%r14)
pushq $0x8
popq %rdi
callq 0x2280
movq %rax, 0x18(%r15,%r14)
movq %rbx, (%rax)
movq 0x18(%r13), %rdi
movl 0x14(%rdi), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
movq %rsi, 0xb8(%rsp)
pushq $0x2
popq %rdx
xorl %ecx, %ecx
callq 0x69316
movq (%r13), %rax
movq 0x10(%r13), %r15
cmpq 0x8(%r13), %rax
jne 0x11e700
leaq (%rax,%rax), %rcx
testq %rax, %rax
pushq $0x2
popq %rax
cmoveq %rax, %rcx
movq %rcx, 0x8(%r13)
imulq $0x28, %rcx, %rsi
movq %r15, %rdi
callq 0x2370
movq %rax, %r15
movq %rax, 0x10(%r13)
movq (%r13), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r13)
imulq $0x28, %rax, %r14
andq $0x0, 0x20(%r15,%r14)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r15,%r14)
movl $0x1, 0x10(%r15,%r14)
movapd 0xce9d4(%rip), %xmm0    # 0x1ed100
movupd %xmm0, (%r15,%r14)
pushq $0x8
popq %rdi
callq 0x2280
movq %rax, 0x18(%r15,%r14)
incq %rbx
movq %rbx, (%rax)
movq 0x18(%r13), %rax
movq 0x28(%rax), %rdi
callq 0x2220
movq 0x18(%r13), %rax
andq $0x0, 0x28(%rax)
andb $0x7f, 0x7(%rax)
movq 0x18(%r13), %rdi
callq 0x694eb
movq 0x40(%rsp), %rbx
movq (%rbx), %rdi
movq 0x18(%r13), %rax
movl 0x14(%rax), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x2, %rsi
callq 0x2370
movq %rbx, %rdi
movq %rax, (%rbx)
movq 0x18(%r13), %rcx
movq %rbp, %rdx
movl 0x14(%rcx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
cmpq %rsi, %rdx
jae 0x11e7b1
movl 0x80(%rdi), %esi
incl %esi
movl %esi, (%rax,%rdx,4)
incq %rdx
jmp 0x11e793
movq %rsi, 0x60(%rdi)
movl 0x14(%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpq %rax, 0x68(%rdi)
jae 0x11e819
decq %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x10, %rcx
orq %rax, %rcx
leaq 0x1(%rcx), %rax
movq %rax, 0x68(%rdi)
movq 0x70(%rdi), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq 0x40(%rsp), %rdi
movq %rax, 0x70(%rdi)
movq %rbp, %rax
cmpq 0x68(%rdi), %rax
jae 0x11e830
movq 0x70(%rdi), %rcx
orq $-0x1, (%rcx,%rax,8)
incq %rax
jmp 0x11e81c
movq 0x18(%r13), %rax
movl 0x14(%rax), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
pushq $0x1
popq %r12
movq %r12, %rsi
callq 0x2120
movq %rax, 0x50(%rsp)
xorl %r14d, %r14d
leaq 0x1359d8(%rip), %r11    # 0x254230
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %eax, %eax
cmpq %rbp, %rax
je 0x11e910
movq 0x18(%r13), %rcx
movq 0x20(%rcx), %rcx
cmpl $0x0, (%rcx,%rax,8)
js 0x11e908
movq 0x10(%r13), %rcx
imulq $0x28, %rax, %rdx
movl 0x10(%rcx,%rdx), %esi
addq %rsi, %rbx
testq %rsi, %rsi
je 0x11e908
addq %rdx, %rcx
cmpl $0x0, 0xc(%rcx)
je 0x11e908
xorl %edi, %edi
xorl %r8d, %r8d
xorl %edx, %edx
movl %esi, %r9d
cmpq %r9, %rdi
jae 0x11e8e4
movq 0x28(%r11), %r9
movq 0x18(%rcx), %r10
movq (%r10,%rdi,8), %r10
shrq $0x21, %r10
movzbl (%r9,%r10), %r9d
cmpl $0x1, %r9d
je 0x11e8cc
cmpl $0x2, %r9d
jne 0x11e8df
movq %r12, %rdx
jmp 0x11e8cf
movq %r9, %r8
addq $0x2, %r15
movq 0x50(%rsp), %rsi
movb $0x1, (%rsi,%rax)
movl 0x10(%rcx), %esi
incq %rdi
jmp 0x11e89e
testq %r8, %r8
jle 0x11e8f6
movq 0x50(%rsp), %rcx
movb $0x1, (%rcx,%rax)
addq $0x2, %r14
testq %rdx, %rdx
jle 0x11e908
movq 0x50(%rsp), %rcx
movb $0x1, (%rcx,%rax)
addq $0x2, %r14
incq %rax
jmp 0x11e85f
movq %rbp, %rax
movq 0x18(%r13), %rcx
movl 0x14(%rcx), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpq %rcx, %rax
jae 0x11e933
movq 0x50(%rsp), %rcx
movb $0x1, (%rcx,%rax)
incq %rax
jmp 0x11e913
movq %rbx, 0x48(%rsp)
movq 0x60(%rsp), %rbx
movq (%rbx), %rcx
cmpq 0x8(%rbx), %rcx
movq %r13, 0x58(%rsp)
jne 0x11e973
leaq (%rcx,%rcx), %rax
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rbx), %rdi
imulq $0x30, %rax, %rsi
callq 0x2370
movq %rax, 0x10(%rbx)
movq (%rbx), %rcx
jmp 0x11e977
movq 0x10(%rbx), %rax
movq %rbx, %r13
leaq 0x1(%rcx), %rdx
movq %rdx, (%rbx)
imulq $0x30, %rcx, %rcx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
movupd %xmm0, 0x10(%rax,%rcx)
movabsq $0x7fdfffffffffffff, %rdi # imm = 0x7FDFFFFFFFFFFFFF
movq %rdi, 0x20(%rax,%rcx)
movl %ebp, 0x8(%rax,%rcx)
movl %ebp, %ebx
movq %rbp, %rsi
incl %ebp
movl %ebp, 0x14(%rax,%rcx)
movb $0x2, 0x28(%rax,%rcx)
movq 0x58(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rdx
movl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
movq %rsi, 0x68(%rsp)
movl (%rdx,%rsi,8), %esi
andl %r12d, %esi
movl %esi, 0x4(%rax,%rcx)
andl $0x0, 0xc(%rax,%rcx)
movl 0x8(%rdx,%rbx,8), %edx
andl %r12d, %edx
incq %rbx
movl %edx, 0x10(%rax,%rcx)
movq (%r13), %rcx
movq 0x10(%r13), %rax
cmpq 0x8(%r13), %rcx
jne 0x11ea34
leaq (%rcx,%rcx), %rdx
testq %rcx, %rcx
pushq $0x2
popq %rcx
cmoveq %rcx, %rdx
movq %rdx, 0x8(%r13)
imulq $0x30, %rdx, %rsi
movq %rax, %rdi
callq 0x2370
movabsq $0x7fdfffffffffffff, %rdi # imm = 0x7FDFFFFFFFFFFFFF
xorpd %xmm0, %xmm0
movq %rax, 0x10(%r13)
movq (%r13), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, (%r13)
imulq $0x30, %rcx, %rcx
movupd %xmm0, 0x20(%rax,%rcx)
movupd %xmm0, (%rax,%rcx)
movupd %xmm0, 0x10(%rax,%rcx)
movq %rdi, 0x20(%rax,%rcx)
movl %ebp, 0x8(%rax,%rcx)
movq 0x68(%rsp), %r8
movl %r8d, 0x14(%rax,%rcx)
movb $0x2, 0x28(%rax,%rcx)
movq 0x58(%rsp), %rdx
movq 0x18(%rdx), %rdx
movq 0x20(%rdx), %rsi
movl (%rsi,%rbx,8), %edi
andl %r12d, %edi
movl %edi, 0x4(%rax,%rcx)
andl $0x0, 0xc(%rax,%rcx)
movl (%rsi,%r8,8), %esi
andl %r12d, %esi
movl %esi, 0x10(%rax,%rcx)
andl 0x14(%rdx), %r12d
movq %r13, %rdi
movl %r12d, %esi
callq 0x88a31
movq (%r13), %rbx
pushq $0x28
popq %rax
xorl %r10d, %r10d
movq %rbx, %rcx
movq 0x40(%rsp), %r9
subq $0x1, %rcx
jb 0x11eaf0
movq 0x10(%r13), %rdx
cmpb $0x0, (%rdx,%rax)
js 0x11eaea
movq (%r9), %rdi
movq 0x80(%r9), %rsi
movl -0x20(%rdx,%rax), %r8d
movl (%rdi,%r8,4), %r8d
incq %rsi
cmpq %r8, %rsi
jb 0x11eaea
movl -0x14(%rdx,%rax), %edx
movl (%rdi,%rdx,4), %edx
cmpq %rdx, %rsi
sbbq $-0x1, %r10
addq $0x30, %rax
jmp 0x11eab1
addq %r14, %r10
movq %r10, 0xc8(%rsp)
je 0x11eb58
leaq -0x1(%r10), %rax
movq %rax, %rcx
shrq %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x2, %rax
orq %rcx, %rax
movq %rax, %rcx
shrq $0x4, %rcx
orq %rax, %rcx
movq %rcx, %rax
shrq $0x8, %rax
orq %rcx, %rax
movq %rax, %r14
shrq $0x10, %r14
orq %rax, %r14
incq %r14
movq %r14, 0x78(%rsp)
imulq $0x30, %r14, %rdi
callq 0x2280
movq %r14, %r11
movq 0x40(%rsp), %r9
movq %rax, %r12
movq %rax, 0x80(%rsp)
jmp 0x11eb5e
xorl %r12d, %r12d
xorl %r11d, %r11d
leaq 0x1356cb(%rip), %r10    # 0x254230
andq $0x0, 0x70(%rsp)
addq %r15, 0x48(%rsp)
xorl %r14d, %r14d
xorl %r8d, %r8d
xorl %ebp, %ebp
cmpq %rbx, %rbp
jae 0x11ed99
movq 0x10(%r13), %rax
cmpb $0x0, 0x28(%rax,%r14)
js 0x11ed8d
movq (%r9), %rdx
movq 0x80(%r9), %rcx
movl 0x8(%rax,%r14), %esi
movl (%rdx,%rsi,4), %esi
incq %rcx
cmpq %rsi, %rcx
jb 0x11ed8d
movl 0x14(%rax,%r14), %eax
movl (%rdx,%rax,4), %eax
cmpq %rax, %rcx
jb 0x11ed8d
cmpq %r11, %r8
jne 0x11ec03
leaq (%r11,%r11), %rbx
testq %r11, %r11
pushq $0x2
popq %rax
cmoveq %rax, %rbx
movq %rbx, 0x78(%rsp)
imulq $0x30, %rbx, %rsi
movq %r12, %rdi
callq 0x2370
leaq 0x135645(%rip), %r10    # 0x254230
movq 0x40(%rsp), %r9
movq %rax, %r12
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %r8
movq %rbx, %r11
imulq $0x30, %r8, %rbx
incq %r8
movq %r8, 0x70(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x20(%r12,%rbx)
movupd %xmm0, 0x10(%r12,%rbx)
movupd %xmm0, (%r12,%rbx)
movq 0x10(%r13), %r13
movl 0x8(%r13,%r14), %eax
movq 0x68(%rsp), %rcx
cmpl %ecx, %eax
jae 0x11ed44
movl 0x14(%r13,%r14), %r15d
cmpl %ecx, %r15d
jae 0x11ed44
movl (%r13,%r14), %edi
movq %rdi, 0xe0(%rsp)
movl 0x4(%r13,%r14), %esi
movq %rsi, 0xd8(%rsp)
movq 0x58(%rsp), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, 0xd0(%rsp)
imulq $0x28, %rax, %rdx
addq %rcx, %rdx
movq %rdx, 0xb0(%rsp)
movq %r11, 0xf8(%rsp)
movq %r8, 0xf0(%rsp)
callq 0x11e508
movq %rax, 0xe8(%rsp)
movl 0xc(%r13,%r14), %edi
movl 0x10(%r13,%r14), %esi
imulq $0x28, %r15, %rdx
addq 0xd0(%rsp), %rdx
callq 0x11e508
movq %rax, %r15
movq 0xe0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
movq 0xb0(%rsp), %rdx
callq 0x1b2312
movq %rax, 0xb0(%rsp)
movq 0x60(%rsp), %r13
movq 0x10(%r13), %rax
movl 0xc(%rax,%r14), %edi
movl 0x10(%rax,%r14), %esi
movl 0x14(%rax,%r14), %eax
imulq $0x28, %rax, %rdx
movq 0x58(%rsp), %rax
addq 0x10(%rax), %rdx
callq 0x1b2312
movq 0xf0(%rsp), %r8
movq 0xf8(%rsp), %r11
leaq 0x13550a(%rip), %r10    # 0x254230
movq 0x40(%rsp), %r9
addq 0xe8(%rsp), %r15
addq 0xb0(%rsp), %r15
addq %rax, %r15
movq 0x10(%r13), %r13
jmp 0x11ed49
movq 0x48(%rsp), %r15
addq %r12, %rbx
movups (%r13,%r14), %xmm0
movupd 0x10(%r13,%r14), %xmm1
movups 0x20(%r13,%r14), %xmm2
movups %xmm2, 0x20(%rbx)
movupd %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
cmpq $0x2, %r15
jae 0x11ed77
pushq $0x1
popq %r15
jmp 0x11ed7a
shrq %r15
movq 0x60(%rsp), %r13
cvtsi2sd %r15, %xmm0
movsd %xmm0, 0x20(%rbx)
movq (%r13), %rbx
incq %rbp
addq $0x30, %r14
jmp 0x11eb78
xorl %r15d, %r15d
xorpd %xmm0, %xmm0
movq 0x58(%rsp), %r13
movq 0x68(%rsp), %rbp
movq 0xb8(%rsp), %r14
movq 0x50(%rsp), %rdi
cmpq %rbp, %r15
je 0x11f18e
cmpb $0x0, (%rdi,%r15)
je 0x11f186
movq 0x10(%r13), %rdx
imulq $0x28, %r15, %rcx
movl 0x10(%rdx,%rcx), %eax
testq %rax, %rax
je 0x11f186
addq %rcx, %rdx
cmpl $0x0, 0xc(%rdx)
je 0x11f186
movq %r8, %r9
movq 0x28(%r10), %rcx
movq 0x18(%rdx), %rdx
xorl %esi, %esi
xorl %ebx, %ebx
xorl %r14d, %r14d
cmpq %rsi, %rax
je 0x11ee31
movq (%rdx,%rsi,8), %rdi
shrq $0x21, %rdi
movb (%rcx,%rdi), %dil
xorl %r8d, %r8d
cmpb $0x1, %dil
sete %r8b
subq %r8, %rbx
xorl %r8d, %r8d
cmpb $0x2, %dil
sete %r8b
subq %r8, %r14
incq %rsi
jmp 0x11edff
testq %rbx, %rbx
je 0x11efdd
cmpq %r11, %r9
jne 0x11ee72
leaq (%r11,%r11), %rax
testq %r11, %r11
pushq $0x2
popq %rcx
cmoveq %rcx, %rax
movq %rax, 0x78(%rsp)
imulq $0x30, %rax, %rsi
movq %r12, %rdi
callq 0x2370
xorpd %xmm0, %xmm0
movq %rax, %r12
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %r9
leaq 0x1(%r9), %rax
movq %rax, 0x70(%rsp)
imulq $0x30, %r9, %rax
movupd %xmm0, 0x20(%r12,%rax)
movupd %xmm0, (%r12,%rax)
movupd %xmm0, 0x10(%r12,%rax)
cvtsi2sd %rbx, %xmm1
movsd %xmm1, 0x20(%r12,%rax)
movq 0xa8(%rsp), %rdi
movl %edi, 0x8(%r12,%rax)
movl %r15d, 0x14(%r12,%rax)
movb $0x2, 0x28(%r12,%rax)
movq 0x18(%r13), %rcx
movq 0x20(%rcx), %rcx
movl (%rcx,%rdi,8), %edx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %edx
movl (%rcx,%r15,8), %esi
andl %r8d, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
movl %esi, 0x4(%r12,%rax)
andl $0x0, 0xc(%r12,%rax)
movl (%rcx,%rdi,8), %edx
andl %r8d, %edx
movl (%rcx,%r15,8), %ecx
andl %r8d, %ecx
cmpl %ecx, %edx
cmovbl %edx, %ecx
movl %ecx, 0x10(%r12,%rax)
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r11
movq 0x80(%rsp), %r12
cmpq %r11, %rbx
jne 0x11ef52
leaq (%rbx,%rbx), %rbp
testq %rbx, %rbx
pushq $0x2
popq %rax
cmoveq %rax, %rbp
movq %rbp, 0x78(%rsp)
imulq $0x30, %rbp, %rsi
movq %r12, %rdi
movsd %xmm1, 0x48(%rsp)
callq 0x2370
movsd 0x48(%rsp), %xmm1
xorpd %xmm0, %xmm0
movq %rbp, %r11
movq 0x68(%rsp), %rbp
movq %rax, %r12
movq %rax, 0x80(%rsp)
leaq 0x1352d7(%rip), %r10    # 0x254230
leaq 0x1(%rbx), %r8
movq %r8, 0x70(%rsp)
imulq $0x30, %rbx, %rax
movupd %xmm0, 0x20(%r12,%rax)
movupd %xmm0, (%r12,%rax)
movupd %xmm0, 0x10(%r12,%rax)
movsd %xmm1, 0x20(%r12,%rax)
movl %r15d, 0x8(%r12,%rax)
movq 0xa8(%rsp), %rdi
movl %edi, 0x14(%r12,%rax)
movb $0x2, 0x28(%r12,%rax)
movq 0x18(%r13), %rcx
movq 0x20(%rcx), %rcx
movl (%rcx,%r15,8), %edx
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andl %r9d, %edx
movl (%rcx,%rdi,8), %esi
andl %r9d, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
movl %esi, 0x4(%r12,%rax)
andl $0x0, 0xc(%r12,%rax)
movl (%rcx,%r15,8), %edx
andl %r9d, %edx
movl (%rcx,%rdi,8), %ecx
andl %r9d, %ecx
cmpl %ecx, %edx
cmovbl %edx, %ecx
movl %ecx, 0x10(%r12,%rax)
jmp 0x11efe0
movq %r9, %r8
testq %r14, %r14
je 0x11f17e
cmpq %r11, %r8
jne 0x11f021
leaq (%r11,%r11), %rax
testq %r11, %r11
pushq $0x2
popq %rcx
cmoveq %rcx, %rax
movq %rax, 0x78(%rsp)
imulq $0x30, %rax, %rsi
movq %r12, %rdi
callq 0x2370
xorpd %xmm0, %xmm0
movq %rax, %r12
movq %rax, 0x80(%rsp)
movq 0x70(%rsp), %r8
leaq 0x1(%r8), %rax
movq %rax, 0x70(%rsp)
imulq $0x30, %r8, %rax
movupd %xmm0, 0x20(%r12,%rax)
movupd %xmm0, (%r12,%rax)
movupd %xmm0, 0x10(%r12,%rax)
cvtsi2sd %r14, %xmm1
movsd %xmm1, 0x20(%r12,%rax)
movq 0xb8(%rsp), %r14
movl %r14d, 0x8(%r12,%rax)
movl %r15d, 0x14(%r12,%rax)
movb $0x2, 0x28(%r12,%rax)
movq 0x18(%r13), %rcx
movq 0x20(%rcx), %rcx
movl (%rcx,%r14,8), %edx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %edx
movl (%rcx,%r15,8), %esi
andl %edi, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
movl %esi, 0x4(%r12,%rax)
andl $0x0, 0xc(%r12,%rax)
movl (%rcx,%r14,8), %edx
andl %edi, %edx
movl (%rcx,%r15,8), %ecx
andl %edi, %ecx
cmpl %ecx, %edx
cmovbl %edx, %ecx
movl %ecx, 0x10(%r12,%rax)
movq 0x70(%rsp), %rbx
movq 0x78(%rsp), %r11
movq 0x80(%rsp), %r12
cmpq %r11, %rbx
jne 0x11f0fe
leaq (%rbx,%rbx), %rbp
testq %rbx, %rbx
pushq $0x2
popq %rax
cmoveq %rax, %rbp
movq %rbp, 0x78(%rsp)
imulq $0x30, %rbp, %rsi
movq %r12, %rdi
movsd %xmm1, 0x48(%rsp)
callq 0x2370
movsd 0x48(%rsp), %xmm1
xorpd %xmm0, %xmm0
movq %rbp, %r11
movq 0x68(%rsp), %rbp
movq %rax, %r12
movq %rax, 0x80(%rsp)
leaq 0x13512b(%rip), %r10    # 0x254230
leaq 0x1(%rbx), %r8
movq %r8, 0x70(%rsp)
imulq $0x30, %rbx, %rax
movupd %xmm0, 0x20(%r12,%rax)
movupd %xmm0, (%r12,%rax)
movupd %xmm0, 0x10(%r12,%rax)
movsd %xmm1, 0x20(%r12,%rax)
movl %r15d, 0x8(%r12,%rax)
movl %r14d, 0x14(%r12,%rax)
movb $0x2, 0x28(%r12,%rax)
movq 0x18(%r13), %rcx
movq 0x20(%rcx), %rcx
movl (%rcx,%r15,8), %edx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %edx
movl (%rcx,%r14,8), %esi
andl %edi, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
movl %esi, 0x4(%r12,%rax)
andl $0x0, 0xc(%r12,%rax)
movl (%rcx,%r15,8), %edx
andl %edi, %edx
movl (%rcx,%r14,8), %ecx
andl %edi, %ecx
cmpl %ecx, %edx
cmovbl %edx, %ecx
movl %ecx, 0x10(%r12,%rax)
jmp 0x11f186
movq 0xb8(%rsp), %r14
incq %r15
jmp 0x11edb2
movq %r8, %rbx
callq 0x2220
cmpq 0xc8(%rsp), %rbx
jne 0x11f34b
movq 0x18(%r13), %rax
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl 0x14(%rax), %esi
leaq 0x70(%rsp), %r15
movq %r15, %rdi
callq 0x88a31
movq 0x18(%r13), %rax
movl 0x14(%rax), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
pushq $0xb
popq %rdi
callq 0x1193f3
movq %rax, %r12
movq %rax, 0x100(%rsp)
movq (%rax), %rax
movq 0xa8(%rsp), %rbx
movb $0x1, (%rax,%rbx)
movq (%r12), %rax
movb $-0x1, (%rax,%r14)
movq (%r12), %rax
movq 0x60(%rsp), %rcx
movq %rcx, 0x20(%rsp)
movq 0x40(%rsp), %rcx
movq %rcx, 0x18(%rsp)
andl $0x0, 0x30(%rsp)
movq %rax, 0x8(%rsp)
andl $0x0, 0x28(%rsp)
movl $0x1, 0x10(%rsp)
andl $0x0, (%rsp)
movsd 0xc42d0(%rip), %xmm0    # 0x1e3500
xorl %edi, %edi
xorl %esi, %esi
movq %r15, %rdx
movq %r13, %rcx
movq 0xc0(%rsp), %r8
xorl %r9d, %r9d
callq 0x12b808
movq (%r12), %rcx
movb (%rcx,%rbx), %al
testb %al, %al
leaq 0x134fd6(%rip), %rdx    # 0x254230
je 0x11f2f5
movb (%rcx,%r14), %cl
testb %cl, %cl
je 0x11f2f5
cmpb %cl, %al
je 0x11f2f5
movq 0x28(%rdx), %rdi
movq 0x50(%rdx), %rdx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x20e0
leaq 0x134fa4(%rip), %r8     # 0x254230
cmpq %rbp, %rbx
je 0x11f2f5
movq 0x18(%r13), %rax
movq 0x20(%rax), %rax
cmpl $0x0, (%rax,%rbx,8)
js 0x11f2f0
movq (%r12), %rcx
movb (%rcx,%rbx), %dl
testb %dl, %dl
je 0x11f2f0
movq 0x10(%r13), %rax
imulq $0x28, %rbx, %rsi
cmpl $0x0, 0xc(%rax,%rsi)
je 0x11f2f0
addq %rsi, %rax
movq 0xa8(%rsp), %rsi
cmpb (%rcx,%rsi), %dl
sete %dl
movb $0x2, %cl
subb %dl, %cl
xorl %edx, %edx
movl 0x10(%rax), %esi
cmpq %rsi, %rdx
jae 0x11f2f0
movq 0x28(%r8), %rsi
movq 0x18(%rax), %rdi
movq (%rdi,%rdx,8), %rdi
shrq $0x21, %rdi
movb %cl, (%rsi,%rdi)
incq %rdx
jmp 0x11f2d0
incq %rbx
jmp 0x11f28c
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0xf6a60
movq %rbx, %rdi
callq 0x2220
movq %r13, %rdi
callq 0x6921d
leaq 0x100(%rsp), %rdi
callq 0x11943a
movq 0x80(%rsp), %rdi
callq 0x2220
movq 0x98(%rsp), %rdi
callq 0x2220
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xcf714(%rip), %rdi     # 0x1eea66
leaq 0xcf623(%rip), %rsi     # 0x1ee97c
leaq 0xcf71e(%rip), %rcx     # 0x1eea7e
movl $0x45dd, %edx           # imm = 0x45DD
callq 0x2110