// File: /workspace/github_c_makefile_star2_O0/sc932[P]ALE/src/ssw.c
// Function: sw_sse2_word
static alignment_end* sw_sse2_word (const int8_t* ref,
							 int8_t ref_dir,	// 0: forward ref; 1: reverse ref
							 int32_t refLen,
							 int32_t readLen,
							 const uint8_t weight_gapO, /* will be used as - */
							 const uint8_t weight_gapE, /* will be used as - */
							 const __m128i* vProfile,
							 uint16_t terminate,
							 int32_t maskLen) {

#define max8(m, vm) (vm) = _mm_max_epi16((vm), _mm_srli_si128((vm), 8)); \
					(vm) = _mm_max_epi16((vm), _mm_srli_si128((vm), 4)); \
					(vm) = _mm_max_epi16((vm), _mm_srli_si128((vm), 2)); \
					(m) = _mm_extract_epi16((vm), 0)

	uint16_t max = 0;		                     /* the max alignment score */
	int32_t end_read = readLen - 1;
	int32_t end_ref = 0; /* 1_based best alignment ending point; Initialized as isn't aligned - 0. */
	int32_t segLen = (readLen + 7) / 8; /* number of segment */

	/* array to record the largest score of each reference position */
	uint16_t* maxColumn = (uint16_t*) calloc(refLen, 2);

	/* array to record the alignment read ending position of the largest score of each reference position */
	int32_t* end_read_column = (int32_t*) calloc(refLen, sizeof(int32_t));

	/* Define 16 byte 0 vector. */
	__m128i vZero = _mm_set1_epi32(0);

	__m128i* pvHStore = (__m128i*) calloc(segLen, sizeof(__m128i));
	__m128i* pvHLoad = (__m128i*) calloc(segLen, sizeof(__m128i));
	__m128i* pvE = (__m128i*) calloc(segLen, sizeof(__m128i));
	__m128i* pvHmax = (__m128i*) calloc(segLen, sizeof(__m128i));

	int32_t i, j, k;
	/* 16 byte insertion begin vector */
	__m128i vGapO = _mm_set1_epi16(weight_gapO);

	/* 16 byte insertion extension vector */
	__m128i vGapE = _mm_set1_epi16(weight_gapE);

	__m128i vMaxScore = vZero; /* Trace the highest score of the whole SW matrix. */
	__m128i vMaxMark = vZero; /* Trace the highest score till the previous column. */
	__m128i vTemp;
	int32_t edge, begin = 0, end = refLen, step = 1;

	/* outer loop to process the reference sequence */
	if (ref_dir == 1) {
		begin = refLen - 1;
		end = -1;
		step = -1;
	}
	for (i = begin; LIKELY(i != end); i += step) {
		int32_t cmp;
		__m128i e, vF = vZero; /* Initialize F value to 0.
							   Any errors to vH values will be corrected in the Lazy_F loop.
							 */
		__m128i vH = pvHStore[segLen - 1];
		vH = _mm_slli_si128 (vH, 2); /* Shift the 128-bit value in vH left by 2 byte. */

		/* Swap the 2 H buffers. */
		__m128i* pv = pvHLoad;

		__m128i vMaxColumn = vZero; /* vMaxColumn is used to record the max values of column i. */

		const __m128i* vP = vProfile + ref[i] * segLen; /* Right part of the vProfile */
		pvHLoad = pvHStore;
		pvHStore = pv;

		/* inner loop to process the query sequence */
		for (j = 0; LIKELY(j < segLen); j ++) {
			vH = _mm_adds_epi16(vH, _mm_load_si128(vP + j));

			/* Get max from vH, vE and vF. */
			e = _mm_load_si128(pvE + j);
			vH = _mm_max_epi16(vH, e);
			vH = _mm_max_epi16(vH, vF);
			vMaxColumn = _mm_max_epi16(vMaxColumn, vH);

			/* Save vH values. */
			_mm_store_si128(pvHStore + j, vH);

			/* Update vE value. */
			vH = _mm_subs_epu16(vH, vGapO); /* saturation arithmetic, result >= 0 */
			e = _mm_subs_epu16(e, vGapE);
			e = _mm_max_epi16(e, vH);
			_mm_store_si128(pvE + j, e);

			/* Update vF value. */
			vF = _mm_subs_epu16(vF, vGapE);
			vF = _mm_max_epi16(vF, vH);

			/* Load the next vH. */
			vH = _mm_load_si128(pvHLoad + j);
		}

		/* Lazy_F loop: has been revised to disallow adjecent insertion and then deletion, so don't update E(i, j), learn from SWPS3 */
		for (k = 0; LIKELY(k < 8); ++k) {
			vF = _mm_slli_si128 (vF, 2);
			for (j = 0; LIKELY(j < segLen); ++j) {
				vH = _mm_load_si128(pvHStore + j);
				vH = _mm_max_epi16(vH, vF);
				vMaxColumn = _mm_max_epi16(vMaxColumn, vH); //newly added line
				_mm_store_si128(pvHStore + j, vH);
				vH = _mm_subs_epu16(vH, vGapO);
				vF = _mm_subs_epu16(vF, vGapE);
				if (UNLIKELY(! _mm_movemask_epi8(_mm_cmpgt_epi16(vF, vH)))) goto end;
			}
		}

end:
		vMaxScore = _mm_max_epi16(vMaxScore, vMaxColumn);
		vTemp = _mm_cmpeq_epi16(vMaxMark, vMaxScore);
		cmp = _mm_movemask_epi8(vTemp);
		if (cmp != 0xffff) {
			uint16_t temp;
			vMaxMark = vMaxScore;
			max8(temp, vMaxScore);
			vMaxScore = vMaxMark;

			if (LIKELY(temp > max)) {
				max = temp;
				end_ref = i;
				for (j = 0; LIKELY(j < segLen); ++j) pvHmax[j] = pvHStore[j];
			}
		}

		/* Record the max score of current column. */
		max8(maxColumn[i], vMaxColumn);
		if (maxColumn[i] == terminate) break;
	}

	/* Trace the alignment ending position on read. */
	uint16_t *t = (uint16_t*)pvHmax;
	int32_t column_len = segLen * 8;
	for (i = 0; LIKELY(i < column_len); ++i, ++t) {
		int32_t temp;
		if (*t == max) {
			temp = i / 8 + i % 8 * segLen;
			if (temp < end_read) end_read = temp;
		}
	}

	free(pvHmax);
	free(pvE);
	free(pvHLoad);
	free(pvHStore);

	/* Find the most possible 2nd best alignment. */
	alignment_end* bests = (alignment_end*) calloc(2, sizeof(alignment_end));
	bests[0].score = max;
	bests[0].ref = end_ref;
	bests[0].read = end_read;

	bests[1].score = 0;
	bests[1].ref = 0;
	bests[1].read = 0;

	edge = (end_ref - maskLen) > 0 ? (end_ref - maskLen) : 0;
	for (i = 0; i < edge; i ++) {
		if (maxColumn[i] > bests[1].score) {
			bests[1].score = maxColumn[i];
			bests[1].ref = i;
		}
	}
	edge = (end_ref + maskLen) > refLen ? refLen : (end_ref + maskLen);
	for (i = edge; i < refLen; i ++) {
		if (maxColumn[i] > bests[1].score) {
			bests[1].score = maxColumn[i];
			bests[1].ref = i;
		}
	}

	free(maxColumn);
	free(end_read_column);
	return bests;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x570, %rsp            # imm = 0x570
movl %r8d, -0x558(%rbp)
movl %ecx, %eax
movl -0x558(%rbp), %ecx
movl %eax, -0x554(%rbp)
movl %edx, %eax
movl -0x554(%rbp), %edx
movl %eax, -0x550(%rbp)
movl %esi, %eax
movl -0x550(%rbp), %esi
movl %eax, -0x54c(%rbp)
movq %rdi, %r8
movl -0x54c(%rbp), %edi
movb %r9b, %al
movl 0x20(%rbp), %r9d
movw 0x18(%rbp), %r9w
movq 0x10(%rbp), %r9
movq %r8, -0x3e0(%rbp)
movb %dil, -0x3e1(%rbp)
movl %esi, -0x3e8(%rbp)
movl %edx, -0x3ec(%rbp)
movb %cl, -0x3ed(%rbp)
movb %al, -0x3ee(%rbp)
movw $0x0, -0x3f0(%rbp)
movl -0x3ec(%rbp), %eax
decl %eax
movl %eax, -0x3f4(%rbp)
movl $0x0, -0x3f8(%rbp)
movl -0x3ec(%rbp), %ecx
movl %ecx, %eax
addl $0x7, %eax
addl $0xe, %ecx
testl %eax, %eax
cmovsl %ecx, %eax
sarl $0x3, %eax
movl %eax, -0x3fc(%rbp)
movslq -0x3e8(%rbp), %rdi
movl $0x2, %esi
callq 0x3310
movq %rax, -0x408(%rbp)
movslq -0x3e8(%rbp), %rdi
movl $0x4, %esi
callq 0x3310
movq %rax, -0x410(%rbp)
movl $0x0, -0x3d4(%rbp)
movl -0x3d4(%rbp), %eax
movl %eax, -0x308(%rbp)
movl %eax, -0x30c(%rbp)
movl %eax, -0x310(%rbp)
movl %eax, -0x314(%rbp)
movd -0x308(%rbp), %xmm0
movd -0x30c(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd -0x310(%rbp), %xmm2
movd -0x314(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movaps %xmm0, -0x330(%rbp)
movaps -0x330(%rbp), %xmm0
movaps %xmm0, -0x420(%rbp)
movslq -0x3fc(%rbp), %rdi
movl $0x10, %esi
movq %rsi, -0x548(%rbp)
callq 0x3310
movq -0x548(%rbp), %rsi
movq %rax, -0x428(%rbp)
movslq -0x3fc(%rbp), %rdi
callq 0x3310
movq -0x548(%rbp), %rsi
movq %rax, -0x430(%rbp)
movslq -0x3fc(%rbp), %rdi
callq 0x3310
movq -0x548(%rbp), %rsi
movq %rax, -0x438(%rbp)
movslq -0x3fc(%rbp), %rdi
callq 0x3310
movq %rax, -0x440(%rbp)
movzbl -0x3ed(%rbp), %eax
movw %ax, -0x302(%rbp)
movw -0x302(%rbp), %ax
movw %ax, -0x53c(%rbp)
movw %ax, -0x22(%rbp)
movw %ax, -0x24(%rbp)
movw %ax, -0x26(%rbp)
movw %ax, -0x28(%rbp)
movw %ax, -0x2a(%rbp)
movw %ax, -0x2c(%rbp)
movw %ax, -0x2e(%rbp)
movw %ax, -0x30(%rbp)
movzwl -0x22(%rbp), %eax
movd %eax, %xmm1
movzwl -0x24(%rbp), %eax
movd %eax, %xmm0
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movzwl -0x26(%rbp), %eax
movd %eax, %xmm2
movzwl -0x28(%rbp), %eax
movd %eax, %xmm1
punpcklwd %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3]
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movzwl -0x2a(%rbp), %eax
movd %eax, %xmm0
movzwl -0x2c(%rbp), %eax
movd %eax, %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movzwl -0x2e(%rbp), %eax
movd %eax, %xmm3
movzwl -0x30(%rbp), %eax
movd %eax, %xmm0
punpcklwd %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1],xmm0[2],xmm3[2],xmm0[3],xmm3[3]
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movaps %xmm0, -0x40(%rbp)
movaps -0x40(%rbp), %xmm0
movaps %xmm0, -0x460(%rbp)
movzbl -0x3ee(%rbp), %eax
movw %ax, -0x304(%rbp)
movw -0x304(%rbp), %ax
movw %ax, -0x53a(%rbp)
movw %ax, -0x2(%rbp)
movw %ax, -0x4(%rbp)
movw %ax, -0x6(%rbp)
movw %ax, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movw %ax, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movw %ax, -0x10(%rbp)
movzwl -0x2(%rbp), %eax
movd %eax, %xmm1
movzwl -0x4(%rbp), %eax
movd %eax, %xmm0
punpcklwd %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3]
movzwl -0x6(%rbp), %eax
movd %eax, %xmm2
movzwl -0x8(%rbp), %eax
movd %eax, %xmm1
punpcklwd %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1],xmm1[2],xmm2[2],xmm1[3],xmm2[3]
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movzwl -0xa(%rbp), %eax
movd %eax, %xmm0
movzwl -0xc(%rbp), %eax
movd %eax, %xmm2
punpcklwd %xmm0, %xmm2    # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1],xmm2[2],xmm0[2],xmm2[3],xmm0[3]
movzwl -0xe(%rbp), %eax
movd %eax, %xmm3
movzwl -0x10(%rbp), %eax
movd %eax, %xmm0
punpcklwd %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1],xmm0[2],xmm3[2],xmm0[3],xmm3[3]
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, -0x20(%rbp)
movdqa -0x20(%rbp), %xmm0
movdqa %xmm0, -0x470(%rbp)
movdqa -0x420(%rbp), %xmm0
movdqa %xmm0, -0x480(%rbp)
movdqa -0x420(%rbp), %xmm0
movdqa %xmm0, -0x490(%rbp)
movl $0x0, -0x4a8(%rbp)
movl -0x3e8(%rbp), %eax
movl %eax, -0x4ac(%rbp)
movl $0x1, -0x4b0(%rbp)
movsbl -0x3e1(%rbp), %eax
cmpl $0x1, %eax
jne 0x1256e
movl -0x3e8(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x4a8(%rbp)
movl $0xffffffff, -0x4ac(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4b0(%rbp) # imm = 0xFFFFFFFF
movl -0x4a8(%rbp), %eax
movl %eax, -0x444(%rbp)
movl -0x444(%rbp), %eax
cmpl -0x4ac(%rbp), %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12eb5
movaps -0x420(%rbp), %xmm0
movaps %xmm0, -0x4e0(%rbp)
movq -0x428(%rbp), %rax
movl -0x3fc(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
movaps (%rax,%rcx), %xmm0
movaps %xmm0, -0x4f0(%rbp)
movaps -0x4f0(%rbp), %xmm0
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movdqa %xmm0, -0x4f0(%rbp)
movq -0x430(%rbp), %rax
movq %rax, -0x4f8(%rbp)
movdqa -0x420(%rbp), %xmm0
movdqa %xmm0, -0x510(%rbp)
movq 0x10(%rbp), %rax
movq -0x3e0(%rbp), %rcx
movslq -0x444(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
imull -0x3fc(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x518(%rbp)
movq -0x428(%rbp), %rax
movq %rax, -0x430(%rbp)
movq -0x4f8(%rbp), %rax
movq %rax, -0x428(%rbp)
movl $0x0, -0x448(%rbp)
movl -0x448(%rbp), %eax
cmpl -0x3fc(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x1299a
movdqa -0x4f0(%rbp), %xmm1
movq -0x518(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x3b8(%rbp)
movq -0x3b8(%rbp), %rax
movdqa (%rax), %xmm0
movdqa %xmm1, -0x2f0(%rbp)
movdqa %xmm0, -0x300(%rbp)
movdqa -0x2f0(%rbp), %xmm0
movdqa -0x300(%rbp), %xmm1
paddsw %xmm1, %xmm0
movdqa %xmm0, -0x4f0(%rbp)
movq -0x438(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x3c0(%rbp)
movq -0x3c0(%rbp), %rax
movdqa (%rax), %xmm0
movdqa %xmm0, -0x4d0(%rbp)
movdqa -0x4f0(%rbp), %xmm1
movdqa -0x4d0(%rbp), %xmm0
movdqa %xmm1, -0x130(%rbp)
movdqa %xmm0, -0x140(%rbp)
movdqa -0x130(%rbp), %xmm0
movdqa -0x140(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movdqa %xmm0, -0x4f0(%rbp)
movdqa -0x4f0(%rbp), %xmm1
movdqa -0x4e0(%rbp), %xmm0
movdqa %xmm1, -0x150(%rbp)
movdqa %xmm0, -0x160(%rbp)
movdqa -0x150(%rbp), %xmm0
movdqa -0x160(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movdqa %xmm0, -0x4f0(%rbp)
movdqa -0x510(%rbp), %xmm1
movdqa -0x4f0(%rbp), %xmm0
movdqa %xmm1, -0x170(%rbp)
movdqa %xmm0, -0x180(%rbp)
movdqa -0x170(%rbp), %xmm0
movdqa -0x180(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movdqa %xmm0, -0x510(%rbp)
movq -0x428(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movdqa -0x4f0(%rbp), %xmm0
movq %rax, -0x358(%rbp)
movdqa %xmm0, -0x370(%rbp)
movdqa -0x370(%rbp), %xmm0
movq -0x358(%rbp), %rax
movdqa %xmm0, (%rax)
movdqa -0x4f0(%rbp), %xmm1
movdqa -0x460(%rbp), %xmm0
movdqa %xmm1, -0x90(%rbp)
movdqa %xmm0, -0xa0(%rbp)
movdqa -0x90(%rbp), %xmm0
movdqa -0xa0(%rbp), %xmm1
psubusw %xmm1, %xmm0
movdqa %xmm0, -0x4f0(%rbp)
movdqa -0x4d0(%rbp), %xmm1
movdqa -0x470(%rbp), %xmm0
movdqa %xmm1, -0xb0(%rbp)
movdqa %xmm0, -0xc0(%rbp)
movdqa -0xb0(%rbp), %xmm0
movdqa -0xc0(%rbp), %xmm1
psubusw %xmm1, %xmm0
movdqa %xmm0, -0x4d0(%rbp)
movdqa -0x4d0(%rbp), %xmm1
movdqa -0x4f0(%rbp), %xmm0
movdqa %xmm1, -0x190(%rbp)
movdqa %xmm0, -0x1a0(%rbp)
movdqa -0x190(%rbp), %xmm0
movdqa -0x1a0(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movdqa %xmm0, -0x4d0(%rbp)
movq -0x438(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movdqa -0x4d0(%rbp), %xmm0
movq %rax, -0x378(%rbp)
movdqa %xmm0, -0x390(%rbp)
movdqa -0x390(%rbp), %xmm0
movq -0x378(%rbp), %rax
movdqa %xmm0, (%rax)
movdqa -0x4e0(%rbp), %xmm1
movdqa -0x470(%rbp), %xmm0
movdqa %xmm1, -0xd0(%rbp)
movdqa %xmm0, -0xe0(%rbp)
movdqa -0xd0(%rbp), %xmm0
movdqa -0xe0(%rbp), %xmm1
psubusw %xmm1, %xmm0
movdqa %xmm0, -0x4e0(%rbp)
movdqa -0x4e0(%rbp), %xmm1
movdqa -0x4f0(%rbp), %xmm0
movdqa %xmm1, -0x1b0(%rbp)
movdqa %xmm0, -0x1c0(%rbp)
movdqa -0x1b0(%rbp), %xmm0
movdqa -0x1c0(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movdqa %xmm0, -0x4e0(%rbp)
movq -0x430(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x3c8(%rbp)
movq -0x3c8(%rbp), %rax
movdqa (%rax), %xmm0
movdqa %xmm0, -0x4f0(%rbp)
movl -0x448(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x448(%rbp)
jmp 0x1264f
movl $0x0, -0x44c(%rbp)
cmpl $0x8, -0x44c(%rbp)
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12bb2
movaps -0x4e0(%rbp), %xmm0
pslldq $0x2, %xmm0             # xmm0 = zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13]
movdqa %xmm0, -0x4e0(%rbp)
movl $0x0, -0x448(%rbp)
movl -0x448(%rbp), %eax
cmpl -0x3fc(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12b9c
movq -0x428(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x3d0(%rbp)
movq -0x3d0(%rbp), %rax
movaps (%rax), %xmm0
movaps %xmm0, -0x4f0(%rbp)
movaps -0x4f0(%rbp), %xmm1
movaps -0x4e0(%rbp), %xmm0
movaps %xmm1, -0x1d0(%rbp)
movaps %xmm0, -0x1e0(%rbp)
movaps -0x1d0(%rbp), %xmm0
movaps -0x1e0(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x4f0(%rbp)
movaps -0x510(%rbp), %xmm1
movaps -0x4f0(%rbp), %xmm0
movaps %xmm1, -0x1f0(%rbp)
movaps %xmm0, -0x200(%rbp)
movaps -0x1f0(%rbp), %xmm0
movaps -0x200(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x510(%rbp)
movq -0x428(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movaps -0x4f0(%rbp), %xmm0
movq %rax, -0x398(%rbp)
movaps %xmm0, -0x3b0(%rbp)
movaps -0x3b0(%rbp), %xmm0
movq -0x398(%rbp), %rax
movaps %xmm0, (%rax)
movaps -0x4f0(%rbp), %xmm1
movaps -0x460(%rbp), %xmm0
movaps %xmm1, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps -0xf0(%rbp), %xmm0
movaps -0x100(%rbp), %xmm1
psubusw %xmm1, %xmm0
movaps %xmm0, -0x4f0(%rbp)
movaps -0x4e0(%rbp), %xmm1
movaps -0x470(%rbp), %xmm0
movaps %xmm1, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movaps -0x110(%rbp), %xmm0
movaps -0x120(%rbp), %xmm1
psubusw %xmm1, %xmm0
movaps %xmm0, -0x4e0(%rbp)
movaps -0x4e0(%rbp), %xmm1
movaps -0x4f0(%rbp), %xmm0
movaps %xmm1, -0x70(%rbp)
movaps %xmm0, -0x80(%rbp)
movaps -0x70(%rbp), %xmm0
movaps -0x80(%rbp), %xmm1
pcmpgtw %xmm1, %xmm0
movdqa %xmm0, -0x340(%rbp)
movdqa -0x340(%rbp), %xmm0
pmovmskb %xmm0, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12b86
jmp 0x12bb4
jmp 0x12b88
movl -0x448(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x448(%rbp)
jmp 0x129dd
jmp 0x12b9e
movl -0x44c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44c(%rbp)
jmp 0x129a4
jmp 0x12bb4
movaps -0x480(%rbp), %xmm1
movaps -0x510(%rbp), %xmm0
movaps %xmm1, -0x210(%rbp)
movaps %xmm0, -0x220(%rbp)
movaps -0x210(%rbp), %xmm0
movaps -0x220(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x480(%rbp)
movaps -0x490(%rbp), %xmm1
movaps -0x480(%rbp), %xmm0
movaps %xmm1, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movaps -0x50(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
pcmpeqw %xmm1, %xmm0
movdqa %xmm0, -0x4a0(%rbp)
movdqa -0x4a0(%rbp), %xmm0
movdqa %xmm0, -0x350(%rbp)
movdqa -0x350(%rbp), %xmm0
pmovmskb %xmm0, %eax
movl %eax, -0x4b4(%rbp)
cmpl $0xffff, -0x4b4(%rbp)   # imm = 0xFFFF
je 0x12dc0
movaps -0x480(%rbp), %xmm0
movaps %xmm0, -0x490(%rbp)
movaps -0x480(%rbp), %xmm1
movaps %xmm1, %xmm0
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movaps %xmm1, -0x230(%rbp)
movaps %xmm0, -0x240(%rbp)
movaps -0x230(%rbp), %xmm0
movaps -0x240(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x480(%rbp)
movaps -0x480(%rbp), %xmm1
movaps %xmm1, %xmm0
psrldq $0x4, %xmm0             # xmm0 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],zero,zero,zero,zero
movaps %xmm1, -0x250(%rbp)
movaps %xmm0, -0x260(%rbp)
movaps -0x250(%rbp), %xmm0
movaps -0x260(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x480(%rbp)
movaps -0x480(%rbp), %xmm1
movaps %xmm1, %xmm0
psrldq $0x2, %xmm0             # xmm0 = xmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero,zero
movaps %xmm1, -0x270(%rbp)
movaps %xmm0, -0x280(%rbp)
movaps -0x270(%rbp), %xmm0
movaps -0x280(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x480(%rbp)
movl -0x480(%rbp), %eax
movzwl %ax, %eax
movw %ax, -0x51a(%rbp)
movdqa -0x490(%rbp), %xmm0
movdqa %xmm0, -0x480(%rbp)
movzwl -0x51a(%rbp), %eax
movzwl -0x3f0(%rbp), %ecx
cmpl %ecx, %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12dbe
movw -0x51a(%rbp), %ax
movw %ax, -0x3f0(%rbp)
movl -0x444(%rbp), %eax
movl %eax, -0x3f8(%rbp)
movl $0x0, -0x448(%rbp)
movl -0x448(%rbp), %eax
cmpl -0x3fc(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12dbc
movq -0x428(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movdqa (%rax), %xmm0
movq -0x440(%rbp), %rax
movslq -0x448(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movdqa %xmm0, (%rax)
movl -0x448(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x448(%rbp)
jmp 0x12d5d
jmp 0x12dbe
jmp 0x12dc0
movaps -0x510(%rbp), %xmm1
movaps %xmm1, %xmm0
psrldq $0x8, %xmm0             # xmm0 = xmm0[8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero
movaps %xmm1, -0x290(%rbp)
movaps %xmm0, -0x2a0(%rbp)
movaps -0x290(%rbp), %xmm0
movaps -0x2a0(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x510(%rbp)
movaps -0x510(%rbp), %xmm1
movaps %xmm1, %xmm0
psrldq $0x4, %xmm0             # xmm0 = xmm0[4,5,6,7,8,9,10,11,12,13,14,15],zero,zero,zero,zero
movaps %xmm1, -0x2b0(%rbp)
movaps %xmm0, -0x2c0(%rbp)
movaps -0x2b0(%rbp), %xmm0
movaps -0x2c0(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x510(%rbp)
movaps -0x510(%rbp), %xmm1
movaps %xmm1, %xmm0
psrldq $0x2, %xmm0             # xmm0 = xmm0[2,3,4,5,6,7,8,9,10,11,12,13,14,15],zero,zero
movaps %xmm1, -0x2d0(%rbp)
movaps %xmm0, -0x2e0(%rbp)
movaps -0x2d0(%rbp), %xmm0
movaps -0x2e0(%rbp), %xmm1
pmaxsw %xmm1, %xmm0
movaps %xmm0, -0x510(%rbp)
movl -0x510(%rbp), %eax
movzwl %ax, %eax
movw %ax, %dx
movq -0x408(%rbp), %rax
movslq -0x444(%rbp), %rcx
movw %dx, (%rax,%rcx,2)
movq -0x408(%rbp), %rax
movslq -0x444(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movzwl 0x18(%rbp), %ecx
cmpl %ecx, %eax
jne 0x12e9c
jmp 0x12eb5
jmp 0x12e9e
movl -0x4b0(%rbp), %eax
addl -0x444(%rbp), %eax
movl %eax, -0x444(%rbp)
jmp 0x1257a
movq -0x440(%rbp), %rax
movq %rax, -0x528(%rbp)
movl -0x3fc(%rbp), %eax
shll $0x3, %eax
movl %eax, -0x52c(%rbp)
movl $0x0, -0x444(%rbp)
movl -0x444(%rbp), %eax
cmpl -0x52c(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x12f8c
movq -0x528(%rbp), %rax
movzwl (%rax), %eax
movzwl -0x3f0(%rbp), %ecx
cmpl %ecx, %eax
jne 0x12f64
movl -0x444(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x55c(%rbp)
movl -0x444(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl -0x55c(%rbp), %eax
imull -0x3fc(%rbp), %edx
addl %edx, %eax
movl %eax, -0x530(%rbp)
movl -0x530(%rbp), %eax
cmpl -0x3f4(%rbp), %eax
jge 0x12f62
movl -0x530(%rbp), %eax
movl %eax, -0x3f4(%rbp)
jmp 0x12f64
jmp 0x12f66
movl -0x444(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x444(%rbp)
movq -0x528(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x528(%rbp)
jmp 0x12edc
movq -0x440(%rbp), %rdi
callq 0x3050
movq -0x438(%rbp), %rdi
callq 0x3050
movq -0x430(%rbp), %rdi
callq 0x3050
movq -0x428(%rbp), %rdi
callq 0x3050
movl $0x2, %edi
movl $0xc, %esi
callq 0x3310
movq %rax, -0x538(%rbp)
movw -0x3f0(%rbp), %cx
movq -0x538(%rbp), %rax
movw %cx, (%rax)
movl -0x3f8(%rbp), %ecx
movq -0x538(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x3f4(%rbp), %ecx
movq -0x538(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x538(%rbp), %rax
movw $0x0, 0xc(%rax)
movq -0x538(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x538(%rbp), %rax
movl $0x0, 0x14(%rax)
movl -0x3f8(%rbp), %eax
subl 0x20(%rbp), %eax
cmpl $0x0, %eax
jle 0x1304b
movl -0x3f8(%rbp), %eax
subl 0x20(%rbp), %eax
movl %eax, -0x560(%rbp)
jmp 0x13055
xorl %eax, %eax
movl %eax, -0x560(%rbp)
jmp 0x13055
movl -0x560(%rbp), %eax
movl %eax, -0x4a4(%rbp)
movl $0x0, -0x444(%rbp)
movl -0x444(%rbp), %eax
cmpl -0x4a4(%rbp), %eax
jge 0x130da
movq -0x408(%rbp), %rax
movslq -0x444(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movq -0x538(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jle 0x130c7
movq -0x408(%rbp), %rax
movslq -0x444(%rbp), %rcx
movw (%rax,%rcx,2), %cx
movq -0x538(%rbp), %rax
movw %cx, 0xc(%rax)
movl -0x444(%rbp), %ecx
movq -0x538(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x130c9
movl -0x444(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x444(%rbp)
jmp 0x1306b
movl -0x3f8(%rbp), %eax
addl 0x20(%rbp), %eax
cmpl -0x3e8(%rbp), %eax
jle 0x130f9
movl -0x3e8(%rbp), %eax
movl %eax, -0x564(%rbp)
jmp 0x13108
movl -0x3f8(%rbp), %eax
addl 0x20(%rbp), %eax
movl %eax, -0x564(%rbp)
movl -0x564(%rbp), %eax
movl %eax, -0x4a4(%rbp)
movl -0x4a4(%rbp), %eax
movl %eax, -0x444(%rbp)
movl -0x444(%rbp), %eax
cmpl -0x3e8(%rbp), %eax
jge 0x1318f
movq -0x408(%rbp), %rax
movslq -0x444(%rbp), %rcx
movzwl (%rax,%rcx,2), %eax
movq -0x538(%rbp), %rcx
movzwl 0xc(%rcx), %ecx
cmpl %ecx, %eax
jle 0x1317c
movq -0x408(%rbp), %rax
movslq -0x444(%rbp), %rcx
movw (%rax,%rcx,2), %cx
movq -0x538(%rbp), %rax
movw %cx, 0xc(%rax)
movl -0x444(%rbp), %ecx
movq -0x538(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x1317e
movl -0x444(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x444(%rbp)
jmp 0x13120
movq -0x408(%rbp), %rdi
callq 0x3050
movq -0x410(%rbp), %rdi
callq 0x3050
movq -0x538(%rbp), %rax
addq $0x570, %rsp            # imm = 0x570
popq %rbp
retq
nopw (%rax,%rax)