// File: /workspace/github_cpp_makefile_star2_O1/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 $0xa8, %rsp
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x58(%rsp)
movq %r9, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %rcx, 0x40(%rsp)
movq %rsi, %r13
movq %rdi, 0x18(%rsp)
movq 0x8(%rsi), %rsi
testq %rsi, %rsi
je 0x1b1164
movq %rdx, %rbx
movq 0xe0(%rsp), %rax
movq %rax, 0x38(%rsp)
cmpl $0x0, 0x120(%rsp)
je 0x1b0c11
movq (%r13), %rdi
leaq (%rsi,%rsi,8), %rax
leaq (%rax,%rax,2), %rax
addq %rdi, %rsi
addq %rax, %rsi
callq 0x195511
movq 0x8(%r13), %rcx
testq %rcx, %rcx
jle 0x1b0c11
movl $0x1, %r15d
movl $0x1c, %r14d
xorl %eax, %eax
cmpq %rcx, %r15
je 0x1b0bce
movq (%r13), %rcx
movl 0x8(%rcx,%r14), %edx
leaq (%rax,%rax,8), %rsi
leaq (%rsi,%rsi,2), %rsi
addq %rax, %rsi
cmpl 0x8(%rcx,%rsi), %edx
jne 0x1b0bce
movq %rax, %rdx
jmp 0x1b0bfa
movq %r15, %rcx
subq %rax, %rcx
movq %r15, %rdx
cmpq $0x2, %rcx
jl 0x1b0bfa
movq (%r13), %rsi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rdi
addq %rax, %rdi
addq %rsi, %rdi
addq %r14, %rsi
callq 0x1957bd
movq %r15, %rdx
leaq 0x1(%r15), %rsi
movq 0x8(%r13), %rcx
addq $0x1c, %r14
movq %rdx, %rax
cmpq %rcx, %r15
movq %rsi, %r15
jl 0x1b0baa
movq %rbx, 0x30(%rsp)
movq 0x100(%rsp), %r15
movl $0x80000000, %ebp       # imm = 0x80000000
movq (%r13), %rax
movl 0x8(%rax), %ecx
cmpq 0xe0(%rsp), %rcx
jne 0x1b0c4e
movq 0x8(%r13), %rcx
leaq (%rcx,%rcx,8), %rdx
leaq (%rdx,%rdx,2), %rdx
addq %rcx, %rdx
cmpl $0x0, -0x18(%rax,%rdx)
je 0x1b12f3
movq 0x8(%r13), %rdx
shlq $0x3, %rdx
movq 0xf8(%rsp), %rdi
xorl %esi, %esi
callq 0x20e0
cmpq $0x0, 0x8(%r13)
jle 0x1b1023
incq 0x38(%rsp)
xorl %ecx, %ecx
movq %r13, 0x60(%rsp)
movq (%r13), %r12
leaq (%rcx,%rcx,8), %rax
leaq (%rax,%rax,2), %r14
movq %rcx, 0x8(%rsp)
addq %rcx, %r14
movl 0xc(%r12,%r14), %eax
movl 0x18(%r12,%r14), %ebx
shrdl $0x1f, %eax, %ebx
cmpq $0x0, 0x108(%rsp)
je 0x1b0cba
movl %ebx, %esi
xorl $0x1, %esi
movq 0x48(%rsp), %rdi
callq 0x19c00f
jmp 0x1b0d24
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movl %ebx, %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 0x1b0d22
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 0x1b0d00
movl %esi, %eax
jmp 0x1b0d24
xorl %eax, %eax
addq %r14, %r12
movl 0x4(%r12), %ecx
addq %rax, %rcx
xorps %xmm0, %xmm0
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 (%r13), %rsi
subl $-0x80, %edx
movq 0x8(%rsp), %rdi
callq 0x19f679
movl (%r12), %ecx
movl 0x8(%r12), %r14d
subl 0x4(%r12), %r14d
movq 0x18(%rsp), %rdx
movq (%rdx), %rdx
imulq $0xa8, %rcx, %rcx
movl 0x30(%rdx,%rcx), %ecx
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
mulsd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %rcx
subq %rcx, %r14
cmpq $0x2, %r14
movl $0x1, %ecx
cmovlq %rcx, %r14
xorl %ecx, %ecx
movq %rcx, 0x70(%rsp)
movq %rcx, 0x78(%rsp)
testl %eax, %eax
js 0x1b0fa4
movl %eax, %r15d
movl %ebx, 0x2c(%rsp)
xorl $0x1, %ebx
movl %ebx, 0x28(%rsp)
leaq (%r15,%r15,8), %rax
leaq (%rax,%rax,2), %r13
addq %r15, %r13
movq $-0x1, 0x10(%rsp)
movq $0x0, (%rsp)
movq %r14, 0x68(%rsp)
movq 0x60(%rsp), %rax
movq (%rax), %rbx
movl 0x8(%rbx,%r13), %ecx
subl $-0x80, %ecx
movl 0x4(%r12), %eax
cmpl %eax, %ecx
jbe 0x1b0fad
subl $-0x80, %eax
cmpl %eax, 0x4(%rbx,%r13)
jbe 0x1b0e24
movq %r14, %rcx
jmp 0x1b0f40
leaq (%rbx,%r13), %rsi
movl 0xc(%rbx,%r13), %eax
movl 0x18(%rbx,%r13), %ebp
shrdl $0x1f, %eax, %ebp
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
movq 0x110(%rsp), %r8
movq 0x118(%rsp), %r9
callq 0x6f050
cmpl %ebp, 0x2c(%rsp)
je 0x1b0f38
xorl $0x1, %ebp
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %rsi
movl 0x28(%rsp), %edx
movl %ebp, %ecx
movq 0x50(%rsp), %r8
movsd 0x58(%rsp), %xmm0
movq %rax, %r9
pushq $0x0
pushq 0x110(%rsp)
callq 0x1a24f3
addq $0x10, %rsp
testq %rax, %rax
je 0x1b0f38
movl 0x8(%r12), %eax
movl 0x4(%rbx,%r13), %ecx
movl 0x8(%rbx,%r13), %esi
cmpl %esi, %eax
cmovbl %eax, %esi
movl 0x4(%r12), %eax
cmpl %ecx, %eax
cmoval %eax, %ecx
subl %ecx, %esi
movl $0x0, %eax
cmovbl %eax, %esi
movl (%r12), %eax
imulq $0xa8, %rax, %rdx
movq 0x18(%rsp), %rax
addq (%rax), %rdx
movq 0x68(%rsp), %rdi
movsd 0x20(%rsp), %xmm0
leaq 0x78(%rsp), %rcx
leaq 0x70(%rsp), %r8
callq 0x1b094a
movq 0x100(%rsp), %rcx
movq (%rcx,%r15,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
movl $0x80000000, %ebp       # imm = 0x80000000
jle 0x1b0f59
xorl %eax, %eax
movq (%rsp), %rsi
testq %rsi, %rsi
setg %al
subq %rax, %rsi
movq %rsi, (%rsp)
movq %r15, 0x10(%rsp)
jmp 0x1b0f84
movq %r14, %rcx
movl $0x80000000, %ebp       # imm = 0x80000000
leaq -0x1(%r15), %rax
addq $-0x1c, %r13
movq %rcx, %r14
testq %r15, %r15
movq %rax, %r15
jg 0x1b0df5
jmp 0x1b0fb0
movq 0xf8(%rsp), %rax
movq 0x8(%rsp), %rcx
cmpq %rcx, (%rax,%r15,8)
jne 0x1b0f81
movq (%rsp), %rax
cmpq 0xe8(%rsp), %rax
jge 0x1b0fad
incq %rax
movq %rax, (%rsp)
movq %r14, %rcx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
andq %rax, %rdx
cmpq %rax, %rdx
je 0x1b0f40
movq 0xf8(%rsp), %rax
movq 0x8(%rsp), %rsi
movq %rsi, (%rax,%rdx,8)
jmp 0x1b0f40
movq $-0x1, 0x10(%rsp)
movq %r14, %rcx
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
cmpq %rsi, %rcx
movl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
cmovlq %rcx, %rax
movl $0x80000000, %edx       # imm = 0x80000000
orl %eax, %edx
negl %eax
testq %rcx, %rcx
cmovnsq %rdx, %rax
shlq $0x20, %rax
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
cmovsq %rsi, %rdx
orq %rax, %rdx
movq 0x100(%rsp), %r15
movq 0x8(%rsp), %rcx
movq %rdx, (%r15,%rcx,8)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
andq %rax, %rdx
orq %rcx, %rdx
movq 0xf0(%rsp), %rax
movq %rdx, (%rax,%rcx,8)
incq %rcx
movq 0x60(%rsp), %r13
cmpq 0x8(%r13), %rcx
jl 0x1b0c7c
movq 0x8(%r13), %rax
movq 0xf0(%rsp), %rdi
leaq (%rdi,%rax,8), %rsi
callq 0x194fef
movq 0x8(%r13), %rcx
xorl %eax, %eax
testq %rcx, %rcx
jle 0x1b116c
movl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
movq $-0x1, %rsi
xorl %r9d, %r9d
movq %r9, %rdi
movq 0x30(%rsp), %r12
movq %rcx, %r8
decq %rcx
movq 0xf0(%rsp), %r10
movl -0x8(%r10,%r8,8), %ebx
leaq (%r9,%r9,8), %r10
leaq (%r10,%r10,2), %r10
addq %r12, %r10
addq %r9, %r10
testb $-0x80, 0x3(%r15,%rbx,8)
jne 0x1b10d2
movq (%r13), %r11
leaq (%rbx,%rbx,8), %r14
leaq (%r14,%r14,2), %r14
addq %rbx, %r14
incq %rdi
movupd (%r11,%r14), %xmm0
movups 0xc(%r11,%r14), %xmm1
movups %xmm1, 0xc(%r10)
movupd %xmm0, (%r10)
movq (%r15,%rbx,8), %r11
movq %r11, %r14
orq %rbp, %r14
movq %r14, (%r15,%rbx,8)
andq %rdx, %r11
addq $0x1c, %r10
cmpq %rdx, %r11
cmoveq %rsi, %r11
movq %r11, %rbx
jne 0x1b107f
jmp 0x1b10d5
movq %rbx, %r11
movq %rdi, %r10
subq %r9, %r10
je 0x1b1155
movq 0xf0(%rsp), %rbx
movq (%rbx,%rcx,8), %r14
movq %r14, %rbx
shrq $0x20, %rbx
leaq -0x80000000(%rbx), %r15
negq %rbx
testq %r14, %r14
cmovsq %r15, %rbx
testq %r11, %r11
js 0x1b112d
movq 0x100(%rsp), %r14
movq (%r14,%r11,8), %r11
movq %r11, %r14
shrq $0x20, %r14
leaq -0x80000000(%r14), %r15
negq %r14
testq %r11, %r11
cmovsq %r15, %r14
subq %r14, %rbx
testq %rbx, %rbx
js 0x1b114a
shlq $0x20, %rbx
orq %r10, %rbx
movq 0xf8(%rsp), %r9
movq %rbx, (%r9,%rax,8)
incq %rax
jmp 0x1b114d
movq %r9, %rdi
movq 0x100(%rsp), %r15
movq %rdi, %r9
cmpq $0x1, %r8
jg 0x1b105e
jmp 0x1b1171
xorl %r14d, %r14d
jmp 0x1b12de
movq 0x30(%rsp), %r12
testq %rax, %rax
jle 0x1b12c0
leaq -0x1c(%r12), %rcx
xorl %r14d, %r14d
xorl %edx, %edx
movq %r14, %rsi
movq 0xf8(%rsp), %rdi
movq (%rdi,%rdx,8), %r8
movl %r8d, %r14d
addq %rsi, %r14
movq %r8, %r9
shrq $0x20, %r9
movq (%r13), %r10
leaq (%rdx,%rdx,8), %rdi
leaq (%rdi,%rdi,2), %rdi
addq %rdx, %rdi
movl %r9d, (%r10,%rdi)
movl %esi, 0x10(%r10,%rdi)
movl %r14d, 0x14(%r10,%rdi)
shrl %r8d
movl $0xffffffff, 0x4(%r10,%rdi) # imm = 0xFFFFFFFF
leaq (%rsi,%rsi,8), %r9
leaq (%r9,%r9,2), %r9
leaq (%r9,%rsi), %r11
movl 0x8(%r12,%r11), %r11d
movl %r11d, 0x8(%r10,%rdi)
testl %r8d, %r8d
je 0x1b1276
leaq (%r12,%rsi), %r11
addq %r9, %r11
leaq (%r14,%r14,8), %r10
leaq (%r10,%r10,2), %rbx
addq %rcx, %rbx
addq %r14, %rbx
xorl %r10d, %r10d
movups (%r11), %xmm0
movups 0xc(%r11), %xmm1
movups %xmm1, 0x8c(%rsp)
movaps %xmm0, 0x80(%rsp)
movups (%rbx), %xmm0
movups 0xc(%rbx), %xmm1
movups %xmm1, 0xc(%r11)
movups %xmm0, (%r11)
movups 0x8c(%rsp), %xmm0
movups %xmm0, 0xc(%rbx)
movapd 0x80(%rsp), %xmm0
movupd %xmm0, (%rbx)
movq (%r13), %r15
addq %rdi, %r15
addq $0x4, %r15
movl 0x4(%r11), %ebp
cmpl %ebp, (%r15)
jbe 0x1b1259
movl %ebp, (%r15)
movl 0x4(%rbx), %ebp
cmpl %ebp, (%r15)
jbe 0x1b1264
movl %ebp, (%r15)
incq %r10
addq $0x1c, %r11
addq $-0x1c, %rbx
cmpq %r10, %r8
jne 0x1b1200
jmp 0x1b1279
xorl %r10d, %r10d
movq 0xf8(%rsp), %r8
testb $0x1, (%r8,%rdx,8)
je 0x1b12b2
movq (%r13), %r8
addq %r12, %rsi
addq %r9, %rsi
leaq (%r10,%r10,8), %r9
leaq (%r9,%r9,2), %r9
addq %r10, %r9
movl 0x4(%rsi,%r9), %esi
cmpl %esi, 0x4(%r8,%rdi)
jbe 0x1b12b2
addq %r8, %rdi
addq $0x4, %rdi
movl %esi, (%rdi)
incq %rdx
cmpq %rax, %rdx
jne 0x1b1184
jmp 0x1b12c3
xorl %r14d, %r14d
movq %rax, 0x8(%r13)
movq (%r13), %rdi
leaq (%rax,%rax,8), %rcx
leaq (%rcx,%rcx,2), %rsi
addq %rax, %rsi
addq %rdi, %rsi
callq 0x195d3d
movq %r14, %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq $0x0, 0x8(%r13)
jle 0x1b1023
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
addq $0x8, %rax
xorl %edx, %edx
cmpl $0x0, -0x4(%rax)
jne 0x1b13a9
movl (%rax), %esi
cmpq 0xe0(%rsp), %rsi
jne 0x1b13a9
movq 0x18(%rsp), %rdi
movq (%rdi), %rdi
movl -0x8(%rax), %r8d
imulq $0xa8, %r8, %r8
movl 0x30(%rdi,%r8), %edi
xorps %xmm0, %xmm0
cvtsi2sd %rdi, %xmm0
mulsd 0x20(%rsp), %xmm0
cvttsd2si %xmm0, %rdi
subq %rdi, %rsi
cmpq $0x2, %rsi
jge 0x1b1361
movl $0x1, %esi
movl $0x7fffffff, %edi       # imm = 0x7FFFFFFF
cmpq %rdi, %rsi
jl 0x1b1370
movl $0x7fffffff, %esi       # imm = 0x7FFFFFFF
shlq $0x20, %rsi
addq %rcx, %rdi
addq %rsi, %rdi
movq %rdi, (%r15,%rdx,8)
movq %rdx, %rdi
orq %rcx, %rdi
orq %rsi, %rdi
movq 0xf0(%rsp), %rsi
movq %rdi, (%rsi,%rdx,8)
incq %rdx
addq $0x1c, %rax
cmpq 0x8(%r13), %rdx
jl 0x1b130e
jmp 0x1b1023
leaq 0x8402e(%rip), %rdi     # 0x2353de
leaq 0x825d4(%rip), %rsi     # 0x23398b
leaq 0x8403e(%rip), %rcx     # 0x2353fc
movl $0x1a8a, %edx           # imm = 0x1A8A
callq 0x2110