// File: /workspace/github_c_makefile_star2_O2/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 $0x108, %rsp            # imm = 0x108
movl %r9d, 0xc(%rsp)
movq %r8, %r13
movl %ecx, %r8d
movq %rdx, %rbp
movq %rdi, %rbx
movq %rdi, 0x18(%rsp)
movsbl 0x148(%rsp), %ecx
movl 0x158(%rsp), %eax
movsbl 0x150(%rsp), %edx
movd %ecx, %xmm0
movdqa %xmm0, 0x30(%rsp)
movl %ecx, 0x80(%rsp)
addl %ecx, %edx
movq %rdx, 0xa0(%rsp)
leal (%rdx,%rdx), %ecx
movl %ecx, 0x7c(%rsp)
movd %ecx, %xmm0
movdqa %xmm0, 0xb0(%rsp)
movq %rsi, %rcx
movq %rsi, 0x48(%rsp)
movq %r8, 0x20(%rsp)
cmpl %ecx, %r8d
cmovgl %r8d, %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movq %rcx, 0xe8(%rsp)
incl %ecx
cmpl %r8d, %ecx
cmovgel %r8d, %ecx
leal 0xf(%r8), %eax
pushq $0x10
popq %rsi
cltd
idivl %esi
movl %eax, %r15d
addl $0xf, %ecx
movl %ecx, %eax
cltd
idivl %esi
leal (%r15,%r15,4), %ecx
incl %ecx
movslq %ecx, %rsi
movq %rax, 0x88(%rsp)
incl %eax
movl %eax, 0x14(%rsp)
pushq $0x10
popq %rdx
callq 0x19e66e
movq %rax, 0xc8(%rsp)
addq $0xf, %rax
andq $-0x10, %rax
movslq %r15d, %r12
movq %r12, %r14
shlq $0x4, %r14
movq %rax, 0x68(%rsp)
addq %r14, %rax
movq %rax, 0x50(%rsp)
leaq (%rax,%r14), %rax
movq %rax, 0xd8(%rsp)
addq %r14, %rax
movq %rax, 0x90(%rsp)
movslq 0x48(%rsp), %rsi
movq %rsi, 0x58(%rsp)
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x19e66e
movq %rax, %r15
movq 0x20(%rsp), %rcx
movl %ecx, %eax
decl %eax
movq %rax, 0xa8(%rsp)
movq 0x58(%rsp), %rax
leal (%rcx,%rax), %ebx
decl %ebx
movl %ebx, %eax
imull 0x14(%rsp), %eax
shll $0x4, %eax
addl $0x10, %eax
movslq %eax, %rsi
movq 0x18(%rsp), %rdi
callq 0x19e512
movq %rax, 0xd0(%rsp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, 0x98(%rsp)
movq %rbx, 0x60(%rsp)
movslq %ebx, %rsi
shlq $0x2, %rsi
movq 0x18(%rsp), %rdi
callq 0x19e512
movq 0x48(%rsp), %r8
movq %rax, 0x70(%rsp)
xorl %eax, %eax
movq 0x58(%rsp), %rdx
testl %edx, %edx
movl $0x0, %ecx
cmovgl %r8d, %ecx
decl %edx
cmpq %rax, %rcx
je 0x1a5b5e
movslq %edx, %rdx
movb (%rbp,%rdx), %sil
movb %sil, (%r15,%rax)
incq %rax
decl %edx
jmp 0x1a5b46
movdqa 0x30(%rsp), %xmm0
punpcklbw %xmm0, %xmm0    # xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa 0xb0(%rsp), %xmm1
punpcklbw %xmm1, %xmm1    # xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
pshuflw $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0,4,5,6,7]
pshufd $0x0, %xmm1, %xmm1      # xmm1 = xmm1[0,0,0,0]
movq 0x90(%rsp), %rax
leaq (%rax,%r14), %rcx
xorl %edx, %edx
movq 0x60(%rsp), %rax
testl %eax, %eax
cmovlel %edx, %eax
movq %rax, 0x60(%rsp)
movsbq 0xc(%rsp), %rdi
leal -0x1(%r8), %esi
movslq 0x88(%rsp), %rax
shlq $0x4, %rax
addq $0x10, %rax
movq %rax, 0xe0(%rsp)
imulq $0x30, %r12, %r9
movq %r12, %r10
shlq $0x5, %r10
shlq $0x6, %r12
pushq $-0x1
popq %rax
pxor %xmm2, %xmm2
movdqa 0x3c258a(%rip), %xmm3   # 0x568170
movdqa 0x3c25b2(%rip), %xmm4   # 0x5681a0
movdqa 0x3c25ba(%rip), %xmm5   # 0x5681b0
movq 0x98(%rsp), %rbx
movq %rsi, 0x28(%rsp)
xorl %r8d, %r8d
xorl %r11d, %r11d
movl $0x0, 0x4(%rsp)
movl %eax, 0x30(%rsp)
cmpq 0x60(%rsp), %r8
je 0x1a5fa9
movl %eax, 0x8(%rsp)
movq %r11, 0xf0(%rsp)
movq %rbx, 0x100(%rsp)
movq %r8, %rax
subq 0x58(%rsp), %rax
leal 0x1(%rax), %r11d
testq %rax, %rax
movl $0x0, %eax
cmovsl %eax, %r11d
movq 0xa8(%rsp), %rdx
cmpl %r8d, %edx
movl %r8d, %eax
cmovll %edx, %eax
movq 0xe8(%rsp), %rdx
leal (%rdx,%r8), %ebx
movl %r8d, %ebp
subl %edx, %ebp
incl %ebp
sarl %ebp
cmpl %ebp, %r11d
movl %ebp, %edx
movl %r11d, 0x84(%rsp)
cmovgl %r11d, %edx
sarl %ebx
cmpl %ebx, %eax
cmovll %eax, %ebx
movq %r8, %r11
movl %edx, 0xc(%rsp)
movl %edx, %r8d
andl $-0x10, %r8d
movq %rbx, 0xb0(%rsp)
leal 0x10(%rbx), %eax
cltd
pushq $0x10
popq %rbx
idivl %ebx
movq %r8, %rbx
movq %r11, %r8
movq 0x70(%rsp), %rdx
movl %ebx, (%rdx,%r11,4)
movzbl 0x80(%rsp), %edx
testl %ebx, %ebx
movq %rbx, 0xf8(%rsp)
jle 0x1a5d1e
movl $0x0, 0x20(%rsp)
cmpl 0x8(%rsp), %ebx
jle 0x1a5d38
decl %ebx
movl $0x0, 0x8(%rsp)
cmpl 0x30(%rsp), %ebx
jg 0x1a5d40
movl %ebx, %r11d
movq %r11, 0x30(%rsp)
movq 0xd8(%rsp), %rbx
movq 0x30(%rsp), %r11
movsbl (%rbx,%r11), %r11d
movl %r11d, 0x20(%rsp)
movq 0x50(%rsp), %rbx
movq 0x30(%rsp), %r11
movb (%rbx,%r11), %r11b
movl %r11d, 0x8(%rsp)
jmp 0x1a5d40
xorl %r11d, %r11d
testq %r8, %r8
movl %edx, %ebx
movl $0x0, 0x20(%rsp)
cmovel %r11d, %ebx
movl %ebx, 0x8(%rsp)
jmp 0x1a5d40
movl $0x0, 0x8(%rsp)
shll $0x4, %eax
movslq %eax, %rbx
cmpq %rbx, %r8
jge 0x1a5d6c
movq 0x90(%rsp), %rbx
movb $0x0, (%rbx,%r8)
testq %r8, %r8
movl $0x0, %ebx
cmovel %ebx, %edx
movq 0x68(%rsp), %rbx
movb %dl, (%rbx,%r8)
decl %eax
movl %eax, 0x30(%rsp)
movl 0x84(%rsp), %eax
cmpl %ebp, %eax
cmovgl %eax, %ebp
movslq %ebp, %rax
movslq 0xb0(%rsp), %rdx
movq 0x140(%rsp), %rbp
cmpq %rdx, %rax
jg 0x1a5dbb
movzbl (%r13,%rax), %r11d
imulq %rdi, %r11
leal (%rsi,%rax), %ebx
movslq %ebx, %rbx
movzbl (%r15,%rbx), %ebx
addq %rbp, %r11
movb (%rbx,%r11), %r11b
movb %r11b, (%rcx,%rax)
incq %rax
jmp 0x1a5d91
movd 0x20(%rsp), %xmm10
movsbl 0x8(%rsp), %eax
movd %eax, %xmm9
movl 0x30(%rsp), %edx
sarl $0x4, %edx
movl 0xc(%rsp), %r11d
movl %r11d, %eax
shrl $0x4, %eax
movslq %edx, %rdx
movl %r11d, %ebp
andl $-0x10, %ebp
addq 0x68(%rsp), %rbp
movq 0x100(%rsp), %rbx
movq %rbx, %r11
cmpq %rdx, %rax
jg 0x1a5f2b
movdqa (%rbp,%r12), %xmm11
paddb %xmm1, %xmm11
movdqa (%rbp,%r10), %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 %xmm10, %xmm8
movdqa (%rbp,%r14), %xmm10
movdqa %xmm10, %xmm7
psrldq $0xf, %xmm7             # xmm7 = xmm7[15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
pslldq $0x1, %xmm10            # xmm10 = zero,xmm10[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
por %xmm9, %xmm10
paddb %xmm10, %xmm8
movdqa (%rbp), %xmm12
movdqa (%rbp,%r9), %xmm9
paddb %xmm12, %xmm9
movdqa %xmm8, %xmm13
pcmpgtb %xmm11, %xmm13
movdqa %xmm11, %xmm14
pcmpgtb %xmm2, %xmm14
pand %xmm11, %xmm14
pmaxub %xmm8, %xmm14
movdqa %xmm9, %xmm11
pcmpgtb %xmm14, %xmm11
movdqa %xmm11, %xmm15
pandn %xmm13, %xmm15
pand %xmm3, %xmm11
psubb %xmm15, %xmm11
pmaxub %xmm9, %xmm14
movdqa %xmm14, %xmm13
psubb %xmm10, %xmm13
movdqa %xmm13, (%rbp)
movdqa %xmm14, %xmm10
psubb %xmm12, %xmm10
movdqa %xmm10, (%rbp,%r14)
psubb %xmm0, %xmm14
psubb %xmm14, %xmm8
psubb %xmm14, %xmm9
movdqa %xmm8, %xmm10
pcmpgtb %xmm2, %xmm10
pand %xmm10, %xmm8
pand %xmm4, %xmm10
por %xmm11, %xmm10
movdqa %xmm8, (%rbp,%r10)
movdqa %xmm9, %xmm8
pcmpgtb %xmm2, %xmm8
pand %xmm8, %xmm9
pand %xmm5, %xmm8
por %xmm10, %xmm8
movdqa %xmm9, (%rbp,%r9)
movdqa %xmm8, (%r11)
incq %rax
addq $0x10, %r11
addq $0x10, %rbp
movdqa %xmm6, %xmm10
movdqa %xmm7, %xmm9
jmp 0x1a5df7
testq %r8, %r8
je 0x1a5f57
movq 0xf0(%rsp), %r11
cmpl 0xc(%rsp), %r11d
jl 0x1a5f6c
cmpl 0xb0(%rsp), %r11d
jg 0x1a5f6c
movl %r11d, %eax
movq 0x50(%rsp), %rdx
movzbl (%rdx,%rax), %eax
jmp 0x1a5f7d
movq 0x50(%rsp), %rax
movzbl (%rax), %eax
subl 0x7c(%rsp), %eax
movl %eax, 0x4(%rsp)
xorl %r11d, %r11d
jmp 0x1a5f8e
movslq %r11d, %r11
movq 0x68(%rsp), %rax
movzbl 0x1(%rax,%r11), %eax
incq %r11
movl 0x4(%rsp), %edx
subl 0xa0(%rsp), %edx
addl %eax, %edx
movl %edx, 0x4(%rsp)
incq %r8
decq %rsi
addq 0xe0(%rsp), %rbx
movq 0xf8(%rsp), %rax
jmp 0x1a5c15
movl 0x14(%rsp), %r14d
shll $0x4, %r14d
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq 0xc8(%rsp), %rsi
callq 0x19e38c
movq %rbx, %rdi
movq %r15, %rsi
callq 0x19e38c
movq %rsp, %rax
andl $0x0, (%rax)
movq 0x160(%rsp), %rax
movl (%rax), %eax
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movq 0x170(%rsp), %rax
movq (%rax), %rax
movq 0x88(%rsp), %rcx
shll $0x4, %ecx
pushq $-0x11
popq %rbp
subl %ecx, %ebp
xorl %r15d, %r15d
pushq $0x2
popq %r13
movq 0x48(%rsp), %r9
movq 0x28(%rsp), %rcx
movq 0xa8(%rsp), %rdx
movl %r14d, 0x14(%rsp)
leal -0x1(%r9), %esi
movl %esi, 0xc(%rsp)
leal -0x1(%rdx), %ebx
movq %rcx, 0x28(%rsp)
leal (%rdx,%rcx), %r12d
imull %r14d, %r12d
addl %edx, %r12d
movl %ebx, %r14d
incl %r14d
js 0x1a613f
testl %r9d, %r9d
jle 0x1a613f
leal (%r9,%rbx), %ecx
movq 0x70(%rsp), %rdx
movl (%rdx,%rcx,4), %edx
xorl %esi, %esi
cmpl %edx, %r14d
jl 0x1a6079
movl %r12d, %ecx
subl %edx, %ecx
movslq %ecx, %rcx
movq 0x98(%rsp), %rsi
movzbl (%rsi,%rcx), %esi
testl %r15d, %r15d
je 0x1a6098
movl %esi, %edi
movl %r15d, %ecx
shrl %cl, %edi
shll $0x1d, %edi
sarl $0x1f, %edi
andl %r15d, %edi
andl $0x7, %esi
movl %esi, %r15d
movl %edi, %esi
jmp 0x1a609e
andl $0x7, %esi
movl %esi, %r15d
testl %esi, %esi
cmovnel %esi, %r15d
cmpl %edx, %r14d
cmovll %r13d, %r15d
cmpl $0x1, %r15d
je 0x1a60b7
cmpl $0x3, %r15d
jne 0x1a60e3
movq 0x18(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
movq %rax, %rcx
movl %r13d, %r8d
movq %r9, %r14
pushq $0x1
popq %r9
callq 0x1a6216
movq %r14, %r9
decl %ebx
addl %ebp, %r12d
jmp 0x1a603d
testl %r15d, %r15d
jne 0x1a6106
movq 0x18(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
movq %rax, %rcx
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0x1a6216
jmp 0x1a6125
movq 0x18(%rsp), %rdi
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
movq %rax, %rcx
pushq $0x1
popq %r8
movl %r8d, %r9d
callq 0x1a6216
movl %r14d, %ebx
movl 0x14(%rsp), %r14d
movq 0x28(%rsp), %rcx
decl %ecx
movl 0xc(%rsp), %edx
movl %edx, %r9d
movl %ebx, %edx
jmp 0x1a6022
testl %r14d, %r14d
js 0x1a6169
addl $0x2, %ebx
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
pushq $0x2
popq %r8
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movq %r9, %r14
movl %ebx, %r9d
callq 0x1a6216
movq %r14, %r9
testl %r9d, %r9d
jle 0x1a6187
movq %rsp, %rsi
leaq 0x10(%rsp), %rdx
pushq $0x1
popq %r8
movq 0x18(%rsp), %rdi
movq %rax, %rcx
callq 0x1a6216
pushq $-0x1
popq %rcx
xorl %edx, %edx
movl (%rsp), %esi
movl %esi, %edi
sarl %edi
movslq %edi, %rdi
cmpq %rdi, %rdx
jge 0x1a61bb
movl (%rax,%rdx,4), %edi
addl %ecx, %esi
movslq %esi, %rsi
movl (%rax,%rsi,4), %esi
movl %esi, (%rax,%rdx,4)
movl (%rsp), %esi
addl %ecx, %esi
movslq %esi, %rsi
movl %edi, (%rax,%rsi,4)
incq %rdx
decl %ecx
jmp 0x1a618c
movl 0x10(%rsp), %ecx
movq 0x160(%rsp), %rdx
movl %ecx, (%rdx)
movq 0x168(%rsp), %rcx
movl %esi, (%rcx)
movq 0x170(%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq 0xd0(%rsp), %rsi
callq 0x19e38c
movq %rbx, %rdi
movq 0x70(%rsp), %rsi
callq 0x19e38c
movl 0x4(%rsp), %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq