// File: iTruth[P]klotski/klotski.cpp
// Function: main
int main(int argc, char *argv[])
{
	if(argc == 1){
		print_help();
		return EXIT_FAILURE;
	}

	int dx = 3;
	int dy = 3;
	bool is_play = false;
	bool is_upset = false;
	bool is_already_upset = false;
	int upset_num = 10;
	bool is_edit = false;
	std::string situation_string;
	bool is_search = false;
	bool is_quiet = false;
	bool is_print_board = false;
	bool is_output_to_file = false;
	std::fstream situation_output_file;
	bool is_read_board_from_file = false;
	std::fstream situation_input_file;
	bool is_research = false;

	const char *optstring = "x:y:pu:e::sqbo:f:rh";
	static struct option long_options[] = {
		{"play",		no_argument, NULL, 'p'},
		{"upset",		required_argument, NULL, 'u'},
		{"edit",		optional_argument, NULL, 'e'},
		{"search",		required_argument, NULL, 's'},
		{"quiet",		no_argument, NULL, 'q'},
		{"board",		no_argument, NULL, 'b'},
		{"output",		required_argument, NULL, 'o'},
		{"file",		required_argument, NULL, 'f'},
		{"research",	no_argument, NULL, 'r'},
		{"help",		no_argument, NULL, 'h'},
		{0, 0, 0, 0}};

	int opt;
	int option_index = 0;
	while((opt = getopt_long(argc, argv,
					optstring, long_options, &option_index)) != -1) {
		switch(opt)
		{
			case 'x':
				try{
					dx = std::stoi(optarg);
				}catch(const std::invalid_argument&){
					cout<<"Invalid argument: x"<<endl;
					return EXIT_FAILURE;
				}
				break;

			case 'y':
				try{
					dy = std::stoi(optarg);
				}catch(const std::invalid_argument&){
					cout<<"Invalid argument: y"<<endl;
					return EXIT_FAILURE;
				}
				break;

			case 'p':
				is_play = true;
				break;

			case 'u':
				is_upset = true;
				try{
					upset_num = std::stoi(optarg);
				}catch(const std::invalid_argument&){
					cout<<"Invalid argument: upset number"<<endl;
					return EXIT_FAILURE;
				}
				break;

			case 'e':
				is_edit = true;
				if(optarg != nullptr){
					situation_string = optarg;
				}
				break;

			case 's':
				is_search = true;
				break;

			case 'q':
				is_quiet = true;
				break;

			case 'b':
				is_print_board = true;
				break;

			case 'o':
				is_output_to_file = true;
				situation_output_file.open(optarg, ios::trunc|ios::out);
				if(!situation_output_file.is_open()){
					cout<<"file not found"<<endl;
					return EXIT_FAILURE;
				}
				break;

			case 'f':
				is_read_board_from_file = true;
				situation_input_file.open(optarg, ios::in);
				if(!situation_input_file.is_open()){
					cout<<"file not found"<<endl;
					return EXIT_FAILURE;
				}
				break;

			case 'r':
				is_research = true;
				break;

			case '?':
			case 'h':
			default:
				print_help();
				return EXIT_SUCCESS;
				break;
		}
	}

	if(is_output_to_file && !is_search){
		cout<<"specifying -o must also specify -s"<<endl;
		return EXIT_FAILURE;
	}

	std::shared_ptr<klotski_board> board = nullptr;

	if(is_read_board_from_file){
		if(is_edit){
			cout<<"specifying -f can't also specify -e"<<endl;
			return EXIT_FAILURE;
		}
		try{
			board = std::make_shared<klotski_board>(situation_input_file, dx, dy);
		}catch(const std::runtime_error&){
			cout<<"file is not a valid board file"<<endl;
			return EXIT_FAILURE;
		}
	}

	if(is_edit){
		try{
			if(situation_string.empty()){
				if(!is_quiet){
					cout<<"Enter "<<dx*dy<<" numbers to construct klotski board"<<endl
						<<"Example input(3x3 board): "<<endl
						<<"1 0 6 7 3 8 2 4 5"<<endl<<endl;
					cout<<"Enter: ";
				}
				std::vector<int> situation;
				for(int i=0; i<dx*dy; ++i){
					int n;
					cin>>n;
					situation.push_back(n);
				}
				board = std::make_shared<klotski_board>(situation, dx, dy);
			}else{
				board = std::make_shared<klotski_board>(situation_string, dx, dy);
			}
		}catch(const std::runtime_error& e){
			cout<<e.what()<<endl;
			return EXIT_FAILURE;
		}
	}

	if(is_upset){
		if(board == nullptr){
			board = std::make_shared<klotski_board>(dx, dy);
		}
		board->upset(upset_num);
		is_already_upset = true;
	}

	if(is_search){
		if(board == nullptr){
			board = std::make_shared<klotski_board>(dx, dy);
		}
		search_answer(board, is_quiet, is_print_board, KLOTSKI_OUTPUT_STREAM);
	}

	if(is_play || is_research){
		int x, y;
		if(board == nullptr){
			board = std::make_shared<klotski_board>(dx, dy);
		}
		if(!is_edit && !is_already_upset){
			board->upset(upset_num);
			is_already_upset = true;
		}
		board->print_board(is_print_board);
		string line;
		string hint = "klotski>";
		while(is_research || !board->is_win()){
			cout<<hint;
			getline(cin, line);
			if(line.empty()){
				continue;
			}
			std::stringstream ss(line);
			ss>>x>>y;
			if(board->move_item(x, y)){
				board->print_board(is_print_board);
				continue;
			}
			line = line.substr(0, line.find_last_not_of(' ')+1);
			auto pos = line.find_first_of(' ');
			const std::string cmd_name = line.substr(0, pos==std::string::npos?line.size():pos);
			const std::string cmd_arg = line.substr(cmd_name.size(), line.size()-1);
			if(cmd_name == "quit" || cmd_name == "q"){
				return EXIT_SUCCESS;
			}else if(cmd_name == "reset" || cmd_name == "r"){
				board->reset();
				if(!is_quiet){
					board->print_board(is_print_board);
				}
			}else if(cmd_name == "print" || cmd_name == "p"){
				board->print_board(is_print_board);
			}else if(cmd_name == "search" || cmd_name == "s"){
				search_answer(board, is_quiet, is_print_board, KLOTSKI_OUTPUT_STREAM);
			}else if(cmd_name == "upset" || cmd_name == "u"){
				try{
					board->upset(std::stoi(cmd_arg));
					if(!is_quiet){
						board->print_board(is_print_board);
					}
				}catch(const std::invalid_argument&){
					cout<<"invalid argument"<<endl
						<<"usage: upset N"<<endl<<endl;
				}
			}else{
				system(line.c_str());
			}
		}
		cout<<"You Win!"<<endl;
	}
	return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x9e0, %rsp            # imm = 0x9E0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x1, -0x8(%rbp)
jne 0x4160
callq 0x3720
movl $0x1, -0x4(%rbp)
jmp 0x57df
movl $0x3, -0x14(%rbp)
movl $0x3, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
movb $0x0, -0x1a(%rbp)
movb $0x0, -0x1b(%rbp)
movl $0xa, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x33e0
movb $0x0, -0x49(%rbp)
movb $0x0, -0x4a(%rbp)
movb $0x0, -0x4b(%rbp)
movb $0x0, -0x4c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x3390
jmp 0x41ac
movb $0x0, -0x26d(%rbp)
leaq -0x480(%rbp), %rdi
callq 0x3390
jmp 0x41c1
movb $0x0, -0x481(%rbp)
leaq 0x141aa(%rip), %rax     # 0x18379
movq %rax, -0x490(%rbp)
movl $0x0, -0x498(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x490(%rbp), %rdx
leaq 0x200bb(%rip), %rcx     # 0x242b0
leaq -0x498(%rbp), %r8
callq 0x3490
movl %eax, -0x494(%rbp)
cmpl $-0x1, %eax
je 0x4851
movl -0x494(%rbp), %eax
addl $-0x3f, %eax
movl %eax, %ecx
movq %rcx, -0x840(%rbp)
subl $0x3a, %eax
ja 0x482f
movq -0x840(%rbp), %rax
leaq 0x13dcb(%rip), %rcx     # 0x18004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x57d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x57c8
movq 0x1fd09(%rip), %rax     # 0x23f80
movq (%rax), %rax
movq %rax, -0x850(%rbp)
leaq -0x4b9(%rbp), %rdi
movq %rdi, -0x848(%rbp)
callq 0x34f0
movq -0x850(%rbp), %rsi
movq -0x848(%rbp), %rdx
leaq -0x4b8(%rbp), %rdi
callq 0x5b20
jmp 0x42b0
xorl %eax, %eax
movl %eax, %esi
leaq -0x4b8(%rbp), %rdi
movl $0xa, %edx
callq 0x5ae0
movl %eax, -0x854(%rbp)
jmp 0x42cd
movl -0x854(%rbp), %eax
movl %eax, -0x14(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x31a0
leaq -0x4b9(%rbp), %rdi
callq 0x3340
jmp 0x43da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x4325
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x4b8(%rbp), %rdi
callq 0x31a0
leaq -0x4b9(%rbp), %rdi
callq 0x3340
movl -0x26c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x57bc
movq -0x268(%rbp), %rdi
callq 0x30e0
movq %rax, -0x4c8(%rbp)
movq 0x1fc4a(%rip), %rdi     # 0x23fa8
leaq 0x14028(%rip), %rsi     # 0x1838d
callq 0x32e0
movq %rax, -0x860(%rbp)
jmp 0x4373
movq -0x860(%rbp), %rdi
movq 0x1fbf7(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x4388
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
callq 0x3480
jmp 0x43b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
callq 0x3480
jmp 0x43d5
jmp 0x5799
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x57bc
jmp 0x57bc
jmp 0x484c
movq 0x1fb9a(%rip), %rax     # 0x23f80
movq (%rax), %rax
movq %rax, -0x870(%rbp)
leaq -0x4f1(%rbp), %rdi
movq %rdi, -0x868(%rbp)
callq 0x34f0
movq -0x870(%rbp), %rsi
movq -0x868(%rbp), %rdx
leaq -0x4f0(%rbp), %rdi
callq 0x5b20
jmp 0x441f
xorl %eax, %eax
movl %eax, %esi
leaq -0x4f0(%rbp), %rdi
movl $0xa, %edx
callq 0x5ae0
movl %eax, -0x874(%rbp)
jmp 0x443c
movl -0x874(%rbp), %eax
movl %eax, -0x18(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x31a0
leaq -0x4f1(%rbp), %rdi
callq 0x3340
jmp 0x4532
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x4494
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x4f0(%rbp), %rdi
callq 0x31a0
leaq -0x4f1(%rbp), %rdi
callq 0x3340
movl -0x26c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x57bc
movq -0x268(%rbp), %rdi
callq 0x30e0
movq %rax, -0x500(%rbp)
movq 0x1fadb(%rip), %rdi     # 0x23fa8
leaq 0x13ecd(%rip), %rsi     # 0x183a1
callq 0x32e0
movq %rax, -0x880(%rbp)
jmp 0x44e2
movq -0x880(%rbp), %rdi
movq 0x1fa88(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x44f7
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
callq 0x3480
jmp 0x4528
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
callq 0x3480
jmp 0x452d
jmp 0x5799
jmp 0x57bc
jmp 0x484c
movb $0x1, -0x19(%rbp)
jmp 0x484c
movb $0x1, -0x1a(%rbp)
movq 0x1fa35(%rip), %rax     # 0x23f80
movq (%rax), %rax
movq %rax, -0x890(%rbp)
leaq -0x521(%rbp), %rdi
movq %rdi, -0x888(%rbp)
callq 0x34f0
movq -0x890(%rbp), %rsi
movq -0x888(%rbp), %rdx
leaq -0x520(%rbp), %rdi
callq 0x5b20
jmp 0x4584
xorl %eax, %eax
movl %eax, %esi
leaq -0x520(%rbp), %rdi
movl $0xa, %edx
callq 0x5ae0
movl %eax, -0x894(%rbp)
jmp 0x45a1
movl -0x894(%rbp), %eax
movl %eax, -0x20(%rbp)
leaq -0x520(%rbp), %rdi
callq 0x31a0
leaq -0x521(%rbp), %rdi
callq 0x3340
jmp 0x4697
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x45f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x520(%rbp), %rdi
callq 0x31a0
leaq -0x521(%rbp), %rdi
callq 0x3340
movl -0x26c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x57bc
movq -0x268(%rbp), %rdi
callq 0x30e0
movq %rax, -0x530(%rbp)
movq 0x1f976(%rip), %rdi     # 0x23fa8
leaq 0x13d7c(%rip), %rsi     # 0x183b5
callq 0x32e0
movq %rax, -0x8a0(%rbp)
jmp 0x4647
movq -0x8a0(%rbp), %rdi
movq 0x1f923(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x465c
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
callq 0x3480
jmp 0x468d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
callq 0x3480
jmp 0x4692
jmp 0x5799
jmp 0x57bc
jmp 0x484c
movb $0x1, -0x21(%rbp)
movq 0x1f8d9(%rip), %rax     # 0x23f80
cmpq $0x0, (%rax)
je 0x46c4
movq 0x1f8cc(%rip), %rax     # 0x23f80
movq (%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0x33d0
jmp 0x46c2
jmp 0x46c4
jmp 0x484c
movb $0x1, -0x49(%rbp)
jmp 0x484c
movb $0x1, -0x4a(%rbp)
jmp 0x484c
movb $0x1, -0x4b(%rbp)
jmp 0x484c
movb $0x1, -0x4c(%rbp)
movq 0x1f891(%rip), %rax     # 0x23f80
movq (%rax), %rax
movq %rax, -0x8b0(%rbp)
movl $0x20, %edi
movl $0x10, %esi
callq 0x5be0
movl %eax, -0x8a4(%rbp)
jmp 0x4710
movl -0x8a4(%rbp), %edx
movq -0x8b0(%rbp), %rsi
leaq -0x260(%rbp), %rdi
callq 0x32b0
jmp 0x472b
leaq -0x260(%rbp), %rdi
callq 0x34c0
movb %al, -0x8b1(%rbp)
jmp 0x473f
movb -0x8b1(%rbp), %al
testb $0x1, %al
jne 0x4792
jmp 0x474b
movq 0x1f856(%rip), %rdi     # 0x23fa8
leaq 0x13c7b(%rip), %rsi     # 0x183d4
callq 0x32e0
movq %rax, -0x8c0(%rbp)
jmp 0x4767
movq -0x8c0(%rbp), %rdi
movq 0x1f803(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x477c
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
jmp 0x5799
jmp 0x484c
movb $0x1, -0x26d(%rbp)
movq 0x1f7db(%rip), %rax     # 0x23f80
movq (%rax), %rsi
leaq -0x480(%rbp), %rdi
movl $0x8, %edx
callq 0x32b0
jmp 0x47bb
leaq -0x480(%rbp), %rdi
callq 0x34c0
movb %al, -0x8c1(%rbp)
jmp 0x47cf
movb -0x8c1(%rbp), %al
testb $0x1, %al
jne 0x4822
jmp 0x47db
movq 0x1f7c6(%rip), %rdi     # 0x23fa8
leaq 0x13beb(%rip), %rsi     # 0x183d4
callq 0x32e0
movq %rax, -0x8d0(%rbp)
jmp 0x47f7
movq -0x8d0(%rbp), %rdi
movq 0x1f773(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x480c
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
jmp 0x5799
jmp 0x484c
movb $0x1, -0x481(%rbp)
jmp 0x484c
jmp 0x482f
callq 0x3720
jmp 0x4836
movl $0x0, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
jmp 0x5799
jmp 0x41e0
testb $0x1, -0x4c(%rbp)
je 0x48a4
testb $0x1, -0x49(%rbp)
jne 0x48a4
movq 0x1f744(%rip), %rdi     # 0x23fa8
leaq 0x13b78(%rip), %rsi     # 0x183e3
callq 0x32e0
movq %rax, -0x8d8(%rbp)
jmp 0x4879
movq -0x8d8(%rbp), %rdi
movq 0x1f6f1(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x488e
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
jmp 0x5799
leaq -0x540(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5c00
testb $0x1, -0x26d(%rbp)
je 0x4a0c
testb $0x1, -0x21(%rbp)
je 0x4925
movq 0x1f6da(%rip), %rdi     # 0x23fa8
leaq 0x13b31(%rip), %rsi     # 0x18406
callq 0x32e0
movq %rax, -0x8e0(%rbp)
jmp 0x48e3
movq -0x8e0(%rbp), %rdi
movq 0x1f687(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x48f8
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
jmp 0x577d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x578b
leaq -0x550(%rbp), %rdi
leaq -0x480(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0x18(%rbp), %rcx
callq 0x5c20
jmp 0x4942
leaq -0x540(%rbp), %rdi
leaq -0x550(%rbp), %rsi
callq 0x5ca0
leaq -0x550(%rbp), %rdi
callq 0x5cd0
jmp 0x4a0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
movl -0x26c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x578b
movq -0x268(%rbp), %rdi
callq 0x30e0
movq %rax, -0x558(%rbp)
movq 0x1f603(%rip), %rdi     # 0x23fa8
leaq 0x13a7e(%rip), %rsi     # 0x1842a
callq 0x32e0
movq %rax, -0x8e8(%rbp)
jmp 0x49ba
movq -0x8e8(%rbp), %rdi
movq 0x1f5b0(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x49cf
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
callq 0x3480
jmp 0x4a00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
callq 0x3480
jmp 0x4a05
jmp 0x577d
jmp 0x578b
jmp 0x4a0c
testb $0x1, -0x21(%rbp)
je 0x4d05
leaq -0x48(%rbp), %rdi
callq 0x34a0
testb $0x1, %al
jne 0x4a28
jmp 0x4ca5
testb $0x1, -0x4a(%rbp)
jne 0x4b57
movq 0x1f56f(%rip), %rdi     # 0x23fa8
leaq 0x13a09(%rip), %rsi     # 0x18449
callq 0x32e0
movq %rax, -0x8f0(%rbp)
jmp 0x4a4e
movq -0x8f0(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %eax
imull %eax, %esi
callq 0x34d0
movq %rax, -0x8f8(%rbp)
jmp 0x4a6c
movq -0x8f8(%rbp), %rdi
leaq 0x139d6(%rip), %rsi     # 0x18450
callq 0x32e0
movq %rax, -0x900(%rbp)
jmp 0x4a88
movq -0x900(%rbp), %rdi
movq 0x1f4e2(%rip), %rsi     # 0x23f78
callq 0x3320
movq %rax, -0x908(%rbp)
jmp 0x4aa4
movq -0x908(%rbp), %rdi
leaq 0x139c2(%rip), %rsi     # 0x18474
callq 0x32e0
movq %rax, -0x910(%rbp)
jmp 0x4ac0
movq -0x910(%rbp), %rdi
movq 0x1f4aa(%rip), %rsi     # 0x23f78
callq 0x3320
movq %rax, -0x918(%rbp)
jmp 0x4adc
movq -0x918(%rbp), %rdi
leaq 0x139a5(%rip), %rsi     # 0x1848f
callq 0x32e0
movq %rax, -0x920(%rbp)
jmp 0x4af8
movq -0x920(%rbp), %rdi
movq 0x1f472(%rip), %rsi     # 0x23f78
callq 0x3320
movq %rax, -0x928(%rbp)
jmp 0x4b14
movq -0x928(%rbp), %rdi
movq 0x1f456(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x4b29
movq 0x1f478(%rip), %rdi     # 0x23fa8
leaq 0x1396a(%rip), %rsi     # 0x184a1
callq 0x32e0
jmp 0x4b3e
jmp 0x4b57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x4bdd
leaq -0x570(%rbp), %rdi
callq 0x5cf0
movl $0x0, -0x574(%rbp)
movl -0x574(%rbp), %eax
movl -0x14(%rbp), %ecx
imull -0x18(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4c5b
movq 0x1f44f(%rip), %rdi     # 0x23fd8
leaq -0x578(%rbp), %rsi
callq 0x3190
jmp 0x4b97
leaq -0x570(%rbp), %rdi
leaq -0x578(%rbp), %rsi
callq 0x5d10
jmp 0x4bac
jmp 0x4bae
movl -0x574(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x574(%rbp)
jmp 0x4b6d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x570(%rbp), %rdi
callq 0x5e00
movl -0x26c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x578b
movq -0x268(%rbp), %rdi
callq 0x30e0
movq %rax, -0x5a0(%rbp)
movq -0x5a0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, %rsi
movq 0x1f38b(%rip), %rdi     # 0x23fa8
callq 0x32e0
movq %rax, -0x930(%rbp)
jmp 0x4c2b
movq -0x930(%rbp), %rdi
movq 0x1f33f(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x4c40
movl $0x1, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
callq 0x3480
jmp 0x4cf9
leaq -0x588(%rbp), %rdi
leaq -0x570(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0x18(%rbp), %rcx
callq 0x5d80
jmp 0x4c78
leaq -0x540(%rbp), %rdi
leaq -0x588(%rbp), %rsi
callq 0x5ca0
leaq -0x588(%rbp), %rdi
callq 0x5cd0
leaq -0x570(%rbp), %rdi
callq 0x5e00
jmp 0x4cde
leaq -0x598(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x14(%rbp), %rdx
leaq -0x18(%rbp), %rcx
callq 0x5e60
jmp 0x4cbf
leaq -0x540(%rbp), %rdi
leaq -0x598(%rbp), %rsi
callq 0x5ca0
leaq -0x598(%rbp), %rdi
callq 0x5cd0
jmp 0x4d03
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
callq 0x3480
jmp 0x4cfe
jmp 0x577d
jmp 0x578b
jmp 0x4d05
testb $0x1, -0x1a(%rbp)
je 0x4d71
leaq -0x540(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5850
testb $0x1, %al
jne 0x4d21
jmp 0x4d56
leaq -0x5b0(%rbp), %rdi
leaq -0x14(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x5ee0
jmp 0x4d37
leaq -0x540(%rbp), %rdi
leaq -0x5b0(%rbp), %rsi
callq 0x5ca0
leaq -0x5b0(%rbp), %rdi
callq 0x5cd0
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movl -0x20(%rbp), %esi
callq 0xcd30
movb $0x1, -0x1b(%rbp)
testb $0x1, -0x49(%rbp)
je 0x4e73
leaq -0x540(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5850
testb $0x1, %al
jne 0x4d91
jmp 0x4dc6
leaq -0x5c0(%rbp), %rdi
leaq -0x14(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x5ee0
jmp 0x4da7
leaq -0x540(%rbp), %rdi
leaq -0x5c0(%rbp), %rsi
callq 0x5ca0
leaq -0x5c0(%rbp), %rdi
callq 0x5cd0
leaq -0x5d0(%rbp), %rdi
leaq -0x540(%rbp), %rsi
callq 0x5f60
movb -0x4a(%rbp), %al
movb %al, -0x932(%rbp)
movb -0x4b(%rbp), %al
movb %al, -0x931(%rbp)
testb $0x1, -0x4c(%rbp)
je 0x4e05
leaq -0x260(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x940(%rbp)
jmp 0x4e15
movq 0x1f19c(%rip), %rax     # 0x23fa8
movq %rax, -0x940(%rbp)
jmp 0x4e15
movb -0x931(%rbp), %al
movb -0x932(%rbp), %dl
movq -0x940(%rbp), %rcx
movzbl %dl, %esi
andl $0x1, %esi
movzbl %al, %edx
andl $0x1, %edx
leaq -0x5d0(%rbp), %rdi
callq 0x3da0
jmp 0x4e42
leaq -0x5d0(%rbp), %rdi
callq 0x5cd0
jmp 0x4e73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x5d0(%rbp), %rdi
callq 0x5cd0
jmp 0x578b
testb $0x1, -0x19(%rbp)
jne 0x4e86
testb $0x1, -0x481(%rbp)
je 0x576c
leaq -0x540(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5850
testb $0x1, %al
jne 0x4e9c
jmp 0x4ed1
leaq -0x5e8(%rbp), %rdi
leaq -0x14(%rbp), %rsi
leaq -0x18(%rbp), %rdx
callq 0x5ee0
jmp 0x4eb2
leaq -0x540(%rbp), %rdi
leaq -0x5e8(%rbp), %rsi
callq 0x5ca0
leaq -0x5e8(%rbp), %rdi
callq 0x5cd0
testb $0x1, -0x21(%rbp)
jne 0x4ef8
testb $0x1, -0x1b(%rbp)
jne 0x4ef8
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movl -0x20(%rbp), %esi
callq 0xcd30
movb $0x1, -0x1b(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
movzbl -0x4b(%rbp), %esi
andl $0x1, %esi
movq 0x1f08c(%rip), %rdx     # 0x23fa8
callq *%rax
leaq -0x608(%rbp), %rdi
callq 0x33e0
leaq -0x629(%rbp), %rdi
movq %rdi, -0x948(%rbp)
callq 0x34f0
movq -0x948(%rbp), %rdx
leaq 0x1355e(%rip), %rsi     # 0x184a9
leaq -0x628(%rbp), %rdi
callq 0x5b20
jmp 0x4f59
leaq -0x629(%rbp), %rdi
callq 0x3340
movb $0x1, %al
testb $0x1, -0x481(%rbp)
movb %al, -0x949(%rbp)
jne 0x4f92
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
callq 0xdb00
xorb $-0x1, %al
movb %al, -0x949(%rbp)
movb -0x949(%rbp), %al
testb $0x1, %al
jne 0x4fa1
jmp 0x56f1
movq 0x1f000(%rip), %rdi     # 0x23fa8
leaq -0x628(%rbp), %rsi
callq 0x32a0
jmp 0x4fb6
movq 0x1f01b(%rip), %rdi     # 0x23fd8
leaq -0x608(%rbp), %rsi
callq 0x3060
jmp 0x4fcb
leaq -0x608(%rbp), %rdi
callq 0x34a0
testb $0x1, %al
jne 0x4fdd
jmp 0x5019
jmp 0x4f65
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x629(%rbp), %rdi
callq 0x3340
jmp 0x575e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x5752
movl $0x10, %edi
movl $0x8, %esi
callq 0x5be0
movl %eax, -0x950(%rbp)
jmp 0x5030
movl -0x950(%rbp), %edx
leaq -0x7b8(%rbp), %rdi
leaq -0x608(%rbp), %rsi
callq 0x3460
jmp 0x504b
leaq -0x7b8(%rbp), %rdi
leaq -0x5d4(%rbp), %rsi
callq 0x3190
movq %rax, -0x958(%rbp)
jmp 0x5067
movq -0x958(%rbp), %rdi
leaq -0x5d8(%rbp), %rsi
callq 0x3190
jmp 0x507c
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movl -0x5d4(%rbp), %esi
movl -0x5d8(%rbp), %edx
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movb %al, -0x959(%rbp)
jmp 0x50a7
movb -0x959(%rbp), %al
testb $0x1, %al
jne 0x50b3
jmp 0x50fe
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movb -0x4b(%rbp), %cl
movq (%rdi), %rax
movq 0x1eed9(%rip), %rdx     # 0x23fa8
andb $0x1, %cl
movzbl %cl, %esi
callq *0x8(%rax)
movl $0x8, -0x4cc(%rbp)
jmp 0x5697
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x56e3
leaq -0x608(%rbp), %rdi
movq %rdi, -0x968(%rbp)
movl $0x20, %esi
movq $-0x1, %rdx
callq 0x31c0
movq -0x968(%rbp), %rsi
movq %rax, %rcx
incq %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x7d8(%rbp), %rdi
callq 0x3310
jmp 0x513c
leaq -0x608(%rbp), %rdi
leaq -0x7d8(%rbp), %rsi
callq 0x33a0
leaq -0x7d8(%rbp), %rdi
callq 0x31a0
leaq -0x608(%rbp), %rdi
movl $0x20, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x31b0
movq %rax, -0x7e0(%rbp)
cmpq $-0x1, -0x7e0(%rbp)
jne 0x5196
leaq -0x608(%rbp), %rdi
callq 0x31e0
movq %rax, -0x970(%rbp)
jmp 0x51a4
movq -0x7e0(%rbp), %rax
movq %rax, -0x970(%rbp)
movq -0x970(%rbp), %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x800(%rbp), %rdi
leaq -0x608(%rbp), %rsi
callq 0x3310
jmp 0x51c4
leaq -0x800(%rbp), %rdi
callq 0x31e0
movq %rax, -0x978(%rbp)
leaq -0x608(%rbp), %rdi
movq %rdi, -0x980(%rbp)
callq 0x31e0
movq -0x980(%rbp), %rsi
movq -0x978(%rbp), %rdx
movq %rax, %rcx
decq %rcx
leaq -0x820(%rbp), %rdi
callq 0x3310
jmp 0x520c
leaq 0x1329f(%rip), %rsi     # 0x184b2
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x981(%rbp)
jmp 0x5227
movb -0x981(%rbp), %al
testb $0x1, %al
jne 0x525a
jmp 0x5233
leaq 0x1327d(%rip), %rsi     # 0x184b7
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x982(%rbp)
jmp 0x524e
movb -0x982(%rbp), %al
testb $0x1, %al
jne 0x525a
jmp 0x529e
movl $0x0, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
jmp 0x567f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x56d7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x56cb
leaq 0x13214(%rip), %rsi     # 0x184b9
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x983(%rbp)
jmp 0x52b9
movb -0x983(%rbp), %al
testb $0x1, %al
jne 0x52ec
jmp 0x52c5
leaq 0x13106(%rip), %rsi     # 0x183d2
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x984(%rbp)
jmp 0x52e0
movb -0x984(%rbp), %al
testb $0x1, %al
jne 0x52ec
jmp 0x5330
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
callq 0xcbf0
testb $0x1, -0x4a(%rbp)
jne 0x532b
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movb -0x4b(%rbp), %cl
movq (%rdi), %rax
movq 0x1ec86(%rip), %rdx     # 0x23fa8
andb $0x1, %cl
movzbl %cl, %esi
callq *0x8(%rax)
jmp 0x5673
leaq 0x13188(%rip), %rsi     # 0x184bf
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x985(%rbp)
jmp 0x534b
movb -0x985(%rbp), %al
testb $0x1, %al
jne 0x537e
jmp 0x5357
leaq 0x12fd4(%rip), %rsi     # 0x18332
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x986(%rbp)
jmp 0x5372
movb -0x986(%rbp), %al
testb $0x1, %al
jne 0x537e
jmp 0x53a8
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movb -0x4b(%rbp), %cl
movq (%rdi), %rax
movq 0x1ec0e(%rip), %rdx     # 0x23fa8
andb $0x1, %cl
movzbl %cl, %esi
callq *0x8(%rax)
jmp 0x5671
leaq 0x12e95(%rip), %rsi     # 0x18244
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x987(%rbp)
jmp 0x53c3
movb -0x987(%rbp), %al
testb $0x1, %al
jne 0x53f9
jmp 0x53cf
leaq 0x1302e(%rip), %rsi     # 0x18404
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x988(%rbp)
jmp 0x53ea
movb -0x988(%rbp), %al
testb $0x1, %al
jne 0x53f9
jmp 0x54a9
leaq -0x830(%rbp), %rdi
leaq -0x540(%rbp), %rsi
callq 0x5f60
movb -0x4a(%rbp), %al
movb %al, -0x98a(%rbp)
movb -0x4b(%rbp), %al
movb %al, -0x989(%rbp)
testb $0x1, -0x4c(%rbp)
je 0x5438
leaq -0x260(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x998(%rbp)
jmp 0x5448
movq 0x1eb69(%rip), %rax     # 0x23fa8
movq %rax, -0x998(%rbp)
jmp 0x5448
movb -0x989(%rbp), %al
movb -0x98a(%rbp), %dl
movq -0x998(%rbp), %rcx
movzbl %dl, %esi
andl $0x1, %esi
movzbl %al, %edx
andl $0x1, %edx
leaq -0x830(%rbp), %rdi
callq 0x3da0
jmp 0x5475
leaq -0x830(%rbp), %rdi
callq 0x5cd0
jmp 0x566f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x830(%rbp), %rdi
callq 0x5cd0
jmp 0x56cb
leaq 0x12d4d(%rip), %rsi     # 0x181fd
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x999(%rbp)
jmp 0x54c4
movb -0x999(%rbp), %al
testb $0x1, %al
jne 0x54fa
jmp 0x54d0
leaq 0x12fee(%rip), %rsi     # 0x184c5
leaq -0x800(%rbp), %rdi
callq 0x5f90
movb %al, -0x99a(%rbp)
jmp 0x54eb
movb -0x99a(%rbp), %al
testb $0x1, %al
jne 0x54fa
jmp 0x5655
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, -0x9a8(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x820(%rbp), %rdi
movl $0xa, %edx
callq 0x5ae0
movl %eax, -0x9a0(%rbp)
jmp 0x552a
movl -0x9a0(%rbp), %esi
movq -0x9a8(%rbp), %rdi
callq 0xcd30
testb $0x1, -0x4a(%rbp)
jne 0x5638
leaq -0x540(%rbp), %rdi
callq 0x5880
movq %rax, %rdi
movb -0x4b(%rbp), %cl
movq (%rdi), %rax
movq 0x1ea46(%rip), %rdx     # 0x23fa8
andb $0x1, %cl
movzbl %cl, %esi
callq *0x8(%rax)
jmp 0x5638
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
movl -0x26c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x56cb
movq -0x268(%rbp), %rdi
callq 0x30e0
movq %rax, -0x838(%rbp)
movq 0x1e9f9(%rip), %rdi     # 0x23fa8
leaq 0x12f11(%rip), %rsi     # 0x184c7
callq 0x32e0
movq %rax, -0x9b0(%rbp)
jmp 0x55c4
movq -0x9b0(%rbp), %rdi
movq 0x1e9a6(%rip), %rsi     # 0x23f78
callq 0x3320
movq %rax, -0x9b8(%rbp)
jmp 0x55e0
movq -0x9b8(%rbp), %rdi
leaq 0x12eea(%rip), %rsi     # 0x184d8
callq 0x32e0
movq %rax, -0x9c0(%rbp)
jmp 0x55fc
movq -0x9c0(%rbp), %rdi
movq 0x1e96e(%rip), %rsi     # 0x23f78
callq 0x3320
movq %rax, -0x9c8(%rbp)
jmp 0x5618
movq -0x9c8(%rbp), %rdi
movq 0x1e952(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x562d
callq 0x3480
jmp 0x5634
jmp 0x5636
jmp 0x566d
jmp 0x5636
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
callq 0x3480
jmp 0x5653
jmp 0x56cb
leaq -0x608(%rbp), %rdi
callq 0x30f0
movq %rax, %rdi
callq 0x3270
jmp 0x566b
jmp 0x566d
jmp 0x566f
jmp 0x5671
jmp 0x5673
jmp 0x5675
movl $0x0, -0x4cc(%rbp)
leaq -0x820(%rbp), %rdi
callq 0x31a0
leaq -0x800(%rbp), %rdi
callq 0x31a0
leaq -0x7b8(%rbp), %rdi
callq 0x3230
movl -0x4cc(%rbp), %eax
movl %eax, -0x9cc(%rbp)
testl %eax, %eax
je 0x56c6
jmp 0x56b5
movl -0x9cc(%rbp), %eax
subl $0x8, %eax
je 0x4f65
jmp 0x572c
jmp 0x4f65
leaq -0x820(%rbp), %rdi
callq 0x31a0
leaq -0x800(%rbp), %rdi
callq 0x31a0
leaq -0x7b8(%rbp), %rdi
callq 0x3230
jmp 0x5752
movq 0x1e8b0(%rip), %rdi     # 0x23fa8
leaq 0x12de8(%rip), %rsi     # 0x184e7
callq 0x32e0
movq %rax, -0x9d8(%rbp)
jmp 0x570d
movq -0x9d8(%rbp), %rdi
movq 0x1e85d(%rip), %rsi     # 0x23f78
callq 0x3320
jmp 0x5722
movl $0x0, -0x4cc(%rbp)
leaq -0x628(%rbp), %rdi
callq 0x31a0
leaq -0x608(%rbp), %rdi
callq 0x31a0
movl -0x4cc(%rbp), %eax
testl %eax, %eax
jne 0x577d
jmp 0x5750
jmp 0x576c
leaq -0x628(%rbp), %rdi
callq 0x31a0
leaq -0x608(%rbp), %rdi
callq 0x31a0
jmp 0x578b
movl $0x0, -0x4(%rbp)
movl $0x1, -0x4cc(%rbp)
leaq -0x540(%rbp), %rdi
callq 0x5cd0
jmp 0x5799
leaq -0x540(%rbp), %rdi
callq 0x5cd0
jmp 0x57bc
leaq -0x480(%rbp), %rdi
callq 0x3070
leaq -0x260(%rbp), %rdi
callq 0x3070
leaq -0x48(%rbp), %rdi
callq 0x31a0
jmp 0x57df
leaq -0x480(%rbp), %rdi
callq 0x3070
leaq -0x260(%rbp), %rdi
callq 0x3070
leaq -0x48(%rbp), %rdi
callq 0x31a0
jmp 0x57eb
movl -0x4(%rbp), %eax
addq $0x9e0, %rsp            # imm = 0x9E0
popq %rbp
retq
movq -0x268(%rbp), %rdi
callq 0x34e0
movq %rax, %rdi
callq 0x5bd0
nop