// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: get_ul_g(mul_ov_t*, mg_gres_a*, ma_ug_t*, asg_t const*, double, double, int, int)
void get_ul_g(mul_ov_t *aov, mg_gres_a *hits, ma_ug_t *ug, const asg_t *rg, 
double cov_thres, double vv, int32_t min_off, int32_t min_read_ovlp)
{
	int64_t c_thres = (aov->asm_cov*cov_thres)>2?(aov->asm_cov*cov_thres):2;
	uint64_t i, k, l, m, v0, v1, r0, r1;
	int32_t qs, qe, rs, re, qs0, qe0, qs1, qe1, ovlp, mmi, nngc2 = 0, is, ie, iocc, m_iocc, max_i;
	mg_gres_t *p = NULL;
	mg_gchain_t *gc = NULL, *gc0, *gc1;
	mg_lres_t *lf = NULL, *ll = NULL;
	asg_t *xg = copy_read_graph(ug->g);
	asg_arc_t *pe = NULL;
	kvec_t(lc_srt_t) tt; kv_init(tt); lc_srt_t *pt = NULL;
	kvec_t(eg_srt_t) td; kv_init(td); eg_srt_t *pd = NULL;
	kvec_t_u64_warp tidx; kv_init(tidx.a);
	///for debug
	kvec_t(eg_srt_t) dbg_vw_srt; kv_init(dbg_vw_srt);
	for (i = 0; i < hits->n; i++) {
		// fprintf(stderr, "+i+: %lu\n",i);
		p = &(hits->a[i]); tt.n = 0;
		// fprintf(stderr, "-i-: %lu\n",i);
		if(p->n_gc < 2) continue;
		nngc2++;
		// fprintf(stderr, "\nsis: %lu, p->n_gc: %d\n",i,p->n_gc);
		for (k = 0; k < (uint64_t)p->n_gc; k++) {
			gc = &(p->gc[k]);
			assert(gc->cnt > 0);
			lf = &(p->lc[gc->off]); ll = gc->cnt>1?&(p->lc[gc->off+gc->cnt-1]):NULL;
			assert(lf->qs != (uint32_t)-1);
			if(ll) assert(ll->qs != (uint32_t)-1);

			transfor_icoord(lf->qs, lf->qe, lf->ts, lf->te, lf->v&1, p->qlen, ug->g->seq[lf->v>>1].len, 
			&qs, ll?NULL:&qe, &rs, ll?NULL:&re);
			if(ll) {
				transfor_icoord(ll->qs, ll->qe, ll->ts, ll->te, ll->v&1, p->qlen, ug->g->seq[ll->v>>1].len, 
				NULL, &qe, NULL, &re);
			} else {
				ll = lf;
			}
			if(qe - qs < min_read_ovlp || re - rs < min_read_ovlp) continue;
			kv_pushp(lc_srt_t, tt, &pt); 
			pt->qse = qs; pt->qse <<= 32; pt->qse |= qe;
			pt->rse = rs; pt->rse <<= 32; pt->rse |= re;
			pt->gld = i; pt->gld <<= 32; pt->gld |= k;
			// fprintf(stderr, ">>>>k: %lu, qs: %d, qe: %d, qs-utg%.6d%c, qe-utg%.6d%c\n", k, qs, qe, 
			// (int32_t)((lf->v>>1)+1), "lc"[ug->u.a[lf->v>>1].circ], 
			// (int32_t)((ll->v>>1)+1), "lc"[ug->u.a[ll->v>>1].circ]);
			// fprintf(stderr, "lf_qs: %u, lf_qe: %u, lf_ts: %u, lf_te: %u\n", lf->qs, lf->qe, lf->ts, lf->te);
			// fprintf(stderr, "ll_qs: %u, ll_qe: %u, ll_ts: %u, ll_te: %u\n", ll->qs, ll->qe, ll->ts, ll->te);
		}
		// fprintf(stderr, "eie: %lu\n",i);
		radix_sort_lc_srt(tt.a, tt.a + tt.n);
		for (k = 0; k < tt.n; k++) {
			for (m = k + 1; m < tt.n; m++) {
				gc0 = &(p->gc[(uint32_t)(tt.a[k].gld)]); 
				v0 = p->lc[gc0->off+gc0->cnt-1].v;
				gc1 = &(p->gc[(uint32_t)(tt.a[m].gld)]);
				v1 = p->lc[gc1->off].v;
				if((v0>>1) == (v1>>1)) continue;

				qs0 = tt.a[k].qse>>32; qe0 = (uint32_t)(tt.a[k].qse);
				qs1 = tt.a[m].qse>>32; qe1 = (uint32_t)(tt.a[m].qse);
				// fprintf(stderr, "++++k: %lu, qs0: %d, qe0: %d, qs1: %d, qe1: %d, q0-utg%.6d%c, q1-utg%.6d%c\n", 
				// k, qs0, qe0, qs1, qe1, (int32_t)((v0>>1)+1), "lc"[ug->u.a[v0>>1].circ], (int32_t)((v1>>1)+1), "lc"[ug->u.a[v1>>1].circ]);
				if(qs1 <= qs0 && qe1 >= qe0) continue;///contain
				if(qs0 <= qs1 && qe0 >= qe1) continue;///contain
				if(ug->u.a[v0>>1].circ || ug->u.a[v1>>1].circ) continue;
				ovlp = ((MIN((qe0), (qe1)) > MAX((qs0), (qs1)))? MIN((qe0), (qe1)) - MAX((qs0), (qs1)):0);
				r0 = v0&1?(ug->u.a[v0>>1].start>>1):(ug->u.a[v0>>1].end>>1);
				r1 = v1&1?(ug->u.a[v1>>1].end>>1):(ug->u.a[v1>>1].start>>1);
				// fprintf(stderr, "----k: %lu, ovlp: %d\n", k, ovlp);
				// if((ovlp == 0) || (ovlp <= ((qe0 - qs0)*vv) && ovlp <= ((qe1 - qs1)*vv)) || 
				//  (asg_arc_n(ug->g, v0) == 0 && asg_arc_n(ug->g, v1^1) == 0)) {
				if(/**(asg_arc_n(ug->g, v0) == 0 && asg_arc_n(ug->g, v1^1) == 0) 
												&& **/(ovlp < (int32_t)(MIN(rg->seq[r0].len, rg->seq[r1].len)))) {
					kv_pushp(eg_srt_t, td, &pd);
					pd->d = MAX((qs0), (qs1)) - MIN((qe0), (qe1));
					pd->x = v0<v1?((v0<<32)|v1):(((v1^1)<<32)|(v0^1));
					pd->id = p->qid; 
					pd->e = (uint32_t)(tt.a[k].gld);
					pd->e <<= 32; pd->e |= (uint32_t)(tt.a[m].gld);
				}
			}
		}
	}
	fprintf(stderr, "td.n: %d\n", (int)td.n);
	radix_sort_eg_srt_x(td.a, td.a + td.n);
	for (k = 1, l = 0; k <= td.n; ++k) 
    {   
        if (k == td.n || td.a[k].x != td.a[l].x) 
        {
			if(k - l >= (uint64_t)c_thres) {
				for (i = l+1, mmi = l; i < k; i++) {
					if(td.a[mmi].d > td.a[i].d) mmi = i;
				}
				mmi = td.a[mmi].d < 0? -td.a[mmi].d:0;
				if(mmi != 0) {
					for (i = l; i < k; i++) td.a[i].d += mmi;
				}


				radix_sort_eg_srt_d(td.a + l, td.a + k);
				for (i = l, iocc = 0, tidx.a.n = 0; i < k; i++) {
					ovlp = (td.a[i].d > mmi? td.a[i].d - mmi: mmi - td.a[i].d) * vv;
					if(ovlp < min_off) ovlp = min_off;
					// fprintf(stderr, "i-%lu, ovlp: %d, td.a[i].d: %d, qid: %u\n", i, ovlp, td.a[i].d, td.a[i].id);
					// if(spec_ovlp_occ(td.a + l, k-l, i - l, ovlp, c_thres)) break;
					iocc = get_spec_ovlp_occ(td.a + l, k-l, i - l, ovlp, c_thres, &is, &ie, &tidx);
					// fprintf(stderr, "c_thres-%ld, iocc-%d\n", c_thres, iocc);
					if(iocc >= c_thres) break;
				}

				

				if(i < k) {
					m_iocc = iocc; max_i = i;
					for (i = ie + 1; i < k; i++) {
						iocc = get_spec_ovlp_occ(td.a + l, k-l, i - l, ovlp, m_iocc, &is, &ie, &tidx);
						if(iocc > m_iocc) m_iocc = iocc, max_i = i;
						i = ie + l;
					}
					///for debug
					kv_pushp(eg_srt_t, dbg_vw_srt, &pd);
					pd->x = m_iocc; pd->e = td.a[l].x;
					
					v0 = (uint32_t)td.a[l].x; v1 = td.a[l].x>>32;
					pe = asg_arc_pushp(xg);
					pe->del = 0; pe->strong = 0; pe->el = 0; pe->no_l_indel = 0; pe->ol = 0;
					pe->v = v0; pe->ul = v1<<32; pe->ul += xg->seq[v1>>1].len;

					v0 = (td.a[l].x>>32)^1; v1 = ((uint32_t)td.a[l].x)^1;
					pe = asg_arc_pushp(xg);
					pe->del = 0; pe->strong = 0; pe->el = 0; pe->no_l_indel = 0; pe->ol = 0;
					pe->v = v0; pe->ul = v1<<32; pe->ul += xg->seq[v1>>1].len;

					// fprintf(stderr, "++++q0-utg%.6d%c, q1-utg%.6d%c, k-l: %lu, c_thres: %ld, flag: %u\n", 
					// (int32_t)((td.a[l].x>>33)+1), "lc"[ug->u.a[td.a[l].x>>33].circ], 
					// (int32_t)(((uint32_t)td.a[l].x)>>1)+1, "lc"[ug->u.a[(((uint32_t)td.a[l].x)>>1)].circ], k-l, c_thres,
					// (asg_arc_n(ug->g, ((uint32_t)td.a[l].x)^1) == 0 && asg_arc_n(ug->g, (td.a[l].x>>32)) == 0));
				}
			}
            l = k;
        }
    }

	xg->is_srt = 0; xg->idx = 0; free(xg->idx); 
    asg_cleanup(xg);
	clean_ul_g(xg);

	///for debug
	fprintf(stderr, "[M::%s::] ==> nngc2: %d\n", __func__, nngc2);
	radix_sort_eg_srt_x(dbg_vw_srt.a, dbg_vw_srt.a + dbg_vw_srt.n);
	for (max_i = (int32_t)dbg_vw_srt.n - 1; max_i >= 0; --max_i) {
		pd = &(dbg_vw_srt.a[max_i]);
		fprintf(stderr, "++++q0-utg%.6d%c, q1-utg%.6d%c, occ: %lu, c_thres: %ld, flag: %u\n", 
					(int32_t)((pd->e>>33)+1), "lc"[ug->u.a[pd->e>>33].circ], 
					(int32_t)(((uint32_t)pd->e)>>1)+1, "lc"[ug->u.a[(((uint32_t)pd->e)>>1)].circ], pd->x, c_thres,
					(asg_arc_n(ug->g, ((uint32_t)pd->e)^1) == 0 && asg_arc_n(ug->g, (pd->e>>32)) == 0));
	}

	
	kv_destroy(tt); kv_destroy(td); kv_destroy(tidx.a); kv_destroy(dbg_vw_srt);
	asg_destroy(xg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %r9d, 0x90(%rsp)
movl %r8d, 0x64(%rsp)
movsd %xmm1, 0xd8(%rsp)
movsd %xmm0, 0x70(%rsp)
movq %rcx, 0x88(%rsp)
movq %rsi, %rbx
movsd 0x8(%rdi), %xmm0
movaps %xmm0, 0xc0(%rsp)
movq %rdx, 0x98(%rsp)
movq 0x18(%rdx), %rdi
callq 0xc8dad
xorps %xmm0, %xmm0
movaps %xmm0, 0xe0(%rsp)
movq $0x0, 0xf0(%rsp)
movq $0x0, 0x80(%rsp)
cmpq $0x0, (%rbx)
movq %rax, 0xa0(%rsp)
movl $0x0, %eax
movq %rax, 0x48(%rsp)
movl $0x0, %r12d
movl $0x0, %eax
movq %rax, 0x20(%rsp)
je 0x1e32b5
movq $0x0, 0x20(%rsp)
movq $0x0, 0x40(%rsp)
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x48(%rsp)
xorl %edx, %edx
movq $0x0, 0x80(%rsp)
movq %rbx, 0x58(%rsp)
movq 0x10(%rbx), %rax
leaq (%rdx,%rdx,4), %rcx
cmpl $0x2, (%rax,%rcx,8)
jl 0x1e32a9
movq %r12, 0x28(%rsp)
leaq (%rax,%rcx,8), %r9
movq 0x80(%rsp), %rax
incl %eax
movq %rax, 0x80(%rsp)
movq %rdx, 0x78(%rsp)
shlq $0x20, %rdx
movq %rdx, 0x30(%rsp)
movl $0xc, %r13d
xorl %r10d, %r10d
xorl %r12d, %r12d
movq %r9, 0x8(%rsp)
movq 0x8(%r9), %rcx
movslq (%rcx,%r13), %rdx
testq %rdx, %rdx
jle 0x1e396b
movq 0x10(%r9), %rax
movslq -0x4(%rcx,%r13), %rsi
leaq (%rsi,%rsi,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rsi, %rcx
addq %rdx, %rsi
leaq (%rsi,%rsi,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rsi, %rdi
cmpl $0x1, %edx
leaq -0x1c(%rax,%rdi), %rdx
movl $0x0, %ebx
cmovneq %rdx, %rbx
movl 0xc(%rax,%rcx), %edi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rdi
je 0x1e398a
movq %r10, 0x10(%rsp)
leaq 0x3c(%rsp), %r11
leaq 0x54(%rsp), %r10
testq %rbx, %rbx
je 0x1e2e4d
cmpl $-0x1, 0xc(%rbx)
je 0x1e39a9
xorl %r11d, %r11d
xorl %r10d, %r10d
addq %rcx, %rax
movl 0x4(%rax), %r8d
movl 0x10(%rax), %esi
movl 0x14(%rax), %edx
movl 0x18(%rax), %ecx
movq 0x8(%rsp), %rbp
movq 0x20(%rbp), %r9
movq 0x98(%rsp), %rax
movq 0x18(%rax), %r14
movq 0x20(%r14), %rax
movl %r8d, %r15d
shrl %r15d
movl (%rax,%r15,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq $0x8, %rsp
andl $0x1, %r8d
pushq %r11
leaq 0x78(%rsp), %r11
pushq %r11
pushq %r10
leaq 0x8c(%rsp), %r10
pushq %r10
pushq %rax
callq 0x1a47b3
addq $0x30, %rsp
testq %rbx, %rbx
je 0x1e2f37
movl 0x4(%rbx), %esi
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r9d
movl 0x14(%rbx), %r8d
movl 0x18(%rbx), %edi
movq 0x20(%rbp), %r15
movq 0x20(%r14), %rdx
movl %esi, %r10d
shrl %r10d
movl (%rdx,%r10,8), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
leaq -0x1(%rdi), %r10
notq %r8
addq %rdx, %r8
testb $0x1, %sil
cmoveq %r10, %r8
movq %r15, %r10
subq %r9, %r10
movq %r8, %r11
notq %r11
addq %rdx, %r11
addl %r10d, %r8d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leal (%rax,%rdx), %ebx
addl %r11d, %r9d
cmpq %r11, %r10
cmovgl %r9d, %r15d
cmovlel %r8d, %ebx
incl %ebx
movl %r15d, 0x54(%rsp)
movl %ebx, 0x3c(%rsp)
testb $0x1, %sil
movl 0x90(%rsp), %eax
jne 0x1e2f4d
movq 0x8(%rsp), %r9
jmp 0x1e2f46
movl 0x54(%rsp), %r15d
movl 0x90(%rsp), %eax
movq %rbp, %r9
movq 0x10(%rsp), %r10
jmp 0x1e2f6e
movq %rdx, %rsi
subq %rdi, %rsi
xorl %edi, %edi
cmpq %rcx, %rsi
movq 0x10(%rsp), %r10
jl 0x1e2f63
subl %esi, %ecx
movl %ecx, %edi
addl %edx, %edi
movl %edi, 0x3c(%rsp)
movq 0x8(%rsp), %r9
movl 0x6c(%rsp), %ecx
movl %r15d, %edx
subl %ecx, %edx
cmpl %eax, %edx
jl 0x1e301d
movl 0x3c(%rsp), %esi
movl 0x68(%rsp), %edx
movl %esi, %edi
subl %edx, %edi
cmpl %eax, %edi
jl 0x1e301d
cmpq 0x18(%rsp), %r10
jne 0x1e2fe2
leaq (%r10,%r10), %rcx
testq %r10, %r10
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x18(%rsp)
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x48(%rsp), %rdi
callq 0x2370
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r9
movl 0x6c(%rsp), %ecx
movl 0x54(%rsp), %r15d
movl 0x68(%rsp), %edx
movl 0x3c(%rsp), %esi
jmp 0x1e2fe7
movq 0x48(%rsp), %rax
leaq (%r10,%r10,2), %rdi
incq %r10
shlq $0x20, %rcx
movslq %r15d, %r8
orq %rcx, %r8
movq %r8, (%rax,%rdi,8)
shlq $0x20, %rdx
movslq %esi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax,%rdi,8)
movq %r12, %rcx
orq 0x30(%rsp), %rcx
movq %rax, 0x48(%rsp)
movq %rcx, 0x10(%rax,%rdi,8)
incq %r12
movslq (%r9), %rax
addq $0x48, %r13
cmpq %rax, %r12
jb 0x1e2dd3
leaq (%r10,%r10,2), %rax
movq 0x48(%rsp), %rbx
leaq (%rbx,%rax,8), %rsi
movq %rbx, %rdi
movq %r10, 0x10(%rsp)
callq 0x1a055f
movq 0x10(%rsp), %r11
testq %r11, %r11
je 0x1e329a
leaq 0x28(%rbx), %r13
xorl %eax, %eax
movq 0x8(%rsp), %r10
leaq 0x1(%rax), %r12
cmpq %r11, %r12
movq %r13, 0xb0(%rsp)
movq %r12, 0xa8(%rsp)
jae 0x1e327d
leaq (%rax,%rax,2), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %r8
movl 0x10(%r8), %eax
movq %r8, 0x30(%rsp)
movl %eax, %ecx
leaq (%rcx,%rcx,8), %rcx
movq 0x8(%r10), %rdx
movq 0x10(%r10), %rsi
movslq 0x8(%rdx,%rcx,8), %rdi
movslq 0xc(%rdx,%rcx,8), %rcx
addq %rdi, %rcx
leaq (%rcx,%rcx,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rcx, %rdi
movl -0x18(%rsi,%rdi), %ebx
movl (%r13), %ecx
leaq (%rcx,%rcx,8), %rcx
movslq 0x8(%rdx,%rcx,8), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
movl 0x4(%rsi,%rdx), %ebp
movl %ebx, %esi
shrl %esi
movl %ebp, %ecx
shrl %ecx
cmpq %rcx, %rsi
je 0x1e31fe
movq (%r8), %rdx
movq %rdx, %r14
shrq $0x20, %r14
movq -0x10(%r13), %r15
movq %r15, %rdi
shrq $0x20, %rdi
cmpl %edx, %r15d
jl 0x1e3110
cmpl %r14d, %edi
jle 0x1e31fe
cmpl %r15d, %edx
jl 0x1e311e
cmpl %edi, %r14d
jle 0x1e31fe
movq 0x98(%rsp), %r8
movq 0x10(%r8), %r8
leaq (%rsi,%rsi,4), %r9
cmpl $0x0, (%r8,%r9,8)
js 0x1e31f9
leaq (%rcx,%rcx,4), %rsi
cmpl $0x0, (%r8,%rsi,8)
js 0x1e31f9
cmpl %r15d, %edx
cmovll %edx, %r15d
cmpl %r14d, %edi
cmovgl %edi, %r14d
movl %r15d, %ecx
subl %r14d, %ecx
movl $0x0, %edx
cmovlel %edx, %ecx
xorl %edx, %edx
testb $0x1, %bl
sete %dl
leaq (%r8,%r9,8), %rdi
movl 0x4(%rdi,%rdx,4), %edx
shrl %edx
leaq (%r8,%rsi,8), %rsi
movl %ebp, %edi
andl $0x1, %edi
movl 0x4(%rsi,%rdi,4), %esi
shrl %esi
movq 0x88(%rsp), %rdi
movq 0x20(%rdi), %rdi
movl (%rdi,%rdx,8), %edx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %edx
movl (%rdi,%rsi,8), %esi
andl %r8d, %esi
cmpl %esi, %edx
cmovbl %edx, %esi
cmpl %esi, %ecx
jge 0x1e31f9
movq 0x20(%rsp), %rax
cmpq 0x40(%rsp), %rax
jne 0x1e3210
leaq (%rax,%rax), %rdx
testq %rax, %rax
movl $0x2, %ecx
cmoveq %rcx, %rdx
movq %rax, 0x20(%rsp)
movq %rdx, 0x40(%rsp)
leaq (,%rdx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x28(%rsp), %rdi
callq 0x2370
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %r10
jmp 0x1e3218
movq 0x30(%rsp), %r8
incq %r12
addq $0x18, %r13
cmpq %r11, %r12
jb 0x1e3096
jmp 0x1e327d
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq 0x30(%rsp), %r8
leaq (%rcx,%rcx,2), %rcx
subl %r15d, %r14d
movq %rax, 0x28(%rsp)
movl %r14d, 0x10(%rax,%rcx,8)
cmpl %ebp, %ebx
jae 0x1e323b
shlq $0x20, %rbx
orq %rbp, %rbx
jmp 0x1e324e
shlq $0x20, %rbp
orq %rbx, %rbp
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x2(%rax), %rbx
xorq %rbp, %rbx
incq 0x20(%rsp)
movq 0x28(%rsp), %rax
leaq (%rax,%rcx,8), %rcx
movq %rbx, (%rcx)
movl 0x18(%r10), %eax
movl %eax, 0x14(%rcx)
movq 0x10(%r8), %rdx
movl %edx, %eax
shlq $0x20, %rdx
movl (%r13), %esi
orq %rdx, %rsi
movq %rsi, 0x8(%rcx)
jmp 0x1e31fe
movq 0xb0(%rsp), %r13
addq $0x18, %r13
movq 0xa8(%rsp), %rax
cmpq %r11, %rax
jne 0x1e3063
movq 0x28(%rsp), %r12
movq 0x58(%rsp), %rbx
movq 0x78(%rsp), %rdx
incq %rdx
cmpq (%rbx), %rdx
jb 0x1e2d87
movapd 0xc0(%rsp), %xmm1
unpcklps 0x4dfbb(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4dfc3(%rip), %xmm1    # 0x231290
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x70(%rsp), %xmm0
maxsd 0x57f79(%rip), %xmm0    # 0x23b260
cvttsd2si %xmm0, %rax
movq %rax, 0x10(%rsp)
movq 0xb1ce8(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
leaq 0x61370(%rip), %rsi     # 0x244672
movq $0x0, 0x18(%rsp)
movq 0x20(%rsp), %rbx
movl %ebx, %edx
xorl %eax, %eax
callq 0x22b0
leaq (%rbx,%rbx,2), %rax
leaq (%r12,%rax,8), %rsi
movq %r12, %rdi
callq 0x1a079e
movl $0x0, %ecx
movq %rcx, 0x40(%rsp)
testq %rbx, %rbx
je 0x1e37d9
movq %rbx, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x28(%r12), %rdx
movq %rdx, 0x78(%rsp)
leaq 0x10(%r12), %rbx
movl $0x1, %ebp
movq $0x0, 0x40(%rsp)
incq %rcx
movq %rcx, 0xc0(%rsp)
movq $0x0, 0x70(%rsp)
movq $0x0, 0x18(%rsp)
xorl %r13d, %r13d
movq %r12, 0x28(%rsp)
movq %rbx, 0x58(%rsp)
cmpq %rax, %rbp
je 0x1e33b9
leaq (,%rbp,2), %rax
addq %rbp, %rax
movq (%r12,%rax,8), %rax
leaq (,%r13,2), %rcx
addq %r13, %rcx
cmpq (%r12,%rcx,8), %rax
movq 0x20(%rsp), %rax
je 0x1e37cd
movq %rbp, %rcx
subq %r13, %rcx
cmpq 0x10(%rsp), %rcx
jae 0x1e33ce
movq %rbp, %r13
jmp 0x1e37cd
movq %rcx, 0x30(%rsp)
leaq 0x1(%r13), %rdx
cmpq %rbp, %rdx
movq %rdx, 0x90(%rsp)
jae 0x1e3422
leaq (,%r13,2), %rax
addq %r13, %rax
movq 0x78(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rdx, %rcx
movl %r13d, %esi
movslq %esi, %rdx
leaq (%rdx,%rdx,2), %rdx
movl 0x10(%r12,%rdx,8), %edi
movl %ecx, %edx
cmpl (%rax), %edi
jg 0x1e3412
movl %esi, %edx
incq %rcx
addq $0x18, %rax
movl %edx, %esi
cmpq %rbp, %rcx
jb 0x1e33fe
jmp 0x1e3425
movl %r13d, %edx
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
movl 0x10(%r12,%rax,8), %r14d
movl %r14d, %eax
negl %eax
sarl $0x1f, %r14d
andl %eax, %r14d
setne %al
cmpq %r13, %rbp
seta %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1e346e
leaq (,%r13,2), %rax
addq %r13, %rax
leaq (%rbx,%rax,8), %rax
movq %r13, %rcx
addl %r14d, (%rax)
incq %rcx
addq $0x18, %rax
cmpq %rcx, %rbp
jne 0x1e345f
leaq (,%r13,2), %r15
addq %r13, %r15
leaq (%r12,%r15,8), %rdi
leaq (,%rbp,2), %rax
addq %rbp, %rax
leaq (%r12,%rax,8), %rsi
movq %rdi, 0x8(%rsp)
callq 0x1a0a0d
movq %rbp, %rax
movq $0x0, 0xe0(%rsp)
movq %r13, 0xa8(%rsp)
subq %r13, %rax
movq %rax, 0xb0(%rsp)
jbe 0x1e37c5
movq %rbp, 0x88(%rsp)
leaq (%rbx,%r15,8), %rbp
xorl %r13d, %r13d
leaq 0x38(%rsp), %r10
movl (%rbp), %eax
subl %r14d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0xd8(%rsp), %xmm0
cvttsd2si %xmm0, %r12d
cmpl 0x64(%rsp), %r12d
jg 0x1e3500
movl 0x64(%rsp), %r12d
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl %r13d, %edx
movl %r12d, %ecx
movq 0x10(%rsp), %rbx
movl %ebx, %r8d
leaq 0xbc(%rsp), %r9
leaq 0xe0(%rsp), %rax
pushq %rax
pushq %r10
callq 0x1e2a5d
addq $0x10, %rsp
movl %eax, %r15d
cltq
cmpq %rax, %rbx
jle 0x1e3577
incq %r13
addq $0x18, %rbp
cmpq %r13, 0xb0(%rsp)
leaq 0x38(%rsp), %r10
jne 0x1e34d2
movq 0x88(%rsp), %rbp
movq %rbp, %r13
movq 0x28(%rsp), %r12
movq 0x20(%rsp), %rax
movq 0x58(%rsp), %rbx
jmp 0x1e37cd
movslq 0x38(%rsp), %rdx
incq %rdx
movq 0x88(%rsp), %rbp
cmpq %rdx, %rbp
jbe 0x1e35e4
movq 0x8(%rsp), %r13
movq 0x30(%rsp), %rbx
movq 0x90(%rsp), %r14
subl 0xa8(%rsp), %edx
movq %r13, %rdi
movl %ebx, %esi
movl %r12d, %ecx
movl %r15d, %r8d
leaq 0xbc(%rsp), %r9
leaq 0xe0(%rsp), %rax
pushq %rax
leaq 0x40(%rsp), %rax
pushq %rax
callq 0x1e2a5d
addq $0x10, %rsp
cmpl %r15d, %eax
cmovgl %eax, %r15d
movslq 0x38(%rsp), %rdx
addq %r14, %rdx
cmpq %rbp, %rdx
jb 0x1e359e
movq 0x40(%rsp), %r13
cmpq 0x70(%rsp), %r13
jne 0x1e3626
leaq (,%r13,2), %rcx
testq %r13, %r13
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x70(%rsp)
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x18(%rsp), %rdi
callq 0x2370
movq 0x28(%rsp), %r12
jmp 0x1e3630
movq 0x28(%rsp), %r12
movq 0x18(%rsp), %rax
movq 0x58(%rsp), %rbx
movq 0x8(%rsp), %r9
leaq (,%r13,2), %rdx
addq %r13, %rdx
movslq %r15d, %rcx
movq %rcx, (%rax,%rdx,8)
movq (%r9), %r14
movq %r14, 0x8(%rax,%rdx,8)
movq 0xa0(%rsp), %r15
movl 0x4(%r15), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
cmpl (%r15), %ecx
movq %rax, 0x18(%rsp)
jne 0x1e36aa
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
movl $0x10, %ecx
cmovel %ecx, %eax
movl %eax, (%r15)
movq 0x8(%r15), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq 0x8(%rsp), %r9
movq %rax, 0x8(%r15)
movl 0x4(%r15), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x1e36ae
movq 0x8(%r15), %rax
movq %r14, %rsi
leal 0x1(%rdx), %edi
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andl %r8d, %edi
andl $0x80000000, %edx       # imm = 0x80000000
orl %edi, %edx
movl %edx, 0x4(%r15)
movl %ecx, %ecx
leaq (%rcx,%rcx,2), %rcx
movb $0x0, 0x12(%rax,%rcx,8)
andb $0x3f, 0x11(%rax,%rcx,8)
shrq $0x21, %rsi
movl $0x0, 0xc(%rax,%rcx,8)
movl %r14d, 0x8(%rax,%rcx,8)
movabsq $-0x100000000, %rdx     # imm = 0xFFFFFFFF00000000
andq %rdx, %r14
movq %r14, (%rax,%rcx,8)
movq 0x20(%r15), %rdx
movl (%rdx,%rsi,8), %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
orq %r14, %rdx
movq %rdx, (%rax,%rcx,8)
movq (%r9), %r14
movl 0x4(%r15), %edx
movl %edx, %ecx
andl %r8d, %ecx
cmpl (%r15), %ecx
jne 0x1e3753
leal (%rcx,%rcx), %eax
testl %ecx, %ecx
movl $0x10, %ecx
cmovel %ecx, %eax
movl %eax, (%r15)
movq 0x8(%r15), %rdi
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x2370
movq %rax, 0x8(%r15)
movl 0x4(%r15), %edx
movl %edx, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
jmp 0x1e3757
movq 0x8(%r15), %rax
incq %r13
movq %r13, 0x40(%rsp)
leal 0x1(%rdx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %edx       # imm = 0x80000000
orl %esi, %edx
movl %edx, 0x4(%r15)
movl %ecx, %ecx
leaq (%rcx,%rcx,2), %rcx
movb $0x0, 0x12(%rax,%rcx,8)
andb $0x3f, 0x11(%rax,%rcx,8)
movq %r14, %rdx
shrq $0x20, %rdx
movl $0x0, 0xc(%rax,%rcx,8)
xorl $0x1, %edx
movl %edx, 0x8(%rax,%rcx,8)
movq %r14, %rdx
shlq $0x20, %rdx
xorq 0xc0(%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x20(%r15), %rsi
shrl %r14d
movl (%rsi,%r14,8), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
orq %rdx, %rsi
movq %rsi, (%rax,%rcx,8)
movq %rbp, %r13
movq 0x20(%rsp), %rax
incq %rbp
cmpq %rax, %rbp
jbe 0x1e338b
movq 0xa0(%rsp), %rbx
andb $0x7f, 0x7(%rbx)
movq $0x0, 0x28(%rbx)
movq %rbx, %rdi
callq 0xa0a7d
movq %rbx, %rdi
callq 0x25b4e
movq 0xb17dc(%rip), %rax     # 0x294fe0
movq (%rax), %rdi
leaq 0x60e6e(%rip), %rsi     # 0x24467c
leaq 0x60e80(%rip), %rdx     # 0x244695
movq 0x80(%rsp), %rcx
xorl %eax, %eax
callq 0x22b0
movq 0x40(%rsp), %r13
leaq (,%r13,2), %rax
addq %r13, %rax
movq 0x18(%rsp), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x1a079e
testl %r13d, %r13d
jle 0x1e3923
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
leaq (,%r13,2), %rax
addq %r13, %rax
incq %r13
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
addq $-0x10, %r14
leaq 0x50ec7(%rip), %r15     # 0x23473b
leaq 0x60e23(%rip), %rbx     # 0x24469e
movq (%r14), %rax
movq 0x98(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq 0x28(%rcx), %rcx
movl %eax, %edx
xorq $0x1, %rdx
cmpl $0x0, (%rcx,%rdx,8)
movl $0x0, %r10d
jne 0x1e38b2
movq %rax, %rdx
shrq $0x20, %rdx
xorl %r10d, %r10d
cmpl $0x0, (%rcx,%rdx,8)
sete %r10b
movq 0xb1727(%rip), %rcx     # 0x294fe0
movq (%rcx), %rdi
movq %rax, %rcx
shrq $0x21, %rcx
leal 0x1(%rcx), %edx
leaq (%rcx,%rcx,4), %rcx
movq 0x98(%rsp), %rsi
movq 0x10(%rsi), %rsi
movl (%rsi,%rcx,8), %ecx
shrl $0x1f, %ecx
movsbl (%rcx,%r15), %ecx
shrl %eax
leal 0x1(%rax), %r8d
leaq (%rax,%rax,4), %rax
movl (%rsi,%rax,8), %eax
shrl $0x1f, %eax
movsbl (%rax,%r15), %r9d
subq $0x8, %rsp
movq %rbx, %rsi
xorl %eax, %eax
pushq %r10
pushq 0x20(%rsp)
pushq -0x8(%r14)
callq 0x22b0
addq $0x20, %rsp
decq %r13
addq $-0x18, %r14
cmpq $0x1, %r13
ja 0x1e387b
movq 0x48(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
callq 0x2220
movq 0xf0(%rsp), %rdi
callq 0x2220
movq 0x18(%rsp), %rdi
callq 0x2220
movq 0xa0(%rsp), %rdi
callq 0xa0494
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5c687(%rip), %rdi     # 0x23fff9
leaq 0x5c2e2(%rip), %rsi     # 0x23fc5b
leaq 0x60c61(%rip), %rcx     # 0x2445e1
movl $0x4fa4, %edx           # imm = 0x4FA4
callq 0x2110
leaq 0x60cb3(%rip), %rdi     # 0x244644
leaq 0x5c2c3(%rip), %rsi     # 0x23fc5b
leaq 0x60c42(%rip), %rcx     # 0x2445e1
movl $0x4fa6, %edx           # imm = 0x4FA6
callq 0x2110
leaq 0x60cab(%rip), %rdi     # 0x24465b
leaq 0x5c2a4(%rip), %rsi     # 0x23fc5b
leaq 0x60c23(%rip), %rcx     # 0x2445e1
movl $0x4fa7, %edx           # imm = 0x4FA7
callq 0x2110