// File: /workspace/github_cpp_makefile_star2_O2/iTruth[P]klotski/klotski.cpp
// Function: search_answer(std::shared_ptr<klotski_board>, bool, bool, std::ostream&)
void search_answer(std::shared_ptr<klotski_board> board, bool is_quiet, bool is_print_board, std::ostream& os = std::cout){
	if(board == nullptr){
		throw std::logic_error("board not init");
	}
	if(!is_quiet){
		board->print_board(is_print_board);
	}
	auto s = std::make_shared<klotski_search>(board);
	if(!is_quiet){
		std::cout<<"searching..."<<std::endl;
	}
	if(s->start_search()){
		const auto& route = s->get_last_route();
		if(!is_quiet){
			std::cout<<"answer found!"<<std::endl;
			os<<"steps = "<<route.size() - 1<<std::endl<<std::endl;
		}
		int step = 0;
		for(const auto& i: route){
			os<<"step "<<step++<<": "<<std::endl;
			klotski_board::print_board(i, board->get_dx(), board->get_dy(), is_print_board, os);
			os<<std::endl;
		}
	}else{
		os<<"No solution"<<std::endl;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x3b38
movq %rcx, %rbx
movl %esi, %r15d
movzbl %dl, %esi
testb %r15b, %r15b
movl %esi, 0xc(%rsp)
je 0x39c5
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x48fa
jmp 0x39f9
movq (%rdi), %rax
movq 0xc5d9(%rip), %r12      # 0xffa8
movq %r12, %rdx
callq *0x8(%rax)
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x48fa
leaq 0x68c6(%rip), %rsi      # 0xa2af
movq %r12, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x30f0
movq 0x18(%rsp), %rdi
movq (%rdi), %rax
callq *(%rax)
testb %al, %al
je 0x3b08
movq 0x18(%rsp), %r12
testb %r15b, %r15b
jne 0x3a68
movq 0xc58c(%rip), %rdi      # 0xffa8
leaq 0x6899(%rip), %rsi      # 0xa2bc
callq 0x3240
movq %rax, %rdi
callq 0x30f0
leaq 0x6893(%rip), %rsi      # 0xa2ca
movq %rbx, %rdi
callq 0x3240
movq %rax, %r15
leaq 0x20(%r12), %rdi
callq 0x4918
leaq -0x1(%rax), %rsi
movq %r15, %rdi
callq 0x3160
movq %rax, %rdi
callq 0x30f0
movq %rax, %rdi
callq 0x30f0
movq 0x30(%r12), %r15
movq 0x40(%r12), %rbp
movq 0x48(%r12), %rax
movq %rax, 0x10(%rsp)
movq 0x50(%r12), %r13
xorl %r12d, %r12d
cmpq %r13, %r15
je 0x3b1f
movq %rbx, %rdi
leaq 0x683c(%rip), %rsi      # 0xa2d3
callq 0x3240
movq %rax, %rdi
movl %r12d, %esi
callq 0x33b0
movq %rax, %rdi
leaq 0x6947(%rip), %rsi      # 0xa3f8
callq 0x3240
movq %rax, %rdi
callq 0x30f0
movq (%r14), %rax
movl 0x8(%rax), %esi
movl 0xc(%rax), %edx
movq %r15, %rdi
movl 0xc(%rsp), %ecx
movq %rbx, %r8
callq 0x62d2
movq %rbx, %rdi
callq 0x30f0
addq $0x18, %r15
incl %r12d
cmpq %rbp, %r15
jne 0x3a84
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r15
addq $0x8, %rax
movq %rax, 0x10(%rsp)
leaq 0x1f8(%r15), %rbp
jmp 0x3a84
leaq 0x67ca(%rip), %rsi      # 0xa2d9
movq %rbx, %rdi
callq 0x3240
movq %rax, %rdi
callq 0x30f0
leaq 0x20(%rsp), %rdi
callq 0x4a42
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x3100
movq %rax, %r14
leaq 0x6756(%rip), %rsi      # 0xa2a0
movq %rax, %rdi
callq 0x32f0
movq 0xc46f(%rip), %rsi      # 0xffc8
movq 0xc438(%rip), %rdx      # 0xff98
movq %r14, %rdi
callq 0x33a0
movq %rax, %rbx
movq %r14, %rdi
callq 0x31a0
jmp 0x3b86
jmp 0x3b79
jmp 0x3b79
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x4a42
movq %rbx, %rdi
callq 0x33c0