// File: /workspace/github_cpp_makefile_star2_O1/iTruth[P]klotski/klotski_search.cpp
// Function: klotski_search::start_search()
bool klotski_search::start_search() noexcept{
	if(!is_situation_valid()){
		return false;
	}
	if(klotski_board::is_win(situation)){
		last_route.clear();
		last_route.push_back(situation);
		return true;
	}
	std::queue<record_item> open;
	std::stack<record_item> close;
	std::unordered_map<klotski_board::situation_type, bool, klotski_board::situation_type_hash> situation_search_state;
	open.push(record_item{situation, record_item::Undefined, nullptr});
	situation_search_state[situation] = true;
	while(!open.empty()){
		auto situation_front = open.front();
		open.pop();
		close.push(situation_front);
		auto zero_pos = get_zero_pos(situation_front.situation);
		if(std::get<0>(zero_pos) != 0){
			auto situation_tmp = situation_front;
			situation_tmp.Orientation = record_item::Horizontal;
			situation_tmp.prev = &close.top();
			std::swap(situation_tmp.situation[std::get<1>(zero_pos)][std::get<0>(zero_pos)],
					situation_tmp.situation[std::get<1>(zero_pos)][std::get<0>(zero_pos) - 1]);
			if(!situation_search_state[situation_tmp.situation]){
				open.push(situation_tmp);
				situation_search_state[situation_tmp.situation] = true;
				if(klotski_board::is_win(situation_tmp.situation)){
					build_route(situation_tmp);
					return true;
				}
			}
		}
		if(std::get<0>(zero_pos) < dx){
			auto situation_tmp = situation_front;
			situation_tmp.Orientation = record_item::Horizontal;
			situation_tmp.prev = &close.top();
			std::swap(situation_tmp.situation[std::get<1>(zero_pos)][std::get<0>(zero_pos)],
					situation_tmp.situation[std::get<1>(zero_pos)][std::get<0>(zero_pos) + 1]);
			if(!situation_search_state[situation_tmp.situation]){
				open.push(situation_tmp);
				situation_search_state[situation_tmp.situation] = true;
				if(klotski_board::is_win(situation_tmp.situation)){
					build_route(situation_tmp);
					return true;
				}
			}
		}
		if(std::get<1>(zero_pos) != 0){
			auto situation_tmp = situation_front;
			situation_tmp.Orientation = record_item::Vertical;
			situation_tmp.prev = &close.top();
			std::swap(situation_tmp.situation[std::get<1>(zero_pos)][std::get<0>(zero_pos)],
					situation_tmp.situation[std::get<1>(zero_pos) - 1][std::get<0>(zero_pos)]);
			if(!situation_search_state[situation_tmp.situation]){
				open.push(situation_tmp);
				situation_search_state[situation_tmp.situation] = true;
				if(klotski_board::is_win(situation_tmp.situation)){
					build_route(situation_tmp);
					return true;
				}
			}
		}
		if(std::get<1>(zero_pos) < dy){
			auto situation_tmp = situation_front;
			situation_tmp.Orientation = record_item::Vertical;
			situation_tmp.prev = &close.top();
			std::swap(situation_tmp.situation[std::get<1>(zero_pos)][std::get<0>(zero_pos)],
					situation_tmp.situation[std::get<1>(zero_pos) + 1][std::get<0>(zero_pos)]);
			if(!situation_search_state[situation_tmp.situation]){
				open.push(situation_tmp);
				situation_search_state[situation_tmp.situation] = true;
				if(klotski_board::is_win(situation_tmp.situation)){
					build_route(situation_tmp);
					return true;
				}
			}
		}
	}
	return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x8(%rax)
testb %al, %al
je 0x872d
leaq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x74ca
testb %al, %al
je 0x8734
addq $0x20, %rbx
movq %rbx, %rdi
callq 0x8d26
movb $0x1, %bpl
movq %rbx, %rdi
movq %r14, %rsi
callq 0x8d60
jmp 0x8c0e
xorl %ebp, %ebp
jmp 0x8c0e
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x926a
leaq 0x90(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x926a
leaq 0x88(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
callq 0x5952
leaq 0x30(%rsp), %rsi
movl $0x2, 0x18(%rsi)
movq $0x0, 0x20(%rsi)
leaq 0xe0(%rsp), %rdi
callq 0x9406
leaq 0x30(%rsp), %rdi
callq 0x5a36
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
callq 0x96c8
movb $0x1, (%rax)
movq 0xf0(%rsp), %r15
cmpq %r15, 0x110(%rsp)
setne %bpl
je 0x8bea
leaq 0x30(%rsp), %r14
movq %rsp, %r12
movq %r14, %rdi
movq %r15, %rsi
callq 0x5952
movups 0x18(%r15), %xmm0
leaq 0x48(%rsp), %rax
movups %xmm0, (%rax)
leaq 0xe0(%rsp), %rdi
callq 0x9b72
leaq 0x90(%rsp), %rdi
movq %r14, %rsi
callq 0x9bdc
leaq 0x28(%rsp), %rdi
movq %r14, %rdx
callq 0x8c30
movslq 0x2c(%rsp), %r15
testq %r15, %r15
je 0x891d
movq %r12, %rdi
movq %r14, %rsi
callq 0x5952
leaq 0x48(%rsp), %rax
movups (%rax), %xmm0
leaq 0x18(%rsp), %rax
movups %xmm0, (%rax)
movl $0x0, 0x18(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0x88a7
movq 0xd8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x1e0, %ecx            # imm = 0x1E0
addq %rcx, %rax
addq $-0x28, %rax
movq %rax, 0x20(%rsp)
movslq 0x28(%rsp), %rax
movq (%rsp), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movl (%rax,%r15,4), %ecx
movl -0x4(%rax,%r15,4), %edx
movl %edx, (%rax,%r15,4)
movl %ecx, -0x4(%rax,%r15,4)
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
cmpb $0x0, (%rax)
jne 0x8915
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x9bdc
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
movb $0x1, (%rax)
movq %r12, %rdi
callq 0x74ca
testb %al, %al
jne 0x8ba6
movq %r12, %rdi
callq 0x5a36
cmpl 0x70(%rbx), %r15d
jge 0x89e6
movq %r12, %rdi
movq %r14, %rsi
callq 0x5952
leaq 0x48(%rsp), %rax
movups (%rax), %xmm0
leaq 0x18(%rsp), %rax
movups %xmm0, (%rax)
movl $0x0, 0x18(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0x8970
movq 0xd8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x1e0, %ecx            # imm = 0x1E0
addq %rcx, %rax
addq $-0x28, %rax
movq %rax, 0x20(%rsp)
movslq 0x28(%rsp), %rax
movq (%rsp), %rcx
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movl (%rax,%r15,4), %ecx
movl 0x4(%rax,%r15,4), %edx
movl %edx, (%rax,%r15,4)
movl %ecx, 0x4(%rax,%r15,4)
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
cmpb $0x0, (%rax)
jne 0x89de
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x9bdc
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
movb $0x1, (%rax)
movq %r12, %rdi
callq 0x74ca
testb %al, %al
jne 0x8bc0
movq %r12, %rdi
callq 0x5a36
movslq 0x28(%rsp), %r13
testq %r13, %r13
je 0x8ab8
movq %r12, %rdi
movq %r14, %rsi
callq 0x5952
leaq 0x48(%rsp), %rax
movups (%rax), %xmm0
leaq 0x18(%rsp), %rax
movups %xmm0, (%rax)
movl $0x1, 0x18(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0x8a3d
movq 0xd8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x1e0, %ecx            # imm = 0x1E0
addq %rcx, %rax
addq $-0x28, %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
leaq (,%r13,2), %rcx
addq %r13, %rcx
movq (%rax,%rcx,8), %rdx
movq -0x18(%rax,%rcx,8), %rax
movl (%rdx,%r15,4), %ecx
movl (%rax,%r15,4), %esi
movl %esi, (%rdx,%r15,4)
movl %ecx, (%rax,%r15,4)
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
cmpb $0x0, (%rax)
jne 0x8ab0
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x9bdc
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
movb $0x1, (%rax)
movq %r12, %rdi
callq 0x74ca
testb %al, %al
jne 0x8bb3
movq %r12, %rdi
callq 0x5a36
cmpl 0x74(%rbx), %r13d
jge 0x8b82
movq %r12, %rdi
movq %r14, %rsi
callq 0x5952
leaq 0x48(%rsp), %rax
movups (%rax), %xmm0
leaq 0x18(%rsp), %rax
movups %xmm0, (%rax)
movl $0x1, 0x18(%rsp)
movq 0xc0(%rsp), %rax
cmpq 0xc8(%rsp), %rax
jne 0x8b0b
movq 0xd8(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x1e0, %ecx            # imm = 0x1E0
addq %rcx, %rax
addq $-0x28, %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
leaq (,%r13,2), %rcx
addq %r13, %rcx
movq (%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rax
movl (%rdx,%r15,4), %ecx
movl (%rax,%r15,4), %esi
movl %esi, (%rdx,%r15,4)
movl %ecx, (%rax,%r15,4)
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
cmpb $0x0, (%rax)
jne 0x8b7a
leaq 0xe0(%rsp), %rdi
movq %r12, %rsi
callq 0x9bdc
leaq 0x58(%rsp), %rdi
movq %r12, %rsi
callq 0x96c8
movb $0x1, (%rax)
movq %r12, %rdi
callq 0x74ca
testb %al, %al
jne 0x8bcd
movq %r12, %rdi
callq 0x5a36
movq %r14, %rdi
callq 0x5a36
movq 0xf0(%rsp), %r15
cmpq %r15, 0x110(%rsp)
setne %bpl
jne 0x880e
jmp 0x8bea
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x8cc4
jmp 0x8bd8
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x8cc4
jmp 0x8bd8
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x8cc4
jmp 0x8bd8
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x8cc4
movq %rsp, %rdi
callq 0x5a36
leaq 0x30(%rsp), %rdi
callq 0x5a36
leaq 0x58(%rsp), %rdi
callq 0x8db2
leaq 0x90(%rsp), %rdi
callq 0x8e4c
leaq 0xe0(%rsp), %rdi
callq 0x8e4c
andb $0x1, %bpl
movl %ebp, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8c28
movq %rax, %rdi
callq 0x563d