// File: /workspace/github_cpp_makefile_star2_O3/chhylp123[P]hifiasm/inter.cpp
// Function: ed_dp_c(overlap_region_alloc*, 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*, double, unsigned long, All_reads*, ma_ug_t*, unsigned int)
int64_t ed_dp_c(overlap_region_alloc *o, 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, double err_sc, 
uint64_t mode, All_reads *ridx, ma_ug_t *ug, uint32_t need_srt)
{
    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, qovl, minus_sc, pj, n_skip, wi, werr;
    ul_ov_t *li = NULL, *lj = NULL, rev_t;
	if(need_srt) {
		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;
			}
		}
	}
	///res->a[0].qe: min_qe; res->a[res->n-1].qs: max_qs
	if(res->a[0].qe == qlen && res->a[res->n-1].qs == 0) {///all alignments are contained
		for (i = 0; i < (int64_t)res->n; ++i) {
			li = &(res->a[i]); assert(li->qs == 0 && li->qe == qlen);
			csc = (li->qe-li->qs); minus_sc = (o->list[li->qn].non_homopolymer_errors*err_sc);
			csc -= minus_sc; if(csc <= 0) csc = 1; mm_sc = csc; mm_idx = -1;

			if(mm_sc > ((int64_t)0x7fffffff)) mm_sc = ((int64_t)0x7fffffff);
			track[i] = push_sc_pre(mm_sc, mm_idx);
			srt[i] = track[i]>>32; srt[i] <<= 32; srt[i] |= i;
		}
	} else {
		memset(idx, 0, (sizeof((*idx))*res->n));
		for (i = 0; i < (int64_t)res->n; ++i) {
			li = &(res->a[i]); li_v = (li->tn<<1)|li->rev;
			// fprintf(stderr, "[M::%s::i->%ld::utg%.6dl] q[%u, %u), t[%u, %u)\n", __func__, i, (int32_t)li->tn+1, li->qs, li->qe, li->ts, li->te);
			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); 
			csc = (li->qe-li->qs); minus_sc = (o->list[li->qn].non_homopolymer_errors*err_sc);
			csc -= minus_sc; if(csc <= 0) csc = 1;
			mm_sc = csc; mm_idx = -1; n_skip = 0; wi = werr = 0;
			for (j = x; j >= 0; --j) { // collect potential destination vertices
				lj = &(res->a[j]); lj_v = (lj->tn<<1)|lj->rev;
				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;///at boundary, migh be lj->qs == li->qs
				qo = infer_rovlp(li, lj, NULL, NULL, ridx, ug); ///overlap length in query (UL read)
				// fprintf(stderr, "[M::%s::j->%ld] qo::%ld\n", __func__, j, qo);
				if(li_v != lj_v && get_ecov_adv(uref, uopt, li_v^1, lj_v^1, bw, diff_ec_ul, qo, mode, NULL)) {
					qovl = ((MIN(li->qe, lj->qe) > MAX(li->qs, lj->qs))? (MIN(li->qe, lj->qe) - MAX(li->qs, lj->qs)):0);
					// fprintf(stderr, "[M::%s::] utg%.6dl->utg%.6dl, icsc::%ld, ierr::%u, ilen::%u, aln::%u, app_sc::%ld\n", 
					// __func__, (int32_t)li->tn+1, (int32_t)lj->tn+1, csc, o->list[li->qn].non_homopolymer_errors, 
					// li->qe - li->qs, o->list[li->qn].align_length, comput_sc_partial_cigar(csc, qovl, err_sc, &(o->list[li->qn]), &wi, &werr));
					sc = comput_sc_partial_cigar(csc, qovl, err_sc, &(o->list[li->qn]), &wi, &werr) 
																						+ pop_sc(track[j]);
					// fprintf(stderr, "[M::%s::j->%ld] qo::%ld, sc::%ld, mm_sc::%ld\n", __func__, j, qo, sc, mm_sc);
					if(sc > mm_sc) {
						mm_sc = sc, mm_idx = j;
						if (n_skip > 0) --n_skip;
					} else if (idx[j] == (uint64_t)i) {
						if (++n_skip > max_skip)
							break;
					}
					pj = pop_pre(track[j]);
					if(pj >= 0) idx[pj] = i;
				}
			}
			if(mm_sc > ((int64_t)0x7fffffff)) mm_sc = ((int64_t)0x7fffffff);
			track[i] = push_sc_pre(mm_sc, mm_idx);
			srt[i] = track[i]>>32; srt[i] <<= 32; srt[i] |= i;
			// fprintf(stderr, "[M::%s::i->%ld] mm_idx::%ld\n", __func__, i, mm_idx);
		}
	}
    
    int64_t n_v, n_u, n_v0; 
    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; 
		for (i = (uint32_t)srt[k]; i >= 0 && (track[i]&((uint64_t)0x80000000)) == 0;) {
			ex[n_v++] = res->a[i]; track[i] |= ((uint64_t)0x80000000);
			i = pop_pre(track[i]);
		}
        if(n_v0 == n_v) continue;
        sc = (i<0?(pop_sc(srt[k])):(pop_sc(srt[k])-pop_sc(track[i])));
        if(sc < 0) {
            n_v = n_v0;
            continue;
        }
        idx[n_u++] = ((uint64_t)sc<<32)|(n_v-n_v0); 
    }

    for (k = 0, n_v = n_v0 = 0; k < n_u; k++) {
        n_v0 = n_v; n_v += (uint32_t)idx[k];
        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;
        }
        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;
        }
    }
    
    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 $0xb8, %rsp
movsd %xmm1, 0x38(%rsp)
movsd %xmm0, 0x10(%rsp)
movq %r9, 0x68(%rsp)
movq %r8, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movq %rdx, %r15
movq %rdi, 0x30(%rsp)
movq 0x8(%rsi), %rdx
testq %rdx, %rdx
je 0x1ba553
movq %rsi, %rbp
movq 0xf0(%rsp), %r13
cmpl $0x0, 0x130(%rsp)
je 0x1b9e65
movq (%rbp), %rdi
leaq (%rdx,%rdx,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdi, %rdx
addq %rax, %rdx
movq %rdx, %rsi
callq 0x19e2b4
movq 0x8(%rbp), %rdx
testq %rdx, %rdx
jle 0x1b9e65
movl $0x1, %r14d
movl $0x1c, %ebx
xorl %eax, %eax
cmpq %rdx, %r14
je 0x1b9e22
movq (%rbp), %rcx
movl 0x8(%rcx,%rbx), %esi
leaq (%rax,%rax,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rax, %rdi
cmpl 0x8(%rcx,%rdi), %esi
jne 0x1b9e22
movq %rax, %rcx
jmp 0x1b9e52
movq %r14, %rsi
subq %rax, %rsi
movq %r14, %rcx
cmpq $0x2, %rsi
jl 0x1b9e52
movq (%rbp), %rsi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rdi
addq %rax, %rdi
addq %rsi, %rdi
addq %rbx, %rsi
callq 0x19e55c
movq 0x8(%rbp), %rdx
movq %r14, %rcx
leaq 0x1(%r14), %rsi
addq $0x1c, %rbx
movq %rcx, %rax
cmpq %rdx, %r14
movq %rsi, %r14
jl 0x1b9dff
movq %r15, 0x48(%rsp)
movq 0x110(%rsp), %r12
movq (%rbp), %rax
movl 0x8(%rax), %ecx
cmpq %r13, %rcx
movq %rbp, 0x20(%rsp)
jne 0x1b9e99
leaq (%rdx,%rdx,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %rdx, %rcx
cmpl $0x0, -0x18(%rax,%rcx)
je 0x1ba58d
shlq $0x3, %rdx
movq 0x108(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
movq 0x8(%rbp), %rdx
testq %rdx, %rdx
jle 0x1ba26f
incq %r13
xorl %ebx, %ebx
movq %r13, 0x70(%rsp)
movq (%rbp), %r14
leaq (%rbx,%rbx,8), %rax
leaq (%rax,%rax,2), %r15
addq %rbx, %r15
movl 0xc(%r14,%r15), %eax
movl 0x18(%r14,%r15), %esi
shrdl $0x1f, %eax, %esi
cmpq $0x0, 0x118(%rsp)
movl %esi, 0x18(%rsp)
je 0x1b9efe
xorl $0x1, %esi
movq 0x60(%rsp), %rdi
callq 0x1a4c50
jmp 0x1b9f68
movq 0x58(%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 0x1b9f66
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 0x1b9f44
movl %esi, %eax
jmp 0x1b9f68
xorl %eax, %eax
addq %r14, %r15
movl 0x4(%r15), %ecx
addq %rax, %rcx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x10(%rsp), %xmm0
cvttsd2si %xmm0, %rdx
movq 0x68(%rsp), %rax
cmpq %rax, %rdx
cmovleq %rax, %rdx
addq %rcx, %rdx
cmpq %r13, %rdx
cmovgeq %r13, %rdx
subl $-0x80, %edx
movl %ebx, %edi
movq %r14, %rsi
callq 0x1a83b5
movl (%r15), %ecx
movl 0x8(%r15), %r14d
subl 0x4(%r15), %r14d
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
imulq $0xa8, %rcx, %rcx
movl 0x30(%rdx,%rcx), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x38(%rsp), %xmm0
cvttsd2si %xmm0, %rcx
subq %rcx, %r14
cmpq $0x2, %r14
movl $0x1, %ecx
cmovlq %rcx, %r14
xorl %ecx, %ecx
movq %rcx, 0x80(%rsp)
movq %rcx, 0x88(%rsp)
testl %eax, %eax
js 0x1ba1ea
movq %rbx, 0x28(%rsp)
movl %eax, %r12d
movl 0x18(%rsp), %eax
xorl $0x1, %eax
movl %eax, 0x44(%rsp)
leaq (%r12,%r12,8), %rax
leaq (%rax,%rax,2), %rbx
addq %r12, %rbx
movq $-0x1, 0x50(%rsp)
movq $0x0, 0x8(%rsp)
movq %r14, 0x78(%rsp)
movq (%rbp), %r13
movl 0x8(%r13,%rbx), %ecx
subl $-0x80, %ecx
movl 0x4(%r15), %eax
cmpl %eax, %ecx
jbe 0x1ba1f3
subl $-0x80, %eax
cmpl %eax, 0x4(%r13,%rbx)
jbe 0x1ba062
movq %r14, %rcx
jmp 0x1ba183
leaq (%rbx,%r13), %rsi
movl 0xc(%r13,%rbx), %eax
movl 0x18(%r13,%rbx), %ebp
shrdl $0x1f, %eax, %ebp
movq %r15, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x120(%rsp), %r8
movq 0x128(%rsp), %r9
callq 0x6ea22
cmpl %ebp, 0x18(%rsp)
je 0x1ba17b
xorl $0x1, %ebp
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl 0x44(%rsp), %edx
movl %ebp, %ecx
movq 0x68(%rsp), %r8
movsd 0x10(%rsp), %xmm0
movq %rax, %r9
pushq $0x0
pushq 0x120(%rsp)
callq 0x1ab640
addq $0x10, %rsp
testq %rax, %rax
je 0x1ba17b
movl 0x8(%r15), %eax
movl 0x4(%r13,%rbx), %ecx
movl 0x8(%r13,%rbx), %esi
cmpl %esi, %eax
cmovbl %eax, %esi
movl 0x4(%r15), %eax
cmpl %ecx, %eax
cmoval %eax, %ecx
subl %ecx, %esi
movl $0x0, %eax
cmovbl %eax, %esi
movl (%r15), %eax
imulq $0xa8, %rax, %rdx
movq 0x30(%rsp), %rax
addq (%rax), %rdx
movq 0x78(%rsp), %rdi
movsd 0x38(%rsp), %xmm0
leaq 0x88(%rsp), %rcx
leaq 0x80(%rsp), %r8
callq 0x1b9b9f
movq 0x110(%rsp), %rcx
movq (%rcx,%r12,8), %rdx
movq %rdx, %rcx
shrq $0x20, %rcx
leaq -0x80000000(%rcx), %rsi
negq %rcx
testq %rdx, %rdx
cmovsq %rsi, %rcx
addq %rax, %rcx
cmpq %r14, %rcx
movq 0x20(%rsp), %rbp
jle 0x1ba19d
xorl %eax, %eax
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
setg %al
subq %rax, %rsi
movq %rsi, 0x8(%rsp)
movq %r12, 0x50(%rsp)
jmp 0x1ba1ca
movq %r14, %rcx
movq 0x20(%rsp), %rbp
leaq -0x1(%r12), %rax
addq $-0x1c, %rbx
movq %rcx, %r14
testq %r12, %r12
movq %rax, %r12
jg 0x1ba038
jmp 0x1ba1f6
movq 0x108(%rsp), %rax
movq 0x28(%rsp), %rcx
cmpq %rcx, (%rax,%r12,8)
jne 0x1ba1c7
movq 0x8(%rsp), %rax
cmpq 0xf8(%rsp), %rax
jge 0x1ba1f3
incq %rax
movq %rax, 0x8(%rsp)
movq %r14, %rcx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rdx
cmpq %rax, %rdx
je 0x1ba183
movq 0x108(%rsp), %rax
movq 0x28(%rsp), %rsi
movq %rsi, (%rax,%rdx,8)
jmp 0x1ba183
movq $-0x1, %rdi
jmp 0x1ba210
movq %r14, %rcx
movq %rcx, %r14
movq 0x110(%rsp), %r12
movq 0x70(%rsp), %r13
movq 0x28(%rsp), %rbx
movq 0x50(%rsp), %rdi
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
cmpq %rdx, %r14
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovlq %r14, %rax
movl $0x80000000, %ecx       # imm = 0x80000000
orl %eax, %ecx
negl %eax
testq %r14, %r14
cmovnsq %rcx, %rax
shlq $0x20, %rax
testq %rdi, %rdi
cmovsq %rdx, %rdi
orq %rax, %rdi
movq %rdi, (%r12,%rbx,8)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %rdi
orq %rbx, %rdi
movq 0x100(%rsp), %rax
movq %rdi, (%rax,%rbx,8)
incq %rbx
movq 0x8(%rbp), %rdx
cmpq %rdx, %rbx
jl 0x1b9ec3
movq 0x100(%rsp), %rdi
leaq (%rdi,%rdx,8), %rsi
callq 0x19dd99
movq 0x8(%rbp), %rcx
testq %rcx, %rcx
jle 0x1ba558
xorl %eax, %eax
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq $-0x80000000, %rsi      # imm = 0x80000000
xorl %r8d, %r8d
movq 0x48(%rsp), %r15
movl $0x80000000, %r13d      # imm = 0x80000000
movq %rcx, %rdi
decq %rcx
movq 0x100(%rsp), %r9
movl -0x8(%r9,%rdi,8), %r11d
leaq (%r8,%r8,8), %r9
leaq (%r9,%r9,2), %r9
addq %r15, %r9
addq %r8, %r9
xorl %r10d, %r10d
movq (%r12,%r11,8), %rbx
testl %ebx, %ebx
js 0x1ba34f
movq (%rbp), %rbx
leaq (%r11,%r11,8), %r14
leaq (%r14,%r14,2), %r14
addq %r11, %r14
movupd (%rbx,%r14), %xmm0
movups 0xc(%rbx,%r14), %xmm1
movups %xmm1, 0xc(%r9)
movupd %xmm0, (%r9)
movq (%r12,%r11,8), %rbx
movq %rbx, %r14
orq %r13, %r14
movq %r14, (%r12,%r11,8)
andq %rdx, %rbx
decq %r10
addq $0x1c, %r9
movq %rbx, %r11
cmpq %rdx, %rbx
jne 0x1ba2cd
testq %r10, %r10
je 0x1ba3b6
movq %r8, %r9
subq %r10, %r9
movq 0x100(%rsp), %r10
movq (%r10,%rcx,8), %r11
movq %r11, %r10
shrq $0x20, %r10
leaq -0x80000000(%r10), %rbx
negq %r10
testq %r11, %r11
cmovsq %rbx, %r10
jmp 0x1ba393
testq %r10, %r10
je 0x1ba3b6
movq %r8, %r9
subq %r10, %r9
movq 0x100(%rsp), %r10
movq (%r10,%rcx,8), %r11
movq %r11, %r10
shrq $0x20, %r10
leaq (%r10,%rsi), %r14
negq %r10
testq %r11, %r11
cmovsq %r14, %r10
movq %rbx, %r11
shrq $0x20, %r11
leaq (%r11,%rsi), %r14
negq %r11
testq %rbx, %rbx
cmovsq %r14, %r11
subq %r11, %r10
testq %r10, %r10
js 0x1ba3b6
shlq $0x20, %r10
movq %r9, %r11
subq %r8, %r11
orq %r10, %r11
movq 0x108(%rsp), %r8
movq %r11, (%r8,%rax,8)
incq %rax
jmp 0x1ba3b9
movq %r8, %r9
movq %r9, %r8
cmpq $0x1, %rdi
jg 0x1ba2a9
movq (%rbp), %rdi
testq %rax, %rax
jle 0x1ba55e
leaq 0x4(%r15), %rcx
movq %rcx, 0x18(%rsp)
leaq -0x1c(%r15), %rcx
movq %rcx, 0x10(%rsp)
xorl %r14d, %r14d
xorl %esi, %esi
movq %r14, %r8
movq 0x108(%rsp), %rcx
movq (%rcx,%rsi,8), %rbx
movl %ebx, %r14d
addq %r8, %r14
movq %rbx, %rcx
shrq $0x20, %rcx
leaq (%rsi,%rsi,8), %rdx
leaq (%rdx,%rdx,2), %r9
addq %rsi, %r9
movl %ecx, (%rdi,%r9)
movl %r8d, 0x10(%rdi,%r9)
movl %r14d, 0x14(%rdi,%r9)
movl %ebx, %r10d
shrl %r10d
movl $0xffffffff, 0x4(%rdi,%r9) # imm = 0xFFFFFFFF
leaq (%r8,%r8,8), %rcx
leaq (%rcx,%rcx,2), %r11
leaq (%r11,%r8), %rcx
movl 0x8(%r15,%rcx), %ecx
movl %ecx, 0x8(%rdi,%r9)
testl %r10d, %r10d
je 0x1ba519
leaq (%r10,%r10,8), %rcx
leaq (%rcx,%rcx,2), %rbx
addq %r10, %rbx
movq 0x18(%rsp), %rcx
leaq (%rcx,%r8), %r15
addq %r11, %r15
leaq (%r14,%r14,8), %rcx
leaq (%rcx,%rcx,2), %r12
movq 0x10(%rsp), %rcx
addq %r14, %rcx
addq %rcx, %r12
xorl %r13d, %r13d
movups -0x4(%r15,%r13), %xmm0
movups 0x8(%r15,%r13), %xmm1
movups %xmm1, 0x9c(%rsp)
movaps %xmm0, 0x90(%rsp)
movups (%r12), %xmm0
movups 0xc(%r12), %xmm1
movups %xmm1, 0x8(%r15,%r13)
movups %xmm0, -0x4(%r15,%r13)
movups 0x9c(%rsp), %xmm0
movups %xmm0, 0xc(%r12)
movapd 0x90(%rsp), %xmm0
movupd %xmm0, (%r12)
movq (%rbp), %rdi
leaq (%rdi,%r9), %rbp
addq $0x4, %rbp
movl (%rbp), %ecx
movl (%r15,%r13), %edx
cmpl %edx, %ecx
jbe 0x1ba4e6
movl %edx, (%rbp)
movl %edx, %ecx
movl 0x4(%r12), %edx
cmpl %edx, %ecx
jbe 0x1ba4f2
movl %edx, (%rbp)
addq $0x1c, %r13
addq $-0x1c, %r12
cmpq %r13, %rbx
movq 0x20(%rsp), %rbp
jne 0x1ba47a
movq 0x108(%rsp), %rcx
movq (%rcx,%rsi,8), %rbx
movq 0x48(%rsp), %r15
testb $0x1, %bl
je 0x1ba545
addq %r15, %r8
addq %r11, %r8
leaq (%r10,%r10,8), %rcx
leaq (%rcx,%rcx,2), %rcx
addq %r10, %rcx
movl 0x4(%r8,%rcx), %ecx
cmpl %ecx, 0x4(%rdi,%r9)
jbe 0x1ba545
leaq (%rdi,%r9), %rdx
addq $0x4, %rdx
movl %ecx, (%rdx)
incq %rsi
cmpq %rax, %rsi
jne 0x1ba3ea
jmp 0x1ba561
xorl %r14d, %r14d
jmp 0x1ba578
movq (%rbp), %rdi
xorl %eax, %eax
xorl %r14d, %r14d
movq %rax, 0x8(%rbp)
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq %rdi, %rsi
callq 0x19ead4
movq %r14, %rax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rdx, %rdx
jle 0x1ba26f
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
addq $0x8, %rax
xorl %esi, %esi
cmpl $0x0, -0x4(%rax)
jne 0x1ba640
movl (%rax), %edx
cmpq %r13, %rdx
jne 0x1ba640
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
movl -0x8(%rax), %edi
imulq $0xa8, %rdi, %rdi
movl 0x30(%rdx,%rdi), %edx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
mulsd 0x38(%rsp), %xmm0
cvttsd2si %xmm0, %rdi
movq %r13, %rdx
subq %rdi, %rdx
cmpq $0x2, %rdx
jge 0x1ba5f5
movl $0x1, %edx
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
cmpq %rdi, %rdx
jl 0x1ba604
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x20, %rdx
addq %rcx, %rdi
addq %rdx, %rdi
movq %rdi, (%r12,%rsi,8)
movq %rsi, %rdi
orq %rcx, %rdi
orq %rdx, %rdi
movq 0x100(%rsp), %rdx
movq %rdi, (%rdx,%rsi,8)
incq %rsi
movq 0x8(%rbp), %rdx
addq $0x1c, %rax
cmpq %rdx, %rsi
jl 0x1ba5a6
jmp 0x1ba26f
leaq 0x87067(%rip), %rdi     # 0x2416ae
leaq 0x8560d(%rip), %rsi     # 0x23fc5b
leaq 0x87077(%rip), %rcx     # 0x2416cc
movl $0x1a8a, %edx           # imm = 0x1A8A
callq 0x2110