// File: chhylp123[P]hifiasm/inter.cpp
// Function: simple_g_chain_dp(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*)
int64_t simple_g_chain_dp(kv_ul_ov_t *in, ul_ov_t *buf, 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)
{
	if(in->n == 0) return 0;
	uint32_t ai_v, aj_v, rev_n; ma_ug_t *ug = uref->ug;
    int64_t mm_ovlp, x, i, j, k, sc, csc, mm_sc, mm_idx, qo, share, in_n = in->n;
	int64_t iqs, iqe, its, ite, i_end, j_end;
    ul_ov_t *ai, *aj, *e_ai, *e_aj, rev_t;
	for (i = 0; i < in_n; i++) {
		gen_end_coord(&(in->a[i]), qlen, ug->u.a[in->a[i].tn].len, NULL, &iqe, NULL, NULL);
		srt[i] = iqe; srt[i] <<= 32; srt[i] |= (uint64_t)i;
	}
	radix_sort_gfa64(srt, srt+in_n); 
	for (i = 0; i < in_n; i++) buf[i] = in->a[(uint32_t)srt[i]];
	memcpy(in->a, buf, in_n *sizeof((*buf)));///all alignments have been sorted by the real end-qe

	for (i = 0; i < in_n; ++i) {
		ai = &(in->a[i]); ai_v = (ai->tn<<1)|ai->rev; e_ai = &(buf[i]); i_end = 0;
		gen_end_coord(ai, qlen, ug->u.a[ai->tn].len, &iqs, &iqe, &its, &ite);
		e_ai->qs = iqs; e_ai->qe = iqe; e_ai->ts = its; e_ai->te = ite;
		mm_ovlp = max_ovlp(uref->ug->g, ai_v^1);
		x = (e_ai->qs + mm_ovlp)*diff_ec_ul; 
        if(x < bw) x = bw; 
        x += e_ai->qs + mm_ovlp;
        if (x > qlen+1) x = qlen+1;
		x = find_ul_ov_max(i, buf, x+G_CHAIN_INDEL); 
		i_end = is_end_check(ai_v^1, ai, uref->ug->g);
		csc = mm_sc = e_ai->sec; mm_idx = -1; 
		for (j = x; j >= 0; --j) { // collect potential destination vertices
            aj = &(in->a[j]); aj_v = (aj->tn<<1)|aj->rev; e_aj = &(buf[i]); j_end = 0;
			if(e_aj->qe+G_CHAIN_INDEL <= e_ai->qs) break;//even this pair has a overlap, its length will be very small; just ignore
            if(e_aj->qs >= e_ai->qs+G_CHAIN_INDEL) continue; // lj is contained in li on the query coordinate; 128 for indel offset
			qo = infer_rovlp(e_ai, e_aj, NULL, NULL, NULL, ug); ///overlap length in query (UL read)
			if(ai_v != aj_v && get_ecov_adv(uref, uopt, ai_v^1, aj_v^1, bw, diff_ec_ul, qo, 0, &share)) {
				sc = csc + pop_sc(track[j]); j_end = is_end_check(aj_v, aj, uref->ug->g);
				if(i_end && j_end) sc -= (share>=csc?csc:share);
				if(sc > mm_sc) mm_sc = sc, mm_idx = j;
			}
		}
		track[i] = push_sc_pre(mm_sc, mm_idx);
        srt[i] = track[i]>>32; srt[i] <<= 32; srt[i] |= i;
	}

	int64_t n_v, n_u, n_v0; 
    radix_sort_gfa64(srt, srt+in_n); 
	for (k = in_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;){
			buf[n_v] = in->a[i]; 
			gen_end_coord(&(buf[n_v]), qlen, ug->u.a[buf[n_v].tn].len, &iqs, &iqe, &its, &ite);
			buf[n_v].qs = iqs; buf[n_v].qe = iqe; buf[n_v].ts = its; buf[n_v].te = ite;

			track[i] |= ((uint64_t)0x80000000);
            i = pop_pre(track[i]);
			n_v++;
		}
		if(n_v0 == n_v) continue;
		sc = (i<0?(pop_sc(srt[k])):(pop_sc(srt[k])-pop_sc(track[i])));
		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];
        in->a[k].qn = idx[k]>>32;//score
        in->a[k].ts = n_v0; in->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
        in->a[k].qs = (uint32_t)-1; in->a[k].qe = buf[n_v0].qe;
        for (i = 0; i < rev_n; i++) {
            rev_t = buf[n_v0+i]; buf[n_v0+i] = buf[n_v-i-1]; buf[n_v-i-1] = rev_t;
            
            if(in->a[k].qs > buf[n_v0+i].qs) in->a[k].qs = buf[n_v0+i].qs;
            if(in->a[k].qs > buf[n_v-i-1].qs) in->a[k].qs = buf[n_v-i-1].qs;
        }
        if(((uint32_t)idx[k])&1) {
            if(in->a[k].qs > buf[n_v0+i].qs) in->a[k].qs = buf[n_v0+i].qs;
        }
        // fprintf(stderr, "[M::%s] k:%ld, qs:%u, qe:%u, chain_occ:%u, chain_score:%u\n", __func__, k, 
        //                  res->a[k].qs, res->a[k].qe, res->a[k].te - res->a[k].ts, res->a[k].qn);
    }

	in->n = n_u;
    radix_sort_ul_ov_srt_qn(in->a, in->a + in->n);//sort by score
	return n_v;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
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)
movsd %xmm0, -0x38(%rbp)
movq %r9, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x2d1f60
movq $0x0, -0x8(%rbp)
jmp 0x2d2b8a
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xb8(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jge 0x2d203a
movq -0x10(%rbp), %rax
movq (%rax), %rdi
imulq $0x1c, -0x70(%rbp), %rax
addq %rax, %rdi
movq -0x40(%rbp), %rsi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
imulq $0x1c, -0x70(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %r9d
leaq -0xc8(%rbp), %r8
movq %r9, %rcx
movq $0x0, (%rsp)
callq 0x2d1d10
movq -0xc8(%rbp), %rdx
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rdx
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2d1f82
movq 0x18(%rbp), %rdi
movq 0x18(%rbp), %rsi
movq -0xb8(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x27a9b0
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jge 0x2d20bc
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rdx
movq (%rax,%rdx,8), %rax
movl %eax, %eax
imulq $0x1c, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
imulq $0x1c, -0x70(%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 -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2d205d
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
imulq $0x1c, -0xb8(%rbp), %rdx
callq 0x2180
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
cmpq -0xb8(%rbp), %rax
jge 0x2d255b
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x70(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0xf0(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x18(%rbp), %rax
imulq $0x1c, -0x70(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x100(%rbp)
movq $0x0, -0xe0(%rbp)
movq -0xf0(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0xf0(%rbp), %rcx
movl 0xc(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
leaq -0xc0(%rbp), %rcx
leaq -0xc8(%rbp), %r8
leaq -0xd0(%rbp), %r9
leaq -0xd8(%rbp), %rax
movq %rax, (%rsp)
callq 0x2d1d10
movq -0xc0(%rbp), %rax
movl %eax, %ecx
movq -0x100(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x100(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0xd0(%rbp), %rax
movl %eax, %ecx
movq -0x100(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0xd8(%rbp), %rax
movl %eax, %ecx
movq -0x100(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
movl -0x44(%rbp), %esi
xorl $0x1, %esi
callq 0x287d20
movq %rax, -0x60(%rbp)
movq -0x100(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x60(%rbp), %rax
cvtsi2sd %rax, %xmm0
mulsd -0x38(%rbp), %xmm0
cvttsd2si %xmm0, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x2d222c
movq -0x30(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x100(%rbp), %rax
movl 0x4(%rax), %eax
addq -0x60(%rbp), %rax
addq -0x68(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq -0x40(%rbp), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
jle 0x2d225f
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
movq -0x70(%rbp), %rax
movl %eax, %edi
movq -0x18(%rbp), %rsi
movq -0x68(%rbp), %rax
addq $0x80, %rax
movl %eax, %edx
callq 0x28cf00
cltq
movq %rax, -0x68(%rbp)
movl -0x44(%rbp), %edi
xorl $0x1, %edi
movq -0xf0(%rbp), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdx
callq 0x2d1ea0
movl %eax, %eax
movq %rax, -0xe0(%rbp)
movq -0x100(%rbp), %rax
movl 0x18(%rax), %eax
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
movl %eax, %eax
movq %rax, -0x98(%rbp)
movq %rax, -0x90(%rbp)
movq $-0x1, -0xa0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
jl 0x2d24e4
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x78(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
movl 0xc(%rax), %eax
shll %eax
movq -0xf8(%rbp), %rcx
movl 0x18(%rcx), %ecx
shrl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x18(%rbp), %rax
imulq $0x1c, -0x70(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x108(%rbp)
movq $0x0, -0xe8(%rbp)
movq -0x108(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x80, %eax
movq -0x100(%rbp), %rcx
cmpl 0x4(%rcx), %eax
ja 0x2d2355
jmp 0x2d24e4
movq -0x108(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x100(%rbp), %rcx
movl 0x4(%rcx), %ecx
addl $0x80, %ecx
cmpl %ecx, %eax
jb 0x2d2378
jmp 0x2d24d3
movq -0x100(%rbp), %rdi
movq -0x108(%rbp), %rsi
movq -0x58(%rbp), %r9
xorl %eax, %eax
movl %eax, %r8d
movq %r8, %rdx
movq %r8, %rcx
callq 0x71a90
movq %rax, -0xa8(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x2d24d1
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x44(%rbp), %edx
xorl $0x1, %edx
movl -0x48(%rbp), %ecx
xorl $0x1, %ecx
movq -0x30(%rbp), %r8
movsd -0x38(%rbp), %xmm0
movq -0xa8(%rbp), %r9
xorl %eax, %eax
leaq -0xb0(%rbp), %rax
movq $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x292000
cmpq $0x0, %rax
je 0x2d24d1
movq -0x90(%rbp), %rax
movq %rax, -0x148(%rbp)
movq 0x28(%rbp), %rax
movq -0x78(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x292b40
movq %rax, %rcx
movq -0x148(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movl -0x48(%rbp), %edi
movq -0xf8(%rbp), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdx
callq 0x2d1ea0
movl %eax, %eax
movq %rax, -0xe8(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x2d24a6
cmpq $0x0, -0xe8(%rbp)
je 0x2d24a6
movq -0xb0(%rbp), %rax
cmpq -0x90(%rbp), %rax
jl 0x2d2480
movq -0x90(%rbp), %rax
movq %rax, -0x150(%rbp)
jmp 0x2d248e
movq -0xb0(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rcx
movq -0x88(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x98(%rbp), %rax
jle 0x2d24cf
movq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xa0(%rbp)
jmp 0x2d24d1
jmp 0x2d24d3
movq -0x78(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x2d22d8
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x292ac0
movq %rax, %rdx
movq 0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
shrq $0x20, %rdx
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
shlq $0x20, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rdx
movq 0x18(%rbp), %rax
movq -0x70(%rbp), %rcx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2d20dc
movq 0x18(%rbp), %rdi
movq 0x18(%rbp), %rsi
movq -0xb8(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x27a9b0
movq -0xb8(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x80(%rbp)
movq $0x0, -0x138(%rbp)
movq $0x0, -0x130(%rbp)
cmpq $0x0, -0x80(%rbp)
jl 0x2d2822
movq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
movq 0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
movq %rax, -0x70(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x70(%rbp)
movb %al, -0x151(%rbp)
jl 0x2d25f8
movq 0x28(%rbp), %rcx
movq -0x70(%rbp), %rdx
movabsq $0x80000000, %rax       # imm = 0x80000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
sete %al
movb %al, -0x151(%rbp)
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x2d2607
jmp 0x2d2757
movq -0x10(%rbp), %rax
movq (%rax), %rcx
imulq $0x1c, -0x70(%rbp), %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
imulq $0x1c, -0x130(%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 -0x18(%rbp), %rdi
imulq $0x1c, -0x130(%rbp), %rax
addq %rax, %rdi
movq -0x40(%rbp), %rsi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
imulq $0x1c, -0x130(%rbp), %rdx
addq %rdx, %rcx
movl 0xc(%rcx), %ecx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl %eax, %eax
movl %eax, %edx
leaq -0xc0(%rbp), %rcx
leaq -0xc8(%rbp), %r8
leaq -0xd0(%rbp), %r9
leaq -0xd8(%rbp), %rax
movq %rax, (%rsp)
callq 0x2d1d10
movq -0xc0(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
imulq $0x1c, -0x130(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0xc8(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
imulq $0x1c, -0x130(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0xd0(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
imulq $0x1c, -0x130(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq -0xd8(%rbp), %rax
movl %eax, %ecx
movq -0x18(%rbp), %rax
imulq $0x1c, -0x130(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movq 0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movabsq $0x80000000, %rdx       # imm = 0x80000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq 0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x292ba0
movq %rax, -0x70(%rbp)
movq -0x130(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x130(%rbp)
jmp 0x2d25c6
movq -0x140(%rbp), %rax
cmpq -0x130(%rbp), %rax
jne 0x2d276c
jmp 0x2d2811
cmpq $0x0, -0x70(%rbp)
jge 0x2d278d
movq 0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x292b40
movq %rax, -0x160(%rbp)
jmp 0x2d27ca
movq 0x18(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x292b40
movq %rax, -0x168(%rbp)
movq 0x28(%rbp), %rax
movq -0x70(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x292b40
movq %rax, %rcx
movq -0x168(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x160(%rbp)
movq -0x160(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdx
shlq $0x20, %rdx
movq -0x130(%rbp), %rax
subq -0x140(%rbp), %rax
orq %rax, %rdx
movq 0x20(%rbp), %rax
movq -0x138(%rbp), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, -0x138(%rbp)
movq %rdx, (%rax,%rcx,8)
movq -0x80(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x2d259b
movq $0x0, -0x80(%rbp)
movq $0x0, -0x140(%rbp)
movq $0x0, -0x130(%rbp)
movq -0x80(%rbp), %rax
cmpq -0x138(%rbp), %rax
jge 0x2d2b51
movq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
movq 0x20(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl %eax, %eax
addq -0x130(%rbp), %rax
movq %rax, -0x130(%rbp)
movq 0x20(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrq $0x20, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movq -0x140(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x10(%rax)
movq -0x130(%rbp), %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movq 0x20(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shrl %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rcx
addq %rcx, %rax
movl $0xffffffff, 0x4(%rax)  # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
imulq $0x1c, -0x140(%rbp), %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq $0x0, -0x70(%rbp)
movq -0x70(%rbp), %rax
movl -0x4c(%rbp), %ecx
cmpq %rcx, %rax
jge 0x2d2ad0
movq -0x18(%rbp), %rax
movq -0x140(%rbp), %rcx
addq -0x70(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq %rcx, -0x124(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x11c(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x114(%rbp)
movl 0x18(%rax), %eax
movl %eax, -0x10c(%rbp)
movq -0x18(%rbp), %rcx
movq -0x130(%rbp), %rax
subq -0x70(%rbp), %rax
subq $0x1, %rax
imulq $0x1c, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq -0x140(%rbp), %rdx
addq -0x70(%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 -0x18(%rbp), %rax
movq -0x130(%rbp), %rcx
subq -0x70(%rbp), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movq -0x124(%rbp), %rcx
movq %rcx, (%rax)
movq -0x11c(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0x114(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl -0x10c(%rbp), %ecx
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
movq -0x140(%rbp), %rdx
addq -0x70(%rbp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2d2a5d
movq -0x18(%rbp), %rax
movq -0x140(%rbp), %rcx
addq -0x70(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
movq -0x130(%rbp), %rdx
subq -0x70(%rbp), %rdx
subq $0x1, %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2d2abd
movq -0x18(%rbp), %rax
movq -0x130(%rbp), %rcx
subq -0x70(%rbp), %rcx
subq $0x1, %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x2d2abf
movq -0x70(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x70(%rbp)
jmp 0x2d2927
movq 0x20(%rbp), %rax
movq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2d2b3e
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
movq -0x140(%rbp), %rdx
addq -0x70(%rbp), %rdx
imulq $0x1c, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jbe 0x2d2b3c
movq -0x18(%rbp), %rax
movq -0x140(%rbp), %rcx
addq -0x70(%rbp), %rcx
imulq $0x1c, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
imulq $0x1c, -0x80(%rbp), %rdx
addq %rdx, %rax
movl %ecx, 0x4(%rax)
jmp 0x2d2b3e
jmp 0x2d2b40
movq -0x80(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x80(%rbp)
jmp 0x2d2840
movq -0x138(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rax
imulq $0x1c, 0x8(%rax), %rax
addq %rax, %rsi
callq 0x27c310
movq -0x130(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw (%rax,%rax)