// File: /workspace/github_cpp_makefile_star2_O2/chhylp123[P]hifiasm/inter.cpp
// Function: gl_chain_lin(kv_ul_ov_t*, overlap_region*, ul_ov_t*, ul_idx_t const*, ug_opt_t const*, long, double, long, long, long, long, Chain_Data*, long, unsigned long, All_reads*, ma_ug_t*, long, long)
int64_t gl_chain_lin(kv_ul_ov_t *res, overlap_region *ol, 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, int64_t max_iter, int64_t max_dis, Chain_Data* dp, int64_t trans_sc, 
uint64_t mode, All_reads *ridx, ma_ug_t *ug, int64_t need_srt, int64_t debug_i)
{
	if(res->n == 0) return 0;
	uint32_t rev_n; int32_t *f, *c_n, *c_sc; int64_t *p, *t, res_n = res->n, st, max_ii, max; rtrace_iter tc;
    int64_t mm_ovlp, x, i, j, k, sc, csc, mm_sc, mm_idx, n_skip, end_j, plus; ul_ov_t *li, *lj, rev_t; 
	resize_Chain_Data(dp, res_n, NULL); memset(&tc, 0, sizeof(tc));
	t = dp->tmp; f = dp->score; p = dp->pre; c_n = dp->occ; c_sc = dp->self_length;
	if(need_srt) {
		radix_sort_ul_ov_srt_qe(res->a, res->a + res_n);
		for (i = 1, j = 0; i <= res_n; i++) {
			if (i == 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;
			}
		}
	}
	
	memset(t, 0, (res_n*sizeof((*t))));
	for (i = st = plus = 0, max_ii = -1; i < res_n; ++i) {
		li = &(res->a[i]); 
        mm_ovlp = mode?max_ovlp_src(uopt, ((li->tn<<1)|li->rev)^1):max_ovlp(uref->ug->g, ((li->tn<<1)|li->rev)^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); 
		csc = aln_sc(ol[(*li).qn], trans_sc, UG_TRANS_ERR_W);
		// fprintf(stderr, "[M::%s::utg%.6dl] i::%ld, csc::%ld, q::[%u, %u), aln::%u, ol::%u, sec_e::%u\n", 
		// 						__func__, (int32_t)li->tn+1, i, csc, li->qs, li->qe, 
		// 						(ol[(*li).qn]).align_length, (ol[(*li).qn]).overlapLen, 
		// 						(ol[(*li).qn]).non_homopolymer_errors);
		mm_sc = csc; mm_idx = -1; 
		n_skip = 0; end_j = -1; tc.k = INT32_MAX;
		if ((x-st) > max_iter) st = x-max_iter;
		for (j = x; j >= st; --j) { // collect potential destination vertices
			lj = &(res->a[j]); 
			if(lj->qe+G_CHAIN_INDEL <= li->qs) break;//even this pair has a overlap, its length will be very small; just ignore
			sc = cal_gl_chain_lin_sc(res->a, i, j, &tc, ol, ridx, ug, uref, uopt, bw, diff_ec_ul, mode, trans_sc, UG_TRANS_ERR_W, f, debug_i);
			// char *as = NULL; 
			// asprintf(&as, "-3-[M::%s::] i::%ld(utg%.6dl), j::%ld(utg%.6dl), sc::%ld\n", 
			// __func__, i, (int32_t)li->tn+1, j, (int32_t)lj->tn+1, sc);
			// push_vlog(&(overall_zdbg->a[debug_i]), as); free(as); as = NULL;

			if(sc == INT32_MIN) continue;
			if(sc > mm_sc) {
				mm_sc = sc, mm_idx = j;
				if (n_skip > 0) --n_skip;
			} else if (t[j] == i) {
				if (++n_skip > max_skip)
					break;
			}
			if (p[j] >= 0) t[p[j]] = i;
		}
	
		end_j = j;
		if (max_ii < 0 || (res->a[i].qe>(res->a[max_ii].qe+max_dis))) {//too long
			max = INT32_MIN; max_ii = -1;
            for (j = i - 1; (j >= st) && (res->a[i].qe<=(max_dis+res->a[j].qe)); --j) {
                if (max < f[j]) {
                    max = f[j], max_ii = j;
                }
            }
		}
		
        if (max_ii >= 0 && max_ii < end_j) {///just have a try with a[i]<->a[max_ii]
			lj = &(res->a[max_ii]); 
			if(lj->qe+G_CHAIN_INDEL > li->qs && lj->qs < li->qs) {
				sc = cal_gl_chain_lin_sc(res->a, i, max_ii, &tc, ol, ridx, ug, uref, uopt, bw, diff_ec_ul, mode, trans_sc, UG_TRANS_ERR_W, f, debug_i);
				if(sc != INT32_MIN) {
					if(sc > mm_sc) {
						mm_sc = sc; mm_idx = max_ii;
					}
				}
			}
		}
        if(mm_sc < 0) {
			mm_sc = csc; mm_idx = -1; 
		}
		f[i] = mm_sc; p[i] = mm_idx;
        if ((max_ii < 0) || ((res->a[i].qe<=max_dis+res->a[max_ii].qe) && (f[max_ii]<f[i]))) {
            max_ii = i;
        }
		if(mm_sc < plus) plus = mm_sc;//minmun negative
		// fprintf(stderr, "-5-[M::%s::utg%.6dl] i::%ld, res_n::%ld, csc::%ld, f[i]::%d, p[i]::%ld, q::[%u, %u)\n", 
		// 						__func__, (int32_t)li->tn+1, i, res_n, csc, f[i], p[i], li->qs, li->qe);
		// char *as = NULL; 
		// asprintf(&as, "-5-[M::%s::utg%.6dl] i::%ld, csc::%ld, f[i]::%d, p[i]::%ld, q::[%u, %u)\n", __func__, (int32_t)li->tn+1, i, csc, f[i], p[i], li->qs, li->qe);
        // push_vlog(&(overall_zdbg->a[debug_i]), as); free(as); as = NULL;
	}
	for (i = 0; i < res_n; ++i) {///make all f[] positive
		f[i] -= plus; t[i] = ((uint64_t)f[i])<<32; t[i] += (i<<1);
	}

	int64_t n_v, n_u, n_v0; 
	radix_sort_gfa64i(t, t + res_n); plus = 0;
	for (k = res_n-1, n_v = n_u = 0; k >= 0; --k) {
		n_v0 = n_v;
		for (i = ((uint32_t)t[k])>>1; i >= 0 && (t[i]&1) == 0; ) {
			ex[n_v++] = res->a[i]; t[i] |= 1; i = p[i];
		}
		if(n_v0 == n_v) continue;
		sc = (i<0?(t[k]>>32):((t[k]>>32)-f[i]));
		// fprintf(stderr, "[M::%s::] n_v::%ld, n_v0::%ld, t[k]::%ld, sc::%ld\n", 
		// 						__func__, n_v, n_v0, t[k]>>32, sc);
		c_n[n_u] = n_v-n_v0; c_sc[n_u] = sc; n_u++; if(sc < plus) plus = sc;
	}
	// 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 += c_n[k];
		res->a[k].qn = c_sc[k]-plus;//score
        res->a[k].ts = n_v0; res->a[k].te = n_v;///idx
		// fprintf(stderr, "[M::%s] k:%ld, c_sc:%d\n", __func__, k, c_sc[k]);

		rev_n = c_n[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;
            ex[n_v0+i].sec = ex[n_v-i-1].sec = SEC_MODE; 
        }
        if(c_n[k]&1) {
            if(res->a[k].qs > ex[n_v0+i].qs) res->a[k].qs = ex[n_v0+i].qs;
            ex[n_v0+i].sec = SEC_MODE; 
        }
	}
	res->n = n_u;
    radix_sort_ul_ov_srt_qn(res->a, res->a + res->n);//sort by score
    return n_v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movsd %xmm0, 0x78(%rsp)
movq %r9, 0x70(%rsp)
movq %r8, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
je 0x16b867
movq %rdi, %rbx
movq 0x1f8(%rsp), %r15
movq 0x1d0(%rsp), %r14
movq 0x1b0(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %r14, %rdi
xorl %edx, %edx
movq %rsi, %r13
callq 0x1383e
leaq 0xe8(%rsp), %rdi
movl $0x90, %edx
xorl %esi, %esi
callq 0x20e0
movq 0x28(%r14), %rax
movq %rax, 0x20(%rsp)
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %r12
movq 0x20(%r14), %rax
movq %rax, 0x40(%rsp)
movq 0x18(%r14), %rax
movq %rax, 0x80(%rsp)
testq %r15, %r15
movq %r13, 0x28(%rsp)
je 0x16b86f
movq (%rbx), %rdi
imulq $0x1c, %r13, %rsi
addq %rdi, %rsi
callq 0x156f5c
xorl %eax, %eax
testq %r13, %r13
movl $0x0, %r14d
cmovgq %r13, %r14
movq %r14, 0x30(%rsp)
negq %r14
pushq $0x1
popq %r15
pushq $0x1c
popq %rbp
movq %r13, %rdi
leaq (%r14,%r15), %rcx
cmpq $0x1, %rcx
je 0x16b860
cmpq %r15, %rdi
je 0x16b82b
movq (%rbx), %rcx
movl 0x8(%rcx,%rbp), %edx
imulq $0x1c, %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x16b82b
movq %rax, %rcx
jmp 0x16b854
movq %r15, %rdx
subq %rax, %rdx
movq %r15, %rcx
cmpq $0x2, %rdx
jl 0x16b854
movq (%rbx), %rsi
imulq $0x1c, %rax, %rdi
addq %rsi, %rdi
addq %rbp, %rsi
callq 0x1571fa
movq 0x28(%rsp), %rdi
movq %r15, %rcx
incq %r15
addq $0x1c, %rbp
movq %rcx, %rax
jmp 0x16b806
movq 0x30(%rsp), %r14
jmp 0x16b87c
xorl %r14d, %r14d
jmp 0x16bf60
xorl %r14d, %r14d
testq %r13, %r13
cmovgq %r13, %r14
movq %r13, %rdi
leaq (,%rdi,8), %rdx
xorl %ebp, %ebp
movq 0x20(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
incq 0x88(%rsp)
pushq $-0x1
popq %rax
pushq $-0x5
popq %r9
movq %rax, %r10
movq %rax, %rdi
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %r12, 0xa0(%rsp)
movq %r14, 0x30(%rsp)
movq %r14, %r8
cmpq %r8, %rbp
je 0x16bd0f
movq %rdi, 0xb8(%rsp)
movq %r10, 0x90(%rsp)
movq %r9, 0x98(%rsp)
movq %r13, 0x38(%rsp)
movq (%rbx), %r13
imulq $0x1c, %rbp, %rax
movq %rax, 0x50(%rsp)
leaq (%rax,%r13), %r12
cmpq $0x0, 0x1e0(%rsp)
je 0x16b91e
movl 0xc(%r12), %eax
movl 0x18(%r12), %esi
shrdl $0x1f, %eax, %esi
xorl $0x1, %esi
movq 0x60(%rsp), %rdi
callq 0x15d49a
movq (%rbx), %r13
jmp 0x16b940
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
movl 0xc(%r12), %eax
movl 0x18(%r12), %esi
shrdl $0x1f, %eax, %esi
xorl $0x1, %esi
callq 0x15d450
movl 0x4(%r12), %ecx
addq %rax, %rcx
cvtsi2sd %rcx, %xmm0
mulsd 0x78(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x70(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
movq 0x88(%rsp), %rax
cmpq %rax, %rdx
cmovgeq %rax, %rdx
subl $-0x80, %edx
movq %rbp, %r14
movl %ebp, %edi
movq %r13, %rsi
callq 0x160717
movslq %eax, %r13
movq %r12, 0xa8(%rsp)
movl (%r12), %eax
imulq $0xa8, %rax, %rax
movq 0x68(%rsp), %rdx
movl 0x20(%rdx,%rax), %ecx
movl 0x28(%rdx,%rax), %esi
subl %esi, %ecx
imulq 0x1d8(%rsp), %rcx
movl 0x30(%rdx,%rax), %eax
shlq $0x6, %rax
addq %rcx, %rax
subq %rax, %rsi
movq $0x7fffffff, 0xe0(%rsp) # imm = 0x7FFFFFFF
movq %r13, %rax
subq %r15, %rax
movq %r13, %rcx
movq 0x1c0(%rsp), %rdx
subq %rdx, %rcx
cmpq %rdx, %rax
cmovgq %rcx, %r15
imulq $0x1c, %r13, %r12
addq $0x8, %r12
movq %rsi, 0xb0(%rsp)
movq %rsi, 0x18(%rsp)
pushq $-0x1
popq %rax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
cmpq %r15, %r13
jl 0x16baf1
movq (%rbx), %rdi
movl (%rdi,%r12), %eax
subl $-0x80, %eax
movq 0xa8(%rsp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x16baf1
subq $0x10, %rsp
movl %r14d, %esi
movl %r13d, %edx
leaq 0xf0(%rsp), %rcx
movq 0x78(%rsp), %r8
movq 0x1f8(%rsp), %r9
movsd 0x88(%rsp), %xmm0
pushq 0x18(%rsp)
pushq $0x40
pushq 0x1f8(%rsp)
pushq 0x208(%rsp)
pushq 0xa0(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x238(%rsp)
callq 0x16b51e
addq $0x50, %rsp
cmpq $-0x80000000, %rax      # imm = 0x80000000
je 0x16bae5
cmpq 0x18(%rsp), %rax
jle 0x16bab3
xorl %ecx, %ecx
testq %rbp, %rbp
setg %cl
subq %rcx, %rbp
movq %rax, 0x18(%rsp)
movq %r13, 0x10(%rsp)
jmp 0x16bacb
movq 0x20(%rsp), %rax
cmpq %r14, (%rax,%r13,8)
jne 0x16bacb
cmpq 0x1b8(%rsp), %rbp
jge 0x16baf1
incq %rbp
movq 0xa0(%rsp), %rax
movq (%rax,%r13,8), %rax
testq %rax, %rax
js 0x16bae5
movq 0x20(%rsp), %rcx
movq %r14, (%rcx,%rax,8)
decq %r13
addq $-0x1c, %r12
jmp 0x16ba08
movq 0xb8(%rsp), %rdi
testq %rdi, %rdi
movq 0xa0(%rsp), %r12
movq 0x1c8(%rsp), %r8
movq 0x98(%rsp), %r9
movq 0x90(%rsp), %r10
js 0x16bb3a
movq (%rbx), %rax
movq 0x50(%rsp), %rcx
movl 0x8(%rax,%rcx), %ecx
imulq $0x1c, %rdi, %rdx
movl 0x8(%rax,%rdx), %eax
addq %r8, %rax
cmpq %rcx, %rax
jge 0x16bb90
movq $-0x80000000, %rax      # imm = 0x80000000
movq %r9, %rcx
movq %r10, %rdx
pushq $-0x1
popq %rdi
leaq 0x1(%rdx), %rsi
cmpq %r15, %rsi
jle 0x16bb90
movq %rdi, %r11
movq (%rbx), %rsi
movq 0x50(%rsp), %rdi
movl 0x8(%rsi,%rdi), %edi
movl (%rsi,%rcx,4), %esi
addq %r8, %rsi
cmpq %rdi, %rsi
jl 0x16bb8d
movq 0x8(%rsp), %rsi
movslq (%rsi,%rdx,4), %rsi
cmpq %rsi, %rax
cmovleq %rsi, %rax
movq %r11, %rdi
cmovlq %rdx, %rdi
decq %rdx
addq $-0x7, %rcx
jmp 0x16bb4a
movq %r11, %rdi
testq %rdi, %rdi
js 0x16bc85
cmpq %r13, %rdi
jge 0x16bc85
movq %rdi, %rax
movq (%rbx), %rdi
movq %rax, %r11
imulq $0x1c, %rax, %rax
movl 0x8(%rdi,%rax), %edx
subl $-0x80, %edx
movq 0xa8(%rsp), %rcx
movl 0x4(%rcx), %ecx
cmpl %ecx, %edx
movq 0x38(%rsp), %r13
jbe 0x16bc8c
addq %rdi, %rax
cmpl %ecx, 0x4(%rax)
movq %r14, %rbp
jae 0x16bd0a
subq $0x10, %rsp
movl %ebp, %esi
movq %r11, %r14
movl %r14d, %edx
leaq 0xf0(%rsp), %rcx
movq 0x78(%rsp), %r8
movq 0x1f8(%rsp), %r9
movsd 0x88(%rsp), %xmm0
pushq 0x18(%rsp)
pushq $0x40
pushq 0x1f8(%rsp)
pushq 0x208(%rsp)
pushq 0xa0(%rsp)
pushq 0x98(%rsp)
pushq 0x98(%rsp)
pushq 0x238(%rsp)
callq 0x16b51e
movq %r14, %rdi
movq 0xe0(%rsp), %r10
movq 0xe8(%rsp), %r9
movq 0x218(%rsp), %r8
addq $0x50, %rsp
cmpq $-0x80000000, %rax      # imm = 0x80000000
setne %cl
movq 0x18(%rsp), %rsi
cmpq %rsi, %rax
setg %dl
testb %dl, %cl
cmovneq %rax, %rsi
movq %rsi, 0x18(%rsp)
movq 0x10(%rsp), %rdx
cmovneq %r14, %rdx
jmp 0x16bc97
movq 0x38(%rsp), %r13
jmp 0x16bc8f
movq %r11, %rdi
movq %r14, %rbp
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rax
testq %rax, %rax
movq 0xb0(%rsp), %rcx
cmovnsq %rax, %rcx
pushq $-0x1
popq %rax
cmovsq %rax, %rdx
movq 0x8(%rsp), %rax
movq %rcx, %rsi
movl %ecx, (%rax,%rbp,4)
movq %rdx, (%r12,%rbp,8)
testq %rdi, %rdi
js 0x16bcec
movq (%rbx), %rax
movq 0x50(%rsp), %rcx
movl 0x8(%rax,%rcx), %ecx
imulq $0x1c, %rdi, %rdx
movl 0x8(%rax,%rdx), %eax
addq %r8, %rax
cmpq %rcx, %rax
jl 0x16bcef
movq 0x8(%rsp), %rax
cmpl %esi, (%rax,%rdi,4)
jge 0x16bcef
movq %rbp, %rdi
cmpq %r13, %rsi
cmovlq %rsi, %r13
incq %rbp
incq %r10
addq $0x7, %r9
movq 0x30(%rsp), %r8
jmp 0x16b8bd
movq %r11, %rdi
jmp 0x16bc92
xorl %eax, %eax
movq 0x28(%rsp), %rdx
movq 0x20(%rsp), %r14
movq 0x8(%rsp), %rsi
subq $0x1, %r8
jb 0x16bd40
movl (%rsi,%rax,2), %ecx
subl %r13d, %ecx
movl %ecx, (%rsi,%rax,2)
shlq $0x20, %rcx
addq %rax, %rcx
movq %rcx, (%r14,%rax,4)
addq $0x2, %rax
jmp 0x16bd20
leaq (%r14,%rdx,8), %rsi
movq %r14, %rdi
callq 0x156cf6
movq 0x28(%rsp), %r11
xorl %eax, %eax
xorl %r8d, %r8d
xorl %ecx, %ecx
testq %r11, %r11
jle 0x16bdff
movq %r8, %rdx
decq %r11
movl (%r14,%r11,8), %edi
shrl %edi
imulq $0x1c, %r8, %r8
addq 0x48(%rsp), %r8
xorl %esi, %esi
testq %rdi, %rdi
js 0x16bdb3
testb $0x1, (%r14,%rdi,8)
jne 0x16bdb3
movq (%rbx), %r9
imulq $0x1c, %rdi, %r10
movupd (%r9,%r10), %xmm0
movups 0xc(%r9,%r10), %xmm1
movups %xmm1, 0xc(%r8)
movupd %xmm0, (%r8)
orb $0x1, (%r14,%rdi,8)
movq (%r12,%rdi,8), %rdi
decq %rsi
addq $0x1c, %r8
jmp 0x16bd78
movq %rdx, %r8
subq %rsi, %r8
testq %rsi, %rsi
je 0x16bd58
movslq 0x4(%r14,%r11,8), %r8
testq %rdi, %rdi
js 0x16bdd4
movq 0x8(%rsp), %r9
movslq (%r9,%rdi,4), %rdi
subq %rdi, %r8
subq %rsi, %rdx
negl %esi
movq 0x40(%rsp), %rdi
movl %esi, (%rdi,%rcx,4)
movq 0x80(%rsp), %rsi
movl %r8d, (%rsi,%rcx,4)
incq %rcx
cmpq %rax, %r8
cmovlq %r8, %rax
movq %rdx, %r8
jmp 0x16bd58
movq 0x48(%rsp), %rdx
addq $-0x1c, %rdx
xorl %esi, %esi
movl $0x3fffffff, %edi       # imm = 0x3FFFFFFF
xorl %r14d, %r14d
cmpq %rcx, %rsi
je 0x16bf4d
movq 0x40(%rsp), %r15
movslq (%r15,%rsi,4), %r8
addq %r14, %r8
movq 0x80(%rsp), %r9
movl (%r9,%rsi,4), %r10d
subl %eax, %r10d
movq (%rbx), %r11
imulq $0x1c, %rsi, %r9
movl %r10d, (%r11,%r9)
movl %r14d, 0x10(%r11,%r9)
movl %r8d, 0x14(%r11,%r9)
movl (%r15,%rsi,4), %r15d
sarl %r15d
orl $-0x1, 0x4(%r11,%r9)
imulq $0x1c, %r14, %r14
movq 0x48(%rsp), %r12
leaq (%r12,%r14), %r10
movl 0x8(%r12,%r14), %ebp
movl %ebp, 0x8(%r11,%r9)
imulq $0x1c, %r15, %r11
imulq $0x1c, %r8, %r14
addq %rdx, %r14
xorl %r15d, %r15d
cmpq %r15, %r11
je 0x16bf12
movups (%r10,%r15), %xmm0
movups 0xc(%r10,%r15), %xmm1
movups %xmm1, 0xcc(%rsp)
movaps %xmm0, 0xc0(%rsp)
movups (%r14), %xmm0
movups 0xc(%r14), %xmm1
movups %xmm1, 0xc(%r10,%r15)
movups %xmm0, (%r10,%r15)
movups 0xcc(%rsp), %xmm0
movups %xmm0, 0xc(%r14)
movapd 0xc0(%rsp), %xmm0
movupd %xmm0, (%r14)
movq (%rbx), %r12
addq %r9, %r12
addq $0x4, %r12
movl (%r12), %ebp
movl 0x4(%r10,%r15), %r13d
cmpl %r13d, %ebp
jbe 0x16beef
movl %r13d, (%r12)
movl %r13d, %ebp
movl 0x4(%r14), %r13d
cmpl %r13d, %ebp
jbe 0x16befc
movl %r13d, (%r12)
orl %edi, 0x18(%r14)
orl %edi, 0x18(%r10,%r15)
addq $0x1c, %r15
addq $-0x1c, %r14
jmp 0x16be7d
movq 0x40(%rsp), %r14
testb $0x1, (%r14,%rsi,4)
je 0x16bf42
movq (%rbx), %r14
movl 0x4(%r10,%r11), %ebp
cmpl %ebp, 0x4(%r14,%r9)
jbe 0x16bf37
addq %r14, %r9
addq $0x4, %r9
movl %ebp, (%r9)
addq %r11, %r10
orl $0x3fffffff, 0x18(%r10) # imm = 0x3FFFFFFF
incq %rsi
movq %r8, %r14
jmp 0x16be12
movq %rcx, 0x8(%rbx)
movq (%rbx), %rdi
imulq $0x1c, %rcx, %rsi
addq %rdi, %rsi
callq 0x15775d
movq %r14, %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq