// File: /workspace/github_cpp_makefile_star2_O1/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 $0xf8, %rsp
movl %r9d, 0x90(%rsp)
movl %r8d, 0x68(%rsp)
movsd %xmm1, 0xc8(%rsp)
movsd %xmm0, 0x78(%rsp)
movq %rcx, 0x60(%rsp)
movq %rsi, %rbx
movsd 0x8(%rdi), %xmm0
movaps %xmm0, 0xb0(%rsp)
movq %rdx, 0x98(%rsp)
movq 0x18(%rdx), %rdi
callq 0xc802c
movq %rax, %rbp
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movq $0x0, 0xe0(%rsp)
cmpq $0x0, (%rbx)
movq %rax, 0x50(%rsp)
jne 0x1d8c7e
movq $0x0, 0x80(%rsp)
movq $0x0, 0x38(%rsp)
xorl %r14d, %r14d
movq $0x0, 0x30(%rsp)
jmp 0x1d91f1
movq $0x0, 0x30(%rsp)
movq $0x0, 0x88(%rsp)
xorl %r14d, %r14d
movq $0x0, 0x58(%rsp)
movq $0x0, 0x38(%rsp)
xorl %edx, %edx
movq $0x0, 0x80(%rsp)
movq %rbx, 0x48(%rsp)
movq 0x10(%rbx), %rax
leaq (%rdx,%rdx,4), %rcx
cmpl $0x2, (%rax,%rcx,8)
jl 0x1d91e5
movq %r14, (%rsp)
leaq (%rax,%rcx,8), %r9
cmpl $0x0, (%r9)
movq %r9, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
je 0x1d8f46
movq %rdx, %rbp
shlq $0x20, %rbp
movl $0xc, %r13d
movq $0x0, 0x18(%rsp)
xorl %r14d, %r14d
movq 0x8(%r9), %rcx
movslq (%rcx,%r13), %rdx
testq %rdx, %rdx
jle 0x1d9866
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 0x1d9885
leaq 0x2c(%rsp), %r11
leaq 0x44(%rsp), %r10
testq %rbx, %rbx
je 0x1d8d77
cmpl $-0x1, 0xc(%rbx)
je 0x1d98a4
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 0x20(%r9), %r9
movq 0x98(%rsp), %rax
movq 0x18(%rax), %r15
movq 0x20(%r15), %rax
movl %r8d, %r12d
shrl %r12d
movl (%rax,%r12,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
subq $0x8, %rsp
andl $0x1, %r8d
pushq %r11
leaq 0x80(%rsp), %r11
pushq %r11
pushq %r10
leaq 0x94(%rsp), %r10
pushq %r10
pushq %rax
callq 0x19bb76
addq $0x30, %rsp
testq %rbx, %rbx
je 0x1d8e69
movl 0x4(%rbx), %edx
movl 0xc(%rbx), %eax
movl 0x10(%rbx), %r9d
movl 0x14(%rbx), %r8d
movl 0x18(%rbx), %esi
movq 0x10(%rsp), %rcx
movq 0x20(%rcx), %rdi
movq 0x20(%r15), %rcx
movl %edx, %r10d
shrl %r10d
movl (%rcx,%r10,8), %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
leaq -0x1(%rsi), %r10
notq %r8
addq %rcx, %r8
testb $0x1, %dl
cmoveq %r10, %r8
movq %rdi, %r10
subq %r9, %r10
movq %r8, %r11
notq %r11
addq %rcx, %r11
addl %r10d, %r8d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
addl %ecx, %ebx
addl %r11d, %r9d
cmpq %r11, %r10
cmovgl %r9d, %edi
cmovlel %r8d, %ebx
incl %ebx
movl %edi, 0x44(%rsp)
movl %ebx, 0x2c(%rsp)
testb $0x1, %dl
je 0x1d8e69
movq %rcx, %rdx
subq %rsi, %rdx
xorl %esi, %esi
cmpq %rax, %rdx
jl 0x1d8e63
subl %edx, %eax
movl %eax, %esi
addl %ecx, %esi
movl %esi, 0x2c(%rsp)
movl 0x44(%rsp), %eax
subl 0x74(%rsp), %eax
movl 0x90(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1d8e86
movq 0x10(%rsp), %r9
jmp 0x1d8f31
movl 0x2c(%rsp), %eax
subl 0x70(%rsp), %eax
cmpl %ecx, %eax
movq 0x10(%rsp), %r9
jl 0x1d8f31
movq 0x58(%rsp), %rax
cmpq %rax, 0x18(%rsp)
jne 0x1d8ed9
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x38(%rsp), %rdi
callq 0x2370
movq 0x10(%rsp), %r9
movq %rbx, 0x58(%rsp)
jmp 0x1d8ede
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rcx,2), %rsi
incq %rcx
movq %rcx, 0x18(%rsp)
movl 0x74(%rsp), %ecx
shlq $0x20, %rcx
movq %rcx, (%rax,%rsi,8)
movslq 0x44(%rsp), %rdx
orq %rcx, %rdx
movq %rdx, (%rax,%rsi,8)
movl 0x70(%rsp), %ecx
shlq $0x20, %rcx
movq %rcx, 0x8(%rax,%rsi,8)
movslq 0x2c(%rsp), %rdx
orq %rcx, %rdx
movq %rdx, 0x8(%rax,%rsi,8)
movq %r14, %rcx
orq %rbp, %rcx
movq %rax, 0x38(%rsp)
movq %rcx, 0x10(%rax,%rsi,8)
incq %r14
movslq (%r9), %rax
addq $0x48, %r13
cmpq %rax, %r14
jb 0x1d8d02
jmp 0x1d8f4f
movq $0x0, 0x18(%rsp)
movq 0x80(%rsp), %rax
incl %eax
movq %rax, 0x80(%rsp)
movq 0x18(%rsp), %r14
leaq (%r14,%r14,2), %rax
movq 0x38(%rsp), %rbx
leaq (%rbx,%rax,8), %rsi
movq %rbx, %rdi
callq 0x1977d2
testq %r14, %r14
je 0x1d91d2
movq %r14, %r9
leaq 0x28(%rbx), %r10
xorl %r11d, %r11d
movq 0x10(%rsp), %r8
movq %r11, %rax
incq %r11
cmpq %r9, %r11
jae 0x1d91b0
leaq (%rax,%rax,2), %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax,8), %rdi
movq %r10, %r14
movq %r11, %r13
movq %rdi, 0x20(%rsp)
movl 0x10(%rdi), %eax
leaq (%rax,%rax,8), %rax
movq 0x8(%r8), %rcx
movq 0x10(%r8), %rdx
movslq 0x8(%rcx,%rax,8), %rsi
movslq 0xc(%rcx,%rax,8), %rax
addq %rsi, %rax
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
movl -0x18(%rdx,%rsi), %ebp
movl (%r14), %eax
leaq (%rax,%rax,8), %rax
movslq 0x8(%rcx,%rax,8), %rax
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rax, %rcx
movl 0x4(%rdx,%rcx), %r12d
movl %ebp, %edx
shrl %edx
movl %r12d, %eax
shrl %eax
cmpq %rax, %rdx
je 0x1d9130
movq (%rdi), %rcx
movq %rcx, %r15
shrq $0x20, %r15
movq -0x10(%r14), %rbx
movq %rbx, %rsi
shrq $0x20, %rsi
cmpl %ecx, %ebx
jl 0x1d9035
cmpl %r15d, %esi
jle 0x1d9130
cmpl %ebx, %ecx
jl 0x1d9042
cmpl %esi, %r15d
jle 0x1d9130
movq 0x98(%rsp), %rdi
movq 0x10(%rdi), %rdi
leaq (%rdx,%rdx,4), %rdx
cmpl $0x0, (%rdi,%rdx,8)
js 0x1d912b
leaq (%rax,%rax,4), %rax
cmpl $0x0, (%rdi,%rax,8)
js 0x1d912b
cmpl %ebx, %ecx
cmovll %ecx, %ebx
cmpl %r15d, %esi
cmovgl %esi, %r15d
movl %ebx, %esi
subl %r15d, %esi
movl $0x0, %ecx
cmovlel %ecx, %esi
xorl %ecx, %ecx
testb $0x1, %bpl
sete %cl
leaq (%rdi,%rdx,8), %rdx
movl 0x4(%rdx,%rcx,4), %ecx
shrl %ecx
leaq (%rdi,%rax,8), %rax
movl %r12d, %edx
andl $0x1, %edx
movl 0x4(%rax,%rdx,4), %eax
shrl %eax
movq 0x60(%rsp), %rdx
movq 0x20(%rdx), %rdx
movl (%rdx,%rcx,8), %ecx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %ecx
movl (%rdx,%rax,8), %eax
andl %edi, %eax
cmpl %eax, %ecx
cmovbl %ecx, %eax
movl %esi, 0x6c(%rsp)
cmpl %eax, %esi
jge 0x1d912b
movq 0x88(%rsp), %rax
cmpq %rax, 0x30(%rsp)
jne 0x1d9142
leaq (%rax,%rax), %rcx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rcx
movq %rcx, 0x88(%rsp)
leaq (,%rcx,8), %rax
leaq (%rax,%rax,2), %rsi
movq (%rsp), %rdi
movq %r10, (%rsp)
movq %r11, 0xa0(%rsp)
callq 0x2370
movq 0xa0(%rsp), %r11
movq (%rsp), %r10
movq 0x18(%rsp), %r9
movq 0x10(%rsp), %r8
jmp 0x1d9146
movq 0x20(%rsp), %rdi
incq %r13
addq $0x18, %r14
cmpq %r9, %r13
jb 0x1d8fba
jmp 0x1d91b0
movq (%rsp), %rax
movq 0x20(%rsp), %rdi
movq 0x30(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
subl %ebx, %r15d
movq %rax, (%rsp)
movl %r15d, 0x10(%rax,%rcx,8)
cmpl %r12d, %ebp
jae 0x1d916e
shlq $0x20, %rbp
orq %r12, %rbp
jmp 0x1d9181
shlq $0x20, %r12
orq %rbp, %r12
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x2(%rax), %rbp
xorq %r12, %rbp
incq 0x30(%rsp)
movq (%rsp), %rax
leaq (%rax,%rcx,8), %rax
movq %rbp, (%rax)
movl 0x18(%r8), %ecx
movl %ecx, 0x14(%rax)
movq 0x10(%rdi), %rcx
shlq $0x20, %rcx
movq %rcx, 0x8(%rax)
movl (%r14), %edx
orq %rcx, %rdx
movq %rdx, 0x8(%rax)
jmp 0x1d9130
addq $0x18, %r10
cmpq %r9, %r11
jne 0x1d8f93
movq 0x50(%rsp), %rbp
movq (%rsp), %r14
movq 0x48(%rsp), %rbx
movq 0x8(%rsp), %rdx
jmp 0x1d91e5
movq (%rsp), %r14
movq 0x48(%rsp), %rbx
movq 0x8(%rsp), %rdx
movq 0x50(%rsp), %rbp
incq %rdx
cmpq (%rbx), %rdx
jb 0x1d8cbb
movapd 0xb0(%rsp), %xmm1
unpcklps 0x4c03f(%rip), %xmm1    # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x4c047(%rip), %xmm1    # 0x225250
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x78(%rsp), %xmm0
maxsd 0x55ded(%rip), %xmm0    # 0x22f010
cvttsd2si %xmm0, %rax
movq %rax, 0x20(%rsp)
movq 0xb0dac(%rip), %rax     # 0x289fe0
movq (%rax), %rdi
leaq 0x5f164(%rip), %rsi     # 0x2383a2
movq $0x0, 0x8(%rsp)
movq 0x30(%rsp), %rbx
movl %ebx, %edx
xorl %eax, %eax
callq 0x22b0
leaq (%rbx,%rbx,2), %rax
leaq (%r14,%rax,8), %rsi
movq %r14, %rdi
callq 0x197a14
movl $0x0, %r12d
testq %rbx, %rbx
movq %r14, (%rsp)
je 0x1d96f3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x28(%r14), %rcx
movq %rcx, 0xc0(%rsp)
leaq 0x10(%r14), %rcx
movq %rcx, 0x48(%rsp)
movl $0x1, %r13d
xorl %r12d, %r12d
incq %rax
movq %rax, 0xb0(%rsp)
movq $0x0, 0x78(%rsp)
movq $0x0, 0x8(%rsp)
xorl %r15d, %r15d
cmpq %rbx, %r13
je 0x1d92e2
leaq (,%r13,2), %rax
addq %r13, %rax
movq (%r14,%rax,8), %rax
leaq (%r15,%r15,2), %rcx
cmpq (%r14,%rcx,8), %rax
movq 0x30(%rsp), %rbx
je 0x1d96e7
movq %r13, %rax
subq %r15, %rax
cmpq 0x20(%rsp), %rax
jae 0x1d92f7
movq %r13, %r15
jmp 0x1d96e7
movq %rax, 0x18(%rsp)
leaq 0x1(%r15), %rbp
cmpq %r13, %rbp
jae 0x1d933f
leaq (%r15,%r15,2), %rax
movq 0xc0(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %rbp, %rcx
movl %r15d, %esi
movslq %esi, %rdx
leaq (%rdx,%rdx,2), %rdx
movl 0x10(%r14,%rdx,8), %edi
movl %ecx, %edx
cmpl (%rax), %edi
jg 0x1d932f
movl %esi, %edx
incq %rcx
addq $0x18, %rax
movl %edx, %esi
cmpq %r13, %rcx
jb 0x1d931b
jmp 0x1d9342
movl %r15d, %edx
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
movl 0x10(%r14,%rax,8), %edx
movl %edx, %eax
negl %eax
sarl $0x1f, %edx
andl %eax, %edx
setne %al
cmpq %r15, %r13
seta %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x1d9385
leaq (%r15,%r15,2), %rax
movq 0x48(%rsp), %rcx
leaq (%rcx,%rax,8), %rax
movq %r15, %rcx
addl %edx, (%rax)
incq %rcx
addq $0x18, %rax
cmpq %rcx, %r13
jne 0x1d9377
movl %edx, 0x60(%rsp)
movq %r12, 0x58(%rsp)
leaq (%r15,%r15,2), %r14
movq (%rsp), %rcx
leaq (%rcx,%r14,8), %rdi
leaq (,%r13,2), %rax
addq %r13, %rax
leaq (%rcx,%rax,8), %rsi
movq %rdi, 0x10(%rsp)
callq 0x197c87
movq $0x0, 0xd0(%rsp)
movq %r15, %rax
xorl %r15d, %r15d
movq %r13, %rcx
movq %rax, 0x90(%rsp)
subq %rax, %rcx
movq %rcx, 0x88(%rsp)
seta %bl
jbe 0x1d9498
movq %rbp, 0xa0(%rsp)
movq 0x48(%rsp), %rax
leaq (%rax,%r14,8), %r14
xorl %r12d, %r12d
movq %r13, %rbp
movl (%r14), %eax
subl 0x60(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
mulsd 0xc8(%rsp), %xmm0
cvttsd2si %xmm0, %ecx
cmpl 0x68(%rsp), %ecx
jg 0x1d9427
movl 0x68(%rsp), %ecx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl %r12d, %edx
movl %ecx, 0x6c(%rsp)
movq 0x20(%rsp), %r13
movl %r13d, %r8d
leaq 0xac(%rsp), %r9
leaq 0xd0(%rsp), %rax
pushq %rax
leaq 0x48(%rsp), %rax
pushq %rax
callq 0x1d8998
addq $0x10, %rsp
movl %eax, %r15d
cltq
cmpq %rax, %r13
jle 0x1d9495
movq 0xa0(%rsp), %rax
addq %r12, %rax
movq %rbp, %r13
cmpq %rbp, %rax
setb %bl
incq %r12
addq $0x18, %r14
cmpq %r12, 0x88(%rsp)
jne 0x1d93f8
jmp 0x1d9498
movq %rbp, %r13
testb $0x1, %bl
je 0x1d9551
movslq 0x40(%rsp), %rdx
incq %rdx
cmpq %rdx, %r13
jbe 0x1d9515
movq 0x90(%rsp), %rax
incq %rax
movq %rax, 0x60(%rsp)
leaq 0x40(%rsp), %r14
leaq 0xac(%rsp), %rbx
movq 0x10(%rsp), %r12
movq 0x18(%rsp), %rbp
subl 0x90(%rsp), %edx
movq %r12, %rdi
movl %ebp, %esi
movl 0x6c(%rsp), %ecx
movl %r15d, %r8d
movq %rbx, %r9
leaq 0xd0(%rsp), %rax
pushq %rax
pushq %r14
callq 0x1d8998
addq $0x10, %rsp
cmpl %r15d, %eax
cmovgl %eax, %r15d
movslq 0x40(%rsp), %rdx
addq 0x60(%rsp), %rdx
cmpq %r13, %rdx
jb 0x1d94d5
movq 0x58(%rsp), %r12
movq 0x78(%rsp), %rax
cmpq %rax, %r12
jne 0x1d956c
leaq (%rax,%rax), %rbx
testq %rax, %rax
movl $0x2, %eax
cmoveq %rax, %rbx
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rsi
movq 0x8(%rsp), %rdi
callq 0x2370
movq %rbx, 0x78(%rsp)
jmp 0x1d9571
movq %r13, %r15
movq 0x50(%rsp), %rbp
movq (%rsp), %r14
movq 0x30(%rsp), %rbx
movq 0x58(%rsp), %r12
jmp 0x1d96e7
movq 0x8(%rsp), %rax
movq 0x50(%rsp), %rbp
movq (%rsp), %r14
leaq (%r12,%r12,2), %rdx
movslq %r15d, %rcx
movq %rcx, (%rax,%rdx,8)
movq 0x10(%rsp), %r15
movq (%r15), %rbx
movq %rax, 0x8(%rsp)
movq %rbx, 0x8(%rax,%rdx,8)
movl 0x4(%rbp), %ecx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andl %eax, %ecx
movl (%rbp), %eax
cmpl %eax, %ecx
jne 0x1d95cd
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%rbp)
movq 0x8(%rbp), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x8(%rbp)
movq 0x8(%rbp), %rax
movl 0x4(%rbp), %ecx
movq %rcx, %rdx
movl $0x7fffffff, %r8d       # imm = 0x7FFFFFFF
andq %r8, %rdx
leal 0x1(%rcx), %esi
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andl %edi, %esi
andl $0x80000000, %ecx       # imm = 0x80000000
orl %esi, %ecx
movl %ecx, 0x4(%rbp)
leaq (%rdx,%rdx,2), %rcx
movb $0x0, 0x12(%rax,%rcx,8)
andb $0x3f, 0x11(%rax,%rcx,8)
movq %rbx, %rdx
shrq $0x21, %rdx
movl $0x0, 0xc(%rax,%rcx,8)
movl %ebx, 0x8(%rax,%rcx,8)
movabsq $-0x100000000, %rsi     # imm = 0xFFFFFFFF00000000
andq %rsi, %rbx
movq %rbx, (%rax,%rcx,8)
movq 0x20(%rbp), %rsi
movl (%rsi,%rdx,8), %edx
andq %r8, %rdx
orq %rbx, %rdx
movq %rdx, (%rax,%rcx,8)
movq (%r15), %rbx
movl 0x4(%rbp), %ecx
andl %edi, %ecx
movl (%rbp), %eax
cmpl %eax, %ecx
jne 0x1d966c
leal (%rax,%rax), %ecx
testl %eax, %eax
movl $0x10, %eax
cmovel %eax, %ecx
movl %ecx, (%rbp)
movq 0x8(%rbp), %rdi
shlq $0x3, %rcx
leaq (%rcx,%rcx,2), %rsi
callq 0x2370
movq %rax, 0x8(%rbp)
incq %r12
movq 0x8(%rbp), %rax
movl 0x4(%rbp), %ecx
movq %rcx, %rdx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
andq %rdi, %rdx
leal 0x1(%rcx), %esi
andl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %esi, %ecx
movl %ecx, 0x4(%rbp)
leaq (%rdx,%rdx,2), %rcx
movb $0x0, 0x12(%rax,%rcx,8)
andb $0x3f, 0x11(%rax,%rcx,8)
movq %rbx, %rdx
shrq $0x20, %rdx
movl $0x0, 0xc(%rax,%rcx,8)
xorl $0x1, %edx
movl %edx, 0x8(%rax,%rcx,8)
movq %rbx, %rdx
shlq $0x20, %rdx
xorq 0xb0(%rsp), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x20(%rbp), %rsi
shrl %ebx
movl (%rsi,%rbx,8), %esi
andq %rdi, %rsi
orq %rdx, %rsi
movq %rsi, (%rax,%rcx,8)
movq %r13, %r15
movq 0x30(%rsp), %rbx
incq %r13
cmpq %rbx, %r13
jbe 0x1d92bb
andb $0x7f, 0x7(%rbp)
movq $0x0, 0x28(%rbp)
movq %rbp, %rdi
callq 0xa02fa
movq %rbp, %rdi
callq 0x269c8
movq 0xb08ca(%rip), %rax     # 0x289fe0
movq (%rax), %rdi
leaq 0x5ec8c(%rip), %rsi     # 0x2383ac
leaq 0x5ec9e(%rip), %rdx     # 0x2383c5
movq 0x80(%rsp), %rcx
xorl %eax, %eax
callq 0x22b0
leaq (%r12,%r12,2), %rax
movq 0x8(%rsp), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x197a14
testl %r12d, %r12d
jle 0x1d9822
andl $0x7fffffff, %r12d      # imm = 0x7FFFFFFF
leaq (%r12,%r12,2), %rax
incq %r12
movq 0x8(%rsp), %rcx
leaq (%rcx,%rax,8), %r14
addq $-0x10, %r14
leaq 0x4eeb8(%rip), %r15     # 0x22862b
leaq 0x5ec54(%rip), %rbx     # 0x2383ce
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 0x1d97b1
movq %rax, %rdx
shrq $0x20, %rdx
xorl %r10d, %r10d
cmpl $0x0, (%rcx,%rdx,8)
sete %r10b
movq 0xb0828(%rip), %rcx     # 0x289fe0
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 0x30(%rsp)
pushq -0x8(%r14)
callq 0x22b0
addq $0x20, %rsp
decq %r12
addq $-0x18, %r14
cmpq $0x1, %r12
jg 0x1d977a
movq 0x38(%rsp), %rdi
callq 0x2220
movq (%rsp), %rdi
callq 0x2220
movq 0xe0(%rsp), %rdi
callq 0x2220
movq 0x8(%rsp), %rdi
callq 0x2220
movq %rbp, %rdi
callq 0x9fcdb
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5a4bc(%rip), %rdi     # 0x233d29
leaq 0x5a117(%rip), %rsi     # 0x23398b
leaq 0x5ea96(%rip), %rcx     # 0x238311
movl $0x4fa4, %edx           # imm = 0x4FA4
callq 0x2110
leaq 0x5eae8(%rip), %rdi     # 0x238374
leaq 0x5a0f8(%rip), %rsi     # 0x23398b
leaq 0x5ea77(%rip), %rcx     # 0x238311
movl $0x4fa6, %edx           # imm = 0x4FA6
callq 0x2110
leaq 0x5eae0(%rip), %rdi     # 0x23838b
leaq 0x5a0d9(%rip), %rsi     # 0x23398b
leaq 0x5ea58(%rip), %rcx     # 0x238311
movl $0x4fa7, %edx           # imm = 0x4FA7
callq 0x2110