// File: /workspace/github_cpp_makefile_star2_O3/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, 0x30(%rsp)
movsd %xmm2, 0x18(%rsp)
movq %xmm1, 0x48(%rsp)
movsd %xmm0, 0x38(%rsp)
movq %r9, 0x28(%rsp)
movq %r8, 0x58(%rsp)
movq %rcx, 0x10(%rsp)
movl %edx, %r13d
movq %rsi, %rbp
movq %rdi, %r15
movq 0x8(%rdi), %rbx
movq %rsi, %rdi
callq 0x3d018
testq %rbx, %rbx
movq %rbp, 0x20(%rsp)
movq %r15, 0x40(%rsp)
je 0x12ed82
leaq 0x18(%r15), %rax
movq %rax, 0x50(%rsp)
movl $0x1, %r12d
xorl %esi, %esi
xorl %r14d, %r14d
movq $0x0, 0x8(%rsp)
movq %r15, %rdi
movl 0x198(%rsp), %r15d
movq (%rdi), %rcx
cmpq %rbx, %r12
jne 0x12ec2a
movq %rsi, %rax
shlq $0x4, %rax
movl (%rcx,%rax), %eax
jmp 0x12ec4c
movq %r12, %rdx
shlq $0x4, %rdx
movq %rsi, %rax
shlq $0x4, %rax
movl (%rcx,%rax), %eax
movl (%rcx,%rdx), %ecx
xorl %eax, %ecx
testl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
je 0x12ed5d
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmpl %r13d, %eax
jne 0x12ec61
movq %r14, %rax
movq %r12, %rsi
jmp 0x12ed71
movl %eax, %eax
movq %rbp, %r9
movq 0x10(%rbp), %rbp
movq %r12, %rdx
subq %rsi, %rdx
movq 0x58(%rsp), %rcx
movq 0x18(%rcx), %r10
movq %r14, %rcx
movq 0x50(%rsp), %r8
movsd 0x38(%rsp), %xmm0
movq 0x48(%rsp), %xmm1
movsd 0x18(%rsp), %xmm2
movsd 0x30(%rsp), %xmm3
pushq $0x1
movl 0x1a8(%rsp), %r11d
pushq %r11
pushq 0x1a0(%rsp)
movl 0x1a0(%rsp), %r11d
pushq %r11
pushq 0x48(%rsp)
pushq 0x1a8(%rsp)
pushq (%r10,%rax,8)
pushq 0x48(%rsp)
pushq %r13
pushq 0x1c0(%rsp)
pushq 0x1c0(%rsp)
pushq 0x1c0(%rsp)
callq 0x42094
addq $0x60, %rsp
addq %r14, %rax
cmpl $0x2, %r15d
jb 0x12ed4e
cmpq $0x0, 0x8(%rsp)
jne 0x12ed4e
movq 0x20(%rsp), %rdx
movq 0x10(%rdx), %rcx
cmpq %rcx, %rbp
movq 0x40(%rsp), %rdi
jae 0x12ed62
movq (%rdx), %rdx
imulq $0xa8, %rbp, %rsi
incq %rbp
addq %rsi, %rdx
addq $0x28, %rdx
movl (%rdx), %esi
cmpq %rcx, %rbp
jae 0x12ed37
incq %rbp
addq $0xa8, %rdx
cmpl %r15d, %esi
jae 0x12ed21
xorl %ecx, %ecx
cmpl %r15d, %esi
setb %cl
movq %rcx, 0x8(%rsp)
movq %r12, %rsi
movq 0x20(%rsp), %rbp
jmp 0x12ed71
movq %r12, %rsi
movq 0x20(%rsp), %rbp
movq 0x40(%rsp), %rdi
jmp 0x12ed71
movq %r14, %rax
jmp 0x12ed71
movq $0x0, 0x8(%rsp)
movq %r12, %rsi
movq %rdx, %rbp
incq %r12
movq %rax, %r14
cmpq %rbx, %r12
jbe 0x12ec16
jmp 0x12ed98
movq $0x0, 0x8(%rsp)
xorl %eax, %eax
movq %r15, %rdi
movl 0x198(%rsp), %r15d
movq %rax, 0x8(%rdi)
movq (%rbp), %rsi
movq 0x10(%rbp), %r9
movq 0x160(%rsp), %r13
cmpq %r13, %r9
jbe 0x12ee4b
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq %r9, %rdi
callq 0x127252
movq 0x10(%rbp), %r9
testq %r9, %r9
movq 0x8(%rsp), %r12
je 0x12ef07
movq 0x1b0(%rsp), %r14
movq 0x1a8(%rsp), %rbx
movq (%rbp), %rax
movq 0x10(%rsp), %rcx
decl %ecx
addq $0x4, %rax
movq %r9, %rdx
movl (%rax), %edi
movl 0x4(%rax), %r8d
testl %edi, %edi
je 0x12ee3f
movl $0x3, %esi
cmpl %ecx, %r8d
jb 0x12ee1a
xorl %esi, %esi
testl %edi, %edi
setne %sil
movslq 0x70(%rsp,%rsi,4), %rdi
incq %rdi
movl %edi, 0x70(%rsp,%rsi,4)
cmpq %r13, %rdi
jne 0x12ee32
movl 0x20(%rax), %edi
movl %edi, 0x60(%rsp,%rsi,4)
addq $0xa8, %rax
decq %rdx
jne 0x12edfe
jmp 0x12ee55
movl $0x2, %esi
cmpl %ecx, %r8d
jne 0x12ee12
jmp 0x12ee1a
movq 0x8(%rsp), %r12
jmp 0x12f2ce
movdqa 0x60(%rsp), %xmm0
pxor %xmm1, %xmm1
pcmpgtd %xmm1, %xmm0
movmskps %xmm0, %eax
testl %eax, %eax
je 0x12f2ca
xorl %r11d, %r11d
cmpq %r14, 0x10(%rsp)
jb 0x12ef0f
movslq 0x7c(%rsp), %rax
movl $0x0, %ebp
cmpq %r13, %rax
jb 0x12ef7b
movq 0x10(%rsp), %rax
xorl %edx, %edx
divq %r14
movq %rax, %r11
cmpq $0x1, %rdx
sbbq $-0x1, %r11
cmpq %r11, 0x8(%rbx)
jae 0x12ef13
leaq -0x1(%r11), %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
movq %r11, %r12
callq 0x2370
movq %r12, %r11
movq %rax, %rbp
movq %rax, 0x10(%rbx)
jmp 0x12ef20
xorl %r9d, %r9d
jmp 0x12f2ca
xorl %ebp, %ebp
jmp 0x12ef7b
movq 0x10(%rbx), %rbp
testq %r11, %r11
je 0x12f671
shrq %r13
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
movq %r14, %rdx
xorl %esi, %esi
xorl %edi, %edi
movq %rdi, %r9
addq %r14, %rdi
movq 0x10(%rsp), %r10
cmpq %rdx, %r10
movq %rdx, %r8
cmovbq %r10, %r8
cmpq %r10, %rdi
cmovbq %rdi, %r10
cmpq %r9, %r10
jbe 0x12f679
addq %rax, %r8
imulq %r13, %r8
cmpq %rcx, %r8
cmovaeq %rcx, %r8
shlq $0x20, %r8
movq %r8, (%rbp,%rsi,8)
incq %rsi
addq %r14, %rdx
subq %r14, %rax
cmpq %r11, %rsi
jb 0x12ef31
movq 0x20(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x12f2b0
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x10(%rsp), %rcx
decl %ecx
movl %ecx, 0x28(%rsp)
movq (%rax), %rsi
xorl %ebx, %ebx
xorl %r9d, %r9d
movq $0x0, 0x8(%rsp)
movq %r11, 0x30(%rsp)
imulq $0xa8, %rbx, %r8
movl 0x4(%rsi,%r8), %ecx
movl 0x8(%rsi,%r8), %r13d
testq %rcx, %rcx
movq %r9, 0x18(%rsp)
je 0x12f127
movl $0x3, %eax
cmpl 0x28(%rsp), %r13d
jb 0x12efe5
xorl %eax, %eax
testq %rcx, %rcx
setne %al
leaq (%rsi,%r8), %r9
movl 0x24(%r9), %edx
movl %eax, %edi
cmpl 0x60(%rsp,%rdi,4), %edx
jge 0x12f0a3
testq %r11, %r11
je 0x12f13c
cmpl $0x3, %eax
jne 0x12f13c
movq %r9, 0x38(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, %rax
xorl %edx, %edx
divq %r14
cmpq %r11, %rax
jae 0x12f206
incl %r13d
movq %rax, %rdx
imulq %r14, %rdx
movq %rax, %r9
movq %rdx, %r10
xorl %edi, %edi
xorl %r8d, %r8d
movq %r10, %r12
addq %r14, %r10
movq 0x10(%rsp), %r11
cmpq %r11, %r10
cmovbq %r10, %r11
cmpq %rcx, %r12
cmovbeq %rcx, %r12
cmpq %r13, %r11
cmovaeq %r13, %r11
subq %r12, %r11
jbe 0x12f146
movq (%rbp,%r9,8), %r12
movl %r12d, %r14d
addq %r11, %r14
shrq $0x20, %r12
cmpq %r12, %r14
jb 0x12f07d
xorl %r12d, %r12d
jmp 0x12f083
movq %r11, %r12
xorl %r11d, %r11d
addq %r12, %r8
addq %r11, %rdi
incq %r9
movq 0x30(%rsp), %r11
cmpq %r11, %r9
movq 0x1b0(%rsp), %r14
jb 0x12f03b
jmp 0x12f14b
movq %r9, 0x38(%rsp)
movq %r8, 0x48(%rsp)
testq %r11, %r11
je 0x12f206
movq %rcx, %rax
xorl %edx, %edx
divq %r14
cmpq %r11, %rax
jae 0x12f206
incl %r13d
movq %rax, %rdx
imulq %r14, %rdx
movq %rdx, %r8
addq %r14, %rdx
movq 0x10(%rsp), %rdi
cmpq %rdi, %rdx
cmovbq %rdx, %rdi
cmpq %rcx, %r8
cmovbeq %rcx, %r8
cmpq %r13, %rdi
cmovaeq %r13, %rdi
subq %r8, %rdi
jbe 0x12f206
movq (%rbp,%rax,8), %r8
movl %r8d, %r9d
addq %rdi, %r9
movq %r8, %r10
orq %r12, %r10
addq %rdi, %r8
cmpq %r12, %r9
cmovaeq %r10, %r8
movq %r8, (%rbp,%rax,8)
incq %rax
cmpq %r11, %rax
jb 0x12f0d1
jmp 0x12f206
movl $0x2, %eax
cmpl 0x28(%rsp), %r13d
jne 0x12efdd
jmp 0x12efe5
movq 0x18(%rsp), %r9
jmp 0x12f29c
movq 0x30(%rsp), %r11
movq %r8, %xmm0
movq 0x102128(%rip), %xmm2   # 0x231280
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0x10212c(%rip), %xmm3   # 0x231290
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 0x102408(%rip), %xmm2   # 0x2315a0
ucomisd %xmm2, %xmm1
jae 0x12f1ae
movq 0x18(%rsp), %r9
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x12f29c
cmpq %r11, %rax
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jae 0x12f206
movq %rdx, %r8
addq %r14, %rdx
movq 0x10(%rsp), %rdi
cmpq %rdi, %rdx
cmovbq %rdx, %rdi
cmpq %rcx, %r8
cmovbeq %rcx, %r8
cmpq %r13, %rdi
cmovaeq %r13, %rdi
subq %r8, %rdi
jbe 0x12f206
movq (%rbp,%rax,8), %r8
movl %r8d, %r9d
addq %rdi, %r9
movq %r8, %r10
orq %r12, %r10
addq %rdi, %r8
cmpq %r12, %r9
cmovaeq %r10, %r8
movq %r8, (%rbp,%rax,8)
incq %rax
cmpq %r11, %rax
jb 0x12f1b9
movq 0x18(%rsp), %r9
cmpq %rbx, %r9
je 0x12f27a
imulq $0xa8, %r9, %rax
addq %rax, %rsi
movl $0xa8, %edx
leaq 0x80(%rsp), %r13
movq %r13, %rdi
movq %r9, %r12
movq %rsi, %r14
callq 0x2160
movl $0xa8, %edx
movq %r14, %rdi
movq 0x38(%rsp), %rsi
callq 0x2160
movq 0x20(%rsp), %r14
movq 0x48(%rsp), %rdi
addq (%r14), %rdi
movl $0xa8, %edx
movq %r13, %rsi
callq 0x2160
movq %r12, %r9
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq 0x30(%rsp), %r11
movq (%r14), %rsi
movq 0x1b0(%rsp), %r14
imulq $0xa8, %r9, %rax
cmpl %r15d, 0x28(%rsi,%rax)
movl $0x1, %eax
movq 0x8(%rsp), %rcx
cmovbq %rax, %rcx
movq %rcx, 0x8(%rsp)
incq %r9
incq %rbx
movq 0x20(%rsp), %rax
cmpq 0x10(%rax), %rbx
jb 0x12efb2
jmp 0x12f2bc
movq $0x0, 0x8(%rsp)
xorl %r9d, %r9d
movq 0x20(%rsp), %rbp
movq %r9, 0x10(%rbp)
movq 0x8(%rsp), %r12
movq (%rbp), %rsi
movq %r9, %rdi
callq 0x126994
movq 0x10(%rbp), %rbx
testq %r12, %r12
je 0x12f551
testq %rbx, %rbx
je 0x12f548
movq 0x40(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, 0x58(%rsp)
xorl %r13d, %r13d
xorl %edi, %edi
movq (%rbp), %r12
imulq $0xa8, %r13, %rcx
leaq (%r12,%rcx), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, 0x38(%rsp)
movl 0x28(%r12,%rcx), %ecx
cmpl %r15d, %ecx
jae 0x12f4d9
movq 0x18(%rsp), %r9
movl 0x4(%r9), %r8d
movl 0x8(%r9), %edx
incl %edx
movq %rdx, %rsi
movq %r8, 0x30(%rsp)
subq %r8, %rsi
movq %rsi, %xmm0
punpckldq 0x101f33(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x101f3b(%rip), %xmm0   # 0x231290
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x10222f(%rip), %xmm1   # 0x231598
cvttsd2si %xmm1, %rsi
movq %rsi, %r8
sarq $0x3f, %r8
subsd 0x101f8b(%rip), %xmm1   # 0x231308
cvttsd2si %xmm1, %r10
andq %r8, %r10
orq %rsi, %r10
cmpq $0x11, %r10
movl $0x10, %esi
cmovbq %rsi, %r10
movq %r10, 0x48(%rsp)
movl 0x24(%r9), %esi
shll $0x4, %esi
movl %esi, 0x8(%rsp)
shll $0x4, %ecx
cmpl %ecx, %r15d
movl %ecx, %esi
cmoval %r15d, %esi
movl %esi, 0x10(%rsp)
xorl %r10d, %r10d
movq %r13, 0x28(%rsp)
imulq $0xa8, %r10, %r14
movl 0x4(%r12,%r14), %r11d
cmpl %r11d, %edx
jbe 0x12f4d9
movq %rbx, %r9
addq %r12, %r14
movl 0x10(%rsp), %esi
cmpl %esi, 0x28(%r14)
jb 0x12f3ec
movl 0x8(%rsp), %esi
cmpl %esi, 0x24(%r14)
jge 0x12f3fc
incq %r10
movq %r9, %rbx
cmpq %r9, %r10
jne 0x12f3bd
jmp 0x12f4d9
movl 0x8(%r14), %ebx
incl %ebx
movq 0x30(%rsp), %rsi
cmpl %esi, %r11d
cmoval %r11d, %esi
cmpl %edx, %ebx
cmovael %edx, %ebx
cmpl %esi, %ebx
jbe 0x12f3ec
movq %rbx, %r15
subq %rsi, %r15
cmpq 0x48(%rsp), %r15
movl 0x198(%rsp), %r15d
jb 0x12f3ec
movl 0x30(%r14), %r14d
movq 0x58(%rsp), %r13
subq %r14, %r13
jbe 0x12f4be
movq %rdi, 0x50(%rsp)
movq (%rax), %r15
shlq $0x4, %r14
addq %r15, %r14
addq $0xc, %r14
movl -0xc(%r14), %ebp
xorl %r15d, %r15d
movl -0xc(%r14), %edi
xorl %ebp, %edi
testl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
jne 0x12f497
cmpq %rcx, %r15
jae 0x12f497
movl -0x4(%r14), %eax
movzbl (%r14), %r8d
movq %rax, %rdi
subq %r8, %rdi
cmpq %rsi, %rdi
setae %dil
cmpl %ebx, %eax
setbe %al
andb %dil, %al
movzbl %al, %eax
addq %rax, %r15
addq $0x10, %r14
decq %r13
jne 0x12f458
cmpq %rcx, %r15
movq 0x20(%rsp), %rbp
movq 0x40(%rsp), %rax
movl 0x198(%rsp), %r15d
movq 0x28(%rsp), %r13
movq 0x50(%rsp), %rdi
jb 0x12f3ec
jmp 0x12f4d1
testq %rcx, %rcx
movq 0x28(%rsp), %r13
jne 0x12f3ec
movq %r9, %rbx
jmp 0x12f53a
cmpl %r11d, %edx
movq %r9, %rbx
ja 0x12f53a
cmpq %r13, %rdi
je 0x12f537
imulq $0xa8, %rdi, %rax
addq %rax, %r12
movl $0xa8, %edx
movq %rdi, %rbx
leaq 0x80(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x2160
movl $0xa8, %edx
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x2160
movq 0x38(%rsp), %rdi
addq (%rbp), %rdi
movl $0xa8, %edx
movq %r14, %rsi
callq 0x2160
movq %rbx, %rdi
movq 0x40(%rsp), %rax
movq 0x10(%rbp), %rbx
incq %rdi
incq %r13
cmpq %rbx, %r13
jb 0x12f2ff
jmp 0x12f54a
xorl %edi, %edi
movq %rdi, 0x10(%rbp)
movq %rdi, %rbx
testq %rbx, %rbx
je 0x12f65f
leaq 0x3(%rbx), %rcx
andq $-0x4, %rcx
decq %rbx
movq %rbx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movl $0x220, %eax            # imm = 0x220
addq (%rbp), %rax
movdqa 0x101d40(%rip), %xmm1   # 0x2312c0
movdqa 0x101d48(%rip), %xmm2   # 0x2312d0
movdqa 0x101d50(%rip), %xmm3   # 0x2312e0
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x101f90(%rip), %xmm5   # 0x231530
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x12f5de
movl $0x0, -0x1f8(%rax)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x12f5f6
movl $0x0, -0x150(%rax)
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x12f637
movl $0x0, -0xa8(%rax)
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x12f647
movl $0x0, (%rax)
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0x2a0, %rax            # imm = 0x2A0
addq $-0x4, %rcx
jne 0x12f5a0
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r11d, %r11d
jmp 0x12ef7b
leaq 0x10b745(%rip), %rdi    # 0x23adc5
leaq 0x10b57c(%rip), %rsi    # 0x23ac03
leaq 0x10b741(%rip), %rcx    # 0x23adcf
movl $0x7b4, %edx            # imm = 0x7B4
callq 0x2110