// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/Overlaps.cpp
// Function: gen_double_scaffold_gfa(ma_ug_t*, ma_ug_t*, ma_ug_t*, scaf_res_t*, scaf_res_t*, asg_t*, kv_u_trans_t*, long, kvect_sec_t**, kvect_sec_t**)
void gen_double_scaffold_gfa(ma_ug_t *ref, ma_ug_t *hu1, ma_ug_t *hu2, scaf_res_t *cp1, scaf_res_t *cp2, asg_t *sg, kv_u_trans_t *os, int64_t minNs, kvect_sec_t **sc1, kvect_sec_t **sc2)
{
    order_contig_trans(os);
    asg_t *g = asg_init(); uint64_t k, s, e, z, rn, pn, dn, rthres = asm_opt.self_scaf_reliable_min, el, glen; ma_utg_t *u, *ut; u_trans_t *p, *d, *r; 
    asg_arc_t t, *c; int64_t zs, ze, gl, gmin = -asm_opt.self_scaf_gap_max, gmax = asm_opt.self_scaf_gap_max; uint64_t mf, blen, bf, is_dip; uint32_t sce[2]; sce[0] = 0; sce[1] = 1;
    asg32_v b0, b1, b2, b3; kv_init(b0); kv_init(b1); kv_init(b2); kv_init(b3); uint8_t *f, *fs, *fsk; CALLOC(f, (ref->u.n<<1)); CALLOC(fs, (ref->u.n<<1)); CALLOC(fsk, ref->u.n);

    // fprintf(stderr, "[M::%s::] SSS\n", __func__); 
    for (k = 0; k < os->idx.n; ++k) {
        u = ((k<hu1->u.n)?&(hu1->u.a[k]):&(hu2->u.a[k-hu1->u.n]));
        asg_seq_set(g, k, u->len, 0); g->seq[k].c = (k<hu1->u.n?1:2);
    }

    // fprintf(stderr, "[M::%s::] MMM\n", __func__); 
    for (k = 0; k < os->idx.n; ++k) {
        
        r = u_trans_a(*os, k); rn = u_trans_n(*os, k); p = d = NULL; pn = dn = 0;
        // fprintf(stderr, "[M::%s::] # k:%lu, rn::%lu\n", __func__, k, rn); 
        if(rn <= 1) continue;
        for (z = 0, p = r; (z < rn) && (!(r[z].del)); z++); pn = z;
        for (d = r + z; (z < rn) && (r[z].qs != ((uint32_t)-1)); z++); dn = z - pn;
        // fprintf(stderr, "[M::%s::] # k:%lu, pn::%lu, dn::%lu\n", __func__, k, pn, dn); 
        if(pn <= 1) continue;///no scaf
        s = e = (uint64_t)-1;
        for (z = 0; z < pn; z++) {
            if((p[z].f) || (((p[z].qe-p[z].qs) >= rthres) && ((p[z].te-p[z].ts) >= rthres))) {
                s = e = z; break;
            }
        }
        for (; z < pn; z++) {
            if((p[z].f) || (((p[z].qe-p[z].qs) >= rthres) && ((p[z].te-p[z].ts) >= rthres))) e = z;
        }
        // fprintf(stderr, "[M::%s::] # k:%lu, s::%lu, e::%lu\n", __func__, k, s, e); 
        ///[s, e]
        u = ((k<hu1->u.n)?&(hu1->u.a[k]):&(hu2->u.a[k-hu1->u.n]));
        set_fsk(fsk, 1, ((k<hu1->u.n)?&(cp1->a[k]):&(cp2->a[k-hu1->u.n])));
        for (z = 1; z < pn; z++) {
            ///cannot scaffold circles
            ut = ((p[z-1].tn<hu1->u.n)?&(hu1->u.a[p[z-1].tn]):&(hu2->u.a[p[z-1].tn-hu1->u.n])); if(ut->circ) continue;
            ut = ((p[z].tn<hu1->u.n)?&(hu1->u.a[p[z].tn]):&(hu2->u.a[p[z].tn-hu1->u.n])); if(ut->circ) continue;
            // fprintf(stderr, "[M::%s::] # k:%lu, z::%lu, p[z-1].tn::%u, p[z].tn::%u, hu1->u.n::%u, hu2->u.n::%u\n", __func__, k, z, p[z-1].tn, p[z].tn, (uint32_t)hu1->u.n, (uint32_t)hu2->u.n); 
            
            el = 0; gl = 0;
            if((sce[(p[z-1].tn<hu1->u.n)?0:1] != sce[(p[z-1].qn<hu1->u.n)?0:1]) && (sce[(p[z].tn<hu1->u.n)?0:1] != sce[(p[z].qn<hu1->u.n)?0:1])) {///tn and qn come from different haplotypes
                if((((z-1)>=s)&&((z-1)<=e))&&(((z)>=s)&&((z)<=e))) el = 1;
                // fprintf(stderr, "-0-[M::%s::] # k::%lu, z::%lu, el::%lu\n", __func__, k, z, el); 
                if(el) {
                    zs = MAX(p[z-1].qs, p[z].qs); 
                    ze = MIN(p[z-1].qe, p[z].qe);
                    if(is_noisy_ov(MIN(zs, ze), MAX(zs, ze), u->len, 2500000, 0.5, d, dn)) el = 0;
                    // fprintf(stderr, "-1-[M::%s::] # k::%lu, z::%lu, el::%lu, zs::%ld, ze::%ld\n", __func__, k, z, el, zs, ze); 
                    if(el) {
                        gl = zs - ze;
                        if((!(p[z-1].f)) || (!(p[z].f))) {
                            if(gl >= gmin && gl <= gmax) el = 1;
                            else el = 0;///gap is too long
                        } else if(p[z-1].f && p[z].f) {
                            if(gl <= gmax) el = 1; ///p[z-1] and p[z] are too far away is bad; p[z-1] and p[z] are overlapped is fine
                            else el = 0;
                        }
                    }
                    // fprintf(stderr, "-2-[M::%s::] # k::%lu, z::%lu, el::%lu, zs::%ld, ze::%ld, p[z-1].f::%u, p[z].f::%u, gmin::%ld, gmax::%ld\n", __func__, k, z, el, zs, ze, p[z-1].f, p[z].f, gmin, gmax); 
                }
                ///final try in graph
                // fprintf(stderr, "[M::%s::] # k::%lu, z::%lu, el::%lu, gl::%ld\n", __func__, k, z, el, gl); 
                is_dip = 0;

                glen = is_small_tangle(&(p[z-1]), &(p[z]), ref, hu1, hu2, cp1, cp2, &b0, &b1, &b2, &b3, f, fs, fsk, 5000000, &is_dip);
                // fprintf(stderr, "[M::%s::] # k::%lu, z::%lu, el::%lu, glen::%lu, gl::%ld\n", __func__, k, z, el, glen, gl); 
                if((glen != (uint64_t)-1) && (((int64_t)glen) <= asm_opt.self_scaf_gap_max)) {
                    el = 1; if(!is_dip) gl = glen;
                }
            }
            if(gl < minNs) gl = minNs;
            if(el) {
                ///in anyway the gap cannot be too large
                if(gl <= gmax) el = 1; ///p[z-1] and p[z] are too far away is bad; p[z-1] and p[z] are overlapped is fine
                else el = 0;
            }
            
            scaf_hit2arc(&(p[z-1]), &(p[z]), 0, el, gl, &t);
            c = asg_arc_pushp(g); *c = t;
            scaf_hit2arc(&(p[z]), &(p[z-1]), 1, el, gl, &t);
            c = asg_arc_pushp(g); *c = t;
        }
        set_fsk(fsk, 0, ((k<hu1->u.n)?&(cp1->a[k]):&(cp2->a[k-hu1->u.n])));  
    }
    asg_cleanup(g); asg_symm(g);
    // fprintf(stderr, "[M::%s::] EEE\n", __func__); 

    uint64_t v, n_vtx = g->n_seq<<1, nv; asg_arc_t *av;
    for (v = 0; v < n_vtx; ++v) {
        if (g->seq[v>>1].del) continue;
        nv = asg_arc_n(g, v);
        if(nv <= 1) continue;
        av = asg_arc_a(g, v);
        for(k = 0; k < nv; k++) {
            if(av[k].del) continue;
            av[k].del = 1;
            asg_arc_del(g, av[k].v^1, (av[k].ul>>32)^1, 1);
        }
    }
    for (k = 0; k < g->n_arc; k++) {
        if(!(g->arc[k].el)) g->arc[k].del = 1;
    }
    asg_cleanup(g);

    if((ref->u.n<<1) < g->n_seq) REALLOC(f, g->n_seq);
    memset(f, 0, sizeof((*f))*g->n_seq);
    asg64_v b64; kv_init(b64); kvect_sec_t *i1 = NULL, *i2 = NULL, *im = NULL; uint64_t len[2];///, mmip;
    sec_t *mmi; CALLOC(i1, 1); CALLOC(i2, 1); ///i1->ctg = hu1; i2->ctg = hu2; 

    b0.n = 0; ///mmip = hu1->u.n; mmip <<= 1;
    for (v = 0; v < n_vtx; ++v) {
        nv = asg_arc_n(g, v); assert(nv <= 1);
        if(f[v>>1]) continue;
        if(asg_arc_n(g, (v^1)) != 0) continue;
        b64.n = 0; mf = gen_scaf_path_lst(g, v, &b64, &blen, &bf);
        assert(mf == END_TIPS);
        // rn = prt_gen_scaf_path_lst(b64.a, b64.n, (mf==LOOP)?1:0, hu1, hu2); kv_push(uint32_t, b0, rn);
        for (k = len[0] = len[1] = 0; k < b64.n; k++) {
            f[((uint32_t)b64.a[k])>>1] = 1;
            len[g->seq[((uint32_t)b64.a[k])>>1].c-1] += g->seq[((uint32_t)b64.a[k])>>1].len;
        }
        im = ((len[0] >= len[1])?i1:i2); kv_pushp(sec_t, (*im), &mmi); memset(mmi, 0, sizeof((*mmi)));
        mmi->is_c = 0; mmi->n = mmi->m = b64.n; MALLOC(mmi->a, mmi->n); memcpy(mmi->a, b64.a, sizeof((*(mmi->a)))*mmi->n);
        // for (k = 0; k < mmi->n; k++) { ///scaffold bug
        //     if((((uint32_t)mmi->a[k])>>1) >= hu1->u.n) mmi->a[k] -= mmip;
        // }
    }

    for (v = 0; v < n_vtx; ++v) {
        nv = asg_arc_n(g, v); assert(nv <= 1);
        if(f[v>>1]) continue;
        assert((nv == 1) && (asg_arc_n(g, (v^1)) == 1));
        b64.n = 0; mf = gen_scaf_path_lst(g, v, &b64, &blen, &bf);
        assert(mf == LOOP);
        // rn = prt_gen_scaf_path_lst(b64.a, b64.n, (mf==LOOP)?1:0, hu1, hu2); kv_push(uint32_t, b0, rn);
        for (k = len[0] = len[1] = 0; k < b64.n; k++) {
            f[((uint32_t)b64.a[k])>>1] = 1;
            len[g->seq[((uint32_t)b64.a[k])>>1].c-1] += g->seq[((uint32_t)b64.a[k])>>1].len;
        }
        im = ((len[0] >= len[1])?i1:i2);
        im = ((len[0] >= len[1])?i1:i2); kv_pushp(sec_t, (*im), &mmi); memset(mmi, 0, sizeof((*mmi)));
        mmi->is_c = 1; mmi->n = mmi->m = b64.n; MALLOC(mmi->a, mmi->n); memcpy(mmi->a, b64.a, sizeof((*(mmi->a)))*mmi->n);
        // for (k = 0; k < mmi->n; k++) { ///scaffold bug
        //     if((((uint32_t)mmi->a[k])>>1) >= hu1->u.n) mmi->a[k] -= mmip;
        // }
    }
    kv_destroy(b64);
    // cal_arr_N50(b0.a, b0.n, "Scf");

    // b1.n = 0;
    // for(k = 0; k < hu1->u.n; k++) kv_push(uint32_t, b1, hu1->u.a[k].len);
    // for(k = 0; k < hu2->u.n; k++) kv_push(uint32_t, b1, hu2->u.a[k].len);
    // cal_arr_N50(b1.a, b1.n, "Ctg");

    kv_destroy(b0); kv_destroy(b1); kv_destroy(b2); kv_destroy(b3); free(f); free(fs); free(fsk); asg_destroy(g); 
    (*sc1) = i1; (*sc2) = i2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %r8, 0x78(%rsp)
movq %rcx, 0x70(%rsp)
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r14
movq 0x1c0(%rsp), %rdi
callq 0x28c50
movl $0x1, %edi
movl $0x48, %esi
callq 0x2120
movq %rax, %r15
leaq 0x1ad3a3(%rip), %rax    # 0x28a758
movq 0x270(%rax), %rcx
movq %rcx, 0xd0(%rsp)
movq 0x278(%rax), %rax
movq %rax, 0x28(%rsp)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
xorl %ebx, %ebx
movq %rbx, 0x120(%rsp)
movaps %xmm0, 0x170(%rsp)
movq %rbx, 0x180(%rsp)
movaps %xmm0, 0x150(%rsp)
movq %rbx, 0x160(%rsp)
movaps %xmm0, 0x130(%rsp)
movq %rbx, 0x140(%rsp)
movq %r14, 0xb0(%rsp)
movq (%r14), %r14
leaq (%r14,%r14), %rbp
movl $0x1, %esi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0x8(%rsp)
movl $0x1, %esi
movq %rbp, %rdi
callq 0x2120
movq %rax, 0xa8(%rsp)
movl $0x1, %esi
movq %r14, %rdi
callq 0x2120
movq 0x1c0(%rsp), %rsi
movq %rax, 0x20(%rsp)
cmpq %rbx, 0x18(%rsi)
je 0xdd4da
xorl %ebx, %ebx
movl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq %r14, %rax
subq (%r12), %rax
jae 0xdd497
movq 0x10(%r12), %rax
addq %rbx, %rax
jmp 0xdd4a3
leaq (%rax,%rax,4), %rax
shlq $0x3, %rax
addq 0x10(%r13), %rax
movl (%rax), %edx
andl %ebp, %edx
movq %r15, %rdi
movl %r14d, %esi
xorl %ecx, %ecx
callq 0xa0115
cmpq (%r12), %r14
movb $0x2, %al
sbbb $0x0, %al
movq 0x20(%r15), %rcx
movb %al, 0x4(%rcx,%r14,8)
incq %r14
addq $0x28, %rbx
movq 0x1c0(%rsp), %rsi
cmpq 0x18(%rsi), %r14
jb 0xdd484
movq %r12, 0x98(%rsp)
movq %r15, 0x30(%rsp)
cmpq $0x0, 0x18(%rsi)
je 0xddb9c
movq 0x28(%rsp), %rax
negq %rax
movq %rax, 0xc8(%rsp)
xorl %ebx, %ebx
movq %r13, 0xf0(%rsp)
movq 0x28(%rsi), %rax
movq (%rax,%rbx,8), %rdx
movl %edx, %ecx
cmpq $0x2, %rcx
jb 0xddb8f
movq 0x10(%rsi), %r14
shrq $0x20, %rdx
leaq (%rdx,%rdx,2), %rax
shlq $0x4, %rax
addq %r14, %rax
shlq $0x4, %rdx
leaq (%rdx,%rdx,2), %r12
leaq (%r14,%r12), %rdx
addq $0x28, %rdx
xorl %r15d, %r15d
cmpb $0x0, (%rdx)
js 0xdd55a
incq %r15
addq $0x30, %rdx
cmpq %r15, %rcx
jne 0xdd546
movq %rcx, %r15
leaq (%r15,%r15,2), %rdi
shlq $0x4, %rdi
movq %r15, %r8
cmpq %rcx, %r15
jae 0xdd588
leaq (%rdi,%r12), %rdx
addq %r14, %rdx
movq %r15, %r8
cmpl $-0x1, (%rdx)
je 0xdd588
incq %r8
addq $0x30, %rdx
cmpq %r8, %rcx
jne 0xdd574
movq %rcx, %r8
cmpq $0x2, %r15
jb 0xddb8f
addq %rax, %rdi
subq %r15, %r8
xorl %ecx, %ecx
movq 0xd0(%rsp), %rsi
testb $0x3f, 0x28(%rax)
jne 0xdd5d5
movl 0x4(%rax), %edx
subl (%rax), %edx
cmpq %rdx, %rsi
ja 0xdd5bd
movl 0x10(%rax), %edx
subl 0xc(%rax), %edx
cmpq %rdx, %rsi
jbe 0xdd5d5
incq %rcx
addq $0x30, %rax
cmpq %rcx, %r15
jne 0xdd5a2
movq $-0x1, %rax
movq %r15, %rcx
jmp 0xdd5d8
movq %rcx, %rax
movq %rax, 0xb8(%rsp)
movq %rax, 0x10(%rsp)
cmpq %r15, %rcx
jae 0xdd633
leaq (%rcx,%rcx,2), %rax
shlq $0x4, %rax
addq %r12, %rax
addq %r14, %rax
movq 0xb8(%rsp), %rdx
movq %rdx, 0x10(%rsp)
testb $0x3f, 0x28(%rax)
je 0xdd612
movq %rcx, 0x10(%rsp)
jmp 0xdd627
movl 0x4(%rax), %edx
subl (%rax), %edx
cmpq %rdx, %rsi
ja 0xdd627
movl 0x10(%rax), %edx
subl 0xc(%rax), %edx
cmpq %rdx, %rsi
jbe 0xdd60b
incq %rcx
addq $0x30, %rax
cmpq %rcx, %r15
jne 0xdd605
movq 0x98(%rsp), %rdx
movq (%rdx), %rax
movq %rbx, %rcx
subq %rax, %rcx
jae 0xdd654
leaq (%rbx,%rbx,4), %rcx
shlq $0x3, %rcx
addq 0x10(%rdx), %rcx
jmp 0xdd660
leaq (%rcx,%rcx,4), %rcx
shlq $0x3, %rcx
addq 0x10(%r13), %rcx
movq %rcx, 0xa0(%rsp)
movq %rbx, %rcx
subq %rax, %rcx
movq %rbx, 0xd8(%rsp)
movq %rdi, 0xe8(%rsp)
movq %r8, 0xe0(%rsp)
jae 0xdd693
imulq $0x58, %rbx, %rdx
movq 0x70(%rsp), %rax
jmp 0xdd69c
imulq $0x58, %rcx, %rdx
movq 0x78(%rsp), %rax
addq (%rax), %rdx
movq 0x20(%rsp), %rdi
movl $0x1, %esi
callq 0xdd315
cmpq $0x3, %r15
movl $0x2, %eax
cmovbq %rax, %r15
addq %r12, %r14
addq $0x30, %r14
movl $0x1, %r12d
movq 0x98(%rsp), %rbx
movq %r15, 0xf8(%rsp)
movl -0x1c(%r14), %ecx
movq (%rbx), %rax
movq %rcx, %rdx
subq %rax, %rdx
jae 0xdd6f5
leaq (%rcx,%rcx,4), %rdx
shlq $0x3, %rdx
addq 0x10(%rbx), %rdx
jmp 0xdd701
leaq (%rdx,%rdx,4), %rdx
shlq $0x3, %rdx
addq 0x10(%r13), %rdx
cmpl $0x0, (%rdx)
js 0xdd9c0
movl 0x14(%r14), %edx
movq %rdx, %rsi
subq %rax, %rsi
jae 0xdd724
leaq (%rdx,%rdx,4), %rsi
shlq $0x3, %rsi
addq 0x10(%rbx), %rsi
jmp 0xdd730
leaq (%rsi,%rsi,4), %rsi
shlq $0x3, %rsi
addq 0x10(%r13), %rsi
cmpl $0x0, (%rsi)
js 0xdd9c0
xorl %esi, %esi
cmpq %rax, %rcx
setae %sil
movl 0x38(%rsp,%rsi,4), %ecx
movl -0x28(%r14), %esi
xorl %edi, %edi
cmpq %rsi, %rax
setbe %dil
cmpl 0x38(%rsp,%rdi,4), %ecx
movq %r12, 0x18(%rsp)
je 0xdd781
xorl %ecx, %ecx
cmpq %rax, %rdx
setae %cl
movl 0x38(%rsp,%rcx,4), %ecx
movl 0x8(%r14), %edx
xorl %esi, %esi
cmpq %rdx, %rax
setbe %sil
cmpl 0x38(%rsp,%rsi,4), %ecx
jne 0xdd9d5
xorl %r10d, %r10d
xorl %r15d, %r15d
movq 0x1c8(%rsp), %rax
cmpq %rax, %r15
cmovleq %rax, %r15
cmpq 0x28(%rsp), %r15
setle %r8b
movl -0x1c(%r14), %edi
movl -0x8(%r14), %ebx
movl 0x14(%r14), %esi
movl 0x28(%r14), %ebp
xorl %r11d, %r11d
testq %r15, %r15
setns %dl
movq %r15, %r12
negq %r12
cmovsq %r15, %r12
movq 0x30(%rsp), %r13
movl 0x4(%r13), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl (%r13), %eax
cmpl %eax, %ecx
jne 0xdd841
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%r13)
movq %rdi, 0x80(%rsp)
movq 0x8(%r13), %rdi
shlq $0x3, %rcx
movq %rsi, 0x88(%rsp)
leaq (%rcx,%rcx,2), %rsi
movq %r10, %r15
movb %dl, 0x90(%rsp)
movb %r8b, 0x7(%rsp)
callq 0x2370
movb 0x7(%rsp), %r8b
movq 0x80(%rsp), %rdi
movq 0x88(%rsp), %rsi
movb 0x90(%rsp), %dl
xorl %r11d, %r11d
movq %r15, %r10
movq %rax, 0x8(%r13)
andb %r8b, %r10b
shrl $0x6, %ebx
andl $0x1, %ebx
leal (%rbx,%rdi,2), %eax
shrl $0x6, %ebp
andl $0x1, %ebp
leal (%rbp,%rsi,2), %ecx
shlq $0x20, %rax
movl $0x7fffffff, %r9d       # imm = 0x7FFFFFFF
andl %r9d, %r12d
movb %dl, %r11b
shll $0xe, %r11d
movq 0x8(%r13), %rdx
movl 0x4(%r13), %esi
movl %esi, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
leal 0x1(%rsi), %r8d
andl %r9d, %r8d
andl $0x80000000, %esi       # imm = 0x80000000
orl %r8d, %esi
movl %esi, 0x4(%r13)
leaq (%rdi,%rdi,2), %rsi
movq %rax, (%rdx,%rsi,8)
movl %ecx, 0x8(%rdx,%rsi,8)
movl %r12d, 0xc(%rdx,%rsi,8)
movw %r11w, 0x10(%rdx,%rsi,8)
movb %r10b, 0x12(%rdx,%rsi,8)
movl $0x0, 0x13(%rdx,%rsi,8)
movb $0x0, 0x17(%rdx,%rsi,8)
movl 0x14(%r14), %esi
movl 0x28(%r14), %ebx
movl -0x1c(%r14), %edx
movl -0x8(%r14), %r15d
movl 0x4(%r13), %ecx
andl %r9d, %ecx
movl (%r13), %eax
cmpl %eax, %ecx
jne 0xdd933
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%r13)
movq 0x8(%r13), %rdi
shlq $0x3, %rcx
movq %rsi, 0x80(%rsp)
leaq (%rcx,%rcx,2), %rsi
movq %r10, 0x90(%rsp)
movl %r11d, %ebp
movq %rdx, 0x88(%rsp)
callq 0x2370
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
movl %ebp, %r11d
movq 0x90(%rsp), %r10
movq %rax, 0x8(%r13)
shrl $0x6, %ebx
andl $0x1, %ebx
leal (%rbx,%rsi,2), %eax
xorl $0x1, %eax
shrl $0x6, %r15d
andl $0x1, %r15d
leal (%r15,%rdx,2), %ecx
shlq $0x20, %rax
xorl $0x1, %ecx
movq 0x8(%r13), %rdx
movl 0x4(%r13), %esi
movl %esi, %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
leal 0x1(%rsi), %r8d
andl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl $0x80000000, %esi       # imm = 0x80000000
orl %r8d, %esi
movl %esi, 0x4(%r13)
leaq (%rdi,%rdi,2), %rsi
movq %rax, (%rdx,%rsi,8)
movl %ecx, 0x8(%rdx,%rsi,8)
movl %r12d, 0xc(%rdx,%rsi,8)
movw %r11w, 0x10(%rdx,%rsi,8)
movb %r10b, 0x12(%rdx,%rsi,8)
movl $0x0, 0x13(%rdx,%rsi,8)
movb $0x0, 0x17(%rdx,%rsi,8)
movq 0xf0(%rsp), %r13
movq 0x98(%rsp), %rbx
movq 0xf8(%rsp), %r15
movq 0x18(%rsp), %r12
incq %r12
addq $0x30, %r14
cmpq %r12, %r15
jne 0xdd6d8
jmp 0xddb51
leaq -0x1(%r12), %rax
movq 0xb8(%rsp), %rdx
cmpq %rdx, %rax
setb %cl
movq 0x10(%rsp), %rsi
cmpq %rsi, %rax
seta %al
cmpq %rdx, %r12
setb %dl
orb %cl, %dl
orb %al, %dl
cmpq %rsi, %r12
seta %al
orb %dl, %al
jne 0xdda6c
movl (%r14), %eax
movl -0x30(%r14), %ecx
cmpl %eax, %ecx
cmoval %ecx, %eax
movl -0x2c(%r14), %ecx
movl 0x4(%r14), %esi
cmpl %esi, %ecx
cmovbl %ecx, %esi
movq %rax, %r15
subq %rsi, %r15
movq %rsi, %rdi
cmovaq %rax, %rsi
cmovbq %rax, %rdi
movq 0xa0(%rsp), %rax
movl (%rax), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movl $0x2625a0, %ecx         # imm = 0x2625A0
movsd 0x147aa2(%rip), %xmm0   # 0x2254f0
movq 0xe8(%rsp), %r8
movq 0xe0(%rsp), %r9
callq 0xdae8e
testq %rax, %rax
je 0xddb19
xorl %r13d, %r13d
xorl %r15d, %r15d
leaq -0x30(%r14), %rdi
movq $0x0, 0xc0(%rsp)
movq %r14, %rsi
movq 0xb0(%rsp), %rdx
movq %rbx, %rcx
movq 0x70(%rsp), %r9
leaq 0xc0(%rsp), %rax
pushq %rax
pushq $0x4c4b40               # imm = 0x4C4B40
pushq 0x30(%rsp)
pushq 0xc0(%rsp)
pushq 0x28(%rsp)
leaq 0x158(%rsp), %rax
pushq %rax
leaq 0x180(%rsp), %rax
pushq %rax
leaq 0x1a8(%rsp), %rax
pushq %rax
leaq 0x150(%rsp), %rax
pushq %rax
pushq 0xc0(%rsp)
callq 0xdcf55
addq $0x50, %rsp
cmpq $-0x1, %rax
je 0xddb11
leaq 0x1acc65(%rip), %rcx    # 0x28a758
cmpq 0x278(%rcx), %rax
jg 0xddb11
cmpq $0x0, 0xc0(%rsp)
cmoveq %rax, %r15
movb $0x1, %r10b
jmp 0xdd787
movq %r13, %r10
jmp 0xdd787
testb $0x3f, -0x8(%r14)
je 0xddb35
testb $0x3f, 0x28(%r14)
je 0xddb35
cmpq 0x28(%rsp), %r15
setle %r13b
jmp 0xdda72
cmpq 0xc8(%rsp), %r15
setge %al
cmpq 0x28(%rsp), %r15
setle %r13b
andb %al, %r13b
jmp 0xdda72
movq 0xd8(%rsp), %rcx
movq %rcx, %rax
subq (%rbx), %rax
jae 0xddb6c
imulq $0x58, %rcx, %rdx
movq 0x70(%rsp), %rax
jmp 0xddb75
imulq $0x58, %rax, %rdx
movq 0x78(%rsp), %rax
addq (%rax), %rdx
movq %rcx, %rbx
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0xdd315
movq 0x1c0(%rsp), %rsi
incq %rbx
cmpq 0x18(%rsi), %rbx
jb 0xdd50c
movq 0x30(%rsp), %r12
movq %r12, %rdi
callq 0xa02fa
movq %r12, %rdi
callq 0xa0333
movq %r12, %rdi
callq 0xa03e9
movl 0x14(%r12), %ebp
movl %ebp, %eax
orl $0x80000000, %eax       # imm = 0x80000000
movl %eax, 0x14(%r12)
addl %ebp, %ebp
movslq %ebp, %r15
testl %r15d, %r15d
je 0xddca7
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq 0x20(%r12), %rdx
movq %rax, %rsi
andq $-0x2, %rsi
cmpl $0x0, (%rdx,%rsi,4)
js 0xddc9b
movq 0x28(%r12), %rdx
movq (%rdx,%rax,8), %rsi
movl %esi, %edx
cmpq $0x2, %rdx
jb 0xddc9b
shrq $0x20, %rsi
leaq (%rsi,%rsi,2), %rsi
shlq $0x3, %rsi
addq 0x8(%r12), %rsi
xorl %edi, %edi
leaq (%rdi,%rdi,2), %r8
movl 0xc(%rsi,%r8,8), %r9d
testl %r9d, %r9d
js 0xddc93
leaq (%rsi,%r8,8), %r8
orl $0x80000000, %r9d       # imm = 0x80000000
movl %r9d, 0xc(%r8)
movl 0x8(%r8), %r9d
xorq $0x1, %r9
movq 0x28(%r12), %r10
movq (%r10,%r9,8), %r10
movq %r10, %r9
andq %rcx, %r9
je 0xddc93
movl 0x4(%r8), %r8d
movq 0x8(%r12), %r11
shrq $0x20, %r10
shlq $0x3, %r9
leaq (%r9,%r9,2), %r9
leaq (%r10,%r10,2), %r10
leaq (%r11,%r10,8), %r10
addq $0xc, %r10
xorl %r11d, %r11d
movl -0x4(%r10,%r11), %ebx
xorl %r8d, %ebx
cmpl $0x1, %ebx
jne 0xddc8a
orb $-0x80, 0x3(%r10,%r11)
addq $0x18, %r11
cmpq %r11, %r9
jne 0xddc77
incq %rdi
cmpq %rdx, %rdi
jne 0xddc1d
incq %rax
cmpq %r15, %rax
jne 0xddbdf
testl $0x7fffffff, 0x4(%r12)  # imm = 0x7FFFFFFF
je 0xddce1
movl $0xc, %eax
xorl %ecx, %ecx
movq 0x8(%r12), %rdx
cmpb $0x0, 0x6(%rdx,%rax)
jne 0xddcca
orb $-0x80, 0x3(%rdx,%rax)
incq %rcx
movl 0x4(%r12), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
addq $0x18, %rax
cmpq %rdx, %rcx
jb 0xddcb9
movq %r12, %rdi
callq 0xa02fa
movq 0xb0(%rsp), %rax
movq (%rax), %rax
addq %rax, %rax
movl 0x14(%r12), %r14d
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
cmpq %r14, %rax
jae 0xddd1a
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x2370
movq %rax, %rdi
jmp 0xddd1f
movq 0x8(%rsp), %rdi
xorl %ebx, %ebx
movq %rdi, 0x8(%rsp)
xorl %esi, %esi
movq %r14, %rdx
callq 0x20e0
movq %rbx, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x2120
movq %rax, 0x18(%rsp)
movl $0x1, %edi
movl $0x20, %esi
callq 0x2120
movq %rax, 0x10(%rsp)
movq %rbx, 0x110(%rsp)
testl %ebp, %ebp
je 0xde02e
xorl %r13d, %r13d
movq 0x8(%rsp), %rbx
movq 0x28(%r12), %rax
testl $0xfffffffe, (%rax,%r13,8) # imm = 0xFFFFFFFE
jne 0xde0c7
movq %r13, %rcx
shrq %rcx
cmpb $0x0, (%rbx,%rcx)
jne 0xddebd
movq %r13, %rcx
xorq $0x1, %rcx
cmpl $0x0, (%rax,%rcx,8)
jne 0xddebd
movq $0x0, 0x40(%rsp)
movq %r12, %rdi
movl %r13d, %esi
leaq 0x40(%rsp), %rdx
leaq 0x108(%rsp), %rcx
leaq 0x100(%rsp), %r8
callq 0xdd0e2
cmpl $0x5, %eax
jne 0xde143
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x40(%rsp), %rbp
testq %rbp, %rbp
je 0xdde25
movq 0x50(%rsp), %rax
movq 0x20(%r12), %rcx
xorl %edx, %edx
movl (%rax,%rdx,8), %esi
shrl %esi
movb $0x1, (%rbx,%rsi)
movl (%rcx,%rsi,8), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movzbl 0x4(%rcx,%rsi,8), %esi
addq %rdi, 0x58(%rsp,%rsi,8)
incq %rdx
cmpq %rdx, %rbp
jne 0xdde01
movq 0x60(%rsp), %rax
cmpq 0x68(%rsp), %rax
movq 0x18(%rsp), %r14
cmovbq 0x10(%rsp), %r14
movq 0x10(%r14), %rax
cmpq %rax, 0x8(%r14)
jne 0xdde67
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x10(%r14)
movq (%r14), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, (%r14)
movq (%r14), %rbx
movq 0x8(%r14), %r12
leaq 0x1(%r12), %rax
movq %rax, 0x8(%r14)
shlq $0x5, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%rbx,%r12)
movups %xmm0, 0x10(%rbx,%r12)
movq %rbp, (%rbx,%r12)
movq %rbp, 0x8(%rbx,%r12)
shlq $0x3, %rbp
movq %rbp, %rdi
callq 0x2280
movq %rax, 0x18(%rbx,%r12)
movq 0x50(%rsp), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2160
movq 0x30(%rsp), %r12
movq 0x8(%rsp), %rbx
incq %r13
cmpq %r15, %r13
jne 0xddd7d
xorl %r13d, %r13d
movq 0x28(%r12), %rax
movl (%rax,%r13,8), %ecx
cmpq $0x2, %rcx
jae 0xde0e6
movq %r13, %rdx
shrq %rdx
movq 0x8(%rsp), %rsi
cmpb $0x0, (%rsi,%rdx)
jne 0xde022
cmpl $0x1, %ecx
movq 0x8(%rsp), %rbx
jne 0xde105
movq %r13, %rcx
xorq $0x1, %rcx
cmpl $0x1, (%rax,%rcx,8)
jne 0xde105
movq $0x0, 0x40(%rsp)
movq %r12, %rdi
movl %r13d, %esi
leaq 0x40(%rsp), %rdx
leaq 0x108(%rsp), %rcx
leaq 0x100(%rsp), %r8
callq 0xdd0e2
cmpl $0x7, %eax
jne 0xde124
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x40(%rsp), %rbp
testq %rbp, %rbp
je 0xddf87
movq 0x50(%rsp), %rax
movq 0x20(%r12), %rcx
xorl %edx, %edx
movl (%rax,%rdx,8), %esi
shrl %esi
movb $0x1, (%rbx,%rsi)
movl (%rcx,%rsi,8), %edi
andl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
movzbl 0x4(%rcx,%rsi,8), %esi
addq %rdi, 0x58(%rsp,%rsi,8)
incq %rdx
cmpq %rdx, %rbp
jne 0xddf63
movq 0x60(%rsp), %rax
cmpq 0x68(%rsp), %rax
movq 0x18(%rsp), %rbx
cmovbq 0x10(%rsp), %rbx
movq 0x10(%rbx), %rax
cmpq %rax, 0x8(%rbx)
jne 0xddfc9
leaq (%rax,%rax), %rsi
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x10(%rbx)
movq (%rbx), %rdi
shlq $0x5, %rsi
callq 0x2370
movq %rax, (%rbx)
movq (%rbx), %r12
movq 0x8(%rbx), %r14
leaq 0x1(%r14), %rax
movq %rax, 0x8(%rbx)
shlq $0x5, %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r12,%r14)
movups %xmm0, (%r12,%r14)
movq $0x1, 0x10(%r12,%r14)
movq %rbp, (%r12,%r14)
movq %rbp, 0x8(%r12,%r14)
shlq $0x3, %rbp
movq %rbp, %rdi
callq 0x2280
movq %rax, 0x18(%r12,%r14)
movq 0x50(%rsp), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2160
movq 0x30(%rsp), %r12
incq %r13
cmpq %r15, %r13
jne 0xddecc
movq 0x1d8(%rsp), %r14
movq 0x1d0(%rsp), %r15
movq 0x50(%rsp), %rdi
callq 0x2220
movq 0x120(%rsp), %rdi
callq 0x2220
movq 0x180(%rsp), %rdi
callq 0x2220
movq 0x160(%rsp), %rdi
callq 0x2220
movq 0x140(%rsp), %rdi
callq 0x2220
movq 0x8(%rsp), %rdi
callq 0x2220
movq 0xa8(%rsp), %rdi
callq 0x2220
movq 0x20(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
callq 0x9fcdb
movq 0x18(%rsp), %rax
movq %rax, (%r15)
movq 0x10(%rsp), %rax
movq %rax, (%r14)
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x14d8dc(%rip), %rdi    # 0x22b9aa
leaq 0x14bbcc(%rip), %rsi    # 0x229ca1
leaq 0x14d8d6(%rip), %rcx    # 0x22b9b2
movl $0x5913, %edx           # imm = 0x5913
callq 0x2110
leaq 0x14d8bd(%rip), %rdi    # 0x22b9aa
leaq 0x14bbad(%rip), %rsi    # 0x229ca1
leaq 0x14d8b7(%rip), %rcx    # 0x22b9b2
movl $0x5925, %edx           # imm = 0x5925
callq 0x2110
leaq 0x14d951(%rip), %rdi    # 0x22ba5d
leaq 0x14bb8e(%rip), %rsi    # 0x229ca1
leaq 0x14d898(%rip), %rcx    # 0x22b9b2
movl $0x5927, %edx           # imm = 0x5927
callq 0x2110
leaq 0x14d95a(%rip), %rdi    # 0x22ba85
leaq 0x14bb6f(%rip), %rsi    # 0x229ca1
leaq 0x14d879(%rip), %rcx    # 0x22b9b2
movl $0x5929, %edx           # imm = 0x5929
callq 0x2110
leaq 0x14d904(%rip), %rdi    # 0x22ba4e
leaq 0x14bb50(%rip), %rsi    # 0x229ca1
leaq 0x14d85a(%rip), %rcx    # 0x22b9b2
movl $0x5917, %edx           # imm = 0x5917
callq 0x2110