// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/inter.cpp
// Function: gl_chain_advance(kv_ul_ov_t*, ul_ov_t*, ul_idx_t const*, ug_opt_t const*, long, double, long, long, unsigned long*, unsigned long*, unsigned long*, long, unsigned long, All_reads*, ma_ug_t*, long, void*)
int64_t gl_chain_advance(kv_ul_ov_t *res, ul_ov_t *ex, const ul_idx_t *uref, const ug_opt_t *uopt, int64_t bw, 
double diff_ec_ul, int64_t qlen, int64_t max_skip, uint64_t *srt, uint64_t *idx, uint64_t *track, int64_t trans_sc, 
uint64_t mode, All_reads *ridx, ma_ug_t *ug, int64_t debug_i, void *km)
{
	// fprintf(stderr, "\n+++[M::%s] res->n:%u\n", __func__, (uint32_t)res->n);
	if(res->n == 0) return 0;
	uint32_t li_v, lj_v, rev_n;
	int64_t mm_ovlp, x, i, j, k, sc, csc, mm_sc, mm_idx, qo, share, n_el = 0;
	ul_ov_t *li = NULL, *lj = NULL, rev_t;
	radix_sort_ul_ov_srt_qe(res->a, res->a + res->n);
	for (i = 1, j = 0; i <= (int64_t)res->n; i++) {
        if (i == (int64_t)res->n || res->a[i].qe != res->a[j].qe) {
            if(i - j > 1) {
                radix_sort_ul_ov_srt_qs(res->a+j, res->a+i);
            }
            j = i;
        }
    }
	for (i = 0; i < (int64_t)res->n; ++i) {
		li = &(res->a[i]); li_v = (li->tn<<1)|li->rev;
		mm_ovlp = mode?max_ovlp_src(uopt, li_v^1):max_ovlp(uref->ug->g, li_v^1);		
		x = (li->qs + mm_ovlp)*diff_ec_ul; 
		if(x < bw) x = bw; 
		x += li->qs + mm_ovlp;
		if (x > qlen+1) x = qlen+1;
		x = find_ul_ov_max(i, res->a, x+G_CHAIN_INDEL); 
		if(li->el) csc = mode?retrieve_r_cov_region(uref, li->tn, 0, li->ts, li->te, NULL):retrieve_u_cov_region(uref, li->tn, 0, li->ts, li->te, NULL);
		else csc = (trans_sc*li->sec); //trans overlaps
		mm_sc = csc; mm_idx = -1; 
		// if(i == 37 || i == 36 || i == 35 || i == 32) fprintf(stderr, "*i:%ld, x:%ld, mm_sc:%ld\n", i, x, mm_sc);
		for (j = x; j >= 0; --j) { // collect potential destination vertices
			lj = &(res->a[j]); lj_v = (lj->tn<<1)|lj->rev;
			// if((lj->qe+gapLen) <= li->qs) break; 
			if(lj->qe+G_CHAIN_INDEL <= li->qs) break;//even this pair has a overlap, its length will be very small; just ignore
			// if(lj->qs >= li->qs+G_CHAIN_INDEL) continue; // lj is contained in li on the query coordinate; 128 for indel offset
			if(lj->qs >= li->qs) continue;
			qo = infer_rovlp(li, lj, NULL, NULL, ridx, ug); ///overlap length in query (UL read)
			// if(i == 37 || i == 36 || i == 35 || i == 32) fprintf(stderr, ">i:%ld, j:%ld, qo:%ld\n", i, j, qo);
			if(li_v != lj_v && get_ecov_adv(uref, uopt, li_v^1, lj_v^1, bw, diff_ec_ul, qo, mode, &share)) {
				// if(i == 37 || i == 36 || i == 35 || i == 32) fprintf(stderr, "#i:%ld, j:%ld, share:%ld\n", i, j, share);
				sc = csc + pop_sc(track[j]);
				// if((!mode)&&i==11&&j==10) {
				// 	fprintf(stderr,"+share:%ld, i:%ld, j:%ld, li_v^1:%u, lj_v^1:%u\n", 
				// 															share, i, j, li_v^1, lj_v^1);
				// }
				// if((mode&&i==21&&j==20) || (mode&&i==22&&j==21) || (mode&&i==23&&j==22)) {
				// 	fprintf(stderr,"-share:%ld, i:%ld, j:%ld, li_v^1:%u, lj_v^1:%u\n", 
				// 															share, i, j, li_v^1, lj_v^1);
				// }
				if(li->el && lj->el) sc -= (share>=csc?csc:share);///csc must be larger than 0
				// if((!li->el) && (!lj->el)) sc -= ((share>=o_csc?o_csc:share)*(-trans_scl));
				if(sc > mm_sc) mm_sc = sc, mm_idx = j;
			}
		}

		track[i] = push_sc_pre(mm_sc, mm_idx);
		srt[i] = track[i]>>32; srt[i] <<= 32; srt[i] |= i;
		n_el += li->el;

		// if(mode) {
		// 	fprintf(stderr, "[M::%.*s] i:%ld, li->el:%u, li->score:%ld (raw_sc:%u), mm_idx:%ld, mm_sc:%ld, q[%u, %u), t[%u, %u), rev:%c\n", 
		// 		(int32_t)Get_NAME_LENGTH(R_INF, li->tn), Get_NAME(R_INF, li->tn), i, li->el, csc, li->te - li->ts, mm_idx, mm_sc, li->qs, li->qe, li->ts, li->te, "+-"[li->rev]);
		// } else {
		// 	fprintf(stderr, "[M::utg%.6u%c] i:%ld, li->el:%u, li->score:%ld (raw_sc:%u), mm_idx:%ld, mm_sc:%ld, q[%u, %u), t[%u, %u), rev:%c\n", 
		// 		li->tn+1, "lc"[uref->ug->u.a[li->tn].circ], i, li->el, csc, li->te - li->ts, mm_idx, mm_sc, li->qs, li->qe, li->ts, li->te, "+-"[li->rev]);
		// }
		// if(!mode) {
		// 	fprintf(stderr, "[M::utg%.6d%c] qs->%u; qe->%u\n", li->tn+1, "lc"[uref->ug->u.a[li->tn].circ], li->qs, li->qe);
		// }
		// fprintf(stderr, "[M::utg%.6d%c] qs->%u; qe->%u; sc->%ld; pre->%ld; el->%u;\n", 
		// li->tn+1, "lc"[uref->ug->u.a[li->tn].circ], li->qs, li->qe, pop_sc(track[i]), pop_pre(track[i]), li->el);
	}
	
	int64_t n_v, n_u, n_v0, le, lnv; 
	radix_sort_gfa64(srt, srt+res->n); 
	for (k = (int64_t)res->n-1, n_v = n_u = 0; k >= 0; --k) {
		n_v0 = n_v; i = (uint32_t)srt[k];
		// fprintf(stderr, "+[M::utg%.6d%c] n_v0->%ld;\n", res->a[i].tn+1, "lc"[uref->ug->u.a[res->a[i].tn].circ], n_v0);
		if(res->a[i].el) { ///chain must start from cis alignments
			for (le = -1; i >= 0 && (track[i]&((uint64_t)0x80000000)) == 0;) {
				if(res->a[i].el) {
					le = -1;
				}else if(n_v>n_v0 && ex[n_v-1].el) {
					le = i; lnv = n_v;///cut the cis alignments in the end
				}
				ex[n_v++] = res->a[i]; track[i] |= ((uint64_t)0x80000000);
				// fprintf(stderr, "[M::utg%.6d%c] qs->%u; qe->%u\n", res->a[i].tn+1, "lc"[uref->ug->u.a[res->a[i].tn].circ], res->a[i].qs, res->a[i].qe);
				i = pop_pre(track[i]);
			}
		}
		// fprintf(stderr, "-[M::] n_v->%ld;\n", n_v);
		if(n_v0 == n_v) continue;
		if(le >= 0) {
			i = le; n_v = lnv;
		}
		if(n_v0 == n_v) continue;
		// fprintf(stderr, "[++chain::] beg_idx->%u, end_idx->%ld, le->%ld, chain_n->%ld\n", (uint32_t)srt[k], i, le, n_v - n_v0);
		///keep the whole score; do not cut score like minigraph
		// sc = pop_sc(srt[k]);
		sc = (i<0?(pop_sc(srt[k])):(pop_sc(srt[k])-pop_sc(track[i])));
		// fprintf(stderr, "++[M::%s] k:%ld, n_v0:%ld, n_v:%ld, le:%ld, sc:%ld, beg:%u, end:%ld, p_score:%ld, cut_score:%ld\n", 
		// __func__, k, n_v0, n_v, le, sc, (uint32_t)srt[k], i, pop_sc(srt[k]), i<0?0:pop_sc(track[i]));
		if(sc /**<=**/< 0) {///sc might be 0, if the UL alignment cannot cover the whole overlap between two HiFi reads
			n_v = n_v0;
			continue;
		}
		// idx[n_u++] = push_sc_pre(sc, n_v-n_v0);	
		idx[n_u++] = ((uint64_t)sc<<32)|(n_v-n_v0);	
	}
	// fprintf(stderr, "[M::%s] n_u:%ld, n_v:%ld\n", __func__, n_u, n_v);
	for (k = 0, n_v = n_v0 = 0; k < n_u; k++) {
		n_v0 = n_v; n_v += (uint32_t)idx[k];
		// fprintf(stderr, "[M::%s] k:%ld, n_v0:%ld, n_v:%ld\n", __func__, k, n_v0, n_v);
		res->a[k].qn = idx[k]>>32;//score
		res->a[k].ts = n_v0; res->a[k].te = n_v;///idx
		
		rev_n = ((uint32_t)idx[k])>>1; 
		///we need to consider contained reads; so determining qs is not such easy
		res->a[k].qs = (uint32_t)-1; res->a[k].qe = ex[n_v0].qe;
		for (i = 0; i < rev_n; i++) {
			rev_t = ex[n_v0+i]; ex[n_v0+i] = ex[n_v-i-1]; ex[n_v-i-1] = rev_t;
			
			if(res->a[k].qs > ex[n_v0+i].qs) res->a[k].qs = ex[n_v0+i].qs;
			if(res->a[k].qs > ex[n_v-i-1].qs) res->a[k].qs = ex[n_v-i-1].qs;
			n_el -= ex[n_v0+i].el; n_el -= ex[n_v-i-1].el;
			ex[n_v0+i].sec = ex[n_v-i-1].sec = SEC_MODE; 
		}
		if(((uint32_t)idx[k])&1) {
			if(res->a[k].qs > ex[n_v0+i].qs) res->a[k].qs = ex[n_v0+i].qs;
			n_el -= ex[n_v0+i].el; ex[n_v0+i].sec = SEC_MODE; 
		}
		assert(ex[n_v0].el && ex[n_v-1].el);
		// fprintf(stderr, "[M::%s] k:%ld, qs:%u, qe:%u, chain_occ:%u, chain_score:%u\n", __func__, k, 
		// 					res->a[k].qs, res->a[k].qe, res->a[k].te - res->a[k].ts, res->a[k].qn);
	}
	// if(n_el) {
	// 	fprintf(stderr, "[M::%s] debug_i->%ld, n_el->%ld, n_u->%ld, n_v->%ld\n", __func__, debug_i, n_el, n_u, n_v);
	// }
	assert(n_el == 0);
	res->n = n_u;
	radix_sort_ul_ov_srt_qn(res->a, res->a + res->n);//sort by score
	// fprintf(stderr, "---[M::%s] n_u:%ld, n_v:%ld\n", __func__, n_u, n_v);
	return n_v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %r9, 0x38(%rsp)
movsd %xmm0, 0x58(%rsp)
movq %r8, 0x50(%rsp)
movq %rcx, 0x48(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, 0x10(%rsp)
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
je 0x1a2f9c
movq %rdi, %rbp
movq (%rdi), %rdi
leaq (%rsi,%rsi,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdi, %rsi
addq %rax, %rsi
callq 0x195511
movq 0x8(%rbp), %rcx
testq %rcx, %rcx
jle 0x1a2c34
movl $0x1, %r14d
movl $0x1c, %ebx
xorl %eax, %eax
cmpq %rcx, %r14
je 0x1a2bf1
movq (%rbp), %rcx
movl 0x8(%rcx,%rbx), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x1a2bf1
movq %rax, %rdx
jmp 0x1a2c1d
movq %r14, %rcx
subq %rax, %rcx
movq %r14, %rdx
cmpq $0x2, %rcx
jl 0x1a2c1d
movq (%rbp), %rsi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rdi
addq %rax, %rdi
addq %rsi, %rdi
addq %rbx, %rsi
callq 0x1957bd
movq %r14, %rdx
leaq 0x1(%r14), %rsi
movq 0x8(%rbp), %rcx
addq $0x1c, %rbx
movq %rdx, %rax
cmpq %rcx, %r14
movq %rsi, %r14
jl 0x1a2bce
movq 0xe8(%rsp), %r13
movq 0x8(%rbp), %rax
testq %rax, %rax
movq %rbp, 0x8(%rsp)
jle 0x1a2fa4
incq 0x38(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movq (%rbp), %r9
leaq (%r14,%r14,8), %rax
leaq (%rax,%rax,2), %rbx
addq %r14, %rbx
movl 0xc(%r9,%rbx), %eax
movl 0x18(%r9,%rbx), %esi
shrdl $0x1f, %eax, %esi
cmpq $0x0, 0xf8(%rsp)
movl %esi, 0x28(%rsp)
je 0x1a2c9a
xorl $0x1, %esi
movq 0x48(%rsp), %rdi
movq %r9, %r12
callq 0x19c00f
movq %r12, %r9
jmp 0x1a2d04
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movl %esi, %ecx
xorl $0x1, %ecx
movq 0x28(%rax), %rdx
movq (%rdx,%rcx,8), %rcx
movq %rcx, %rdx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
andq %rsi, %rdx
je 0x1a2d02
movq 0x8(%rax), %rsi
shrq $0x20, %rcx
shlq $0x3, %rdx
leaq (%rdx,%rdx,2), %rax
leaq (%rcx,%rcx,2), %rcx
leaq (%rsi,%rcx,8), %rcx
addq $0xc, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl %esi, %edi
movl (%rcx,%rdx), %r8d
cmpl %r8d, %esi
movl %r8d, %esi
cmoval %edi, %esi
testl %r8d, %r8d
cmovsl %edi, %esi
addq $0x18, %rdx
cmpq %rdx, %rax
jne 0x1a2ce0
movl %esi, %eax
jmp 0x1a2d04
xorl %eax, %eax
addq %rbx, %r9
movq %r9, (%rsp)
movl 0x4(%r9), %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0x58(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x50(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0x38(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
movq (%rbp), %rsi
subl $-0x80, %edx
movl %r14d, %edi
callq 0x19f679
movq (%rsp), %rdi
movl %eax, %r13d
movl 0x18(%rdi), %eax
btl $0x1e, %eax
jb 0x1a2d6c
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
imulq 0xf0(%rsp), %rax
jmp 0x1a2da5
movl 0xc(%rdi), %esi
movl 0x10(%rdi), %ecx
movl 0x14(%rdi), %r8d
cmpq $0x0, 0xf8(%rsp)
je 0x1a2d92
movq 0x18(%rsp), %rdi
xorl %edx, %edx
xorl %r9d, %r9d
callq 0x37028
jmp 0x1a2da1
movq 0x18(%rsp), %rdi
xorl %edx, %edx
xorl %r9d, %r9d
callq 0x36ec9
movq (%rsp), %rdi
movq %r14, 0x60(%rsp)
testl %r13d, %r13d
js 0x1a2f13
movslq %r13d, %rbp
movl 0x28(%rsp), %ecx
xorl $0x1, %ecx
movl %ecx, 0x34(%rsp)
movq %rax, %rcx
leaq (,%rbp,8), %rax
addq %rbp, %rax
leaq (%rax,%rax,2), %rbx
addq %rbp, %rbx
movq $-0x1, %r14
movq %rcx, 0x40(%rsp)
movq %rcx, 0x20(%rsp)
movq 0xe8(%rsp), %r13
movq 0x8(%rsp), %rax
movq (%rax), %r12
movl 0x8(%r12,%rbx), %ecx
subl $-0x80, %ecx
movl 0x4(%rdi), %eax
cmpl %eax, %ecx
jbe 0x1a2f27
cmpl %eax, 0x4(%r12,%rbx)
jae 0x1a2efd
leaq (%r12,%rbx), %rsi
movl 0xc(%r12,%rbx), %eax
movl 0x18(%r12,%rbx), %r13d
shrdl $0x1f, %eax, %r13d
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x100(%rsp), %r8
movq 0x108(%rsp), %r9
callq 0x6f050
cmpl %r13d, 0x28(%rsp)
je 0x1a2ef1
xorl $0x1, %r13d
movq 0x18(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl 0x34(%rsp), %edx
movl %r13d, %ecx
movq 0x50(%rsp), %r8
movsd 0x58(%rsp), %xmm0
movq %rax, %r9
leaq 0x68(%rsp), %rax
pushq %rax
pushq 0x100(%rsp)
callq 0x1a24f3
addq $0x10, %rsp
testq %rax, %rax
je 0x1a2ef1
movq 0xe8(%rsp), %r13
movq (%r13,%rbp,8), %rcx
movq %rcx, %rax
shrq $0x20, %rax
leaq -0x80000000(%rax), %rdx
negq %rax
testq %rcx, %rcx
cmovsq %rdx, %rax
addq 0x40(%rsp), %rax
movq (%rsp), %rdi
testb $0x40, 0x1b(%rdi)
je 0x1a2eda
testb $0x40, 0x1b(%r12,%rbx)
je 0x1a2eda
movq 0x68(%rsp), %rcx
movq 0x40(%rsp), %rdx
cmpq %rdx, %rcx
cmovgeq %rdx, %rcx
subq %rcx, %rax
movq 0x20(%rsp), %rcx
cmpq %rcx, %rax
cmovgq %rax, %rcx
movq %rcx, 0x20(%rsp)
cmovgq %rbp, %r14
jmp 0x1a2efd
movq 0xe8(%rsp), %r13
movq (%rsp), %rdi
leaq -0x1(%rbp), %rax
addq $-0x1c, %rbx
testq %rbp, %rbp
movq %rax, %rbp
jg 0x1a2def
jmp 0x1a2f27
movq $-0x1, %r14
movq %rax, 0x20(%rsp)
movq 0xe8(%rsp), %r13
movq 0x20(%rsp), %rdx
movl %edx, %eax
movl $0x80000000, %ecx       # imm = 0x80000000
orl %ecx, %eax
movl %edx, %ecx
negl %ecx
testq %rdx, %rdx
cmovnsq %rax, %rcx
shlq $0x20, %rcx
testq %r14, %r14
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovsq %rax, %r14
orq %rcx, %r14
movq 0x60(%rsp), %rcx
movq %r14, (%r13,%rcx,8)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %r14
orq %rcx, %r14
movq 0xd8(%rsp), %rax
movq %r14, (%rax,%rcx,8)
movq %rcx, %r14
btl $0x1e, 0x18(%rdi)
adcq $0x0, %r15
incq %r14
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rax
cmpq %rax, %r14
jl 0x1a2c59
jmp 0x1a2fa7
xorl %r14d, %r14d
jmp 0x1a3372
xorl %r15d, %r15d
movq 0xd8(%rsp), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x194fef
movq 0x8(%rbp), %r10
testq %r10, %r10
jle 0x1a316c
movq $0x0, (%rsp)
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %r8d, %r8d
movq %r10, %rdi
movq 0xd8(%rsp), %r9
movl -0x8(%r9,%r10,8), %r10d
movq (%rbp), %r9
leaq (%r10,%r10,8), %r11
leaq (%r11,%r11,2), %r11
addq %r10, %r11
testb $0x40, 0x1b(%r9,%r11)
jne 0x1a3007
movq %r10, %r11
movq %r8, %r9
jmp 0x1a30b8
leaq (%r8,%r8,8), %rsi
leaq (%rsi,%rsi,2), %rbx
movq 0x10(%rsp), %rsi
addq %r8, %rsi
addq %rsi, %rbx
movq $-0x1, %rsi
movq %r8, %r9
testb $-0x80, 0x3(%r13,%r10,8)
jne 0x1a30b5
movq (%rbp), %r14
leaq (%r10,%r10,8), %r11
leaq (%r11,%r11,2), %r13
addq %r10, %r13
movq $-0x1, %r11
testb $0x40, 0x1b(%r14,%r13)
jne 0x1a3061
cmpq %r8, %r9
jle 0x1a3068
testb $0x40, -0x1(%rbx)
cmovneq %r10, %rsi
cmovneq %r9, %rdx
jmp 0x1a3068
movq $-0x1, %rsi
incq %r9
movupd (%r14,%r13), %xmm0
movups 0xc(%r14,%r13), %xmm1
movups %xmm1, 0xc(%rbx)
movupd %xmm0, (%rbx)
movq 0xe8(%rsp), %r13
movq (%r13,%r10,8), %r14
movq %r14, %r12
movl $0x80000000, %eax       # imm = 0x80000000
orq %rax, %r12
movq %r12, (%r13,%r10,8)
andq %rcx, %r14
addq $0x1c, %rbx
cmpq %rcx, %r14
cmoveq %r11, %r14
movq %r14, %r10
jne 0x1a3024
jmp 0x1a30b8
movq %r10, %r11
leaq -0x1(%rdi), %r10
cmpq %r9, %r8
je 0x1a315d
testq %rsi, %rsi
cmovnsq %rsi, %r11
cmovnsq %rdx, %r9
movq %r9, %rbx
subq %r8, %rbx
je 0x1a315d
movq 0xd8(%rsp), %r14
movq (%r14,%r10,8), %r12
movq %r12, %r14
shrq $0x20, %r14
leaq -0x80000000(%r14), %r13
negq %r14
testq %r12, %r12
cmovsq %r13, %r14
testq %r11, %r11
js 0x1a312d
movq 0xe8(%rsp), %r12
movq (%r12,%r11,8), %r11
movq %r11, %r12
shrq $0x20, %r12
leaq -0x80000000(%r12), %r13
negq %r12
testq %r11, %r11
cmovsq %r13, %r12
subq %r12, %r14
testq %r14, %r14
js 0x1a3152
shlq $0x20, %r14
orq %rbx, %r14
movq (%rsp), %rax
movq 0xe0(%rsp), %r8
movq %r14, (%r8,%rax,8)
incq %rax
movq %rax, (%rsp)
jmp 0x1a3155
movq %r8, %r9
movq 0xe8(%rsp), %r13
movq %r9, %r8
cmpq $0x1, %rdi
jg 0x1a2fd5
jmp 0x1a3174
movq $0x0, (%rsp)
cmpq $0x0, (%rsp)
jle 0x1a334b
movq 0x10(%rsp), %rdx
leaq -0x4(%rdx), %rcx
leaq 0x18(%rdx), %rax
movq %rax, 0x28(%rsp)
leaq -0x1c(%rdx), %rsi
xorl %r9d, %r9d
movl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
xorl %r8d, %r8d
movq 0xe0(%rsp), %rax
movq (%rax,%r8,8), %rbx
movl %ebx, %r14d
addq %r9, %r14
movq %rbx, %rdx
shrq $0x20, %rdx
movq (%rbp), %r13
leaq (%r8,%r8,8), %r10
leaq (%r10,%r10,2), %r11
addq %r8, %r11
movl %edx, (%r13,%r11)
movl %r9d, 0x10(%r13,%r11)
movl %r14d, 0x14(%r13,%r11)
shrl %ebx
movl $0xffffffff, 0x4(%r13,%r11) # imm = 0xFFFFFFFF
leaq (%r9,%r9,8), %rdx
leaq (%rdx,%rdx,2), %r12
leaq (%r12,%r9), %r10
movq 0x10(%rsp), %rdx
movl 0x8(%rdx,%r10), %edx
movl %edx, 0x8(%r13,%r11)
testl %ebx, %ebx
je 0x1a32bb
addq 0x28(%rsp), %r9
addq %r12, %r9
leaq (%r14,%r14,8), %rdx
leaq (%rdx,%rdx,2), %rbp
addq %rsi, %rbp
addq %r14, %rbp
xorl %r13d, %r13d
movups -0x18(%r9), %xmm0
movups -0xc(%r9), %xmm1
movups %xmm1, 0x7c(%rsp)
movaps %xmm0, 0x70(%rsp)
movups (%rbp), %xmm0
movups 0xc(%rbp), %xmm1
movups %xmm1, -0xc(%r9)
movups %xmm0, -0x18(%r9)
movups 0x7c(%rsp), %xmm0
movups %xmm0, 0xc(%rbp)
movapd 0x70(%rsp), %xmm0
movupd %xmm0, (%rbp)
movq 0x8(%rsp), %rdx
movq (%rdx), %rdx
leaq (%rdx,%r11), %r12
addq $0x4, %r12
movl -0x14(%r9), %edx
cmpl %edx, (%r12)
jbe 0x1a3276
movl %edx, (%r12)
movl 0x4(%rbp), %edx
cmpl %edx, (%r12)
jbe 0x1a3283
movl %edx, (%r12)
movl 0x18(%rbp), %edx
movl %edx, %r12d
shrl $0x1e, %r12d
andl $0x1, %r12d
btl $0x1e, (%r9)
adcl $0x0, %r12d
subq %r12, %r15
orl %edi, %edx
movl %edx, 0x18(%rbp)
orl %edi, (%r9)
incq %r13
addq $0x1c, %r9
addq $-0x1c, %rbp
cmpq %r13, %rbx
jne 0x1a321e
jmp 0x1a32be
xorl %r13d, %r13d
addq 0x10(%rsp), %r10
movq 0xe0(%rsp), %rax
testb $0x1, (%rax,%r8,8)
je 0x1a331b
movq 0x8(%rsp), %rdx
movq (%rdx), %rbx
leaq (,%r13,8), %rdx
addq %r13, %rdx
leaq (%rdx,%rdx,2), %r9
addq %r13, %r9
movl 0x4(%r10,%r9), %ebp
cmpl %ebp, 0x4(%rbx,%r11)
jbe 0x1a3302
leaq (%rbx,%r11), %rdx
addq $0x4, %rdx
movl %ebp, (%rdx)
addq %r10, %r9
movl 0x18(%r9), %edx
btl $0x1e, %edx
sbbq $0x0, %r15
orl $0x3fffffff, %edx       # imm = 0x3FFFFFFF
movl %edx, 0x18(%r9)
movq 0x8(%rsp), %rbp
testb $0x40, 0x1b(%r10)
je 0x1a3387
leaq (%r14,%r14,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %r14, %rdx
testb $0x40, 0x3(%rcx,%rdx)
je 0x1a3387
incq %r8
movq %r14, %r9
cmpq (%rsp), %r8
jne 0x1a31a0
jmp 0x1a334e
xorl %r14d, %r14d
testq %r15, %r15
jne 0x1a33a6
movq (%rsp), %rax
movq %rax, 0x8(%rbp)
movq (%rbp), %rdi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq %rdi, %rsi
callq 0x195d3d
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x910bb(%rip), %rdi     # 0x234449
leaq 0x905f6(%rip), %rsi     # 0x23398b
leaq 0x910c9(%rip), %rcx     # 0x234465
movl $0xf0e, %edx            # imm = 0xF0E
callq 0x2110
leaq 0x91191(%rip), %rdi     # 0x23453e
leaq 0x905d7(%rip), %rsi     # 0x23398b
leaq 0x910aa(%rip), %rcx     # 0x234465
movl $0xf15, %edx            # imm = 0xF15
callq 0x2110