// File: chhylp123[P]hifiasm/inter.cpp
// Function: gen_cns_chain_linear(ul_ov_t*, long, asg_t const*, R_to_U*, long, long, double, Chain_Data*, long, long, long, unsigned long, unsigned long, unsigned long)
uint64_t gen_cns_chain_linear(ul_ov_t *a, int64_t a_n, /**ul_ov_t *ab,**/ const asg_t *rg, R_to_U *ri, int64_t qlen, int64_t bw, double diff_thre, Chain_Data* dp, 
int64_t max_skip, int64_t max_iter, int64_t max_dis, uint64_t mqs, uint64_t mqe, uint64_t ulid)
{
	if(a_n == 0) return 0;
	uint32_t li_v, lj_v; int32_t *f, *c_n, *len; int64_t *p, *t, st, max_ii, max, qo, cL, sn, ln, csn, mm_sn, cln, mm_ln; 
	int64_t mm_ovlp, x, i, j, sc, csc, mm_sc, mm_idx, n_skip, end_j, ch_sc, cn_sn, ch_ln, ch_i; ul_ov_t *li, *lj; 
	resize_Chain_Data(dp, a_n, NULL); 
	t = dp->tmp; f = dp->score; p = dp->pre; c_n = dp->occ; len = dp->indels;
        
	radix_sort_ul_ov_srt_qe(a, a + a_n);
    for (i = 1, j = 0; i <= a_n; i++) {
        if (i == a_n || a[i].qe != a[j].qe) {
            if(i - j > 1) radix_sort_ul_ov_srt_qs(a+j, a+i);
            j = i;
        }
    }

	memset(t, 0, (a_n*sizeof((*t)))); 
	ch_sc = ch_i = cn_sn = INT32_MIN; ch_ln = INT32_MAX;
	for (i = st = 0, max_ii = -1; i < a_n; ++i) {
        li = &(a[i]); 
        mm_ovlp = max_ovlp(rg, ((li->tn<<1)|li->rev)^1);        
        x = (li->qs + mm_ovlp)*diff_thre; 
        if(x < bw) x = bw; 
        x += li->qs + mm_ovlp;
        if (x > qlen+1) x = qlen+1;
        x = find_ul_ov_max(i, a, x+G_CHAIN_INDEL); 

		csc = 0; csn = 1; cln = 0; 
		if(is_contain_r((*ri), li->tn)) {csc = -1; csn = 0; cln = rg->seq[li->tn].len;}
        mm_sc = INT32_MIN+1; mm_sn = INT32_MIN+1; mm_ln = INT32_MAX; 
		mm_idx = -1; n_skip = 0; end_j = -1; 

		li_v = (li->tn<<1)|li->rev; li_v ^= 1;
        if ((x-st) > max_iter) st = x-max_iter;
		for (j = x; j >= st; --j) { // collect potential destination vertices
			lj = &(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
			if(f[j] == INT32_MIN) continue;///could not reach the left end
			sc = sn = ln = INT32_MIN;
			if(lj->qs <= li->qs && lj->qe <= li->qe) {///not contained
				lj_v = (lj->tn<<1)|lj->rev; lj_v ^= 1;
				qo = infer_rovlp(li, lj, NULL, NULL, NULL, NULL);
				if(gconnect_test(rg, li_v, lj_v, bw, diff_thre, qo)) {
					sc = f[j] + csc; sn = c_n[j] + csn; ln = len[j] + cln;
				}
			}
			if(sc == INT32_MIN) continue;
			if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_sn)) || 
				((sc == mm_sc) && (sn == mm_sn) && (ln < mm_ln))) {
				mm_sc = sc, mm_idx = j, mm_sn = sn, mm_ln = ln;
				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 || (a[i].qe > (a[max_ii].qe+max_dis))) {//too long
            max = INT32_MIN; max_ii = -1;
            for (j = i - 1; (j >= st) && (a[i].qe<=(max_dis+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 = &(a[max_ii]); 
			if(((lj->qe+G_CHAIN_INDEL)>li->qs) && (lj->qs<=li->qs) && (lj->qe<=li->qe) && (f[max_ii]!=INT32_MIN)) {
				lj_v = (lj->tn<<1)|lj->rev; lj_v ^= 1; sc = sn = ln = INT32_MIN;
				qo = infer_rovlp(li, lj, NULL, NULL, NULL, NULL);
				if(gconnect_test(rg, li_v, lj_v, bw, diff_thre, qo)) {
					sc = f[max_ii] + csc; sn = c_n[max_ii] + csn; ln = len[max_ii] + cln;
				}
				if(sc != INT32_MIN) {
					if((sc > mm_sc) || ((sc == mm_sc) && (sn > mm_sn)) || 
						((sc == mm_sc) && (sn == mm_sn) && (ln < mm_ln))) {
						mm_sc = sc, mm_idx = max_ii, mm_sn = sn, mm_ln = ln;
					}
				}
			}
		}

		if((mm_idx == -1) && (((int64_t)li->qs) > ((int64_t)(mqs+bw)))) {
			mm_sc = mm_idx = mm_sn = INT32_MIN; mm_ln = INT32_MAX;
		}
		if((mm_sc==(INT32_MIN+1))) {
			mm_sc = csc; mm_sn = csn; mm_ln = cln;
		}

        
        f[i] = mm_sc; p[i] = mm_idx; c_n[i] = mm_sn; len[i] = mm_ln;
        if ((max_ii < 0) || ((a[i].qe<=max_dis+a[max_ii].qe) && (f[max_ii]<f[i]))) {
            max_ii = i;
        }

		if((mm_sc!=INT32_MIN) && (((int64_t)(a[i].qe+bw))>=((int64_t)(mqe)))) {
			if((mm_sc > ch_sc) || ((mm_sc == ch_sc) && (mm_sn > cn_sn)) || 
				((mm_sc == ch_sc) && (mm_sn == cn_sn) && (mm_ln < ch_ln))) {
				ch_sc = mm_sc; ch_i = i; cn_sn = mm_sn; ch_ln = mm_ln;
			}
		}
		// if(ulid == 442462) {
		// 	fprintf(stderr, "[M::%s::id->%u::%.*s] i::%ld, q::[%u, %u), t::[%u, %u), is_cr::%u, mm_idx::%ld, end::%u\n", 
		// 	__func__, li->tn, (int)Get_NAME_LENGTH(R_INF, li->tn), Get_NAME(R_INF, li->tn), i, 
		// 	li->qs, li->qe, li->ts, li->te, !!(is_contain_r((*ri), li->tn)), mm_idx, !!(((int64_t)(a[i].qe+bw))>=((int64_t)(mqe))));
		// }
    }
	// if(ulid == 442462) {
	// 	fprintf(stderr, "[M::%s::] ch_i::%ld, mqs::%lu, mqe::%lu\n", 
	// 	__func__, ch_i, mqs, mqe);
	// }
	if(ch_i == INT32_MIN) return 0;

	i = ch_i; cL = 0;
    while (i >= 0) {t[cL++] = i; i = p[i];}
	for (i = 0; i < cL; i++) a[i] = a[t[cL-i-1]];
	return cL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
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, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movsd %xmm0, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x2e6ff8
movq $0x0, -0x8(%rbp)
jmp 0x2e7cc7
movq 0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x226f0
movq 0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x70(%rbp)
movq 0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq 0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
imulq $0x1c, -0x18(%rbp), %rax
addq %rax, %rsi
callq 0x27b350
movq $0x1, -0xe0(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jg 0x2e7111
movq -0xe0(%rbp), %rax
cmpq -0x18(%rbp), %rax
je 0x2e70b3
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0xe8(%rbp), %rdx
addq %rdx, %rcx
cmpl 0x8(%rcx), %eax
je 0x2e70f8
movq -0xe0(%rbp), %rax
subq -0xe8(%rbp), %rax
cmpq $0x1, %rax
jle 0x2e70ea
movq -0x10(%rbp), %rdi
imulq $0x1c, -0xe8(%rbp), %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
imulq $0x1c, -0xe0(%rbp), %rax
addq %rax, %rsi
callq 0x27b890
movq -0xe0(%rbp), %rax
movq %rax, -0xe8(%rbp)
jmp 0x2e70fa
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x2e706f
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rdx
shlq $0x3, %rdx
xorl %esi, %esi
callq 0x2100
movq $-0x80000000, -0x128(%rbp) # imm = 0x80000000
movq $-0x80000000, -0x138(%rbp) # imm = 0x80000000
movq $-0x80000000, -0x120(%rbp) # imm = 0x80000000
movq $0x7fffffff, -0x130(%rbp) # imm = 0x7FFFFFFF
movq $0x0, -0x78(%rbp)
movq $0x0, -0xe0(%rbp)
movq $-0x1, -0x80(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x18(%rbp), %rax
jge 0x2e7bc7
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x140(%rbp)
movq -0x20(%rbp), %rdi
movq -0x140(%rbp), %rax
movl 0xc(%rax), %esi
shll %esi
movq -0x140(%rbp), %rax
movl 0x18(%rax), %eax
shrl $0x1f, %eax
orl %eax, %esi
xorl $0x1, %esi
callq 0x287d20
movq %rax, -0xd0(%rbp)
movq -0x140(%rbp), %rax
movl 0x4(%rax), %eax
addq -0xd0(%rbp), %rax
cvtsi2sd %rax, %xmm0
mulsd -0x40(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x2e71ff
movq -0x38(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x140(%rbp), %rax
movl 0x4(%rax), %eax
addq -0xd0(%rbp), %rax
addq -0xd8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0xd8(%rbp), %rax
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0x2e7241
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd8(%rbp)
movq -0xe0(%rbp), %rax
movl %eax, %edi
movq -0x10(%rbp), %rsi
movq -0xd8(%rbp), %rax
addq $0x80, %rax
movl %eax, %edx
callq 0x28cf00
cltq
movq %rax, -0xd8(%rbp)
movq $0x0, -0xf8(%rbp)
movq $0x1, -0xb0(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0x140(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x28(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x2e730d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x140(%rbp), %rcx
movl 0xc(%rcx), %ecx
cmpl $-0x1, (%rax,%rcx,4)
je 0x2e730d
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x140(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl (%rax,%rcx,4), %eax
shrl $0x1f, %eax
cmpl $0x0, %eax
jne 0x2e730d
movq $-0x1, -0xf8(%rbp)
movq $0x0, -0xb0(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x140(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl (%rax,%rcx,8), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movq %rax, -0xc0(%rbp)
movq $-0x7fffffff, -0x100(%rbp) # imm = 0x80000001
movq $-0x7fffffff, -0xb8(%rbp) # imm = 0x80000001
movq $0x7fffffff, -0xc8(%rbp) # imm = 0x7FFFFFFF
movq $-0x1, -0x108(%rbp)
movq $0x0, -0x110(%rbp)
movq $-0x1, -0x118(%rbp)
movq -0x140(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0x140(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x44(%rbp)
movq -0xd8(%rbp), %rax
subq -0x78(%rbp), %rax
cmpq 0x20(%rbp), %rax
jle 0x2e7396
movq -0xd8(%rbp), %rax
subq 0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
cmpq -0x78(%rbp), %rax
jl 0x2e766d
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe8(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x80, %eax
movq -0x140(%rbp), %rcx
cmpl 0x4(%rcx), %eax
ja 0x2e73eb
jmp 0x2e766d
movq -0x50(%rbp), %rax
movq -0xe8(%rbp), %rcx
cmpl $0x80000000, (%rax,%rcx,4) # imm = 0x80000000
jne 0x2e7404
jmp 0x2e7656
movq $-0x80000000, -0xa8(%rbp) # imm = 0x80000000
movq $-0x80000000, -0xa0(%rbp) # imm = 0x80000000
movq $-0x80000000, -0xf0(%rbp) # imm = 0x80000000
movq -0x148(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x140(%rbp), %rcx
cmpl 0x4(%rcx), %eax
ja 0x2e7526
movq -0x148(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x140(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x2e7526
movq -0x148(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0x148(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x48(%rbp)
movq -0x140(%rbp), %rdi
movq -0x148(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rdx
movq %r9, %rcx
movq %r9, %r8
callq 0x71a90
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x48(%rbp), %edx
movq -0x38(%rbp), %rcx
movsd -0x40(%rbp), %xmm0
movq -0x90(%rbp), %r8
callq 0x2e6e20
cmpq $0x0, %rax
je 0x2e7524
movq -0x50(%rbp), %rax
movq -0xe8(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0xf8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x58(%rbp), %rax
movq -0xe8(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x60(%rbp), %rax
movq -0xe8(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x2e7526
cmpq $-0x80000000, -0xf0(%rbp) # imm = 0x80000000
jne 0x2e7538
jmp 0x2e7656
movq -0xf0(%rbp), %rax
cmpq -0x100(%rbp), %rax
jg 0x2e7598
movq -0xf0(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x2e7568
movq -0xa0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jg 0x2e7598
movq -0xf0(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x2e75ee
movq -0xa0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jne 0x2e75ee
movq -0xa8(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jge 0x2e75ee
movq -0xf0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0x110(%rbp)
jle 0x2e75ec
movq -0x110(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x110(%rbp)
jmp 0x2e7624
movq -0x70(%rbp), %rax
movq -0xe8(%rbp), %rcx
movq (%rax,%rcx,8), %rax
cmpq -0xe0(%rbp), %rax
jne 0x2e7622
movq -0x110(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x110(%rbp)
cmpq 0x18(%rbp), %rax
jle 0x2e7620
jmp 0x2e766d
jmp 0x2e7622
jmp 0x2e7624
movq -0x68(%rbp), %rax
movq -0xe8(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jl 0x2e7654
movq -0xe0(%rbp), %rdx
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movq -0xe8(%rbp), %rsi
movq (%rcx,%rsi,8), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x2e7656
movq -0xe8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xe8(%rbp)
jmp 0x2e73a4
movq -0xe8(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, -0x80(%rbp)
jl 0x2e76b0
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rcx
movl 0x8(%rcx), %ecx
addq 0x28(%rbp), %rcx
cmpq %rcx, %rax
jle 0x2e7784
movq $-0x80000000, -0x88(%rbp) # imm = 0x80000000
movq $-0x1, -0x80(%rbp)
movq -0xe0(%rbp), %rax
subq $0x1, %rax
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rcx
xorl %eax, %eax
cmpq -0x78(%rbp), %rcx
movb %al, -0x149(%rbp)
jl 0x2e7721
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq 0x28(%rbp), %rcx
movq -0x10(%rbp), %rdx
imulq $0x1c, -0xe8(%rbp), %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
setle %al
movb %al, -0x149(%rbp)
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x2e772d
jmp 0x2e7782
movq -0x88(%rbp), %rax
movq -0x50(%rbp), %rcx
movq -0xe8(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cmpq %rcx, %rax
jge 0x2e7769
movq -0x50(%rbp), %rax
movq -0xe8(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
movq %rax, -0x88(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x2e776b
movq -0xe8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0xe8(%rbp)
jmp 0x2e76d5
jmp 0x2e7784
cmpq $0x0, -0x80(%rbp)
jl 0x2e79aa
movq -0x80(%rbp), %rax
cmpq -0x118(%rbp), %rax
jge 0x2e79aa
movq -0x10(%rbp), %rax
imulq $0x1c, -0x80(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x80, %eax
movq -0x140(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2e79a8
movq -0x148(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x140(%rbp), %rcx
cmpl 0x4(%rcx), %eax
ja 0x2e79a8
movq -0x148(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x140(%rbp), %rcx
cmpl 0x8(%rcx), %eax
ja 0x2e79a8
movq -0x50(%rbp), %rax
movq -0x80(%rbp), %rcx
cmpl $0x80000000, (%rax,%rcx,4) # imm = 0x80000000
je 0x2e79a8
movq -0x148(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0x148(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
xorl $0x1, %eax
movl %eax, -0x48(%rbp)
movq $-0x80000000, -0xa8(%rbp) # imm = 0x80000000
movq $-0x80000000, -0xa0(%rbp) # imm = 0x80000000
movq $-0x80000000, -0xf0(%rbp) # imm = 0x80000000
movq -0x140(%rbp), %rdi
movq -0x148(%rbp), %rsi
xorl %eax, %eax
movl %eax, %r9d
movq %r9, %rdx
movq %r9, %rcx
movq %r9, %r8
callq 0x71a90
movq %rax, -0x90(%rbp)
movq -0x20(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x48(%rbp), %edx
movq -0x38(%rbp), %rcx
movsd -0x40(%rbp), %xmm0
movq -0x90(%rbp), %r8
callq 0x2e6e20
cmpq $0x0, %rax
je 0x2e78fe
movq -0x50(%rbp), %rax
movq -0x80(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0xf8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x58(%rbp), %rax
movq -0x80(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0xb0(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x60(%rbp), %rax
movq -0x80(%rbp), %rcx
movslq (%rax,%rcx,4), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $-0x80000000, -0xf0(%rbp) # imm = 0x80000000
je 0x2e79a6
movq -0xf0(%rbp), %rax
cmpq -0x100(%rbp), %rax
jg 0x2e796f
movq -0xf0(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x2e793f
movq -0xa0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jg 0x2e796f
movq -0xf0(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x2e79a4
movq -0xa0(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jne 0x2e79a4
movq -0xa8(%rbp), %rax
cmpq -0xc8(%rbp), %rax
jge 0x2e79a4
movq -0xf0(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x2e79a6
jmp 0x2e79a8
jmp 0x2e79aa
cmpq $-0x1, -0x108(%rbp)
jne 0x2e79f7
movq -0x140(%rbp), %rax
movl 0x4(%rax), %eax
movq 0x30(%rbp), %rcx
addq -0x38(%rbp), %rcx
cmpq %rcx, %rax
jle 0x2e79f7
movq $-0x80000000, -0xb8(%rbp) # imm = 0x80000000
movq $-0x80000000, -0x108(%rbp) # imm = 0x80000000
movq $-0x80000000, -0x100(%rbp) # imm = 0x80000000
movq $0x7fffffff, -0xc8(%rbp) # imm = 0x7FFFFFFF
cmpq $-0x7fffffff, -0x100(%rbp) # imm = 0x80000001
jne 0x2e7a2e
movq -0xf8(%rbp), %rax
movq %rax, -0x100(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x100(%rbp), %rax
movl %eax, %edx
movq -0x50(%rbp), %rax
movq -0xe0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x108(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0xb8(%rbp), %rax
movl %eax, %edx
movq -0x58(%rbp), %rax
movq -0xe0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0xc8(%rbp), %rax
movl %eax, %edx
movq -0x60(%rbp), %rax
movq -0xe0(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpq $0x0, -0x80(%rbp)
jl 0x2e7ad8
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movq 0x28(%rbp), %rcx
movq -0x10(%rbp), %rdx
imulq $0x1c, -0x80(%rbp), %rsi
addq %rsi, %rdx
movl 0x8(%rdx), %edx
addq %rdx, %rcx
cmpq %rcx, %rax
jg 0x2e7ae3
movq -0x50(%rbp), %rax
movq -0x80(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x50(%rbp), %rcx
movq -0xe0(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x2e7ae3
movq -0xe0(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $-0x80000000, -0x100(%rbp) # imm = 0x80000000
je 0x2e7bae
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
addq -0x38(%rbp), %rax
cmpq 0x38(%rbp), %rax
jl 0x2e7bae
movq -0x100(%rbp), %rax
cmpq -0x120(%rbp), %rax
jg 0x2e7b74
movq -0x100(%rbp), %rax
cmpq -0x120(%rbp), %rax
jne 0x2e7b44
movq -0xb8(%rbp), %rax
cmpq -0x128(%rbp), %rax
jg 0x2e7b74
movq -0x100(%rbp), %rax
cmpq -0x120(%rbp), %rax
jne 0x2e7bac
movq -0xb8(%rbp), %rax
cmpq -0x128(%rbp), %rax
jne 0x2e7bac
movq -0xc8(%rbp), %rax
cmpq -0x130(%rbp), %rax
jge 0x2e7bac
movq -0x100(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x128(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0x130(%rbp)
jmp 0x2e7bae
jmp 0x2e7bb0
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x2e716b
cmpq $-0x80000000, -0x138(%rbp) # imm = 0x80000000
jne 0x2e7be1
movq $0x0, -0x8(%rbp)
jmp 0x2e7cc7
movq -0x138(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq $0x0, -0x98(%rbp)
cmpq $0x0, -0xe0(%rbp)
jl 0x2e7c40
movq -0xe0(%rbp), %rdx
movq -0x70(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x98(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x68(%rbp), %rax
movq -0xe0(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xe0(%rbp)
jmp 0x2e7bfa
movq $0x0, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x98(%rbp), %rax
jge 0x2e7cbc
movq -0x10(%rbp), %rcx
movq -0x70(%rbp), %rax
movq -0x98(%rbp), %rdx
subq -0xe0(%rbp), %rdx
subq $0x1, %rdx
imulq $0x1c, (%rax,%rdx,8), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
imulq $0x1c, -0xe0(%rbp), %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 -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x2e7c4b
movq -0x98(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)