// File: /workspace/github_cpp_makefile_star2_O2/jianxinzhou[P]Smart/./src/MyTask.cpp
// Function: MyTask::editdistance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int MyTask::editdistance(const std::string& right)
{
	std::cout << __FILE__ << std::endl ;
	std::cout << " ----------edit_dist right:------------" << right <<"  size:" << right.size() << std::endl ;
	int len_left = length(queryWord_);
	int len_right = length(right);
	int ** arr_dist = new int* [len_left + 1];
	int index , index_left, index_right;
	std::string subleft , subright ;
	for(index = 0 ; index <= len_left ; index ++)
	{
		arr_dist[index] = new int[len_right + 1];
	}
	int index_i , index_j ;
	for(index_i = 0 , index_j = 0 ; index_j <= len_right ; index_j ++)
	{
		arr_dist[index_i][index_j] = index_j ;
	}
	for(index_i = 1 , index_j = 0 ; index_i <= len_left; index_i ++)
	{
		arr_dist[index_i][index_j] = index_i ;
	}
	for(index_i = 1 , index_left = 0;  index_i <= len_left; index_i ++, index_left ++)
	{
		if(queryWord_[index_left] & (1 << 7))
		{
			subleft = queryWord_.substr(index_left, 2);
			index_left ++ ; 
		}else 
		{
			subleft = queryWord_[index_left];

		}
		for(index_j = 1 , index_right = 0; index_j <= len_right; index_j ++ ,index_right ++)
		{
			if(right[index_right] & (1 << 7)) 
			{
				subright = right.substr(index_right, 2);
				index_right ++ ; 
			}else 
			{
				subright = right[index_right];
			}
			int a = arr_dist[index_i - 1][index_j - 1] + (subleft == subright ? 0 : 1) ;
			arr_dist[index_i][index_j] =  triple_min(a, arr_dist[index_i - 1][index_j] + 1, arr_dist[index_i][index_j - 1] + 1);
		}
	}
	int result = arr_dist[len_left][len_right] ;
	for(index = 0 ; index <= len_left; index ++)
	{
		delete [] arr_dist[index];
	}
	delete [] arr_dist ;
	return result ;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x6c0f(%rip), %r14      # 0xdfd0
leaq 0x1e77(%rip), %rsi      # 0x923f
movq %r14, %rdi
callq 0x3270
movq %rax, %rdi
callq 0x3160
leaq 0x1e71(%rip), %rsi      # 0x9250
movq %r14, %rdi
callq 0x3270
movq %rax, %rdi
movq %r15, %rsi
callq 0x3250
leaq 0x1e7f(%rip), %rsi      # 0x9278
movq %rax, %rdi
callq 0x3270
movq 0x8(%r15), %rsi
movq %rax, %rdi
callq 0x31d0
movq %rax, %rdi
callq 0x3160
movq %rbx, %rdi
movq %rbx, %rsi
callq 0x77f2
movl %eax, %r14d
movq %rbx, -0x50(%rbp)
movq %rbx, %rdi
movq %r15, -0x60(%rbp)
movq %r15, %rsi
callq 0x77f2
movl %eax, %r12d
leal 0x1(%r14), %edi
shlq $0x3, %rdi
cmpl $-0x1, %r14d
pushq $-0x1
popq %r15
cmovlq %r15, %rdi
callq 0x3030
leaq -0x80(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movq %rax, -0x30(%rbp)
xorl %ebx, %ebx
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %bl, (%rcx)
movb %bl, (%rax)
leal 0x1(%r12), %r13d
shlq $0x2, %r13
movq %r12, -0x40(%rbp)
cmpl $-0x1, %r12d
cmovlq %r15, %r13
movslq %r14d, %r12
cmpq %r12, %rbx
jg 0x74ab
movq %r13, %rdi
callq 0x3030
movq -0x30(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
jmp 0x7491
movslq -0x40(%rbp), %rax
movq %rax, -0x58(%rbp)
xorl %eax, %eax
movq -0x50(%rbp), %rsi
cmpq -0x58(%rbp), %rax
jg 0x74ce
movq -0x30(%rbp), %rcx
movq (%rcx), %rcx
movl %eax, (%rcx,%rax,4)
incq %rax
jmp 0x74b9
xorl %eax, %eax
testl %r14d, %r14d
cmovgl %r14d, %eax
leal 0x1(%rax), %ecx
movq %rcx, -0x70(%rbp)
negq %rax
pushq $0x1
popq %rcx
leaq (%rax,%rcx), %rdx
cmpq $0x1, %rdx
je 0x74fd
movq -0x30(%rbp), %rdx
movq (%rdx,%rcx,8), %rdx
movl %ecx, (%rdx)
incq %rcx
jmp 0x74e4
xorl %ecx, %ecx
movq -0x40(%rbp), %rax
testl %eax, %eax
movl $0x0, -0x34(%rbp)
cmovlel %ecx, %eax
movq %rax, -0x40(%rbp)
pushq $0x1
popq %r14
movq %r12, -0x68(%rbp)
cmpq -0x70(%rbp), %r14
je 0x7641
movslq -0x34(%rbp), %rdx
movq (%rsi), %rax
movb (%rax,%rdx), %al
testb %al, %al
js 0x7544
movsbl %al, %esi
leaq -0x90(%rbp), %rdi
callq 0x3440
jmp 0x7570
leaq -0xd0(%rbp), %rbx
movq %rbx, %rdi
pushq $0x2
popq %rcx
callq 0x32a0
leaq -0x90(%rbp), %rdi
movq %rbx, %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3140
incl -0x34(%rbp)
xorl %r12d, %r12d
xorl %eax, %eax
cmpq %r12, -0x40(%rbp)
je 0x762e
movl %eax, %r15d
movslq %eax, %rdx
movq -0x60(%rbp), %rax
movq (%rax), %rax
movb (%rax,%rdx), %al
testb %al, %al
leaq -0xb0(%rbp), %rbx
js 0x75a7
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3440
jmp 0x75d3
leaq -0xd0(%rbp), %r13
movq %r13, %rdi
movq -0x60(%rbp), %rsi
pushq $0x2
popq %rcx
callq 0x32a0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3320
movq %r13, %rdi
callq 0x3140
incl %r15d
movq %rbx, %rsi
movq -0x30(%rbp), %rbx
movq %r14, %r13
movq -0x8(%rbx,%r14,8), %r14
movl (%r14,%r12,4), %eax
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x6b7e
xorb $0x1, %al
movzbl %al, %eax
addl -0x44(%rbp), %eax
movl 0x4(%r14,%r12,4), %ecx
movq %r13, %r14
incl %ecx
movq (%rbx,%r13,8), %rdx
movl (%rdx,%r12,4), %esi
incl %esi
cmpl %ecx, %eax
cmovll %eax, %ecx
cmpl %esi, %ecx
cmovgel %esi, %ecx
movl %ecx, 0x4(%rdx,%r12,4)
incl %r15d
incq %r12
movl %r15d, %eax
jmp 0x7575
incq %r14
incl -0x34(%rbp)
movq -0x50(%rbp), %rsi
movq -0x68(%rbp), %r12
jmp 0x751b
movq -0x30(%rbp), %rax
movq (%rax,%r12,8), %rax
movq -0x58(%rbp), %rcx
movl (%rax,%rcx,4), %ebx
xorl %r14d, %r14d
cmpq %r12, %r14
jg 0x766f
movq -0x30(%rbp), %rax
movq (%rax,%r14,8), %rdi
testq %rdi, %rdi
je 0x766a
callq 0x3340
incq %r14
jmp 0x7653
movq -0x30(%rbp), %rdi
callq 0x3340
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x3140
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x76ac
jmp 0x76ac
jmp 0x76ac
jmp 0x76ac
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x3140
leaq -0x90(%rbp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x3480
nop