// File: /workspace/github_cpp_makefile_star2_O1/chhylp123[P]hifiasm/anchor.cpp
// Function: lchain_qgen_mcopy_fast(Candidates_list*, overlap_region_alloc*, unsigned int, unsigned long, All_reads*, unsigned int, unsigned long, long, long, long, double, double, double, long, unsigned int, long, double, unsigned int, unsigned int, st_mt_t*, unsigned long)
void lchain_qgen_mcopy_fast(Candidates_list* cl, overlap_region_alloc* ol, uint32_t rid, uint64_t rl, All_reads* rdb, 
				uint32_t apend_be, uint64_t max_n_chain, int64_t max_skip, int64_t max_iter, 
				int64_t max_dis, double chn_pen_gap, double chn_pen_skip, double bw_rate, int64_t quick_check, 
				uint32_t gen_off, int64_t mcopy_num, double mcopy_rate, uint32_t chain_cutoff, uint32_t mcopy_khit_cut, st_mt_t *sp, uint64_t ocv_w)
{
	// fprintf(stderr, "+[M::%s] chain_cutoff::%u\n", __func__, chain_cutoff);
	uint64_t i, k, l, m, cn = cl->length, yid, ol0, lch, *cc = NULL, cwn = 0, cws, cwe, os, oe, rs, re, cw0, cw1/**, dbgn = 0**/; overlap_region *r, t; ///srt = 0
	clear_overlap_region_alloc(ol);

	for (l = 0, k = 1, m = 0, lch = 0; k <= cn; k++) {
		if((k == cn) || (cl->list[k].readID != cl->list[l].readID)) {
			if(cl->list[l].readID != rid) {
				yid = cl->list[l].readID; ol0 = ol->length;
				m += lchain_qdp_mcopy_fast(cl, l, k-l, m, &(cl->chainDP), ol, max_skip, max_iter, max_dis, chn_pen_gap, chn_pen_skip, bw_rate, 
				rid, rl, Get_READ_LENGTH((*rdb), yid), quick_check, apend_be, gen_off, mcopy_num, mcopy_rate, mcopy_khit_cut, 1);
				if((chain_cutoff >= 2) && (!lch)) {
					for (i = ol0; (i<ol->length) && (!lch); i++) {
						if(ol->list[i].align_length < chain_cutoff) lch = 1;
					}
				}
			}
			l = k;
		}
	}
	cl->length = m;

	// fprintf(stderr, "[M::%s::] rn::%lu\tmax_n_chain::%lu\n", __func__, ol->length, max_n_chain);
	// for (k = 0; k < ol->length; k++) {
	// 	fprintf(stderr, "---[M::%s::%.*s(qid::%u)] q[%d, %d), t[%d, %d), sc::%d, type::%d\n", __func__, 
	// 	(int32_t)Get_NAME_LENGTH(R_INF, ol->list[k].y_id), Get_NAME(R_INF, ol->list[k].y_id), ol->list[k].y_id,
	// 	ol->list[k].x_pos_s, ol->list[k].x_pos_e+1, ol->list[k].y_pos_s, ol->list[k].y_pos_e+1, ol->list[k].shared_seed, ha_ov_type(&(ol->list[k]), rl));
	// }

	k = ol->length;
	if (ol->length > max_n_chain) {
		int32_t w, n[4], s[4]; 
		n[0] = n[1] = n[2] = n[3] = 0, s[0] = s[1] = s[2] = s[3] = 0; 
		ks_introsort_or_ss(ol->length, ol->list); 
		for (i = 0; i < ol->length; ++i) {
			r = &(ol->list[i]);
			w = ha_ov_type(r, rl);
			++n[w];
			if (((uint64_t)n[w]) == max_n_chain) s[w] = r->shared_seed;
		}
		// fprintf(stderr, "[M::%s::] s[0]::%d, s[1]::%d, s[2]::%d, s[3]::%d\n", __func__, s[0], s[1], s[2], s[3]);
		if (s[0] > 0 || s[1] > 0 || s[2] > 0 || s[3] > 0) {
			if((((uint64_t)n[3]) >= max_n_chain) && (rl >= ocv_w)) {
				cwn = (rl/ocv_w) + ((rl % ocv_w)?(1):(0));
				kv_resize(uint64_t, (*sp), (cwn));
				cc = sp->a;
				for (i = cws = cwe = 0; i < cwn; i++) {
					cwe = cws + ocv_w; if(cwe > rl) cwe = rl;
					assert(cwe > cws);
					cc[i] = (cwe - cws)*(max_n_chain>>1); 
					// fprintf(stderr, "[M::%s::] cw::[%lu, %lu), cc::%lu\n", __func__, cws, cwe, cc[i]);
					if(cc[i] > UINT32_MAX) cc[i] = UINT32_MAX; cc[i] <<= 32;
					cws += ocv_w;
				}
			}
			for (i = 0, k = 0, lch = 0; i < ol->length; ++i) {
				r = &(ol->list[i]);
				w = ha_ov_type(r, rl);
				// ++n[w];
				// if (((int)n[w] <= max_n_chain) || (r->shared_seed >= s[w] && s[w] >= (asm_opt.k_mer_length<<1))) {
				if (r->shared_seed >= s[w]) {
					if(cwn) {
						m = (ol->list[i].x_pos_s/ocv_w); 
						rs = ol->list[i].x_pos_s; re = ol->list[i].x_pos_e + 1;
						for (cws = m*ocv_w; m < cwn; m++) {
							cwe = cws + ocv_w; if(cwe > rl) cwe = rl;
							os = ((rs >= cws)? rs : cws);
        					oe = ((re <= cwe)? re : cwe);
							if(oe <= os) break;
							if(((uint32_t)cc[m]) + (oe - os) < UINT32_MAX) {
								cc[m] += (oe - os);
							} else {
								cc[m] >>= 32; cc[m] <<= 32; cc[m] |= UINT32_MAX;
							}
							cws += ocv_w;
						}
					}
					if (k != i) {
						t = ol->list[k];
						ol->list[k] = ol->list[i];
						ol->list[i] = t;
					}
					if(ol->list[k].align_length < chain_cutoff) lch = 1;
					++k;
				} else if(w == 3 && cwn > 0) {
					m = (ol->list[i].x_pos_s/ocv_w); cw0 = cw1 = 0;
					rs = ol->list[i].x_pos_s; re = ol->list[i].x_pos_e + 1;
					for (cws = m*ocv_w; m < cwn; m++) {
						cwe = cws + ocv_w; if(cwe > rl) cwe = rl;
						os = ((rs >= cws)? rs : cws);
						oe = ((re <= cwe)? re : cwe);
						if(oe <= os) break;
						// fprintf(stderr, "+++[M::%s::%.*s(qid::%u)] o[%lu, %lu), cur::%lu, max::%lu\n", __func__, 
						// 	(int32_t)Get_NAME_LENGTH(R_INF, ol->list[i].y_id), Get_NAME(R_INF, ol->list[i].y_id), ol->list[i].y_id,
						// 	os, oe, ((uint64_t)((uint32_t)cc[m])), (cc[m]>>32));
						if((oe - os) + ((uint64_t)((uint32_t)cc[m])) >= (cc[m]>>32)) {
							cw1 += (oe - os);
						} else {
							cw0 += (oe - os);
						}
						cws += ocv_w;
					}

					if(cw0 >= ((cw0 + cw1)*0.7)) {
						m = (ol->list[i].x_pos_s/ocv_w); 
						rs = ol->list[i].x_pos_s; re = ol->list[i].x_pos_e + 1;
						for (cws = m*ocv_w; m < cwn; m++) {
							cwe = cws + ocv_w; if(cwe > rl) cwe = rl;
							os = ((rs >= cws)? rs : cws);
        					oe = ((re <= cwe)? re : cwe);
							if(oe <= os) break;
							if(((uint32_t)cc[m]) + (oe - os) < UINT32_MAX) {
								cc[m] += (oe - os);
							} else {
								cc[m] >>= 32; cc[m] <<= 32; cc[m] |= UINT32_MAX;
							}
							cws += ocv_w;
						}
						if (k != i) {
							t = ol->list[k];
							ol->list[k] = ol->list[i];
							ol->list[i] = t;
						}
						if(ol->list[k].align_length < chain_cutoff) lch = 1;
						++k;
						// dbgn++;
						// fprintf(stderr, "+++[M::%s::%.*s(qid::%u)] q[%d, %d), t[%d, %d), sc::%d, type::%d, cw0::%lu, cw1::%lu\n", __func__, 
						// 	(int32_t)Get_NAME_LENGTH(R_INF, ol->list[k].y_id), Get_NAME(R_INF, ol->list[k].y_id), ol->list[k].y_id,
						// 	ol->list[k].x_pos_s, ol->list[k].x_pos_e+1, ol->list[k].y_pos_s, ol->list[k].y_pos_e+1, ol->list[k].shared_seed, ha_ov_type(&(ol->list[k]), rl), cw0, cw1);
					}
				}
			}
			ol->length = k;
		}
	} 
	
	ks_introsort_or_xs(ol->length, ol->list);
	if(lch) {
		//@brief r485
		uint64_t zs, ze, rs, re, ob, os, oe, ocn, pp, kn, ms, me; int64_t osc;
		for (i = l = 0, cn = cl->length; i < ol->length; ++i) {
			if(ol->list[i].align_length < chain_cutoff) {
				zs = ol->list[i].x_pos_s; ze = ol->list[i].x_pos_e + 1;
				ob = (ze - zs)*OFL; if(ob < 16) ob = 16;
				osc = ol->list[i].shared_seed*CH_SC;
				ocn = ol->list[i].align_length<<CH_OCC;
				for (k = 0; (k < ol->length) && (ze > ol->list[k].x_pos_s); k++) {
					if(ol->list[k].align_length < chain_cutoff) continue;
					if(ol->list[k].align_length < ocn) continue;
					if(ol->list[k].shared_seed < osc) continue;
					rs = ol->list[k].x_pos_s; re = ol->list[k].x_pos_e + 1;
					os = ((rs>=zs)?rs:zs); oe = ((re<=ze)?re:ze);
					if((oe > os) && (oe - os) >= ob) {
						m = ol->list[k].non_homopolymer_errors;
						pp = cl->list[m].readID; kn = 0;
						for (; (m < cn) && (cl->list[m].readID == pp) && (kn < ocn); m++) {
							me = cl->list[m].self_offset; ms = me - (cl->list[m].cnt&(0xffu)); 
							if((ms >= os) && (me <= oe)) kn++;
						}
						if(kn >= ocn) break;
					}
				}
				if((k < ol->length) && (ze > ol->list[k].x_pos_s)) continue;
			}
			if (l != i) {
				t = ol->list[l];
				ol->list[l] = ol->list[i];
				ol->list[i] = t;
			}
			l++;
		}
		ol->length = l;
	} 

	for (i = 0; i < ol->length; ++i) ol->list[i].align_length = 0;
	// fprintf(stderr, "+[M::%s] rid::%u, ol->length0::%lu, dbgn::%lu\n", __func__, rid, ol->length, dbgn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movsd %xmm3, 0x10(%rsp)
movsd %xmm2, 0x20(%rsp)
movsd %xmm1, 0x18(%rsp)
movsd %xmm0, 0x40(%rsp)
movq %r9, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, 0x8(%rsp)
movq %rdi, %r13
movq 0x160(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x8(%rdi), %rbp
movq %rsi, (%rsp)
movq %rsi, %rdi
callq 0x3db37
testq %rbp, %rbp
movq %r13, 0x48(%rsp)
je 0x128d73
leaq 0x18(%r13), %rax
movq %rax, 0x58(%rsp)
xorl %esi, %esi
movl $0x1, %r15d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq (%rsp), %r9
movq %r13, %r8
movq 0x8(%rsp), %r11
cmpq %rbp, %r15
je 0x128c34
movq (%r8), %rax
movq %r15, %rcx
shlq $0x4, %rcx
movq %rsi, %rdx
shlq $0x4, %rdx
movl (%rax,%rdx), %edx
xorl (%rax,%rcx), %edx
testl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
je 0x128d58
movq (%r8), %rax
movq %rsi, %rcx
shlq $0x4, %rcx
movl (%rax,%rcx), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl %r11d, %eax
jne 0x128c56
movq %r14, %rax
movq %r15, %rsi
jmp 0x128d5b
movq 0x10(%r9), %r13
movq %r15, %rdx
subq %rsi, %rdx
movq 0x30(%rsp), %rcx
movq 0x18(%rcx), %r10
movq %r8, %rdi
movq %r14, %rcx
movq 0x58(%rsp), %r8
movsd 0x40(%rsp), %xmm0
movsd 0x18(%rsp), %xmm1
movsd 0x20(%rsp), %xmm2
movsd 0x10(%rsp), %xmm3
pushq $0x1
movl 0x1a8(%rsp), %r12d
pushq %r12
pushq 0x1a0(%rsp)
movl 0x1a0(%rsp), %r12d
pushq %r12
pushq 0x58(%rsp)
pushq 0x1a8(%rsp)
pushq (%r10,%rax,8)
pushq 0x60(%rsp)
pushq %r11
pushq 0x1c0(%rsp)
pushq 0x1c0(%rsp)
pushq 0x1c0(%rsp)
callq 0x4287f
addq $0x60, %rsp
addq %r14, %rax
movl 0x198(%rsp), %edi
cmpl $0x2, %edi
jb 0x128d45
testq %rbx, %rbx
jne 0x128d45
movq (%rsp), %r9
movq 0x10(%r9), %rcx
cmpq %rcx, %r13
movq 0x48(%rsp), %r8
movq 0x8(%rsp), %r11
jae 0x128d6c
movq (%r9), %rdx
imulq $0xa8, %r13, %rsi
incq %r13
addq %rsi, %rdx
addq $0x28, %rdx
xorl %ebx, %ebx
movl $0x1, %esi
cmpl %edi, (%rdx)
cmovbq %rsi, %rbx
cmpq %rcx, %r13
jae 0x128c4e
incq %r13
addq $0xa8, %rdx
testq %rbx, %rbx
je 0x128d22
jmp 0x128c4e
movq %r15, %rsi
movq (%rsp), %r9
movq 0x48(%rsp), %r8
movq 0x8(%rsp), %r11
jmp 0x128d5b
movq %r14, %rax
incq %r15
movq %rax, %r14
cmpq %rbp, %r15
jbe 0x128c0c
jmp 0x128d7e
xorl %ebx, %ebx
jmp 0x128c4e
xorl %ebx, %ebx
xorl %eax, %eax
movq (%rsp), %r9
movq %r13, %r8
movq %rax, 0x8(%r8)
movq 0x10(%r9), %rdi
movq 0x160(%rsp), %r14
cmpq %r14, %rdi
jbe 0x1292a0
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
movq (%r9), %rsi
callq 0x121388
movq (%rsp), %r9
movq 0x10(%r9), %rax
testq %rax, %rax
movl 0x198(%rsp), %ebp
movq 0x28(%rsp), %r12
je 0x128e22
movq (%r9), %rcx
leal -0x1(%r12), %edx
addq $0x4, %rcx
movl (%rcx), %edi
movl 0x4(%rcx), %r8d
testl %edi, %edi
je 0x128e16
movl $0x3, %esi
cmpl %edx, %r8d
jb 0x128df0
xorl %esi, %esi
testl %edi, %edi
setne %sil
movslq 0x70(%rsp,%rsi,4), %rdi
incq %rdi
movl %edi, 0x70(%rsp,%rsi,4)
cmpq %r14, %rdi
jne 0x128e08
movl 0x20(%rcx), %edi
movl %edi, 0x60(%rsp,%rsi,4)
addq $0xa8, %rcx
decq %rax
jne 0x128dd4
jmp 0x128e22
movl $0x2, %esi
cmpl %edx, %r8d
jne 0x128de8
jmp 0x128df0
cmpl $0x0, 0x60(%rsp)
jg 0x128e42
cmpl $0x0, 0x64(%rsp)
jg 0x128e42
cmpl $0x0, 0x68(%rsp)
jg 0x128e42
cmpl $0x0, 0x6c(%rsp)
jle 0x1292a7
movq 0x1b0(%rsp), %r15
xorl %r13d, %r13d
cmpq %r15, %r12
jb 0x128f56
movslq 0x7c(%rsp), %rax
movl $0x0, %edx
movq %rdx, 0x8(%rsp)
cmpq %r14, %rax
jb 0x128f5f
movq %r12, %rax
xorl %edx, %edx
divq %r15
movq %rax, %r13
movq 0x1a8(%rsp), %rbx
cmpq $0x1, %rdx
sbbq $-0x1, %r13
cmpq %r13, 0x8(%rbx)
jae 0x128ee5
leaq -0x1(%r13), %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, 0x8(%rbx)
movq 0x10(%rbx), %rdi
leaq 0x8(,%rcx,8), %rsi
callq 0x2370
movq (%rsp), %r9
movq %rax, 0x10(%rbx)
movq 0x10(%rbx), %rax
movq %rax, 0x8(%rsp)
testq %r13, %r13
je 0x128f5f
shrq 0x50(%rsp)
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r15, %rdx
xorl %esi, %esi
xorl %edi, %edi
movq %rdi, %r11
addq %r15, %rdi
cmpq %rdx, %r12
movq %rdx, %r8
cmovbq %r12, %r8
cmpq %r12, %rdi
movq %r12, %r10
cmovbq %rdi, %r10
cmpq %r11, %r10
jbe 0x129599
addq %rax, %r8
imulq 0x50(%rsp), %r8
cmpq %rcx, %r8
cmovaeq %rcx, %r8
shlq $0x20, %r8
movq 0x8(%rsp), %r10
movq %r8, (%r10,%rsi,8)
incq %rsi
addq %r15, %rdx
subq %r15, %rax
cmpq %r13, %rsi
jb 0x128f06
jmp 0x128f5f
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x10(%r9)
je 0x129298
leal -0x1(%r12), %eax
movl %eax, 0x30(%rsp)
xorl %ebp, %ebp
xorl %esi, %esi
xorl %ebx, %ebx
movq (%r9), %r8
imulq $0xa8, %rbp, %rdi
movl 0x4(%r8,%rdi), %ecx
movl 0x8(%r8,%rdi), %edx
testq %rcx, %rcx
movq %rbp, 0x20(%rsp)
movq %rsi, 0x10(%rsp)
je 0x129181
movl $0x3, %eax
cmpl 0x30(%rsp), %edx
jb 0x128fb3
xorl %eax, %eax
testq %rcx, %rcx
setne %al
leaq (%r8,%rdi), %r10
movl 0x24(%r10), %edx
movl %eax, %esi
cmpl 0x60(%rsp,%rsi,4), %edx
jge 0x1290eb
testq %r13, %r13
movq 0x20(%rsp), %rbp
je 0x1290e1
cmpl $0x3, %eax
jne 0x1290e1
movq %r8, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
movq %rcx, %rax
xorl %edx, %edx
divq %r15
movq %r10, 0x18(%rsp)
movl 0x8(%r10), %edx
incl %edx
movq %rax, %rsi
imulq %r15, %rsi
movl $0x0, %r8d
movl $0x0, %edi
cmpq %r13, %rax
jae 0x12907e
movq %rax, %r9
movq %rsi, %r10
xorl %edi, %edi
xorl %r8d, %r8d
movq %r10, %r15
movq 0x1b0(%rsp), %r10
addq %r15, %r10
cmpq %r12, %r10
movq %r12, %r11
cmovbq %r10, %r11
cmpq %rcx, %r15
cmovbeq %rcx, %r15
cmpq %rdx, %r11
cmovaeq %rdx, %r11
subq %r15, %r11
jbe 0x12907e
movq 0x8(%rsp), %r14
movq (%r14,%r9,8), %r15
movl %r15d, %r12d
addq %r11, %r12
shrq $0x20, %r15
cmpq %r15, %r12
jb 0x129065
xorl %r15d, %r15d
jmp 0x12906b
movq %r11, %r15
xorl %r11d, %r11d
addq %r15, %r8
addq %r11, %rdi
incq %r9
cmpq %r13, %r9
movq 0x28(%rsp), %r12
jb 0x12901d
movq %r8, %xmm0
movq 0xfc1b5(%rip), %xmm2    # 0x225240
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0xfc1b9(%rip), %xmm3    # 0x225250
subpd %xmm3, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
addq %r8, %rdi
movq %rdi, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm3, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
mulsd 0xfc3d5(%rip), %xmm2    # 0x2254a0
ucomisd %xmm2, %xmm1
jae 0x129195
movq (%rsp), %r9
movq 0x1b0(%rsp), %r15
movq 0x10(%rsp), %rsi
jmp 0x129289
movq %r10, 0x18(%rsp)
movq %r8, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
testq %r13, %r13
je 0x1291fc
movq %rcx, %rax
xorl %edx, %edx
divq %r15
cmpq %r13, %rax
jae 0x1291fc
movq 0x18(%rsp), %rdx
movl 0x8(%rdx), %edx
incl %edx
movq %rax, %rsi
imulq %r15, %rsi
movq %rsi, %r8
addq %r15, %rsi
cmpq %r12, %rsi
movq %r12, %rdi
cmovbq %rsi, %rdi
cmpq %rcx, %r8
cmovbeq %rcx, %r8
cmpq %rdx, %rdi
cmovaeq %rdx, %rdi
subq %r8, %rdi
jbe 0x1291fc
movq 0x8(%rsp), %rbp
movq (%rbp,%rax,8), %r8
movl %r8d, %r11d
addq %rdi, %r11
movq %r8, %r10
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
orq %r14, %r10
addq %rdi, %r8
cmpq %r14, %r11
cmovaeq %r10, %r8
movq %r8, (%rbp,%rax,8)
incq %rax
cmpq %r13, %rax
jb 0x129125
jmp 0x1291fc
movl $0x2, %eax
cmpl 0x30(%rsp), %edx
jne 0x128fab
jmp 0x128fb3
cmpq %r13, %rax
movq (%rsp), %r9
movq 0x1b0(%rsp), %r15
jae 0x1291fc
movq %rsi, %r8
addq %r15, %rsi
cmpq %r12, %rsi
movq %r12, %rdi
cmovbq %rsi, %rdi
cmpq %rcx, %r8
cmovbeq %rcx, %r8
cmpq %rdx, %rdi
cmovaeq %rdx, %rdi
subq %r8, %rdi
jbe 0x1291fc
movq 0x8(%rsp), %rbp
movq (%rbp,%rax,8), %r8
movl %r8d, %r11d
addq %rdi, %r11
movq %r8, %r10
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
orq %r14, %r10
addq %rdi, %r8
cmpq %r14, %r11
cmovaeq %r10, %r8
movq %r8, (%rbp,%rax,8)
incq %rax
cmpq %r13, %rax
jb 0x1291a6
movq 0x20(%rsp), %rbp
movq 0x10(%rsp), %rsi
cmpq %rbp, %rsi
je 0x129268
imulq $0xa8, %rsi, %rax
movq 0x38(%rsp), %r14
addq %rax, %r14
movl $0xa8, %edx
leaq 0x80(%rsp), %rdi
movq %r14, %rsi
callq 0x2160
movl $0xa8, %edx
movq %r14, %rdi
movq 0x18(%rsp), %rsi
callq 0x2160
movq (%rsp), %rax
movq 0x40(%rsp), %rdi
addq (%rax), %rdi
movl $0xa8, %edx
leaq 0x80(%rsp), %rsi
callq 0x2160
movq 0x10(%rsp), %rsi
movq (%rsp), %r9
movq (%r9), %rax
imulq $0xa8, %rsi, %rcx
movl 0x198(%rsp), %edx
cmpl %edx, 0x28(%rax,%rcx)
movl $0x1, %eax
cmovbq %rax, %rbx
incq %rsi
incq %rbp
cmpq 0x10(%r9), %rbp
jb 0x128f79
jmp 0x12929c
xorl %ebx, %ebx
xorl %esi, %esi
movq %rsi, 0x10(%r9)
movl 0x198(%rsp), %ebp
movq (%r9), %rsi
movq 0x10(%r9), %rdi
callq 0x120acf
movq (%rsp), %r8
testq %rbx, %rbx
je 0x129565
movq 0x10(%r8), %rax
testq %rax, %rax
je 0x12955e
movq 0x48(%rsp), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, 0x50(%rsp)
xorl %r14d, %r14d
xorl %r9d, %r9d
movq (%r8), %r12
imulq $0xa8, %r14, %rcx
leaq (%r12,%rcx), %r11
movq %rcx, 0x18(%rsp)
movl 0x28(%r12,%rcx), %edx
cmpl %ebp, %edx
jae 0x1294ec
movl 0x4(%r11), %edi
movl 0x8(%r11), %ecx
incl %ecx
movq %rcx, %rsi
movq %rdi, 0x20(%rsp)
subq %rdi, %rsi
movq %rsi, %xmm0
punpckldq 0xfbf1d(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xfbf25(%rip), %xmm0    # 0x225250
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xfc159(%rip), %xmm1    # 0x225498
cvttsd2si %xmm1, %rsi
movq %rsi, %rdi
subsd 0xfbf19(%rip), %xmm1    # 0x225268
cvttsd2si %xmm1, %r10
sarq $0x3f, %rdi
andq %rdi, %r10
orq %rsi, %r10
cmpq $0x11, %r10
movl $0x10, %esi
cmovbq %rsi, %r10
movq %r10, 0x40(%rsp)
shll $0x4, %edx
cmpl %edx, %ebp
movl %edx, %edi
cmoval %ebp, %edi
cmpq $0x1, %rax
movq %rax, %rsi
adcq $0x0, %rsi
movq %rsi, 0x8(%rsp)
movl 0x4(%r12), %r13d
cmpl %r13d, %ecx
jbe 0x1294d4
movl 0x24(%r11), %esi
shll $0x4, %esi
movl %esi, 0x10(%rsp)
movb $0x1, %bl
xorl %r10d, %r10d
movq %r14, 0x38(%rsp)
movq %r9, 0x30(%rsp)
movq %r11, 0x58(%rsp)
movl %edi, 0x28(%rsp)
imulq $0xa8, %r10, %rsi
cmpl %edi, 0x28(%r12,%rsi)
jb 0x1294ad
addq %r12, %rsi
movl 0x10(%rsp), %r15d
cmpl %r15d, 0x24(%rsi)
jl 0x1294ad
movl 0x8(%rsi), %r15d
incl %r15d
movq 0x20(%rsp), %rdi
cmpl %edi, %r13d
cmovbel %edi, %r13d
movl 0x28(%rsp), %edi
cmpl %ecx, %r15d
cmovael %ecx, %r15d
cmpl %r13d, %r15d
jbe 0x1294ad
movq %r15, %rdi
subq %r13, %rdi
cmpq 0x40(%rsp), %rdi
movl 0x28(%rsp), %edi
jb 0x1294ad
movl 0x30(%rsi), %edi
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
jbe 0x129487
movq 0x48(%rsp), %r8
movq (%r8), %r11
shlq $0x4, %rdi
leaq (%r11,%rdi), %r14
addq $0xc, %r14
movl -0xc(%r14), %edi
xorl %r11d, %r11d
movl -0xc(%r14), %ebp
xorl %edi, %ebp
testl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
jne 0x12948a
cmpq %rdx, %r11
jae 0x12948a
movl -0x4(%r14), %r9d
movzbl (%r14), %r8d
movq %r9, %rbp
subq %r8, %rbp
cmpq %r13, %rbp
setae %r8b
cmpl %r15d, %r9d
setbe %r9b
andb %r8b, %r9b
movzbl %r9b, %r8d
addq %r8, %r11
addq $0x10, %r14
decq %rsi
jne 0x129443
jmp 0x12948a
xorl %r11d, %r11d
cmpq %rdx, %r11
movq (%rsp), %r8
movl 0x198(%rsp), %ebp
movq 0x38(%rsp), %r14
movq 0x30(%rsp), %r9
movq 0x58(%rsp), %r11
movl 0x28(%rsp), %edi
jae 0x1294d9
incq %r10
cmpq 0x8(%rsp), %r10
je 0x1294ec
cmpq %rax, %r10
setb %bl
imulq $0xa8, %r10, %rsi
movl 0x4(%r12,%rsi), %r13d
cmpl %r13d, %ecx
ja 0x1293bb
jmp 0x1294d9
movb $0x1, %bl
xorl %r10d, %r10d
testb $0x1, %bl
je 0x1294ec
imulq $0xa8, %r10, %rax
cmpl 0x4(%r12,%rax), %ecx
ja 0x12954c
cmpq %r14, %r9
je 0x129549
imulq $0xa8, %r9, %rax
addq %rax, %r12
movl $0xa8, %edx
leaq 0x80(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r9, %rbx
movq %r11, %r13
callq 0x2160
movl $0xa8, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x2160
movq (%rsp), %rax
movq 0x18(%rsp), %rdi
addq (%rax), %rdi
movl $0xa8, %edx
movq %r15, %rsi
callq 0x2160
movq %rbx, %r9
movq (%rsp), %r8
incq %r9
incq %r14
movq 0x10(%r8), %rax
cmpq %rax, %r14
jb 0x1292e1
jmp 0x129561
xorl %r9d, %r9d
movq %r9, 0x10(%r8)
movq 0x10(%r8), %rax
testq %rax, %rax
je 0x129587
movq (%r8), %rcx
addq $0x28, %rcx
movl $0x0, (%rcx)
addq $0xa8, %rcx
decq %rax
jne 0x129575
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x105615(%rip), %rdi    # 0x22ebb5
leaq 0x10544c(%rip), %rsi    # 0x22e9f3
leaq 0x105611(%rip), %rcx    # 0x22ebbf
movl $0x7b4, %edx            # imm = 0x7B4
callq 0x2110