// File: chhylp123[P]hifiasm/inter.cpp
// Function: extract_microsatellite(char const*, unsigned int, hpc_re_t*, asg64_v*, unsigned int, unsigned int, unsigned int, unsigned int, hpc_idx_t*)
void extract_microsatellite(const char *in, uint32_t in_len, hpc_re_t *res, asg64_v *buf, uint32_t mcs_len, 
uint32_t min_klen_simple, uint32_t min_klen_complex, uint32_t ksimple_cut, hpc_idx_t *idx)
{
	uint32_t k, i, l, c, o, ls; char sk[256]; hpc_ss_t z, *za; 
	uint32_t m, cutoff, zn, bn, ovlp, os, oe, oks, oke;
	idx->s = idx->e = res->n;
	if(mcs_len > 255) mcs_len = 255;
	for (k = 1; k <= mcs_len; k++) {
		memset(sk, 'N', k); ///k->length of k-mer
		o = ((k<=ksimple_cut)?(k*min_klen_simple):(k*min_klen_complex));
		for (i = l = ls = 0; i < in_len; i++) {
			c = seq_nt4_table[(uint8_t)in[i]]; 
			if((c < 4) && (((l >= k) && (sk[(l+ls)%k] == in[i])) || (l < k))) {
				if(l < k) sk[(l+ls)%k] = in[i]; 
				l++;
			} else {
				if(l >= o) {
					z.s = i-l; z.e = i; z.k = k;
					kv_push(hpc_ss_t, *res, z);
				}

				if(c >= 4) {
					l = ls = 0;
				} else if(l >= 0) {
					sk[(l+ls)%k] = in[i]; l++;
					m = ((l<=k)?(l-1):(k));
					ls = (ls+(l-m))%k; l = m;
				}
			}
		}
	}

	uint32_t ks, ke, fs, fe;
	radix_sort_hpc_ss_t_s(res->a+idx->s, res->a+res->n);
	for (k = ks = ke = idx->e = idx->s; k < res->n; k++) {
		fs = fe = (uint32_t)-1;
		if(ke > idx->s) {
			fs = res->a[ks].s; fe = res->a[ke-1].e;
		}
		///new interval is not overlapped with existing one
		if((fs == ((uint32_t)-1)) || (fe <= res->a[k].s)) {
			res->a[idx->e++] = res->a[k]; ks = idx->e - 1; ke = idx->e;
		} else {
			assert(res->a[k].s >= fs);
			///new interval might be contained in an exist one
			if(res->a[k].s >= fs && res->a[k].e <= fe) {
				for (i = ks; i < ke; i++) {
					if(res->a[k].s >= res->a[i].s && res->a[k].e <= res->a[i].e) {///new interval is contained in an exist one
						if((res->a[k].s == res->a[i].s) && (res->a[k].e == res->a[i].e) 
															&& (res->a[k].k < res->a[i].k)) {
							res->a[i] = res->a[k];
						}
						break;
					}
				}
				if(i < ke) continue;
			}

			for (i = m = ks; i < ke; i++) {
				///exist interval is contained in new interval
				if(res->a[k].s <= res->a[i].s && res->a[k].e >= res->a[i].e) continue;
				res->a[m++] = res->a[i];
			}
			ke = idx->e = m;
			res->a[idx->e++] = res->a[k]; ke = idx->e;
		}
	}
	res->n = idx->e;
	cutoff = (in_len/sizeof((*(res->a))))/4; if(cutoff < 10) cutoff = 10;
	if(idx->e-idx->s > cutoff) {///compress if there are too many intervals
		kv_resize(uint64_t, *buf, res->n-idx->s);
		za = res->a + idx->s; zn = idx->e - idx->s;
		for (k = buf->n = 0; k < zn; k++) {
			kv_push(uint64_t, *buf, ((((uint64_t)za[k].k)<<32)|((uint64_t)(k))));
		}
		radix_sort_gfa64(buf->a, buf->a+buf->n);///sorted by the k-mer length
		for (i = 0, bn = buf->n; i < bn; i++) {
			k = (uint32_t)buf->a[i]; oks = za[k].s; oke = za[k].e;
			for (m = 0; m < zn && za[m].s < za[k].e; m++) {
				if(!(buf->a[m]&((uint64_t)0x8000000000000000))) continue;
				if(m == k) continue;
				///now has overlap
				os = MAX(za[m].s, oks); oe = MIN(za[m].e, oke);
				ovlp = ((oe > os)?(oe - os):(0));
				if(!ovlp) continue;
				assert(os == oks || oe == oke);
				if(os == oks) oks = oe;
				if(oe == oke) oke = os;
				if(oke < oks + za[k].k) break;
			}
			if(oke >= oks + za[k].k) {
				buf->a[k] |= ((uint64_t)0x8000000000000000);
			}
		}
		for (i = 0, idx->e = idx->s; i < bn; i++) {
			if(!(buf->a[i]&((uint64_t)0x8000000000000000))) continue;
			res->a[idx->e++] = za[i];
		}
		res->n = idx->e;
	}
	// for (i = idx->s; i < idx->e; i++) {
	// 	fprintf(stderr, "k::%u\tin::[%u,\t%u)\n", res->a[i].k, res->a[i].s, res->a[i].e);
	// }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq 0x20(%rbp), %rax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl %eax, %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq 0x20(%rbp), %rax
movl %ecx, (%rax)
cmpl $0xff, -0x24(%rbp)
jbe 0x307c82
movl $0xff, -0x24(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x24(%rbp), %eax
ja 0x307f00
leaq -0x140(%rbp), %rdi
movl -0x2c(%rbp), %eax
movl %eax, %edx
movl $0x4e, %esi
callq 0x2100
movl -0x2c(%rbp), %eax
cmpl 0x18(%rbp), %eax
ja 0x307cc2
movl -0x2c(%rbp), %eax
imull -0x28(%rbp), %eax
movl %eax, -0x190(%rbp)
jmp 0x307ccf
movl -0x2c(%rbp), %eax
imull 0x10(%rbp), %eax
movl %eax, -0x190(%rbp)
movl -0x190(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jae 0x307ef0
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x82ad3(%rip), %rax     # 0x38a7e0
movzbl (%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
cmpl $0x4, -0x38(%rbp)
jae 0x307d82
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jb 0x307d46
movl -0x34(%rbp), %eax
addl -0x40(%rbp), %eax
xorl %edx, %edx
divl -0x2c(%rbp)
movl %edx, %eax
movsbl -0x140(%rbp,%rax), %eax
movq -0x8(%rbp), %rcx
movl -0x30(%rbp), %edx
movsbl (%rcx,%rdx), %ecx
cmpl %ecx, %eax
je 0x307d4e
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x307d82
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jae 0x307d74
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
movb (%rax,%rcx), %cl
movl -0x34(%rbp), %eax
addl -0x40(%rbp), %eax
xorl %edx, %edx
divl -0x2c(%rbp)
movl %edx, %eax
movb %cl, -0x140(%rbp,%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x307ee0
movl -0x34(%rbp), %eax
cmpl -0x3c(%rbp), %eax
jb 0x307e4f
movl -0x30(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x14c(%rbp)
movl -0x30(%rbp), %eax
movl %eax, -0x148(%rbp)
movl -0x2c(%rbp), %eax
movb %al, -0x144(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x307e1a
movq -0x18(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x307ddc
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x198(%rbp)
jmp 0x307dea
movl $0x2, %eax
movq %rax, -0x198(%rbp)
jmp 0x307dea
movq -0x198(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rax
imulq $0xc, 0x8(%rax), %rsi
callq 0x2360
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rdx
movq (%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, (%rdx)
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq -0x14c(%rbp), %rcx
movq %rcx, (%rax)
movl -0x144(%rbp), %ecx
movl %ecx, 0x8(%rax)
jmp 0x307e4f
cmpl $0x4, -0x38(%rbp)
jb 0x307e65
movl $0x0, -0x40(%rbp)
movl $0x0, -0x34(%rbp)
jmp 0x307ede
cmpl $0x0, -0x34(%rbp)
jb 0x307edc
movq -0x8(%rbp), %rax
movl -0x30(%rbp), %ecx
movb (%rax,%rcx), %cl
movl -0x34(%rbp), %eax
addl -0x40(%rbp), %eax
xorl %edx, %edx
divl -0x2c(%rbp)
movl %edx, %eax
movb %cl, -0x140(%rbp,%rax)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x2c(%rbp), %eax
ja 0x307ea8
movl -0x34(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x19c(%rbp)
jmp 0x307eb1
movl -0x2c(%rbp), %eax
movl %eax, -0x19c(%rbp)
movl -0x19c(%rbp), %eax
movl %eax, -0x15c(%rbp)
movl -0x40(%rbp), %eax
movl -0x34(%rbp), %ecx
subl -0x15c(%rbp), %ecx
addl %ecx, %eax
xorl %edx, %edx
divl -0x2c(%rbp)
movl %edx, -0x40(%rbp)
movl -0x15c(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x307ede
jmp 0x307ee0
jmp 0x307ee2
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x307ced
jmp 0x307ef2
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x307c89
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
movq 0x20(%rbp), %rax
movl (%rax), %eax
imulq $0xc, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x18(%rbp), %rax
imulq $0xc, (%rax), %rax
addq %rax, %rsi
callq 0x27df70
movq 0x20(%rbp), %rax
movl (%rax), %eax
movq 0x20(%rbp), %rcx
movl %eax, 0x4(%rcx)
movl %eax, -0x184(%rbp)
movl %eax, -0x180(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x308344
movl $0xffffffff, -0x18c(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x188(%rbp) # imm = 0xFFFFFFFF
movl -0x184(%rbp), %eax
movq 0x20(%rbp), %rcx
cmpl (%rcx), %eax
jbe 0x307fbb
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x180(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x188(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x184(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x18c(%rbp)
cmpl $-0x1, -0x188(%rbp)
je 0x307fe0
movl -0x18c(%rbp), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x2c(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
ja 0x308040
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x2c(%rbp), %eax
imulq $0xc, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rsi
movl 0x4(%rsi), %edx
movl %edx, %edi
addl $0x1, %edi
movl %edi, 0x4(%rsi)
movl %edx, %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
subl $0x1, %eax
movl %eax, -0x180(%rbp)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x184(%rbp)
jmp 0x308334
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x188(%rbp), %eax
jb 0x30805e
jmp 0x30807d
leaq 0x8d898(%rip), %rdi     # 0x3958fd
leaq 0x887c3(%rip), %rsi     # 0x39082f
movl $0x589c, %edx           # imm = 0x589C
leaq 0x8d897(%rip), %rcx     # 0x39590f
callq 0x2130
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x188(%rbp), %eax
jb 0x308212
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x18c(%rbp), %eax
ja 0x308212
movl -0x180(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x184(%rbp), %eax
jae 0x308200
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jb 0x3081f0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
ja 0x3081f0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
jne 0x3081ee
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jne 0x3081ee
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x8(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movzbl 0x8(%rcx), %ecx
cmpl %ecx, %eax
jge 0x3081ee
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x2c(%rbp), %eax
imulq $0xc, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
jmp 0x308200
jmp 0x3081f2
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3080c7
movl -0x30(%rbp), %eax
cmpl -0x184(%rbp), %eax
jae 0x308210
jmp 0x308336
jmp 0x308212
movl -0x180(%rbp), %eax
movl %eax, -0x15c(%rbp)
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x184(%rbp), %eax
jae 0x3082d6
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl (%rcx), %eax
ja 0x308288
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rcx
movl -0x30(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
jb 0x308288
jmp 0x3082c8
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x30(%rbp), %eax
imulq $0xc, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x15c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x15c(%rbp)
movl %edx, %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x308221
movl -0x15c(%rbp), %eax
movq 0x20(%rbp), %rcx
movl %eax, 0x4(%rcx)
movl %eax, -0x184(%rbp)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x2c(%rbp), %eax
imulq $0xc, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rsi
movl 0x4(%rsi), %edx
movl %edx, %edi
addl $0x1, %edi
movl %edi, 0x4(%rsi)
movl %edx, %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x184(%rbp)
jmp 0x308336
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x307f49
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movl -0xc(%rbp), %eax
movl $0xc, %ecx
xorl %edx, %edx
divq %rcx
shrq $0x2, %rax
movl %eax, -0x160(%rbp)
cmpl $0xa, -0x160(%rbp)
jae 0x30837e
movl $0xa, -0x160(%rbp)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq 0x20(%rbp), %rcx
subl (%rcx), %eax
cmpl -0x160(%rbp), %eax
jbe 0x30896f
jmp 0x308399
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movq 0x20(%rbp), %rdx
movl (%rdx), %edx
subq %rdx, %rcx
cmpq %rcx, %rax
jae 0x30848d
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq 0x20(%rbp), %rax
movl (%rax), %eax
subq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $-0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shrq %rcx
movq -0x20(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x2, %rcx
movq -0x20(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x4, %rcx
movq -0x20(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x8, %rcx
movq -0x20(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x10, %rcx
movq -0x20(%rbp), %rax
orq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x30848f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rcx
movl (%rcx), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x158(%rbp)
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq 0x20(%rbp), %rcx
subl (%rcx), %eax
movl %eax, -0x164(%rbp)
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x164(%rbp), %eax
jae 0x3085a0
jmp 0x3084e1
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x308552
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x308511
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
movq %rax, -0x1a8(%rbp)
jmp 0x30851f
movl $0x2, %eax
movq %rax, -0x1a8(%rbp)
jmp 0x30851f
movq -0x1a8(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
shlq $0x3, %rsi
callq 0x2360
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x158(%rbp), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movzbl 0x8(%rax), %eax
movl %eax, %edx
shlq $0x20, %rdx
movl -0x2c(%rbp), %eax
orq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rsi
movq (%rsi), %rcx
movq %rcx, %rdi
addq $0x1, %rdi
movq %rdi, (%rsi)
movq %rdx, (%rax,%rcx,8)
jmp 0x308592
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x3084d0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rax
movq (%rax), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x27a9b0
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x168(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x168(%rbp), %eax
jae 0x3088d5
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x30(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl %eax, -0x2c(%rbp)
movq -0x158(%rbp), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x178(%rbp)
movq -0x158(%rbp), %rax
movl -0x2c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x17c(%rbp)
movl $0x0, -0x15c(%rbp)
movl -0x15c(%rbp), %ecx
xorl %eax, %eax
cmpl -0x164(%rbp), %ecx
movb %al, -0x1a9(%rbp)
jae 0x30867e
movq -0x158(%rbp), %rax
movl -0x15c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movq -0x158(%rbp), %rcx
movl -0x2c(%rbp), %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x4(%rcx), %eax
setb %al
movb %al, -0x1a9(%rbp)
movb -0x1a9(%rbp), %al
testb $0x1, %al
jne 0x30868d
jmp 0x308881
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x15c(%rbp), %eax
movl %eax, %edx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
jne 0x3086b6
jmp 0x30886d
movl -0x15c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x3086c6
jmp 0x30886d
movq -0x158(%rbp), %rax
movl -0x15c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x178(%rbp), %eax
jb 0x308702
movq -0x158(%rbp), %rax
movl -0x15c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x1b0(%rbp)
jmp 0x30870e
movl -0x178(%rbp), %eax
movl %eax, -0x1b0(%rbp)
movl -0x1b0(%rbp), %eax
movl %eax, -0x170(%rbp)
movq -0x158(%rbp), %rax
movl -0x15c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
cmpl -0x17c(%rbp), %eax
ja 0x308758
movq -0x158(%rbp), %rax
movl -0x15c(%rbp), %ecx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x1b4(%rbp)
jmp 0x308764
movl -0x17c(%rbp), %eax
movl %eax, -0x1b4(%rbp)
movl -0x1b4(%rbp), %eax
movl %eax, -0x174(%rbp)
movl -0x174(%rbp), %eax
cmpl -0x170(%rbp), %eax
jbe 0x308792
movl -0x174(%rbp), %eax
subl -0x170(%rbp), %eax
movl %eax, -0x1b8(%rbp)
jmp 0x30879c
xorl %eax, %eax
movl %eax, -0x1b8(%rbp)
jmp 0x30879c
movl -0x1b8(%rbp), %eax
movl %eax, -0x16c(%rbp)
cmpl $0x0, -0x16c(%rbp)
jne 0x3087b6
jmp 0x30886d
movl -0x170(%rbp), %ecx
movb $0x1, %al
cmpl -0x178(%rbp), %ecx
movb %al, -0x1b9(%rbp)
je 0x3087e1
movl -0x174(%rbp), %eax
cmpl -0x17c(%rbp), %eax
sete %al
movb %al, -0x1b9(%rbp)
movb -0x1b9(%rbp), %al
testb $0x1, %al
jne 0x3087ed
jmp 0x3087ef
jmp 0x30880e
leaq 0x8d199(%rip), %rdi     # 0x39598f
leaq 0x88032(%rip), %rsi     # 0x39082f
movl $0x58c6, %edx           # imm = 0x58C6
leaq 0x8d106(%rip), %rcx     # 0x39590f
callq 0x2130
movl -0x170(%rbp), %eax
cmpl -0x178(%rbp), %eax
jne 0x308828
movl -0x174(%rbp), %eax
movl %eax, -0x178(%rbp)
movl -0x174(%rbp), %eax
cmpl -0x17c(%rbp), %eax
jne 0x308842
movl -0x170(%rbp), %eax
movl %eax, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
movl -0x178(%rbp), %ecx
movq -0x158(%rbp), %rdx
movl -0x2c(%rbp), %esi
imulq $0xc, %rsi, %rsi
addq %rsi, %rdx
movzbl 0x8(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jae 0x30886b
jmp 0x308881
jmp 0x30886d
movl -0x15c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x15c(%rbp)
jmp 0x308635
movl -0x17c(%rbp), %eax
movl -0x178(%rbp), %ecx
movq -0x158(%rbp), %rdx
movl -0x2c(%rbp), %esi
imulq $0xc, %rsi, %rsi
addq %rsi, %rdx
movzbl 0x8(%rdx), %edx
addl %edx, %ecx
cmpl %ecx, %eax
jb 0x3088c5
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x2c(%rbp), %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x3088c7
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3085d7
movl $0x0, -0x30(%rbp)
movq 0x20(%rbp), %rax
movl (%rax), %ecx
movq 0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x30(%rbp), %eax
cmpl -0x168(%rbp), %eax
jae 0x30895f
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x30(%rbp), %eax
movl %eax, %edx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
jne 0x308917
jmp 0x308954
movq -0x158(%rbp), %rcx
movl -0x30(%rbp), %eax
imulq $0xc, %rax, %rax
addq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x20(%rbp), %rsi
movl 0x4(%rsi), %edx
movl %edx, %edi
addl $0x1, %edi
movl %edi, 0x4(%rsi)
movl %edx, %edx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movq (%rcx), %rdx
movq %rdx, (%rax)
movl 0x8(%rcx), %ecx
movl %ecx, 0x8(%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3088e9
movq 0x20(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopl (%rax,%rax)