// File: 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
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xa0(%rbp)
movb %dl, %al
movb %sil, %dl
movq %rdi, -0x8(%rbp)
andb $0x1, %dl
movb %dl, -0x9(%rbp)
andb $0x1, %al
movb %al, -0xa(%rbp)
movq %rcx, -0x18(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x5850
testb $0x1, %al
jne 0x3dd9
jmp 0x3e35
movl $0x10, %edi
callq 0x3130
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xa8(%rbp)
leaq 0x1453d(%rip), %rsi     # 0x18334
callq 0x3400
jmp 0x3dfe
movq -0xa8(%rbp), %rdi
movq 0x201bc(%rip), %rsi     # 0x23fc8
movq 0x20185(%rip), %rdx     # 0x23f98
callq 0x34b0
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x3210
jmp 0x411e
testb $0x1, -0x9(%rbp)
jne 0x3e60
movq -0xa0(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movb -0xa(%rbp), %cl
movq (%rdi), %rax
movq 0x20151(%rip), %rdx     # 0x23fa8
andb $0x1, %cl
movzbl %cl, %esi
callq *0x8(%rax)
movq -0xa0(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x58a0
testb $0x1, -0x9(%rbp)
jne 0x3ec3
movq 0x2012b(%rip), %rdi     # 0x23fa8
leaq 0x144bf(%rip), %rsi     # 0x18343
callq 0x32e0
movq %rax, -0xb0(%rbp)
jmp 0x3e92
movq -0xb0(%rbp), %rdi
movq 0x200d8(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x3ea7
jmp 0x3ec3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x5ac0
jmp 0x411e
leaq -0x38(%rbp), %rdi
callq 0x5910
movq %rax, %rdi
movq (%rdi), %rax
callq *(%rax)
testb $0x1, %al
jne 0x3edd
jmp 0x40dc
leaq -0x38(%rbp), %rdi
callq 0x5910
movq %rax, %rdi
callq 0x5930
movq %rax, -0x40(%rbp)
testb $0x1, -0x9(%rbp)
jne 0x3f9d
movq 0x200a5(%rip), %rdi     # 0x23fa8
leaq 0x14446(%rip), %rsi     # 0x18350
callq 0x32e0
movq %rax, -0xb8(%rbp)
jmp 0x3f18
movq -0xb8(%rbp), %rdi
movq 0x20052(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x3f2d
movq -0x18(%rbp), %rdi
leaq 0x14426(%rip), %rsi     # 0x1835e
callq 0x32e0
movq %rax, -0xc0(%rbp)
jmp 0x3f46
movq -0x40(%rbp), %rdi
callq 0x5950
movq -0xc0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x3080
movq %rax, -0xc8(%rbp)
jmp 0x3f6a
movq -0xc8(%rbp), %rdi
movq 0x20000(%rip), %rsi     # 0x23f78
callq 0x3320
movq %rax, -0xd0(%rbp)
jmp 0x3f86
movq -0xd0(%rbp), %rdi
movq 0x1ffe4(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x3f9b
jmp 0x3f9d
movl $0x0, -0x44(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x5980
movq -0x50(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x59b0
leaq -0x70(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x59e0
testb $0x1, %al
jne 0x3fe2
jmp 0x40da
leaq -0x70(%rbp), %rdi
callq 0x5a10
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rdi
leaq 0x1436a(%rip), %rsi     # 0x18367
callq 0x32e0
movq %rax, -0xd8(%rbp)
jmp 0x400b
movq -0xd8(%rbp), %rdi
movl -0x44(%rbp), %esi
movl %esi, %eax
incl %eax
movl %eax, -0x44(%rbp)
callq 0x34d0
movq %rax, -0xe0(%rbp)
jmp 0x402a
movq -0xe0(%rbp), %rdi
leaq 0x14454(%rip), %rsi     # 0x1848c
callq 0x32e0
movq %rax, -0xe8(%rbp)
jmp 0x4046
movq -0xe8(%rbp), %rdi
movq 0x1ff24(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x405b
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rax
movq %rax, -0xf8(%rbp)
callq 0x5880
movq %rax, %rdi
callq 0x5a30
movq -0xa0(%rbp), %rdi
movl %eax, -0xec(%rbp)
callq 0x5880
movq %rax, %rdi
callq 0x5a50
movq -0xf8(%rbp), %rdi
movl -0xec(%rbp), %esi
movl %eax, %edx
movq -0x18(%rbp), %r8
movzbl -0xa(%rbp), %ecx
andl $0x1, %ecx
callq 0xce80
jmp 0x40b8
movq -0x18(%rbp), %rdi
movq 0x1feb5(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x40ca
jmp 0x40cc
leaq -0x70(%rbp), %rdi
callq 0x5a70
jmp 0x3fc9
jmp 0x410c
movq -0x18(%rbp), %rdi
leaq 0x14286(%rip), %rsi     # 0x1836d
callq 0x32e0
movq %rax, -0x100(%rbp)
jmp 0x40f5
movq -0x100(%rbp), %rdi
movq 0x1fe75(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x410a
jmp 0x410c
leaq -0x38(%rbp), %rdi
callq 0x5ac0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x34e0
nopw (%rax,%rax)