// File: /workspace/github_c_makefile_star2_O1/nh13[P]ksw/src/ksw2/ksw2_gg2_sse.c
// Function: ksw_gg2_sse
int ksw_gg2_sse(void *km, int qlen, const uint8_t *query, int tlen, const uint8_t *target, int8_t m, const int8_t *mat, int8_t q, int8_t e, int w, int *m_cigar_, int *n_cigar_, uint32_t **cigar_)
{
	int r, t, n_col, n_col_, *off, tlen_, last_st, last_en, H0 = 0, last_H0_t = 0;
	uint8_t *qr, *mem, *mem2;
	__m128i *u, *v, *x, *y, *s, *p;
	__m128i q_, qe2_, zero_, flag1_, flag2_, flag8_, flag16_;

	zero_   = _mm_set1_epi8(0);
	q_      = _mm_set1_epi8(q);
	qe2_    = _mm_set1_epi8((q + e) * 2);
	flag1_  = _mm_set1_epi8(1);
	flag2_  = _mm_set1_epi8(2);
	flag8_  = _mm_set1_epi8(0x08);
	flag16_ = _mm_set1_epi8(0x10);

	if (w < 0) w = tlen > qlen? tlen : qlen;
	n_col = w + 1 < tlen? w + 1 : tlen; // number of columns in the backtrack matrix
	tlen_ = (tlen + 15) / 16;
	n_col_ = (n_col + 15) / 16 + 1;
	n_col = n_col_ * 16;

	mem = (uint8_t*)kcalloc(km, tlen_ * 5 + 1, 16);
	u = (__m128i*)(((size_t)mem + 15) >> 4 << 4); // 16-byte aligned
	v = u + tlen_, x = v + tlen_, y = x + tlen_, s = y + tlen_;
	qr = (uint8_t*)kcalloc(km, qlen, 1);
	mem2 = (uint8_t*)kmalloc(km, ((qlen + tlen - 1) * n_col_ + 1) * 16);
	p = (__m128i*)(((size_t)mem2 + 15) >> 4 << 4);
	off = (int*)kmalloc(km, (qlen + tlen - 1) * sizeof(int));

	for (t = 0; t < qlen; ++t)
		qr[t] = query[qlen - 1 - t];

	for (r = 0, last_st = last_en = -1; r < qlen + tlen - 1; ++r) {
		int st = 0, en = tlen - 1, st0, en0, st_, en_;
		int8_t x1, v1;
		__m128i x1_, v1_, *pr;
		// find the boundaries
		if (st < r - qlen + 1) st = r - qlen + 1;
		if (en > r) en = r;
		if (st < (r-w+1)>>1) st = (r-w+1)>>1; // take the ceil
		if (en > (r+w)>>1) en = (r+w)>>1; // take the floor
		st0 = st, en0 = en;
		st = st / 16 * 16, en = (en + 16) / 16 * 16 - 1;
		off[r] = st;
		// set boundary conditions
		if (st > 0) {
			if (st - 1 >= last_st && st - 1 <= last_en)
				x1 = ((uint8_t*)x)[st - 1], v1 = ((uint8_t*)v)[st - 1]; // (r-1,s-1) calculated in the last round
			else x1 = v1 = 0; // not calculated; set to zeros
		} else x1 = 0, v1 = r? q : 0;
		if (en >= r) ((uint8_t*)y)[r] = 0, ((uint8_t*)u)[r] = r? q : 0;
		// loop fission: set scores first
		for (t = st0; t <= en0; ++t)
			((uint8_t*)s)[t] = mat[target[t] * m + qr[t + qlen - 1 - r]];
		// core loop
		x1_ = _mm_cvtsi32_si128(x1);
		v1_ = _mm_cvtsi32_si128(v1);
		st_ = st>>4, en_ = en>>4;
		pr = p + r * n_col_ - st_;
		for (t = st_; t <= en_; ++t) {
			__m128i d, z, a, b, xt1, vt1, ut, tmp;

			z = _mm_add_epi8(_mm_load_si128(&s[t]), qe2_);

			xt1 = _mm_load_si128(&x[t]);          // xt1 <- x[r-1][t..t+15]
			tmp = _mm_srli_si128(xt1, 15);                   // tmp <- x[r-1][t+15]
			xt1 = _mm_or_si128(_mm_slli_si128(xt1, 1), x1_); // xt1 <- x[r-1][t-1..t+14]
			x1_ = tmp;
			vt1 = _mm_load_si128(&v[t]);          // vt1 <- v[r-1][t..t+15]
			tmp = _mm_srli_si128(vt1, 15);                   // tmp <- v[r-1][t+15]
			vt1 = _mm_or_si128(_mm_slli_si128(vt1, 1), v1_); // vt1 <- v[r-1][t-1..t+14]
			v1_ = tmp;
			a = _mm_add_epi8(xt1, vt1);                      // a <- x[r-1][t-1..t+14] + v[r-1][t-1..t+14]

			ut = _mm_load_si128(&u[t]);           // ut <- u[t..t+15]
			b = _mm_add_epi8(_mm_load_si128(&y[t]), ut); // b <- y[r-1][t..t+15] + u[r-1][t..t+15]

			d = _mm_and_si128(_mm_cmpgt_epi8(a, z), flag1_); // d = a > z? 1 : 0
#ifdef __SSE4_1__
			z = _mm_max_epi8(z, a);                          // z = z > a? z : a (signed)
			tmp = _mm_cmpgt_epi8(b, z);
			d = _mm_blendv_epi8(d, flag2_, tmp);             // d = b > z? 2 : d
#else // we need to emulate SSE4.1 intrinsics _mm_max_epi8() and _mm_blendv_epi8()
			z = _mm_and_si128(z, _mm_cmpgt_epi8(z, zero_));  // z = z > 0? z : 0;
			z = _mm_max_epu8(z, a);                          // z = max(z, a); this works because both are non-negative
			tmp = _mm_cmpgt_epi8(b, z);
			d = _mm_or_si128(_mm_andnot_si128(tmp, d), _mm_and_si128(tmp, flag2_)); // d = b > z? 2 : d; emulating blendv
#endif
			z = _mm_max_epu8(z, b);                          // z = max(z, b); this works because both are non-negative
			_mm_store_si128(&u[t], _mm_sub_epi8(z, vt1)); // u[r][t..t+15] <- z - v[r-1][t-1..t+14]
			_mm_store_si128(&v[t], _mm_sub_epi8(z, ut));  // v[r][t..t+15] <- z - u[r-1][t..t+15]

			z = _mm_sub_epi8(z, q_);
			a = _mm_sub_epi8(a, z);
			b = _mm_sub_epi8(b, z);
			tmp = _mm_cmpgt_epi8(a, zero_);
			d = _mm_or_si128(d, _mm_and_si128(flag8_,  tmp));
			_mm_store_si128(&x[t], _mm_and_si128(a, tmp));
			tmp = _mm_cmpgt_epi8(b, zero_);
			d = _mm_or_si128(d, _mm_and_si128(flag16_, tmp));
			_mm_store_si128(&y[t], _mm_and_si128(b, tmp));
			_mm_store_si128(&pr[t], d);
		}
		if (r > 0) {
			if (last_H0_t >= st0 && last_H0_t <= en0)
				H0 += ((uint8_t*)v)[last_H0_t] - (q + e);
			else ++last_H0_t, H0 += ((uint8_t*)u)[last_H0_t] - (q + e);
		} else H0 = ((uint8_t*)v)[0] - 2 * (q + e), last_H0_t = 0;
		last_st = st, last_en = en;
		//for (t = st0; t <= en0; ++t) printf("(%d,%d)\t(%d,%d,%d,%d)\t%x\n", r, t, ((uint8_t*)u)[t], ((uint8_t*)v)[t], ((uint8_t*)x)[t], ((uint8_t*)y)[t], ((uint8_t*)(p + r * n_col_))[t-st]); // for debugging
	}
	kfree(km, mem); kfree(km, qr);
	ksw_backtrack(km, 1, 0, 0, (uint8_t*)p, off, 0, n_col, tlen-1, qlen-1, m_cigar_, n_cigar_, cigar_);
	kfree(km, mem2); kfree(km, off);
	return H0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movl %r9d, 0x8(%rsp)
movq %r8, 0xd0(%rsp)
movl %ecx, %r15d
movq %rdx, %rbp
movq %rsi, 0x30(%rsp)
cmpl %esi, %ecx
movl %esi, %ecx
cmovgl %r15d, %ecx
movl 0x138(%rsp), %eax
testl %eax, %eax
cmovnsl %eax, %ecx
movq %rcx, 0xc8(%rsp)
leal 0x1(%rcx), %ebx
cmpl %r15d, %ebx
cmovgel %r15d, %ebx
movq %rdi, %r14
leal 0xf(%r15), %eax
leal 0x1e(%r15), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x4, %ecx
leal 0xf(%rbx), %eax
addl $0x1e, %ebx
testl %eax, %eax
cmovnsl %eax, %ebx
sarl $0x4, %ebx
leal 0x1(%rbx), %r13d
movq %rcx, 0x20(%rsp)
leal (%rcx,%rcx,4), %eax
incl %eax
movslq %eax, %rsi
movl $0x10, %edx
callq 0x1fbc8d
movq %rax, 0x80(%rsp)
movslq 0x30(%rsp), %r12
movl $0x1, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x1fbc8d
movq %rax, 0x48(%rsp)
movq %r15, 0x88(%rsp)
addl %r12d, %r15d
decl %r15d
movl %r15d, %eax
movl %r13d, 0x28(%rsp)
imull %r13d, %eax
shll $0x4, %eax
addl $0x10, %eax
movslq %eax, %rsi
movq %r14, %rdi
callq 0x1fbb36
movq %rax, 0x78(%rsp)
addq $0xf, %rax
movq %rax, 0x38(%rsp)
movslq %r15d, %rsi
shlq $0x2, %rsi
movq %r14, 0x10(%rsp)
movq %r14, %rdi
callq 0x1fbb36
movq 0x48(%rsp), %rcx
movq %rax, 0x60(%rsp)
movl 0x30(%rsp), %eax
movq %r12, 0xc0(%rsp)
testl %r12d, %r12d
jle 0x203c1c
movq %rax, %rdx
movb -0x1(%rbp,%rdx), %sil
movb %sil, (%rcx)
incq %rcx
decq %rdx
jne 0x203c0c
andq $-0x10, 0x38(%rsp)
movl $0x0, %esi
testl %r15d, %r15d
jle 0x2040ac
movsbl 0x128(%rsp), %ecx
movsbl 0x130(%rsp), %edx
addl %ecx, %edx
movq 0x80(%rsp), %rsi
addq $0xf, %rsi
movslq 0x20(%rsp), %r10
movq %rdx, 0x90(%rsp)
addl %edx, %edx
andq $-0x10, %rsi
movq %r10, %r9
shlq $0x4, %r9
movl %ecx, 0x2c(%rsp)
movd %ecx, %xmm0
movl %edx, 0x6c(%rsp)
movd %edx, %xmm1
movq %rsi, 0x50(%rsp)
leaq (%rsi,%r9), %rcx
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
punpcklbw %xmm1, %xmm1    # xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
movq %rcx, 0x40(%rsp)
addq %r9, %rcx
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
movq %rcx, 0x98(%rsp)
addq %r9, %rcx
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
movq %rcx, 0xa0(%rsp)
leaq (%rcx,%r9), %r11
movsbq 0x8(%rsp), %rdx
movl %r15d, %ecx
movq %rcx, 0xb0(%rsp)
movslq %ebx, %rcx
shlq $0x4, %rcx
addq $0x10, %rcx
movq %rcx, 0xa8(%rsp)
movq %r10, %rdi
shlq $0x5, %rdi
shlq $0x6, %r10
pxor %xmm2, %xmm2
movdqa 0x392459(%rip), %xmm3   # 0x596150
movdqa 0x392481(%rip), %xmm4   # 0x596180
movdqa 0x392489(%rip), %xmm5   # 0x596190
movq 0x88(%rsp), %rcx
decl %ecx
movl %ecx, 0x70(%rsp)
leaq (%r9,%r9,2), %rbx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x38(%rsp), %r14
xorl %ebp, %ebp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %r8d, %r8d
movq %r10, 0xb8(%rsp)
movl %r12d, 0x1c(%rsp)
movq %r8, 0xd8(%rsp)
movl %esi, 0xc(%rsp)
movl %r15d, 0x58(%rsp)
movq %rbp, %rcx
subq 0xc0(%rsp), %rcx
leal 0x1(%rcx), %r8d
testq %rcx, %rcx
movl $0x0, %ecx
cmovsl %ecx, %r8d
movl 0x70(%rsp), %esi
cmpl %ebp, %esi
movl %ebp, %ecx
cmovll %esi, %ecx
movq 0xc8(%rsp), %rsi
leal (%rsi,%rbp), %r12d
movl %ebp, %r13d
subl %esi, %r13d
incl %r13d
sarl %r13d
cmpl %r13d, %r8d
movl %r13d, %esi
cmovgl %r8d, %esi
sarl %r12d
cmpl %r12d, %ecx
cmovll %ecx, %r12d
movl %esi, 0x8(%rsp)
movl %esi, %r15d
andl $-0x10, %r15d
leal 0x10(%r12), %ecx
movq %r12, 0x20(%rsp)
leal 0x1f(%r12), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
movq 0x60(%rsp), %rcx
movl %r15d, (%rcx,%rbp,4)
testl %r15d, %r15d
movq %r14, 0xe0(%rsp)
jle 0x203e0a
xorl %r12d, %r12d
cmpl 0x58(%rsp), %r15d
jle 0x203e1c
leal -0x1(%r15), %ecx
movl $0x0, %r14d
cmpl 0x1c(%rsp), %ecx
jg 0x203e1f
movl %ecx, %ecx
movq 0x98(%rsp), %r14
movsbl (%r14,%rcx), %r12d
movq 0x40(%rsp), %r14
movb (%r14,%rcx), %r14b
jmp 0x203e1f
xorl %r12d, %r12d
testq %rbp, %rbp
movzbl 0x2c(%rsp), %r14d
cmovel %r12d, %r14d
jmp 0x203e1f
xorl %r14d, %r14d
movl %r14d, 0x74(%rsp)
movl %r12d, 0x1c(%rsp)
movq %r15, 0x58(%rsp)
andl $-0x10, %esi
movslq %esi, %rcx
cmpq %rcx, %rbp
jge 0x203e60
movq 0xa0(%rsp), %rcx
movb $0x0, (%rcx,%rbp)
testq %rbp, %rbp
movzbl 0x2c(%rsp), %ecx
movl $0x0, %r10d
cmovel %r10d, %ecx
movq 0x50(%rsp), %r14
movb %cl, (%r14,%rbp)
movl 0x8(%rsp), %ecx
cmpl 0x20(%rsp), %ecx
movq 0xd0(%rsp), %r12
movq 0x48(%rsp), %r15
movq 0x120(%rsp), %r10
jg 0x203ebb
cmpl %r13d, %r8d
cmovgl %r8d, %r13d
movslq %r13d, %r8
movslq 0x20(%rsp), %r13
decq %r8
movzbl 0x1(%r12,%r8), %ecx
imulq %rdx, %rcx
leal (%rax,%r8), %r14d
movslq %r14d, %r14
movzbl (%r15,%r14), %r14d
addq %r10, %rcx
movb (%r14,%rcx), %cl
movb %cl, 0x1(%r11,%r8)
incq %r8
cmpq %r13, %r8
jl 0x203e91
movl %esi, %r12d
decl %r12d
movl 0x8(%rsp), %ecx
movl %ecx, %r8d
shrl $0x4, %r8d
movl %r12d, %r13d
sarl $0x4, %r13d
cmpl %r13d, %r8d
movq 0xb8(%rsp), %r10
movq 0xe0(%rsp), %r14
jg 0x204033
movsbl 0x74(%rsp), %ecx
movd %ecx, %xmm9
movd 0x1c(%rsp), %xmm7
incl %r13d
movl %r8d, %esi
shll $0x4, %esi
addq 0x50(%rsp), %rsi
subq %r13, %r8
movq %r14, %r13
movdqa (%rsi,%r10), %xmm10
paddb %xmm1, %xmm10
movdqa (%rsi,%rdi), %xmm8
movdqa %xmm8, %xmm6
psrldq $0xf, %xmm6             # xmm6 = xmm6[15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
pslldq $0x1, %xmm8             # xmm8 = zero,xmm8[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
por %xmm7, %xmm8
movdqa (%rsi,%r9), %xmm11
movdqa %xmm11, %xmm7
psrldq $0xf, %xmm7             # xmm7 = xmm7[15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
pslldq $0x1, %xmm11            # xmm11 = zero,xmm11[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
por %xmm9, %xmm11
paddb %xmm11, %xmm8
movdqa (%rsi), %xmm12
movdqa (%rsi,%rbx), %xmm9
paddb %xmm12, %xmm9
movdqa %xmm8, %xmm13
pcmpgtb %xmm10, %xmm13
movdqa %xmm10, %xmm14
pcmpgtb %xmm2, %xmm14
pand %xmm10, %xmm14
pmaxub %xmm8, %xmm14
movdqa %xmm9, %xmm10
pcmpgtb %xmm14, %xmm10
movdqa %xmm10, %xmm15
pandn %xmm13, %xmm15
pand %xmm3, %xmm10
psubb %xmm15, %xmm10
pmaxub %xmm9, %xmm14
movdqa %xmm14, %xmm13
psubb %xmm11, %xmm13
movdqa %xmm13, (%rsi)
movdqa %xmm14, %xmm11
psubb %xmm12, %xmm11
movdqa %xmm11, (%rsi,%r9)
psubb %xmm0, %xmm14
psubb %xmm14, %xmm8
psubb %xmm14, %xmm9
movdqa %xmm8, %xmm11
pcmpgtb %xmm2, %xmm11
pand %xmm11, %xmm8
pand %xmm4, %xmm11
por %xmm10, %xmm11
movdqa %xmm8, (%rsi,%rdi)
movdqa %xmm9, %xmm8
pcmpgtb %xmm2, %xmm8
pand %xmm8, %xmm9
pand %xmm5, %xmm8
por %xmm11, %xmm8
movdqa %xmm9, (%rsi,%rbx)
movdqa %xmm8, (%r13)
addq $0x10, %r13
addq $0x10, %rsi
movdqa %xmm7, %xmm9
movdqa %xmm6, %xmm7
incq %r8
jne 0x203f10
testq %rbp, %rbp
movq 0x58(%rsp), %r15
je 0x204061
movq 0xd8(%rsp), %r8
cmpl 0x8(%rsp), %r8d
jl 0x204072
cmpl 0x20(%rsp), %r8d
jg 0x204072
movl %r8d, %ecx
movq 0x40(%rsp), %rsi
movzbl (%rsi,%rcx), %ecx
jmp 0x204083
movq 0x40(%rsp), %rcx
movzbl (%rcx), %esi
subl 0x6c(%rsp), %esi
xorl %r8d, %r8d
jmp 0x204090
movslq %r8d, %r8
movq 0x50(%rsp), %rcx
movzbl 0x1(%rcx,%r8), %ecx
incq %r8
movl 0xc(%rsp), %esi
subl 0x90(%rsp), %esi
addl %ecx, %esi
incq %rbp
decq %rax
addq 0xa8(%rsp), %r14
cmpq 0xb0(%rsp), %rbp
jne 0x203d39
movl %esi, 0xc(%rsp)
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq 0x80(%rsp), %rsi
callq 0x1fb9e5
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
callq 0x1fb9e5
movq 0x88(%rsp), %rdi
leal -0x1(%rdi), %r15d
movq 0x30(%rsp), %rsi
leal -0x1(%rsi), %r12d
movq 0x140(%rsp), %rax
movl (%rax), %ebp
movq 0x150(%rsp), %rax
movq (%rax), %rax
testl %edi, %edi
setg %cl
testl %esi, %esi
setg %r13b
movl %r15d, %edx
orl %r12d, %edx
js 0x2042fc
shll $0x4, 0x28(%rsp)
xorl %ebx, %ebx
movl $0x2, %r8d
xorl %r10d, %r10d
leal (%r12,%r15), %ecx
movq 0x60(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
movl $0x0, %esi
cmpl %edx, %r15d
jl 0x20414f
imull 0x28(%rsp), %ecx
addl %r15d, %ecx
subl %edx, %ecx
movslq %ecx, %rcx
movq 0x38(%rsp), %rsi
movzbl (%rsi,%rcx), %esi
movl %esi, %edi
testl %ebx, %ebx
je 0x204163
movl %ebx, %ecx
shrl %cl, %edi
shll $0x1d, %edi
sarl $0x1f, %edi
andl %ebx, %edi
jmp 0x204166
andl $0x7, %edi
andl $0x7, %esi
testl %edi, %edi
cmovnel %edi, %esi
cmpl %edx, %r15d
movl %esi, %ebx
cmovll %r8d, %ebx
cmpl $0x3, %ebx
je 0x2041ef
cmpl $0x1, %ebx
je 0x2041ef
testl %ebx, %ebx
jne 0x20425f
testl %r10d, %r10d
je 0x20419e
movslq %r10d, %rcx
movl -0x4(%rax,%rcx,4), %edx
testb $0xf, %dl
je 0x2042cc
cmpl %ebp, %r10d
jne 0x2041dd
leal (,%rbp,2), %r13d
testl %ebp, %ebp
movl $0x4, %ecx
cmovel %ecx, %r13d
leal (,%r13,4), %ecx
movslq %ecx, %rdx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r14
callq 0x1fbaa3
movl $0x2, %r8d
movq %r14, %r10
movl %r13d, %ebp
movslq %r10d, %rcx
incl %r10d
movl $0x10, (%rax,%rcx,4)
jmp 0x2042d3
testl %r10d, %r10d
je 0x20420e
movslq %r10d, %rcx
movl -0x4(%rax,%rcx,4), %edx
movl %edx, %esi
andl $0xf, %esi
cmpl $0x2, %esi
jne 0x20420e
addl $0x10, %edx
movl %edx, -0x4(%rax,%rcx,4)
jmp 0x20425a
cmpl %ebp, %r10d
jne 0x20424d
leal (,%rbp,2), %r13d
testl %ebp, %ebp
movl $0x4, %ecx
cmovel %ecx, %r13d
leal (,%r13,4), %ecx
movslq %ecx, %rdx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r14
callq 0x1fbaa3
movl $0x2, %r8d
movq %r14, %r10
movl %r13d, %ebp
movslq %r10d, %rcx
incl %r10d
movl $0x12, (%rax,%rcx,4)
decl %r15d
jmp 0x2042d9
movslq %r10d, %r13
testl %r10d, %r10d
je 0x204280
movl -0x4(%rax,%r13,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0x204280
addl $0x10, %ecx
movl %ecx, -0x4(%rax,%r13,4)
jmp 0x2042d6
cmpl %ebp, %r10d
jne 0x2042bf
leal (,%rbp,2), %r14d
testl %ebp, %ebp
movl $0x4, %ecx
cmovel %ecx, %r14d
leal (,%r14,4), %ecx
movslq %ecx, %rdx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r10, %rbp
callq 0x1fbaa3
movl $0x2, %r8d
movq %rbp, %r10
movl %r14d, %ebp
incl %r10d
movl $0x11, (%rax,%r13,4)
jmp 0x2042d6
addl $0x10, %edx
movl %edx, -0x4(%rax,%rcx,4)
decl %r15d
decl %r12d
testl %r12d, %r12d
setns %r13b
testl %r15d, %r15d
setns %cl
js 0x2042f1
testl %r12d, %r12d
jns 0x204123
incl %r15d
incl %r12d
movl %r15d, %edi
jmp 0x204302
xorl %r10d, %r10d
movq %rsi, %r12
testb %cl, %cl
je 0x20436c
movslq %r10d, %rbx
testl %r10d, %r10d
je 0x204327
movl -0x4(%rax,%rbx,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x2, %edx
jne 0x204327
shll $0x4, %edi
addl %edi, %ecx
movl %ecx, -0x4(%rax,%rbx,4)
jmp 0x20436c
cmpl %ebp, %r10d
jne 0x204360
leal (,%rbp,2), %ecx
testl %ebp, %ebp
movl $0x4, %ebp
cmovnel %ecx, %ebp
leal (,%rbp,4), %ecx
movslq %ecx, %rdx
movq %rdi, %r15
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r14
callq 0x1fbaa3
movq %r15, %rdi
movq %r14, %r10
shll $0x4, %edi
orl $0x2, %edi
incl %r10d
movl %edi, (%rax,%rbx,4)
testb %r13b, %r13b
je 0x204399
movslq %r10d, %rbx
testl %r10d, %r10d
movq 0x78(%rsp), %r14
je 0x2043a0
movl -0x4(%rax,%rbx,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0x2043a0
shll $0x4, %r12d
addl %r12d, %ecx
movl %ecx, -0x4(%rax,%rbx,4)
jmp 0x2043e1
movq 0x78(%rsp), %r14
jmp 0x2043e1
cmpl %ebp, %r10d
jne 0x2043d3
leal (,%rbp,2), %ecx
testl %ebp, %ebp
movl $0x4, %ebp
cmovnel %ecx, %ebp
leal (,%rbp,4), %ecx
movslq %ecx, %rdx
movq 0x10(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r15
callq 0x1fbaa3
movq %r15, %r10
shll $0x4, %r12d
incl %r12d
incl %r10d
movl %r12d, (%rax,%rbx,4)
movq 0x148(%rsp), %rcx
movl %r10d, %edx
sarl %edx
testl %edx, %edx
jle 0x204417
movl %edx, %edx
leal -0x1(%r10), %esi
xorl %edi, %edi
movl (%rax,%rdi,4), %r8d
movslq %esi, %rsi
movl (%rax,%rsi,4), %r9d
movl %r9d, (%rax,%rdi,4)
movl %r8d, (%rax,%rsi,4)
incq %rdi
decl %esi
cmpq %rdi, %rdx
jne 0x2043fa
movq 0x140(%rsp), %rdx
movl %ebp, (%rdx)
movl %r10d, (%rcx)
movq 0x150(%rsp), %rcx
movq %rax, (%rcx)
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1fb9e5
movq %rbx, %rdi
movq 0x60(%rsp), %rsi
callq 0x1fb9e5
movl 0xc(%rsp), %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop