// File: 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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq 0x60(%rbp), %rax
movq 0x58(%rbp), %rax
movq 0x50(%rbp), %rax
movq 0x48(%rbp), %rax
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movq 0x30(%rbp), %rax
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdx, -0x48(%rbp)
movq %rcx, -0x50(%rbp)
movq %r8, -0x58(%rbp)
movq %r9, -0x60(%rbp)
movsd %xmm0, -0x68(%rbp)
movq -0x38(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x2a28c5
movq $0x0, -0x30(%rbp)
jmp 0x2a3915
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq 0x30(%rbp), %rdi
movq -0xa0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x226f0
leaq -0x150(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x2100
movq 0x30(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x98(%rbp)
movq 0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq 0x30(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq 0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
movq 0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x88(%rbp)
cmpq $0x0, 0x58(%rbp)
je 0x2a2a34
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
imulq $0x1c, -0xa0(%rbp), %rax
addq %rax, %rsi
callq 0x27b350
movq $0x1, -0x168(%rbp)
movq $0x0, -0x170(%rbp)
movq -0x168(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jg 0x2a2a32
movq -0x168(%rbp), %rax
cmpq -0xa0(%rbp), %rax
je 0x2a29ce
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x168(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x170(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x2a2a19
movq -0x168(%rbp), %rax
subq -0x170(%rbp), %rax
cmpq $0x1, %rax
jle 0x2a2a0b
movq -0x38(%rbp), %rax
movq (%rax), %rdi
imulq $0x1c, -0x170(%rbp), %rax
addq %rax, %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
imulq $0x1c, -0x168(%rbp), %rax
addq %rax, %rsi
callq 0x27b890
movq -0x168(%rbp), %rax
movq %rax, -0x170(%rbp)
jmp 0x2a2a1b
movq -0x168(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x168(%rbp)
jmp 0x2a297e
jmp 0x2a2a34
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2100
movq $0x0, -0x1b0(%rbp)
movq $0x0, -0xa8(%rbp)
movq $0x0, -0x168(%rbp)
movq $-0x1, -0xb0(%rbp)
movq -0x168(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jge 0x2a31dd
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x168(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1b8(%rbp)
cmpq $0x0, 0x40(%rbp)
je 0x2a2add
movq -0x58(%rbp), %rdi
movq -0x1b8(%rbp), %rax
movl 0xc(%rax), %esi
shll %esi
movq -0x1b8(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
orl %eax, %esi
xorl $0x1, %esi
callq 0x287de0
movq %rax, -0x200(%rbp)
jmp 0x2a2b12
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
movq -0x1b8(%rbp), %rax
movl 0xc(%rax), %esi
shll %esi
movq -0x1b8(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
orl %eax, %esi
xorl $0x1, %esi
callq 0x287d20
movq %rax, -0x200(%rbp)
movq -0x200(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x1b8(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x158(%rbp), %rax
cvtsi2sd %rax, %xmm0
mulsd -0x68(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
cmpq -0x60(%rbp), %rax
jge 0x2a2b5f
movq -0x60(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x1b8(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x158(%rbp), %rax
addq -0x160(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq 0x10(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0x2a2ba1
movq 0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x160(%rbp)
movq -0x168(%rbp), %rax
movl %eax, %edi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq -0x160(%rbp), %rax
addq $0x80, %rax
movl %eax, %edx
callq 0x28cf00
cltq
movq %rax, -0x160(%rbp)
movq -0x40(%rbp), %rax
movq -0x1b8(%rbp), %rcx
movl (%rcx), %ecx
imulq $0xa8, %rcx, %rcx
addq %rcx, %rax
movl 0x28(%rax), %eax
movq -0x40(%rbp), %rcx
movq -0x1b8(%rbp), %rdx
movl (%rdx), %edx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movl 0x20(%rcx), %ecx
movq -0x40(%rbp), %rdx
movq -0x1b8(%rbp), %rsi
movl (%rsi), %esi
imulq $0xa8, %rsi, %rsi
addq %rsi, %rdx
subl 0x28(%rdx), %ecx
movl %ecx, %ecx
imulq 0x38(%rbp), %rcx
subq %rcx, %rax
movq -0x40(%rbp), %rcx
movq -0x1b8(%rbp), %rdx
movl (%rdx), %edx
imulq $0xa8, %rdx, %rdx
addq %rdx, %rcx
movl 0x30(%rcx), %ecx
shlq $0x6, %rcx
subq %rcx, %rax
movq %rax, -0x188(%rbp)
movq -0x188(%rbp), %rax
movq %rax, -0x190(%rbp)
movq $-0x1, -0x198(%rbp)
movq $0x0, -0x1a0(%rbp)
movq $-0x1, -0x1a8(%rbp)
movq $0x7fffffff, -0x150(%rbp) # imm = 0x7FFFFFFF
movq -0x160(%rbp), %rax
subq -0xa8(%rbp), %rax
cmpq 0x20(%rbp), %rax
jle 0x2a2cae
movq -0x160(%rbp), %rax
subq 0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rax
cmpq -0xa8(%rbp), %rax
jl 0x2a2e79
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x170(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x80, %eax
movq -0x1b8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
ja 0x2a2d09
jmp 0x2a2e79
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x168(%rbp), %rax
movl %eax, %esi
movq -0x170(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %r8
movq 0x48(%rbp), %r9
movq 0x50(%rbp), %r13
movq -0x50(%rbp), %r12
movq -0x58(%rbp), %r15
movq -0x60(%rbp), %r14
movsd -0x68(%rbp), %xmm0
movq 0x40(%rbp), %rbx
movq 0x38(%rbp), %r11
movq -0x78(%rbp), %r10
movq 0x60(%rbp), %rax
leaq -0x150(%rbp), %rcx
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movq %r11, 0x28(%rsp)
movq $0x40, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0x2a2550
movq %rax, -0x180(%rbp)
cmpq $-0x80000000, -0x180(%rbp) # imm = 0x80000000
jne 0x2a2da4
jmp 0x2a2e62
movq -0x180(%rbp), %rax
cmpq -0x190(%rbp), %rax
jle 0x2a2dee
movq -0x180(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0x198(%rbp)
cmpq $0x0, -0x1a0(%rbp)
jle 0x2a2dec
movq -0x1a0(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x1a0(%rbp)
jmp 0x2a2e27
movq -0x98(%rbp), %rax
movq -0x170(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0x168(%rbp), %rax
jne 0x2a2e25
movq -0x1a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1a0(%rbp)
cmpq 0x18(%rbp), %rax
jle 0x2a2e23
jmp 0x2a2e79
jmp 0x2a2e25
jmp 0x2a2e27
movq -0x90(%rbp), %rax
movq -0x170(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jl 0x2a2e60
movq -0x168(%rbp), %rdx
movq -0x98(%rbp), %rax
movq -0x90(%rbp), %rcx
movq -0x170(%rbp), %rsi
movq (%rcx,%rsi,8), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x2a2e62
movq -0x170(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x170(%rbp)
jmp 0x2a2cbc
movq -0x170(%rbp), %rax
movq %rax, -0x1a8(%rbp)
cmpq $0x0, -0xb0(%rbp)
jl 0x2a2ec8
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x168(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x38(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0xb0(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addq 0x28(%rbp), %rcx
cmpq %rcx, %rax
jle 0x2a2fab
movq $-0x80000000, -0xb8(%rbp) # imm = 0x80000000
movq $-0x1, -0xb0(%rbp)
movq -0x168(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x170(%rbp)
movq -0x170(%rbp), %rcx
xorl %eax, %eax
cmpq -0xa8(%rbp), %rcx
movb %al, -0x201(%rbp)
jl 0x2a2f45
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x168(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq 0x28(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rdx), %rdx
imulq $0x1c, -0x170(%rbp), %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
setle %al
movb %al, -0x201(%rbp)
movb -0x201(%rbp), %al
testb $0x1, %al
jne 0x2a2f51
jmp 0x2a2fa9
movq -0xb8(%rbp), %rax
movq -0x78(%rbp), %rcx
movq -0x170(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpq %rcx, %rax
jge 0x2a2f90
movq -0x78(%rbp), %rax
movq -0x170(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0xb8(%rbp)
movq -0x170(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0x2a2f92
movq -0x170(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x170(%rbp)
jmp 0x2a2ef0
jmp 0x2a2fab
cmpq $0x0, -0xb0(%rbp)
jl 0x2a30e7
movq -0xb0(%rbp), %rax
cmpq -0x1a8(%rbp), %rax
jge 0x2a30e7
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0xb0(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x1c0(%rbp)
movq -0x1c0(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x80, %eax
movq -0x1b8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2a30e5
movq -0x1c0(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x1b8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x2a30e5
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x168(%rbp), %rax
movl %eax, %esi
movq -0xb0(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %r8
movq 0x48(%rbp), %r9
movq 0x50(%rbp), %r13
movq -0x50(%rbp), %r12
movq -0x58(%rbp), %r15
movq -0x60(%rbp), %r14
movsd -0x68(%rbp), %xmm0
movq 0x40(%rbp), %rbx
movq 0x38(%rbp), %r11
movq -0x78(%rbp), %r10
movq 0x60(%rbp), %rax
leaq -0x150(%rbp), %rcx
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
movq %r14, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
movq %r11, 0x28(%rsp)
movq $0x40, 0x30(%rsp)
movq %r10, 0x38(%rsp)
movq %rax, 0x40(%rsp)
callq 0x2a2550
movq %rax, -0x180(%rbp)
cmpq $-0x80000000, -0x180(%rbp) # imm = 0x80000000
je 0x2a30e3
movq -0x180(%rbp), %rax
cmpq -0x190(%rbp), %rax
jle 0x2a30e1
movq -0x180(%rbp), %rax
movq %rax, -0x190(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x198(%rbp)
jmp 0x2a30e3
jmp 0x2a30e5
jmp 0x2a30e7
cmpq $0x0, -0x190(%rbp)
jge 0x2a310a
movq -0x188(%rbp), %rax
movq %rax, -0x190(%rbp)
movq $-0x1, -0x198(%rbp)
movq -0x190(%rbp), %rax
movl %eax, %edx
movq -0x78(%rbp), %rax
movq -0x168(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x198(%rbp), %rdx
movq -0x90(%rbp), %rax
movq -0x168(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
cmpq $0x0, -0xb0(%rbp)
jl 0x2a3198
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x168(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq 0x28(%rbp), %rcx
movq -0x38(%rbp), %rdx
movq (%rdx), %rdx
imulq $0x1c, -0xb0(%rbp), %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jg 0x2a31a6
movq -0x78(%rbp), %rax
movq -0xb0(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x78(%rbp), %rcx
movq -0x168(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x2a31a6
movq -0x168(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x190(%rbp), %rax
cmpq -0x1b0(%rbp), %rax
jge 0x2a31c4
movq -0x190(%rbp), %rax
movq %rax, -0x1b0(%rbp)
jmp 0x2a31c6
movq -0x168(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x168(%rbp)
jmp 0x2a2a79
movq $0x0, -0x168(%rbp)
movq -0x168(%rbp), %rax
cmpq -0xa0(%rbp), %rax
jge 0x2a3270
movq -0x1b0(%rbp), %rsi
movq -0x78(%rbp), %rax
movq -0x168(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
subq %rsi, %rdx
movl %edx, (%rax,%rcx,4)
movq -0x78(%rbp), %rax
movq -0x168(%rbp), %rcx
movslq (%rax,%rcx,4), %rdx
shlq $0x20, %rdx
movq -0x98(%rbp), %rax
movq -0x168(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x168(%rbp), %rdx
shlq %rdx
movq -0x98(%rbp), %rax
movq -0x168(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x168(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x168(%rbp)
jmp 0x2a31e8
movq -0x98(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x27ae10
movq $0x0, -0x1b0(%rbp)
movq -0xa0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x178(%rbp)
movq $0x0, -0x1f0(%rbp)
movq $0x0, -0x1e8(%rbp)
cmpq $0x0, -0x178(%rbp)
jl 0x2a34c3
movq -0x1e8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x98(%rbp), %rax
movq -0x178(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, %eax
movq %rax, -0x168(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x168(%rbp)
movb %al, -0x202(%rbp)
jl 0x2a3332
movq -0x98(%rbp), %rax
movq -0x168(%rbp), %rcx
movq (%rax,%rcx,8), %rax
andq $0x1, %rax
cmpq $0x0, %rax
sete %al
movb %al, -0x202(%rbp)
movb -0x202(%rbp), %al
testb $0x1, %al
jne 0x2a3341
jmp 0x2a33c7
movq -0x38(%rbp), %rax
movq (%rax), %rcx
imulq $0x1c, -0x168(%rbp), %rax
addq %rax, %rcx
movq -0x48(%rbp), %rax
movq -0x1e8(%rbp), %rdx
movq %rdx, %rsi
addq $0x1, %rsi
movq %rsi, -0x1e8(%rbp)
imulq $0x1c, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x18(%rax)
movq -0x98(%rbp), %rax
movq -0x168(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
orq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x90(%rbp), %rax
movq -0x168(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x168(%rbp)
jmp 0x2a32fd
movq -0x1f8(%rbp), %rax
cmpq -0x1e8(%rbp), %rax
jne 0x2a33dc
jmp 0x2a34ac
cmpq $0x0, -0x168(%rbp)
jge 0x2a3405
movq -0x98(%rbp), %rax
movq -0x178(%rbp), %rcx
movq (%rax,%rcx,8), %rax
sarq $0x20, %rax
movq %rax, -0x210(%rbp)
jmp 0x2a3434
movq -0x98(%rbp), %rax
movq -0x178(%rbp), %rcx
movq (%rax,%rcx,8), %rax
sarq $0x20, %rax
movq -0x78(%rbp), %rcx
movq -0x168(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
subq %rcx, %rax
movq %rax, -0x210(%rbp)
movq -0x210(%rbp), %rax
movq %rax, -0x180(%rbp)
movq -0x1e8(%rbp), %rax
subq -0x1f8(%rbp), %rax
movl %eax, %edx
movq -0x80(%rbp), %rax
movq -0x1f0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x180(%rbp), %rax
movl %eax, %edx
movq -0x88(%rbp), %rax
movq -0x1f0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x1f0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1f0(%rbp)
movq -0x180(%rbp), %rax
cmpq -0x1b0(%rbp), %rax
jge 0x2a34aa
movq -0x180(%rbp), %rax
movq %rax, -0x1b0(%rbp)
jmp 0x2a34ac
movq -0x178(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x2a32c4
movq $0x0, -0x178(%rbp)
movq $0x0, -0x1f8(%rbp)
movq $0x0, -0x1e8(%rbp)
movq -0x178(%rbp), %rax
cmpq -0x1f0(%rbp), %rax
jge 0x2a38dc
movq -0x1e8(%rbp), %rax
movq %rax, -0x1f8(%rbp)
movq -0x80(%rbp), %rax
movq -0x178(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0x1e8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x88(%rbp), %rax
movq -0x178(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
subq -0x1b0(%rbp), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x1f8(%rbp), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq -0x1e8(%rbp), %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movq -0x80(%rbp), %rax
movq -0x178(%rbp), %rcx
movl (%rax,%rcx,4), %eax
sarl %eax
movl %eax, -0x6c(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rcx
addq %rcx, %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rax
imulq $0x1c, -0x1f8(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq $0x0, -0x168(%rbp)
movq -0x168(%rbp), %rax
movl -0x6c(%rbp), %ecx
cmpq %rcx, %rax
jge 0x2a381a
movq -0x48(%rbp), %rax
movq -0x1f8(%rbp), %rcx
addq -0x168(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x1dc(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x1d4(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x1cc(%rbp)
movl 0x18(%rax), %eax
movl %eax, -0x1c4(%rbp)
movq -0x48(%rbp), %rcx
movq -0x1e8(%rbp), %rax
subq -0x168(%rbp), %rax
subq $0x1, %rax
imulq $0x1c, %rax, %rax
addq %rax, %rcx
movq -0x48(%rbp), %rax
movq -0x1f8(%rbp), %rdx
addq -0x168(%rbp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rdx
movq %rdx, 0x8(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movl 0x18(%rcx), %ecx
movl %ecx, 0x18(%rax)
movq -0x48(%rbp), %rax
movq -0x1e8(%rbp), %rcx
subq -0x168(%rbp), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq -0x1dc(%rbp), %rcx
movq %rcx, (%rax)
movq -0x1d4(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x1cc(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x1c4(%rbp), %ecx
movl %ecx, 0x18(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x48(%rbp), %rcx
movq -0x1f8(%rbp), %rdx
addq -0x168(%rbp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2a373d
movq -0x48(%rbp), %rax
movq -0x1f8(%rbp), %rcx
addq -0x168(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x48(%rbp), %rcx
movq -0x1e8(%rbp), %rdx
subq -0x168(%rbp), %rdx
subq $0x1, %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2a37a9
movq -0x48(%rbp), %rax
movq -0x1e8(%rbp), %rcx
subq -0x168(%rbp), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
movq -0x1e8(%rbp), %rcx
subq -0x168(%rbp), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, 0x18(%rax)
movq -0x48(%rbp), %rax
movq -0x1f8(%rbp), %rcx
addq -0x168(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, 0x18(%rax)
movq -0x168(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x168(%rbp)
jmp 0x2a35ec
movq -0x80(%rbp), %rax
movq -0x178(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2a38c3
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x48(%rbp), %rcx
movq -0x1f8(%rbp), %rdx
addq -0x168(%rbp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2a3898
movq -0x48(%rbp), %rax
movq -0x1f8(%rbp), %rcx
addq -0x168(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x178(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
movq -0x1f8(%rbp), %rcx
addq -0x168(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
andl $0xc0000000, %ecx       # imm = 0xC0000000
orl $0x3fffffff, %ecx       # imm = 0x3FFFFFFF
movl %ecx, 0x18(%rax)
jmp 0x2a38c5
movq -0x178(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x178(%rbp)
jmp 0x2a34e4
movq -0x1f0(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rsi
movq -0x38(%rbp), %rax
imulq $0x1c, 0x8(%rax), %rax
addq %rax, %rsi
callq 0x27c310
movq -0x1e8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)