// File: chhylp123[P]hifiasm/./Levenshtein_distance.h
// Function: Reserve_Banded_BPM_PATH(char*, int, char*, int, unsigned short, unsigned int*, int*, int*, unsigned long*, char*, int, int)
inline int Reserve_Banded_BPM_PATH
(char *pattern, int p_length, char *text, int t_length, unsigned short errthold, 
		unsigned int* return_err, int* return_start_site, int* return_path_length, Word* matrix_bit, char* path, 
		int old_error, int old_end_site)
{
	if (old_error != -1 && old_end_site != -1)
	{
		if (old_error == 0)
		{
			(*return_err) = old_error;
			(*return_start_site) = old_end_site - t_length + 1;
			return old_end_site;
		}

		if (try_cigar(pattern, p_length, text, t_length, old_end_site, path,
		old_error, return_start_site, return_path_length))
		{
			(*return_err) = old_error;
			return old_end_site;
		}
		
	}
	
	(*return_err) = (unsigned int)-1;

	Word Peq[256];

	int band_length = (errthold << 1) + 1;
	int i = 0;
	Word tmp_Peq_1 = (Word)1;

	Peq[(uint8_t)'A'] = (Word)0;
	Peq[(uint8_t)'T'] = (Word)0;
	Peq[(uint8_t)'G'] = (Word)0;
	Peq[(uint8_t)'C'] = (Word)0;


	Word Peq_A;
	Word Peq_T;
	Word Peq_C;
	Word Peq_G;

	///band_length = 2k + 1
	for (i = 0; i<band_length; i++)
	{
		Peq[(uint8_t)pattern[i]] = Peq[(uint8_t)pattern[i]] | tmp_Peq_1;
		tmp_Peq_1 = tmp_Peq_1 << 1;
	}

	///Peq[(uint8_t)'T'] = Peq[(uint8_t)'T'] | Peq[(uint8_t)'C'];

	Peq_A = Peq[(uint8_t)'A'];
	Peq_C = Peq[(uint8_t)'C'];
	Peq_T = Peq[(uint8_t)'T'];
	Peq_G = Peq[(uint8_t)'G'];


	memset(Peq, 0, sizeof(Word)* 256);


	Peq[(uint8_t)'A'] = Peq_A;
	Peq[(uint8_t)'C'] = Peq_C;
	Peq[(uint8_t)'T'] = Peq_T;
	Peq[(uint8_t)'G'] = Peq_G;


	

	Word Mask = ((Word)1 << (errthold << 1));

	Word VP = 0;
	Word VN = 0;
	Word X = 0;
	Word D0 = 0;
	Word HN = 0;
	Word HP = 0;


	i = 0;

	Word column_start;

	int err = 0;

	Word err_mask = (Word)1;


	///band_down = 2k
	///i_bd = 2k
	///int i_bd = i + band_down;
	int i_bd = (errthold << 1);


	int last_high = (errthold << 1);


	/// t_length_1 = SEQ_LENGTH - 1
	int t_length_1 = t_length - 1;
	//while(i<t_length)

	while (i<t_length_1)
	{
		///pattern[0]ÔÚPeq[2k], ¶øpattern[2k]ÔÚPeq[0]
		X = Peq[(uint8_t)text[i]] | VN;

		D0 = ((VP + (X&VP)) ^ VP) | X;

		HN = VP&D0;
		HP = VN | ~(VP | D0);

		X = D0 >> 1;
		VN = X&HP;
		VP = HN | ~(X | HP);

		if (!(D0&err_mask))
		{
			++err;

			if ((err - last_high)>(int)errthold)
			{
				return -1;
			}
				
		}


		Peq[(uint8_t)'A'] = Peq[(uint8_t)'A'] >> 1;
		Peq[(uint8_t)'C'] = Peq[(uint8_t)'C'] >> 1;
		Peq[(uint8_t)'G'] = Peq[(uint8_t)'G'] >> 1;
		Peq[(uint8_t)'T'] = Peq[(uint8_t)'T'] >> 1;


		++i;
		++i_bd;
		Peq[(uint8_t)pattern[i_bd]] = Peq[(uint8_t)pattern[i_bd]] | Mask;


		///Peq[(uint8_t)'T'] = Peq[(uint8_t)'T'] | Peq[(uint8_t)'C'];

		column_start = i << 3;
		matrix_bit[column_start] = D0;
		matrix_bit[column_start + 1] = VP;
		matrix_bit[column_start + 2] = VN;
		matrix_bit[column_start + 3] = HP;
		matrix_bit[column_start + 4] = HN;
	}





	X = Peq[(uint8_t)text[i]] | VN;
	D0 = ((VP + (X&VP)) ^ VP) | X;
	HN = VP&D0;
	HP = VN | ~(VP | D0);
	X = D0 >> 1;
	VN = X&HP;
	VP = HN | ~(X | HP);
	if (!(D0&err_mask))
	{
		++err;
		if ((err - last_high)>(int)errthold)
			return -1;
	}


	column_start = (i + 1) << 3;
	matrix_bit[column_start] = D0;
	matrix_bit[column_start + 1] = VP;
	matrix_bit[column_start + 2] = VN;
	matrix_bit[column_start + 3] = HP;
	matrix_bit[column_start + 4] = HN;


	////fprintf(stderr, "sucess(2)\n");

	/// last_high = 2k
	/// site = (SEQ_LENGTH + 2k) - 2k -1
	/// site = SEQ_LENGTH - 1
	///int site = p_length - last_high - 1;
	int site = t_length - 1;
	int return_site = -1;

	/****************************may have bugs********************************/
	unsigned int ungap_error = (unsigned int)-1;
	/****************************may have bugs********************************/

	///in most cases, p_length should be t_length + 2 * errthold
	int available_i = p_length - t_length;
	if ((err <= (int)errthold) && ((unsigned int)err<=*return_err))
	{
		*return_err = err;
		return_site = site;
	}
	i = 0;

	while (i < available_i)
	{
		err = err + ((VP >> i)&(Word)1);
		err = err - ((VN >> i)&(Word)1);
		++i;

		if ((err <= (int)errthold) && ((unsigned int)err <= *return_err))
		{
			*return_err = err;
			return_site = site + i;
		}

		/****************************may have bugs********************************/
		if(i == (int)errthold)
		{
			ungap_error = err;
		}
		/****************************may have bugs********************************/
	}

	


	if ((*return_err) == (unsigned int)-1)
	{
		return return_site;
	}


	/****************************may have bugs********************************/
	if((ungap_error<=errthold) && (ungap_error == (*return_err)))
	{
		return_site = site + errthold;
	}
	/****************************may have bugs********************************/
	

	///need to correct p_length here, since p_length might be smaller than t_length + 2* err_threashlod
	p_length = t_length + 2 * errthold;
	///end_site is always correct
	int end_site = return_site;
	int start_site = end_site;
	int back_track_site = band_length - (p_length - end_site);

	Word v_value, h_value, delta_value, min_value, current_value;
	///Word direction; ///0 is match, 1 is mismatch, 2 is up, 3 is left
	Word direction = 0; ///0 is match, 1 is mismatch, 2 is up, 3 is left
	i = t_length;
	int path_length = 0;
	current_value = *return_err;


	int low_bound = band_length - 1;


	while (i>0)
	{
		if (current_value == 0)
		{
			break;
		}

		column_start = i << 3;

		delta_value = current_value -
			((~(matrix_bit[column_start] >> back_track_site))&err_mask);


		if (back_track_site == 0)
		{
			///HP
			h_value = current_value - ((matrix_bit[column_start + 3] >> back_track_site)&err_mask);
			//HN
			h_value = h_value + ((matrix_bit[column_start + 4] >> back_track_site)&err_mask);


			min_value = delta_value;
			direction = 0;

			if (h_value < min_value)
			{
				min_value = h_value;
				direction = 3;
			}

		}
		else if (back_track_site == low_bound)
		{
			v_value = current_value - ((matrix_bit[column_start + 1] >> (back_track_site - 1))&err_mask);
			v_value = v_value + ((matrix_bit[column_start + 2] >> (back_track_site - 1))&err_mask);

			min_value = delta_value;
			direction = 0;

			if (v_value < min_value)
			{
				min_value = v_value;
				direction = 2;
			}

		}
		else
		{

			h_value = current_value - ((matrix_bit[column_start + 3] >> back_track_site)&(Word)1);


			h_value = h_value + ((matrix_bit[column_start + 4] >> back_track_site)&(Word)1);


			v_value = current_value - ((matrix_bit[column_start + 1] >> (back_track_site - 1))&err_mask);
			v_value = v_value + ((matrix_bit[column_start + 2] >> (back_track_site - 1))&err_mask);


			min_value = delta_value;
			direction = 0;

			if (v_value < min_value)
			{
				min_value = v_value;
				direction = 2;
			}


			if (h_value < min_value)
			{
				min_value = h_value;
				direction = 3;
			}

		}


		if (direction == 0)
		{

			if (delta_value != current_value)
			{
				direction = 1;
			}

			i--;

			start_site--;

		}
		if (direction == 2)///ru guo xiang shang yi dong, bing bu huan lie
		{
			back_track_site--;
			start_site--;
		}
		else if (direction == 3)///ru guo xiang zuo yi dong
		{
			i--;
			back_track_site++;
		}


		path[path_length++] = direction;


		current_value = min_value;

	}


	if (i > 0)
	{
		memset(path + path_length, 0, i);
		start_site = start_site - i;
		direction = 0;
		path_length = path_length + i;
	}

	if (direction != 3)
	{
		start_site++;
	}
	(*return_start_site) = start_site;
	(*return_path_length) = path_length;

	return return_site;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x930, %rsp            # imm = 0x930
movw %r8w, %ax
movl 0x38(%rbp), %r8d
movl 0x30(%rbp), %r8d
movq 0x28(%rbp), %r8
movq 0x20(%rbp), %r8
movq 0x18(%rbp), %r8
movq 0x10(%rbp), %r8
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movw %ax, -0x26(%rbp)
movq %r9, -0x30(%rbp)
cmpl $-0x1, 0x30(%rbp)
je 0x9e492
cmpl $-0x1, 0x38(%rbp)
je 0x9e492
cmpl $0x0, 0x30(%rbp)
jne 0x9e442
movl 0x30(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl 0x38(%rbp), %ecx
subl -0x24(%rbp), %ecx
addl $0x1, %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl 0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9f0de
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
movl 0x38(%rbp), %r8d
movq 0x28(%rbp), %r9
movl 0x30(%rbp), %r11d
movq 0x10(%rbp), %r10
movq 0x18(%rbp), %rax
movl %r11d, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0xc2e40
cmpl $0x0, %eax
je 0x9e490
movl 0x30(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl 0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9f0de
jmp 0x9e492
movq -0x30(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movzwl -0x26(%rbp), %eax
shll %eax
addl $0x1, %eax
movl %eax, -0x834(%rbp)
movl $0x0, -0x838(%rbp)
movq $0x1, -0x840(%rbp)
movq $0x0, -0x628(%rbp)
movq $0x0, -0x590(%rbp)
movq $0x0, -0x5f8(%rbp)
movq $0x0, -0x618(%rbp)
movl $0x0, -0x838(%rbp)
movl -0x838(%rbp), %eax
cmpl -0x834(%rbp), %eax
jge 0x9e55b
movq -0x10(%rbp), %rax
movslq -0x838(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x830(%rbp,%rax,8), %rcx
orq -0x840(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x838(%rbp), %rdx
movzbl (%rax,%rdx), %eax
movq %rcx, -0x830(%rbp,%rax,8)
movq -0x840(%rbp), %rax
shlq %rax
movq %rax, -0x840(%rbp)
movl -0x838(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x838(%rbp)
jmp 0x9e4f6
movq -0x628(%rbp), %rax
movq %rax, -0x848(%rbp)
movq -0x618(%rbp), %rax
movq %rax, -0x858(%rbp)
movq -0x590(%rbp), %rax
movq %rax, -0x850(%rbp)
movq -0x5f8(%rbp), %rax
movq %rax, -0x860(%rbp)
leaq -0x830(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x2100
movq -0x848(%rbp), %rax
movq %rax, -0x628(%rbp)
movq -0x858(%rbp), %rax
movq %rax, -0x618(%rbp)
movq -0x850(%rbp), %rax
movq %rax, -0x590(%rbp)
movq -0x860(%rbp), %rax
movq %rax, -0x5f8(%rbp)
movzwl -0x26(%rbp), %eax
shll %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x868(%rbp)
movq $0x0, -0x870(%rbp)
movq $0x0, -0x878(%rbp)
movq $0x0, -0x880(%rbp)
movq $0x0, -0x888(%rbp)
movq $0x0, -0x890(%rbp)
movq $0x0, -0x898(%rbp)
movl $0x0, -0x838(%rbp)
movl $0x0, -0x8a4(%rbp)
movq $0x1, -0x8b0(%rbp)
movzwl -0x26(%rbp), %eax
shll %eax
movl %eax, -0x8b4(%rbp)
movzwl -0x26(%rbp), %eax
shll %eax
movl %eax, -0x8b8(%rbp)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x8bc(%rbp)
movl -0x838(%rbp), %eax
cmpl -0x8bc(%rbp), %eax
jge 0x9e8c6
movq -0x20(%rbp), %rax
movslq -0x838(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x830(%rbp,%rax,8), %rax
orq -0x878(%rbp), %rax
movq %rax, -0x880(%rbp)
movq -0x870(%rbp), %rax
movq -0x880(%rbp), %rcx
andq -0x870(%rbp), %rcx
addq %rcx, %rax
xorq -0x870(%rbp), %rax
orq -0x880(%rbp), %rax
movq %rax, -0x888(%rbp)
movq -0x870(%rbp), %rax
andq -0x888(%rbp), %rax
movq %rax, -0x890(%rbp)
movq -0x878(%rbp), %rax
movq -0x870(%rbp), %rcx
orq -0x888(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x898(%rbp)
movq -0x888(%rbp), %rax
shrq %rax
movq %rax, -0x880(%rbp)
movq -0x880(%rbp), %rax
andq -0x898(%rbp), %rax
movq %rax, -0x878(%rbp)
movq -0x890(%rbp), %rax
movq -0x880(%rbp), %rcx
orq -0x898(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x870(%rbp)
movq -0x888(%rbp), %rax
andq -0x8b0(%rbp), %rax
cmpq $0x0, %rax
jne 0x9e7a6
movl -0x8a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8a4(%rbp)
movl -0x8a4(%rbp), %eax
subl -0x8b8(%rbp), %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jle 0x9e7a4
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9f0de
jmp 0x9e7a6
movq -0x628(%rbp), %rax
shrq %rax
movq %rax, -0x628(%rbp)
movq -0x618(%rbp), %rax
shrq %rax
movq %rax, -0x618(%rbp)
movq -0x5f8(%rbp), %rax
shrq %rax
movq %rax, -0x5f8(%rbp)
movq -0x590(%rbp), %rax
shrq %rax
movq %rax, -0x590(%rbp)
movl -0x838(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x838(%rbp)
movl -0x8b4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8b4(%rbp)
movq -0x10(%rbp), %rax
movslq -0x8b4(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x830(%rbp,%rax,8), %rcx
orq -0x868(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x8b4(%rbp), %rdx
movzbl (%rax,%rdx), %eax
movq %rcx, -0x830(%rbp,%rax,8)
movl -0x838(%rbp), %eax
shll $0x3, %eax
cltq
movq %rax, -0x8a0(%rbp)
movq -0x888(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x870(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x878(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movq -0x898(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x18(%rax,%rcx,8)
movq -0x890(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
jmp 0x9e67c
movq -0x20(%rbp), %rax
movslq -0x838(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movq -0x830(%rbp,%rax,8), %rax
orq -0x878(%rbp), %rax
movq %rax, -0x880(%rbp)
movq -0x870(%rbp), %rax
movq -0x880(%rbp), %rcx
andq -0x870(%rbp), %rcx
addq %rcx, %rax
xorq -0x870(%rbp), %rax
orq -0x880(%rbp), %rax
movq %rax, -0x888(%rbp)
movq -0x870(%rbp), %rax
andq -0x888(%rbp), %rax
movq %rax, -0x890(%rbp)
movq -0x878(%rbp), %rax
movq -0x870(%rbp), %rcx
orq -0x888(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x898(%rbp)
movq -0x888(%rbp), %rax
shrq %rax
movq %rax, -0x880(%rbp)
movq -0x880(%rbp), %rax
andq -0x898(%rbp), %rax
movq %rax, -0x878(%rbp)
movq -0x890(%rbp), %rax
movq -0x880(%rbp), %rcx
orq -0x898(%rbp), %rcx
xorq $-0x1, %rcx
orq %rcx, %rax
movq %rax, -0x870(%rbp)
movq -0x888(%rbp), %rax
andq -0x8b0(%rbp), %rax
cmpq $0x0, %rax
jne 0x9e9de
movl -0x8a4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8a4(%rbp)
movl -0x8a4(%rbp), %eax
subl -0x8b8(%rbp), %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jle 0x9e9dc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x9f0de
jmp 0x9e9de
movl -0x838(%rbp), %eax
addl $0x1, %eax
shll $0x3, %eax
cltq
movq %rax, -0x8a0(%rbp)
movq -0x888(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x870(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x878(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x10(%rax,%rcx,8)
movq -0x898(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x18(%rax,%rcx,8)
movq -0x890(%rbp), %rdx
movq 0x20(%rbp), %rax
movq -0x8a0(%rbp), %rcx
movq %rdx, 0x20(%rax,%rcx,8)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x8c0(%rbp)
movl $0xffffffff, -0x8c4(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x8c8(%rbp) # imm = 0xFFFFFFFF
movl -0x14(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x8cc(%rbp)
movl -0x8a4(%rbp), %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jg 0x9eac5
movl -0x8a4(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
ja 0x9eac5
movl -0x8a4(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0x8c0(%rbp), %eax
movl %eax, -0x8c4(%rbp)
movl $0x0, -0x838(%rbp)
movl -0x838(%rbp), %eax
cmpl -0x8cc(%rbp), %eax
jge 0x9eb97
movslq -0x8a4(%rbp), %rax
movq -0x870(%rbp), %rdx
movl -0x838(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq $0x1, %rcx
addq %rcx, %rax
movl %eax, -0x8a4(%rbp)
movslq -0x8a4(%rbp), %rax
movq -0x878(%rbp), %rdx
movl -0x838(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq $0x1, %rcx
subq %rcx, %rax
movl %eax, -0x8a4(%rbp)
movl -0x838(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x838(%rbp)
movl -0x8a4(%rbp), %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jg 0x9eb78
movl -0x8a4(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
ja 0x9eb78
movl -0x8a4(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movl -0x8c0(%rbp), %eax
addl -0x838(%rbp), %eax
movl %eax, -0x8c4(%rbp)
movl -0x838(%rbp), %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jne 0x9eb92
movl -0x8a4(%rbp), %eax
movl %eax, -0x8c8(%rbp)
jmp 0x9eacf
movq -0x30(%rbp), %rax
cmpl $-0x1, (%rax)
jne 0x9ebae
movl -0x8c4(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x9f0de
movl -0x8c8(%rbp), %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
ja 0x9ebdc
movl -0x8c8(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jne 0x9ebdc
movl -0x8c0(%rbp), %eax
movzwl -0x26(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x8c4(%rbp)
movl -0x24(%rbp), %eax
movzwl -0x26(%rbp), %ecx
shll %ecx
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x8c4(%rbp), %eax
movl %eax, -0x8d0(%rbp)
movl -0x8d0(%rbp), %eax
movl %eax, -0x8d4(%rbp)
movl -0x834(%rbp), %eax
movl -0x14(%rbp), %ecx
subl -0x8d0(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x8d8(%rbp)
movq $0x0, -0x908(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x838(%rbp)
movl $0x0, -0x90c(%rbp)
movq -0x30(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x900(%rbp)
movl -0x834(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x910(%rbp)
cmpl $0x0, -0x838(%rbp)
jle 0x9f050
cmpq $0x0, -0x900(%rbp)
jne 0x9ec6f
jmp 0x9f050
movl -0x838(%rbp), %eax
shll $0x3, %eax
cltq
movq %rax, -0x8a0(%rbp)
movq -0x900(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq (%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
xorq $-0x1, %rcx
andq -0x8b0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8f0(%rbp)
cmpl $0x0, -0x8d8(%rbp)
jne 0x9ed74
movq -0x900(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x18(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq -0x8b0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8e8(%rbp)
movq -0x8e8(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x20(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq -0x8b0(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x8e8(%rbp)
movq -0x8f0(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x0, -0x908(%rbp)
movq -0x8e8(%rbp), %rax
cmpq -0x8f8(%rbp), %rax
jae 0x9ed6f
movq -0x8e8(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x3, -0x908(%rbp)
jmp 0x9ef82
movl -0x8d8(%rbp), %eax
cmpl -0x910(%rbp), %eax
jne 0x9ee3f
movq -0x900(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x8(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq -0x8b0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8e0(%rbp)
movq -0x8e0(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x10(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq -0x8b0(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x8e0(%rbp)
movq -0x8f0(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x0, -0x908(%rbp)
movq -0x8e0(%rbp), %rax
cmpq -0x8f8(%rbp), %rax
jae 0x9ee3a
movq -0x8e0(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x2, -0x908(%rbp)
jmp 0x9ef80
movq -0x900(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x18(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq $0x1, %rcx
subq %rcx, %rax
movq %rax, -0x8e8(%rbp)
movq -0x8e8(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x20(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq $0x1, %rcx
addq %rcx, %rax
movq %rax, -0x8e8(%rbp)
movq -0x900(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x8(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq -0x8b0(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x8e0(%rbp)
movq -0x8e0(%rbp), %rax
movq 0x20(%rbp), %rcx
movq -0x8a0(%rbp), %rdx
movq 0x10(%rcx,%rdx,8), %rdx
movl -0x8d8(%rbp), %ecx
subl $0x1, %ecx
movl %ecx, %ecx
shrq %cl, %rdx
movq %rdx, %rcx
andq -0x8b0(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x8e0(%rbp)
movq -0x8f0(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x0, -0x908(%rbp)
movq -0x8e0(%rbp), %rax
cmpq -0x8f8(%rbp), %rax
jae 0x9ef55
movq -0x8e0(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x2, -0x908(%rbp)
movq -0x8e8(%rbp), %rax
cmpq -0x8f8(%rbp), %rax
jae 0x9ef7e
movq -0x8e8(%rbp), %rax
movq %rax, -0x8f8(%rbp)
movq $0x3, -0x908(%rbp)
jmp 0x9ef80
jmp 0x9ef82
cmpq $0x0, -0x908(%rbp)
jne 0x9efc5
movq -0x8f0(%rbp), %rax
cmpq -0x900(%rbp), %rax
je 0x9efa7
movq $0x1, -0x908(%rbp)
movl -0x838(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x838(%rbp)
movl -0x8d4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8d4(%rbp)
cmpq $0x2, -0x908(%rbp)
jne 0x9efef
movl -0x8d8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8d8(%rbp)
movl -0x8d4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8d4(%rbp)
jmp 0x9f019
cmpq $0x3, -0x908(%rbp)
jne 0x9f017
movl -0x838(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x838(%rbp)
movl -0x8d8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8d8(%rbp)
jmp 0x9f019
movq -0x908(%rbp), %rax
movb %al, %dl
movq 0x28(%rbp), %rax
movl -0x90c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x90c(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x8f8(%rbp), %rax
movq %rax, -0x900(%rbp)
jmp 0x9ec53
cmpl $0x0, -0x838(%rbp)
jle 0x9f0a4
movq 0x28(%rbp), %rdi
movslq -0x90c(%rbp), %rax
addq %rax, %rdi
movslq -0x838(%rbp), %rdx
xorl %esi, %esi
callq 0x2100
movl -0x8d4(%rbp), %eax
subl -0x838(%rbp), %eax
movl %eax, -0x8d4(%rbp)
movq $0x0, -0x908(%rbp)
movl -0x90c(%rbp), %eax
addl -0x838(%rbp), %eax
movl %eax, -0x90c(%rbp)
cmpq $0x3, -0x908(%rbp)
je 0x9f0bd
movl -0x8d4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8d4(%rbp)
movl -0x8d4(%rbp), %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x90c(%rbp), %ecx
movq 0x18(%rbp), %rax
movl %ecx, (%rax)
movl -0x8c4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x930, %rsp            # imm = 0x930
popq %rbp
retq
nopw (%rax,%rax)