// File: 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
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq 0xcc3b(%rip), %rdi      # 0x1cfd0
leaq 0x2ea7(%rip), %rsi      # 0x13243
callq 0x32c0
movq %rax, %rdi
movq 0xcc0d(%rip), %rsi      # 0x1cfb8
callq 0x3310
movq 0xcc19(%rip), %rdi      # 0x1cfd0
leaq 0x2e96(%rip), %rsi      # 0x13254
callq 0x32c0
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x32a0
movq %rax, %rdi
leaq 0x2ea3(%rip), %rsi      # 0x1327c
callq 0x32c0
movq %rax, -0xe8(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3220
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0x30d0
movq %rax, %rdi
movq 0xcbb1(%rip), %rsi      # 0x1cfb8
callq 0x3310
movq -0xe0(%rbp), %rsi
movq %rsi, %rdi
callq 0x10b70
movq -0xe0(%rbp), %rdi
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rsi
callq 0x10b70
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
cltq
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, -0x20(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x3420
leaq -0x70(%rbp), %rdi
callq 0x3420
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x104eb
movl -0x18(%rbp), %eax
incl %eax
cltq
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
movq $-0x1, %rax
cmovoq %rax, %rdi
callq 0x3030
movq %rax, -0xf0(%rbp)
jmp 0x104aa
movq -0xf0(%rbp), %rdx
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x10477
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31f0
leaq -0x50(%rbp), %rdi
callq 0x31f0
jmp 0x10870
movl $0x0, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x10534
movl -0x84(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x104fc
movl $0x1, -0x80(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x10571
movl -0x80(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x10545
movl $0x1, -0x80(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x107cc
movq -0xe0(%rbp), %rdi
movslq -0x28(%rbp), %rsi
callq 0x3590
movq %rax, -0xf8(%rbp)
jmp 0x105a4
movq -0xf8(%rbp), %rax
movsbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x105fd
movq -0xe0(%rbp), %rsi
movslq -0x28(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
movl $0x2, %ecx
callq 0x32f0
jmp 0x105d6
leaq -0x50(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x33a0
leaq -0xa8(%rbp), %rdi
callq 0x31f0
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1062d
movq -0xe0(%rbp), %rdi
movslq -0x28(%rbp), %rsi
callq 0x3590
movq %rax, -0x100(%rbp)
jmp 0x10616
movq -0x100(%rbp), %rax
movsbl (%rax), %esi
leaq -0x50(%rbp), %rdi
callq 0x34f0
jmp 0x1062b
jmp 0x1062d
movl $0x1, -0x84(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x18(%rbp), %eax
jg 0x107b3
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x3340
movsbl (%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x106a9
movq -0x10(%rbp), %rsi
movslq -0x2c(%rbp), %rdx
leaq -0xc8(%rbp), %rdi
movl $0x2, %ecx
callq 0x32f0
jmp 0x10682
leaq -0x70(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x33a0
leaq -0xc8(%rbp), %rdi
callq 0x31f0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x106c6
movq -0x10(%rbp), %rdi
movslq -0x2c(%rbp), %rsi
callq 0x3340
movsbl (%rax), %esi
leaq -0x70(%rbp), %rdi
callq 0x34f0
jmp 0x106c4
jmp 0x106c6
movq -0x20(%rbp), %rax
movl -0x80(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movl -0x84(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x108(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0xe8d0
movq -0xe0(%rbp), %rdi
movb %al, %cl
movl -0x108(%rbp), %eax
xorb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl %eax, -0xcc(%rbp)
movq -0x20(%rbp), %rax
movl -0x80(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movl (%rax,%rcx,4), %eax
incl %eax
movl %eax, -0xd0(%rbp)
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl -0x84(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
incl %eax
movl %eax, -0xd4(%rbp)
leaq -0xcc(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
leaq -0xd4(%rbp), %rcx
callq 0x10bf0
movl %eax, -0x104(%rbp)
jmp 0x1077a
movl -0x104(%rbp), %edx
movq -0x20(%rbp), %rax
movslq -0x80(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1063e
jmp 0x107b5
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1057f
movq -0x20(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x18(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xd8(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x10826
movq -0x20(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x110(%rbp)
cmpq $0x0, %rax
je 0x10819
movq -0x110(%rbp), %rdi
callq 0x33d0
jmp 0x1081b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x107ec
movq -0x20(%rbp), %rax
movq %rax, -0x118(%rbp)
cmpq $0x0, %rax
je 0x10843
movq -0x118(%rbp), %rdi
callq 0x33d0
movl -0xd8(%rbp), %eax
movl %eax, -0x11c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x31f0
leaq -0x50(%rbp), %rdi
callq 0x31f0
movl -0x11c(%rbp), %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x3530
nopl (%rax)