// File: /workspace/github_c_makefile_star2_O3/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 $0xf8, %rsp
movl %r9d, 0x38(%rsp)
movq %r8, 0xe0(%rsp)
movl %ecx, %r13d
movq %rdx, 0x28(%rsp)
cmpl %esi, %ecx
movl %esi, %ecx
movq %rsi, %rbx
movq %rsi, 0x88(%rsp)
cmovgl %r13d, %ecx
movl 0x148(%rsp), %eax
testl %eax, %eax
cmovnsl %eax, %ecx
movq %rcx, 0xd8(%rsp)
leal 0x1(%rcx), %r14d
cmpl %r13d, %r14d
cmovgel %r13d, %r14d
movq %rdi, %r15
leal 0xf(%r13), %eax
leal 0x1e(%r13), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x4, %ecx
leal 0xf(%r14), %eax
addl $0x1e, %r14d
testl %eax, %eax
cmovnsl %eax, %r14d
sarl $0x4, %r14d
leal 0x1(%r14), %ebp
movq %rcx, 0x58(%rsp)
leal (%rcx,%rcx,4), %eax
incl %eax
movslq %eax, %rsi
movl $0x10, %edx
callq 0x1fbc89
movq %rax, 0x80(%rsp)
movslq %ebx, %r12
movl $0x1, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x1fbc89
movq %rax, %rbx
movq %r13, 0x30(%rsp)
addl %r12d, %r13d
decl %r13d
movl %r13d, %eax
movl %ebp, 0x20(%rsp)
imull %ebp, %eax
shll $0x4, %eax
addl $0x10, %eax
movslq %eax, %rsi
movq %r15, %rdi
callq 0x1fbb34
movq %rax, 0xa8(%rsp)
leaq 0xf(%rax), %rbp
movslq %r13d, %rsi
shlq $0x2, %rsi
movq %r15, 0x18(%rsp)
movq %r15, %rdi
callq 0x1fbb34
movq %rax, 0x70(%rsp)
movl 0x88(%rsp), %eax
movq %r12, 0x98(%rsp)
testl %r12d, %r12d
setg %dil
jle 0x203dd0
movq 0x98(%rsp), %rcx
movq 0x28(%rsp), %rdx
addq %rdx, %rcx
decq %rcx
xorl %edx, %edx
movb (%rcx), %sil
movb %sil, (%rbx,%rdx)
incq %rdx
decq %rcx
cmpq %rdx, %rax
jne 0x203dbe
movq 0x30(%rsp), %rcx
decl %ecx
movq %rcx, 0x50(%rsp)
movq %rbp, %rsi
andq $-0x10, %rsi
testl %r13d, %r13d
movq %rsi, 0x48(%rsp)
movq %rbx, 0xa0(%rsp)
movb %dil, 0x13(%rsp)
jle 0x2042b8
movsbl 0x138(%rsp), %ecx
movsbl 0x140(%rsp), %edx
addl %ecx, %edx
movq 0x80(%rsp), %rdi
addq $0xf, %rdi
movslq 0x58(%rsp), %r10
movq %rdx, 0x90(%rsp)
addl %edx, %edx
andq $-0x10, %rdi
movq %r10, %r9
shlq $0x4, %r9
movl %ecx, 0x40(%rsp)
movd %ecx, %xmm0
movl %edx, 0x7c(%rsp)
movd %edx, %xmm1
movq %rdi, 0x68(%rsp)
leaq (%rdi,%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, 0x60(%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, 0xb0(%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, 0xb8(%rsp)
leaq (%rcx,%r9), %r11
movsbq 0x38(%rsp), %rdx
movl %r13d, %ecx
movq %rcx, 0xc8(%rsp)
movslq %r14d, %rcx
shlq $0x4, %rcx
addq $0x10, %rcx
movq %rcx, 0xc0(%rsp)
movq %r10, %rdi
shlq $0x5, %rdi
shlq $0x6, %r10
pxor %xmm2, %xmm2
movdqa 0x3c62bb(%rip), %xmm3   # 0x5ca180
movdqa 0x3c62e3(%rip), %xmm4   # 0x5ca1b0
movdqa 0x3c62eb(%rip), %xmm5   # 0x5ca1c0
leaq (%r9,%r9,2), %rcx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r8, 0x28(%rsp)
movq %rsi, %r15
xorl %esi, %esi
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
movl $0x0, 0xc(%rsp)
xorl %r12d, %r12d
movq 0x50(%rsp), %r14
movq %r10, 0xd0(%rsp)
movq %r15, 0xf0(%rsp)
movq %r12, 0xe8(%rsp)
movq 0x28(%rsp), %r8
movl %r8d, 0x28(%rsp)
movq %rsi, %r8
subq 0x98(%rsp), %r8
leal 0x1(%r8), %r13d
testq %r8, %r8
movl $0x0, %r8d
cmovsl %r8d, %r13d
cmpl %esi, %r14d
movl %esi, %r8d
cmovll %r14d, %r8d
movq 0xd8(%rsp), %rbx
leal (%rbx,%rsi), %r15d
movl %esi, %ebp
subl %ebx, %ebp
incl %ebp
sarl %ebp
cmpl %ebp, %r13d
movl %ebp, %ebx
cmovgl %r13d, %ebx
sarl %r15d
cmpl %r15d, %r8d
cmovll %r8d, %r15d
movl %ebx, %r12d
andl $-0x10, %r12d
leal 0x10(%r15), %r14d
movq %r15, 0x38(%rsp)
leal 0x1f(%r15), %r8d
testl %r14d, %r14d
cmovnsl %r14d, %r8d
movq 0x70(%rsp), %r14
movl %r12d, (%r14,%rsi,4)
testl %r12d, %r12d
movl %ebx, 0x58(%rsp)
jle 0x203fe7
movl $0x0, 0x24(%rsp)
cmpl 0x28(%rsp), %r12d
jle 0x204006
leal -0x1(%r12), %r14d
movl $0x0, 0x14(%rsp)
cmpl 0x44(%rsp), %r14d
jg 0x20400e
movl %r14d, %r14d
movq 0xb0(%rsp), %rbx
movsbl (%rbx,%r14), %ebx
movl %ebx, 0x24(%rsp)
movq 0x60(%rsp), %rbx
movb (%rbx,%r14), %bl
movl %ebx, 0x14(%rsp)
movl 0x58(%rsp), %ebx
jmp 0x20400e
xorl %r14d, %r14d
testq %rsi, %rsi
movzbl 0x40(%rsp), %r15d
movl $0x0, 0x24(%rsp)
cmovel %r14d, %r15d
movl %r15d, 0x14(%rsp)
jmp 0x20400e
movl $0x0, 0x14(%rsp)
movq %r12, 0x28(%rsp)
andl $-0x10, %r8d
movslq %r8d, %r14
cmpq %r14, %rsi
jge 0x20404d
movl %ebx, %r15d
movq 0xb8(%rsp), %rbx
movb $0x0, (%rbx,%rsi)
testq %rsi, %rsi
movzbl 0x40(%rsp), %r14d
movl $0x0, %r10d
cmovel %r10d, %r14d
movq 0x68(%rsp), %rbx
movb %r14b, (%rbx,%rsi)
movl %r15d, %ebx
cmpl 0x38(%rsp), %ebx
movq 0xe0(%rsp), %rbx
movq 0xa0(%rsp), %r12
movq 0x130(%rsp), %r10
jg 0x2040a7
cmpl %ebp, %r13d
cmovgl %r13d, %ebp
movslq %ebp, %r13
movslq 0x38(%rsp), %rbp
decq %r13
movzbl 0x1(%rbx,%r13), %r14d
imulq %rdx, %r14
leal (%rax,%r13), %r15d
movslq %r15d, %r15
movzbl (%r12,%r15), %r15d
addq %r10, %r14
movb (%r15,%r14), %r14b
movb %r14b, 0x1(%r11,%r13)
incq %r13
cmpq %rbp, %r13
jl 0x20407d
movl %r8d, %r10d
decl %r10d
movl 0x58(%rsp), %ebx
movl %ebx, %r8d
shrl $0x4, %r8d
movl %r10d, 0x44(%rsp)
movl %r10d, %ebp
sarl $0x4, %ebp
cmpl %ebp, %r8d
movq 0xd0(%rsp), %r10
movq 0xf0(%rsp), %r15
jg 0x20422d
movsbl 0x14(%rsp), %r14d
movd %r14d, %xmm9
movd 0x24(%rsp), %xmm7
incl %ebp
movl %r8d, %r13d
shll $0x4, %r13d
addq 0x68(%rsp), %r13
subq %rbp, %r8
movq %r15, %rbp
movdqa (%r13,%r10), %xmm10
paddb %xmm1, %xmm10
movdqa (%r13,%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 (%r13,%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 (%r13), %xmm12
movdqa (%r13,%rcx), %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, (%r13)
movdqa %xmm14, %xmm11
psubb %xmm12, %xmm11
movdqa %xmm11, (%r13,%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, (%r13,%rdi)
movdqa %xmm9, %xmm8
pcmpgtb %xmm2, %xmm8
pand %xmm8, %xmm9
pand %xmm5, %xmm8
por %xmm11, %xmm8
movdqa %xmm9, (%r13,%rcx)
movdqa %xmm8, (%rbp)
addq $0x10, %rbp
addq $0x10, %r13
movdqa %xmm7, %xmm9
movdqa %xmm6, %xmm7
incq %r8
jne 0x204101
testq %rsi, %rsi
je 0x20425a
movq 0xe8(%rsp), %r12
cmpl %ebx, %r12d
movq 0x50(%rsp), %r14
jl 0x204277
cmpl 0x38(%rsp), %r12d
jg 0x204277
movl %r12d, %r8d
movq 0x60(%rsp), %rbx
movzbl (%rbx,%r8), %r8d
jmp 0x204288
movq 0x60(%rsp), %r8
movzbl (%r8), %r8d
subl 0x7c(%rsp), %r8d
movl %r8d, 0xc(%rsp)
xorl %r12d, %r12d
movq 0x50(%rsp), %r14
jmp 0x20429a
movslq %r12d, %r12
movq 0x68(%rsp), %r8
movzbl 0x1(%r8,%r12), %r8d
incq %r12
movl 0xc(%rsp), %ebp
subl 0x90(%rsp), %ebp
addl %r8d, %ebp
movl %ebp, 0xc(%rsp)
incq %rsi
decq %rax
addq 0xc0(%rsp), %r15
cmpq 0xc8(%rsp), %rsi
jne 0x203f09
jmp 0x2042c5
movl $0x0, 0xc(%rsp)
movq 0x50(%rsp), %r14
movq 0x18(%rsp), %r15
movq %r15, %rdi
movq 0x80(%rsp), %rsi
callq 0x1fb9e0
movq %r15, %rdi
movq 0xa0(%rsp), %rsi
callq 0x1fb9e0
movq 0x88(%rsp), %r12
decl %r12d
movq 0x150(%rsp), %rax
movl (%rax), %r10d
movq 0x160(%rsp), %rax
movq (%rax), %rax
movl %r14d, %ecx
orl %r12d, %ecx
js 0x204546
movl 0x20(%rsp), %ebp
shll $0x4, %ebp
xorl %ebx, %ebx
movl $0x2, %r9d
xorl %r13d, %r13d
movq 0x48(%rsp), %r8
movl %ebp, 0x20(%rsp)
leal (%r12,%r14), %ecx
movq 0x70(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
movl $0x0, %esi
cmpl %edx, %r14d
jl 0x204358
imull %ebp, %ecx
addl %r14d, %ecx
subl %edx, %ecx
movslq %ecx, %rcx
movzbl (%r8,%rcx), %esi
testl %ebx, %ebx
je 0x204373
movl %esi, %edi
movl %ebx, %ecx
shrl %cl, %edi
shll $0x1d, %edi
sarl $0x1f, %edi
andl %ebx, %edi
andl $0x7, %esi
movl %esi, %ebx
movl %edi, %esi
jmp 0x204378
andl $0x7, %esi
movl %esi, %ebx
testl %esi, %esi
cmovnel %esi, %ebx
cmpl %edx, %r14d
cmovll %r9d, %ebx
cmpl $0x3, %ebx
je 0x2043fa
cmpl $0x1, %ebx
je 0x2043fa
testl %ebx, %ebx
jne 0x20446b
testl %r13d, %r13d
je 0x2043ab
movslq %r13d, %rcx
movl -0x4(%rax,%rcx,4), %edx
testb $0xf, %dl
je 0x2044e9
cmpl %r10d, %r13d
jne 0x2043e8
addl %r10d, %r10d
testl %r13d, %r13d
movl $0x4, %ecx
cmovel %ecx, %r10d
leal (,%r10,4), %ecx
movslq %ecx, %rdx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r15
callq 0x1fbaa1
movl $0x2, %r9d
movq %r15, %r10
movq 0x48(%rsp), %r8
movslq %r13d, %rcx
incl %r13d
movl $0x10, (%rax,%rcx,4)
jmp 0x2044f0
testl %r13d, %r13d
je 0x204419
movslq %r13d, %rcx
movl -0x4(%rax,%rcx,4), %edx
movl %edx, %esi
andl $0xf, %esi
cmpl $0x2, %esi
jne 0x204419
addl $0x10, %edx
movl %edx, -0x4(%rax,%rcx,4)
jmp 0x204463
cmpl %r10d, %r13d
jne 0x204456
addl %r10d, %r10d
testl %r13d, %r13d
movl $0x4, %ecx
cmovel %ecx, %r10d
leal (,%r10,4), %ecx
movslq %ecx, %rdx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r15
callq 0x1fbaa1
movl $0x2, %r9d
movq %r15, %r10
movq 0x48(%rsp), %r8
movslq %r13d, %rcx
incl %r13d
movl $0x12, (%rax,%rcx,4)
decl %r14d
jmp 0x2044f6
movq %r14, %r15
movq %r12, %rbp
movslq %r13d, %r12
testl %r13d, %r13d
je 0x204492
movl -0x4(%rax,%r12,4), %ecx
movl %ecx, %edx
andl $0xf, %edx
cmpl $0x1, %edx
jne 0x204492
addl $0x10, %ecx
movl %ecx, -0x4(%rax,%r12,4)
jmp 0x2044da
cmpl %r10d, %r13d
jne 0x2044cf
addl %r10d, %r10d
testl %r13d, %r13d
movl $0x4, %ecx
cmovel %ecx, %r10d
leal (,%r10,4), %ecx
movslq %ecx, %rdx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movq %r10, %r14
callq 0x1fbaa1
movl $0x2, %r9d
movq %r14, %r10
movq 0x48(%rsp), %r8
incl %r13d
movl $0x11, (%rax,%r12,4)
movq %rbp, %r12
decl %r12d
movl 0x20(%rsp), %ebp
movq %r15, %r14
jmp 0x2044f6
addl $0x10, %edx
movl %edx, -0x4(%rax,%rcx,4)
decl %r14d
decl %r12d
testl %r12d, %r12d
setns %r15b
testl %r14d, %r14d
js 0x20450b
testl %r12d, %r12d
jns 0x204332
testl %r14d, %r14d
js 0x2045ac
incl %r14d
testl %r13d, %r13d
je 0x204559
movslq %r13d, %rcx
movl -0x4(%rax,%rcx,4), %edx
movl %edx, %esi
andl $0xf, %esi
cmpl $0x2, %esi
jne 0x204560
shll $0x4, %r14d
addl %r14d, %edx
movl %edx, -0x4(%rax,%rcx,4)
testl %r12d, %r12d
js 0x204622
incl %r12d
jmp 0x2045c0
xorl %r13d, %r13d
movb $0x1, %cl
cmpl $0x0, 0x30(%rsp)
movb 0x13(%rsp), %r15b
jg 0x204567
jmp 0x2045ac
xorl %r13d, %r13d
movb $0x1, %cl
jmp 0x204562
xorl %ecx, %ecx
movq %r14, 0x30(%rsp)
cmpl %r10d, %r13d
jne 0x204598
leal (,%r13,2), %edx
testb %cl, %cl
movl $0x4, %ebx
cmovel %edx, %ebx
leal (,%rbx,4), %ecx
movslq %ecx, %rdx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x1fbaa1
movq %rbx, %r10
movq 0x30(%rsp), %rdx
shll $0x4, %edx
orl $0x2, %edx
movslq %r13d, %rcx
incl %r13d
movl %edx, (%rax,%rcx,4)
testb %r15b, %r15b
je 0x204622
incl %r12d
testl %r13d, %r13d
je 0x2045db
movslq %r13d, %rcx
movl -0x4(%rax,%rcx,4), %edx
movl %edx, %esi
andl $0xf, %esi
cmpl $0x1, %esi
jne 0x2045d7
shll $0x4, %r12d
addl %r12d, %edx
movl %edx, -0x4(%rax,%rcx,4)
jmp 0x204622
xorl %ecx, %ecx
jmp 0x2045e0
xorl %r13d, %r13d
movb $0x1, %cl
cmpl %r10d, %r13d
jne 0x204611
leal (,%r13,2), %edx
testb %cl, %cl
movl $0x4, %ebx
cmovel %edx, %ebx
leal (,%rbx,4), %ecx
movslq %ecx, %rdx
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x1fbaa1
movq %rbx, %r10
shll $0x4, %r12d
incl %r12d
movslq %r13d, %rcx
incl %r13d
movl %r12d, (%rax,%rcx,4)
movq 0x158(%rsp), %rcx
movl %r13d, %edx
sarl %edx
testl %edx, %edx
jle 0x204658
movl %edx, %edx
leal -0x1(%r13), %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 0x20463b
movq 0x150(%rsp), %rdx
movl %r10d, (%rdx)
movl %r13d, (%rcx)
movq 0x160(%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq 0xa8(%rsp), %rsi
callq 0x1fb9e0
movq %rbx, %rdi
movq 0x70(%rsp), %rsi
callq 0x1fb9e0
movl 0xc(%rsp), %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)