// File: /workspace/github_cpp_makefile_star2_O2/mbourand[P]webserv/srcs/Methods/GetMethod.cpp
// Function: GetMethod::process(Request const&, ConfigContext const&, ServerSocket const&)
Response GetMethod::process(const Request& request, const ConfigContext& config, const ServerSocket& socket)
{
	const URL& url = request._url;
	Response response(200, url._path);
	response.setCompression(request._headers);
	int base_depth = 0;
	std::string realPath = config.rootPath(url._path, base_depth);
	try
	{
		realPath = ft::simplify_path(realPath, true, base_depth);
	}
	catch (std::exception& e)
	{
		return Logger::print("Path is not safe", response.setCode(400), ERROR, VERBOSE);
	}

	if (realPath[0] != '/')
		realPath = g_webserv.cwd + "/" + realPath;

	if (ft::is_directory(realPath))
	{
		try
		{
			std::string index = "/" + config.getParam("index").front();
			realPath += index;
			std::string extension = index.substr(index.rfind('.'));
			if (config.getCGIExtensions().find(extension) != config.getCGIExtensions().end() || (realPath.find(config.getParam("cgi_dir").front()) == 0))
				return process_cgi(realPath, url, config, socket, request);
		}
		catch (std::exception& e)
		{
			if (config.hasAutoIndex())
				return directory_listing(request, config, realPath);
			if (!url._is_directory)
			{
				response.addHeader("Location", url._path + "/");
				return response.setCode(301);
			}
		}
	}
	else if (url._is_directory)
		return Logger::print("File not found", response.setCode(404), ERROR, VERBOSE);


	std::list<std::string> splitted = ft::split(realPath, '/');
	std::string current_path;
	current_path.reserve(realPath.size());
	if (realPath[0] == '/')
		current_path.push_back('/');
	for (std::list<std::string>::iterator it = splitted.begin();it != splitted.end(); it++, current_path.push_back('/'))
	{
		current_path += *it;
		if (!ft::is_regular_file(current_path))
			continue;
		std::string file_name;
		if (ft::contains(current_path, '/'))
			file_name = current_path.substr(current_path.rfind('/'));
		else
			file_name = current_path;
		if (file_name.rfind('.') != std::string::npos)
		{
			std::string extension = file_name.substr(file_name.rfind('.'));
			if (config.getCGIExtensions().find(extension) != config.getCGIExtensions().end() || (realPath.find(config.getParam("cgi_dir").front()) == 0))
				return process_cgi(realPath, url, config, socket, request);
		}
	}

	std::fstream file;
	if (!request.getHeaderValue("Accept-Language").empty())
	{
		std::string filename = realPath.substr((realPath.rfind('/') == std::string::npos ? 0 : realPath.rfind('/')));
		std::string folder = (realPath.size() == filename.size() ? "" : realPath.substr(0, realPath.rfind(filename))) + "/.langs/";

		if (ft::is_directory(folder))
		{
			AcceptLanguageHeader* ach;
			for (Request::HeadersVector::const_iterator it = request._headers.begin(); it != request._headers.end(); it++)
				if ((*it)->getType() == AcceptLanguageHeader().getType())
					ach = reinterpret_cast<AcceptLanguageHeader*>(*it);

			std::multimap<float, std::string, std::greater<float> > language_preferences = ach->getPreferences();
			for (std::map<float, std::string, std::greater<float> >::const_iterator it = language_preferences.begin(); it != language_preferences.end(); it++)
			{
				if (g_webserv.languages->GetNode(it->second) == NULL)
					continue;

				file.open((folder + it->second + "/" + filename).c_str());
				if (file.good() && file.is_open())
				{
					response.addHeader("Content-Language", it->second);
					break;
				}
			}
		}
	}

	if (!file.good() || !file.is_open())
	{
		file.open(realPath.c_str());
		if (!file.good() || !file.is_open())
		{
			if (errno == ENOENT || errno == ENOTDIR)
				return Logger::print("File not found", response.setCode(404), ERROR, VERBOSE);
			if (errno == EACCES || errno == EISDIR)
				return Logger::print("Permission denied", response.setCode(403), ERROR, VERBOSE);
			return Logger::print("Unexpected error while trying to open file: " + std::string(strerror(errno)), response.setCode(500), ERROR, VERBOSE);
		}
	}


	std::string content((std::istreambuf_iterator<char>(file)), (std::istreambuf_iterator<char>()));
	std::ostringstream convert;
	struct stat file_stats;

	lstat(realPath.c_str(), &file_stats);
	convert << file_stats.st_size;
	response.addHeader("Content-Length", convert.str());
	convert.str("");


	convert << file_stats.st_mtime;
	struct tm	time;
	strptime(std::string(convert.str()).c_str(), "%s", &time);
	if (time.tm_gmtoff > 0) // convert to GMT
		file_stats.st_mtim.tv_sec -= time.tm_gmtoff;
	if (time.tm_isdst) // substract Daylight saving time
		file_stats.st_mtim.tv_sec -= 3600;
	convert.str("");

	convert << file_stats.st_mtime;
	strptime(std::string(convert.str()).c_str(), "%s", &time);
	char		buffer[1024];
	strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S GMT", &time);
	response.addHeader("Last-Modified", buffer);
	convert.str("");


	response.addDateHeader();
	response.addHeader("Server", "Webserv");
	t_hnode	*hnode = g_webserv.file_formatname->GetNode(realPath.substr(realPath.find_last_of('.') + 1));
	if (hnode != NULL)
		response.addHeader("Content-Type", hnode->value + "; charset=UTF-8");


	response.setBody(content);

	return (response);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe18, %rsp            # imm = 0xE18
movq %r8, 0xa0(%rsp)
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, 0x10(%rsp)
leaq 0xb8(%rdx), %r13
leaq 0x218(%rsp), %rbx
movq %rbx, %rdi
movl $0xc8, %esi
movq %r13, %rdx
callq 0x2a080
movq %r14, 0x20(%rsp)
leaq 0x140(%r14), %rsi
movq %rbx, %rdi
callq 0x2a838
leaq 0x74(%rsp), %rcx
andl $0x0, (%rcx)
leaq 0x30(%rsp), %rdi
movq %r15, 0x18(%rsp)
movq %r15, %rsi
movq %r13, %rdx
callq 0x21a22
movl 0x74(%rsp), %ecx
leaq 0x6f0(%rsp), %rdi
leaq 0x30(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x17b31
leaq 0x30(%rsp), %rbx
leaq 0x6f0(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x75f0
movq %r14, %rdi
callq 0x79b8
movq (%rbx), %rax
cmpb $0x2f, (%rax)
je 0xa856
leaq 0x38db6(%rip), %rsi     # 0x435b0
addq $0x48, %rsi
leaq 0x22243(%rip), %rdx     # 0x2ca48
leaq 0x4c0(%rsp), %rdi
callq 0xc1e9
leaq 0x6f0(%rsp), %rdi
leaq 0x4c0(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0xc1ca
leaq 0x30(%rsp), %rdi
leaq 0x6f0(%rsp), %rbx
movq %rbx, %rsi
callq 0x75f0
movq %rbx, %rdi
callq 0x79b8
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x1d8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x7690
leaq 0x1d8(%rsp), %rdi
callq 0x17813
movl %eax, %ebx
movq 0x20(%rsp), %r14
leaq 0x30(%r14), %rax
movq %rax, 0x98(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x79b8
testb %bl, %bl
je 0xa9b3
leaq 0x2444f(%rip), %rsi     # 0x2ecf3
leaq 0x4c0(%rsp), %rdi
leaq 0x348(%rsp), %rdx
callq 0x8032
leaq 0x4c0(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x2167a
movq (%rax), %rdx
addq $0x10, %rdx
leaq 0x2216f(%rip), %rsi     # 0x2ca48
leaq 0x6f0(%rsp), %rdi
callq 0xc154
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x30(%rsp), %rdi
leaq 0x6f0(%rsp), %rsi
callq 0x7950
leaq 0x6f0(%rsp), %rbx
pushq $0x2e
popq %rsi
pushq $-0x1
popq %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x7970
leaq 0x4c0(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x7540
movq 0x18(%rsp), %rdi
movq 0xa0(%rsp), %r14
callq 0x21648
leaq 0x4c0(%rsp), %rsi
movq %rax, %rdi
callq 0xcdc8
movq %rax, %rbx
movq 0x18(%rsp), %rdi
callq 0x21648
addq $0x8, %rax
cmpq %rax, %rbx
je 0xaa3e
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rdi
movq 0x98(%rsp), %rcx
movq 0x18(%rsp), %r8
movq %r14, %r9
callq 0xbc76
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
jmp 0xaa34
cmpb $0x1, 0x118(%r14)
jne 0xaab2
leaq 0x21d01(%rip), %rsi     # 0x2c6c9
leaq 0x1b8(%rsp), %rdi
leaq 0x6f0(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
movl $0x194, %esi            # imm = 0x194
callq 0x2a818
leaq 0xcd8(%rsp), %rdi
movq %rax, %rsi
callq 0x29f62
leaq 0x1b8(%rsp), %rsi
leaq 0xcd8(%rsp), %rdx
pushq $0x3
popq %rcx
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
callq 0xc0bc
leaq 0xcd8(%rsp), %rdi
callq 0x29f10
leaq 0x1b8(%rsp), %rdi
callq 0x79b8
jmp 0xb6c3
leaq 0x21c7c(%rip), %rsi     # 0x2c6c1
leaq 0x348(%rsp), %rdi
leaq 0x2b8(%rsp), %rdx
callq 0x8032
leaq 0x348(%rsp), %rsi
movq 0x18(%rsp), %rdi
callq 0x2167a
movq (%rax), %rsi
addq $0x10, %rsi
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x7990
movq %rax, %rbx
leaq 0x348(%rsp), %rdi
callq 0x79b8
testq %rbx, %rbx
je 0xa971
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdx
movb $0x2f, (%rdx)
leaq 0x100(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x16fd4
leaq 0x128(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x38(%rsp), %rsi
leaq 0x118(%rsp), %rdi
callq 0x7760
movq 0x30(%rsp), %rax
cmpb $0x2f, (%rax)
jne 0xab0f
leaq 0x118(%rsp), %rdi
pushq $0x2f
popq %rsi
callq 0x7480
movq 0x100(%rsp), %r12
leaq 0x118(%rsp), %rbx
leaq 0x6d0(%rsp), %r15
leaq 0x4c0(%rsp), %rbp
leaq 0x100(%rsp), %rax
cmpq %rax, %r12
je 0xace8
leaq 0x10(%r12), %rsi
movq %rbx, %rdi
callq 0x7950
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7690
movq %r15, %rdi
callq 0x179a4
movl %eax, %r14d
movq %r15, %rdi
callq 0x79b8
testb %r14b, %r14b
je 0xacd4
leaq 0x700(%rsp), %rax
movq %rax, 0x6f0(%rsp)
andq $0x0, 0x6f8(%rsp)
movb $0x0, 0x700(%rsp)
movb $0x2f, 0x4c0(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xc288
testb %al, %al
je 0xabec
movq %rbx, %rdi
pushq $0x2f
popq %rsi
pushq $-0x1
popq %r14
movq %r14, %rdx
callq 0x7970
movq %rbp, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x7540
leaq 0x6f0(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
callq 0x75f0
movq %rbp, %rdi
callq 0x79b8
jmp 0xabff
leaq 0x6f0(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x7300
movq %r13, %rdi
pushq $0x2e
popq %rsi
pushq $-0x1
popq %rdx
callq 0x7970
cmpq $-0x1, %rax
je 0xaccc
movq %r13, %rdi
pushq $0x2e
popq %rsi
pushq $-0x1
popq %r14
movq %r14, %rdx
callq 0x7970
movq %rbp, %rdi
movq %r13, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x7540
movq 0x18(%rsp), %rdi
callq 0x21648
movq %rax, %rdi
movq %rbp, %rsi
callq 0xcdc8
movq %rax, %r14
movq 0x18(%rsp), %rdi
callq 0x21648
addq $0x8, %rax
cmpq %rax, %r14
jne 0xad7d
leaq 0x348(%rsp), %r13
movq %r13, %rdi
leaq 0x21a46(%rip), %rsi     # 0x2c6c1
leaq 0x2b8(%rsp), %rdx
callq 0x8032
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x2167a
movq (%rax), %rsi
addq $0x10, %rsi
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x7990
movq %rax, %r14
movq %r13, %rdi
callq 0x79b8
testq %r14, %r14
je 0xad7d
movq %rbp, %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %r13
movq %r13, %rdi
callq 0x79b8
movq (%r12), %r12
movq %rbx, %rdi
pushq $0x2f
popq %rsi
callq 0x7480
jmp 0xab2f
leaq 0x4c0(%rsp), %rdi
callq 0x75b0
leaq 0x21380(%rip), %rsi     # 0x2c07c
leaq 0x348(%rsp), %rdi
leaq 0x2b8(%rsp), %rdx
callq 0x8032
leaq 0x6f0(%rsp), %rdi
leaq 0x348(%rsp), %rdx
movq 0x20(%rsp), %rsi
callq 0x292c2
leaq 0x6f0(%rsp), %rdi
movq 0x8(%rdi), %rbx
callq 0x79b8
leaq 0x348(%rsp), %rdi
callq 0x79b8
testq %rbx, %rbx
je 0xb087
leaq 0x30(%rsp), %rdi
pushq $0x2f
popq %rsi
pushq $-0x1
popq %rdx
callq 0x7970
cmpq $-0x1, %rax
je 0xadc9
leaq 0x30(%rsp), %rdi
pushq $0x2f
popq %rsi
pushq $-0x1
popq %rdx
callq 0x7970
movq %rax, %rdx
jmp 0xadcb
movq 0x20(%rsp), %rax
movq %rax, (%rsp)
leaq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rdi
movq 0x98(%rsp), %rcx
movq 0x18(%rsp), %r8
movq 0xa0(%rsp), %r9
callq 0xbc76
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
jmp 0xb6a9
xorl %edx, %edx
leaq 0x348(%rsp), %rdi
leaq 0x30(%rsp), %rsi
pushq $-0x1
popq %rcx
callq 0x7540
movq 0x38(%rsp), %r14
movq 0x350(%rsp), %r15
cmpq %r15, %r14
jne 0xae0d
leaq 0x21f56(%rip), %rsi     # 0x2cd4f
leaq 0x6f0(%rsp), %rdi
leaq 0x2f(%rsp), %rdx
callq 0x8032
jmp 0xae3a
leaq 0x30(%rsp), %rbx
leaq 0x348(%rsp), %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x7400
leaq 0x6f0(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x7540
leaq 0x21897(%rip), %rdx     # 0x2c6d8
leaq 0x2b8(%rsp), %rdi
leaq 0x6f0(%rsp), %rsi
callq 0xbe83
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
cmpq %r15, %r14
leaq 0x198(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x7690
leaq 0x198(%rsp), %rdi
callq 0x17813
movl %eax, %ebx
leaq 0x198(%rsp), %rdi
callq 0x79b8
testb %bl, %bl
je 0xb06d
movq 0x20(%rsp), %rax
movq 0x140(%rax), %r13
leaq 0xa8(%rsp), %r14
leaq 0x6f0(%rsp), %r15
leaq 0xe0(%rsp), %r12
movq 0x20(%rsp), %rax
cmpq 0x148(%rax), %r13
je 0xaf25
movq (%r13), %rsi
movq (%rsi), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %r15, %rdi
callq 0x81ac
movq %r12, %rdi
movq %r15, %rsi
callq 0x81f8
movq %r14, %rdi
movq %r12, %rsi
callq 0xc2ad
movl %eax, %ebp
movq %r12, %rdi
callq 0x79b8
movq %r15, %rdi
callq 0x81d8
movq %r14, %rdi
callq 0x79b8
testb %bpl, %bpl
je 0xaf1f
movq (%r13), %rbx
addq $0x8, %r13
jmp 0xaec3
movq (%rbx), %rax
leaq 0x6f0(%rsp), %rdi
movq %rbx, %rsi
callq *0x28(%rax)
leaq 0x6f8(%rsp), %r13
movq 0x10(%r13), %r14
leaq 0x50(%rsp), %r15
leaq 0xe0(%rsp), %rbp
leaq 0xa8(%rsp), %rbx
cmpq %r13, %r14
je 0xb060
leaq 0x38649(%rip), %rax     # 0x435b0
movq 0x10(%rax), %rdi
leaq 0x28(%r14), %r12
movq %r12, %rsi
callq 0x13334
testq %rax, %rax
je 0xb00f
movq %r15, %rdi
leaq 0x2b8(%rsp), %rsi
movq %r12, %rdx
callq 0xc2d6
movq %rbp, %rdi
movq %r15, %rsi
leaq 0x21aa8(%rip), %rdx     # 0x2ca48
callq 0xbe83
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x348(%rsp), %rdx
callq 0xc1ca
movq 0xa8(%rsp), %rsi
leaq 0x4c0(%rsp), %rdi
pushq $0x18
popq %rdx
callq 0x74d0
movq %rbx, %rdi
callq 0x79b8
movq %rbp, %rdi
callq 0x79b8
movq %r15, %rdi
callq 0x79b8
movq 0x4c0(%rsp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x4e0(%rsp,%rax)
jne 0xb00f
leaq 0x540(%rsp), %rdi
callq 0x7130
testb %al, %al
jne 0xb01f
movq %r14, %rdi
callq 0x7580
movq %rax, %r14
jmp 0xaf57
leaq 0x210b5(%rip), %rsi     # 0x2c0db
leaq 0xa8(%rsp), %rdi
leaq 0xe0(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movq %r12, %rdx
callq 0x2a124
leaq 0xa8(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
callq 0x8ffa
leaq 0x2b8(%rsp), %rdi
callq 0x79b8
leaq 0x348(%rsp), %rdi
callq 0x79b8
movq 0x4c0(%rsp), %rax
movq -0x18(%rax), %rbx
cmpl $0x0, 0x4e0(%rsp,%rbx)
jne 0xb0ae
leaq 0x540(%rsp), %rdi
callq 0x7130
testb %al, %al
jne 0xb0f2
movq 0x30(%rsp), %rsi
leaq 0x4c0(%rsp), %rdi
pushq $0x18
popq %rdx
callq 0x74d0
movq 0x4c0(%rsp), %rax
movq -0x18(%rax), %rbx
cmpl $0x0, 0x4e0(%rsp,%rbx)
jne 0xb4e3
leaq 0x540(%rsp), %rdi
callq 0x7130
testb %al, %al
je 0xb4e3
movq 0x5a8(%rsp,%rbx), %rsi
leaq 0xf0(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xe0(%rsp), %rdi
pushq $-0x1
popq %rdx
xorl %ecx, %ecx
movl %edx, %r8d
callq 0xcee8
leaq 0x348(%rsp), %rdi
callq 0x7670
movq 0x30(%rsp), %rdi
leaq 0x2b8(%rsp), %rbx
movq %rbx, %rsi
callq 0x7940
movq 0x30(%rbx), %rsi
leaq 0x348(%rsp), %rdi
callq 0x74f0
leaq 0x20faf(%rip), %rsi     # 0x2c104
leaq 0x6f0(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x8032
leaq 0x350(%rsp), %r14
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x7780
leaq 0x218(%rsp), %rdi
leaq 0x6f0(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x2a124
leaq 0xa8(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
leaq 0x21b92(%rip), %rsi     # 0x2cd4f
leaq 0x6f0(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
callq 0x8032
leaq 0x6f0(%rsp), %rsi
movq %r14, %rdi
callq 0x7720
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
movq 0x310(%rsp), %rbx
leaq 0x348(%rsp), %rdi
movq %rbx, %rsi
callq 0x74f0
leaq 0x6f0(%rsp), %rdi
movq %r14, %rsi
callq 0x7780
leaq 0x6f0(%rsp), %r15
movq (%r15), %rdi
leaq 0x21130(%rip), %rsi     # 0x2c359
leaq 0xa8(%rsp), %r12
movq %r12, %rdx
callq 0x70a0
movq %r15, %rdi
callq 0x79b8
movq 0x28(%r12), %rax
testq %rax, %rax
jle 0xb256
subq %rax, %rbx
movq %rbx, 0x310(%rsp)
cmpl $0x0, 0xc8(%rsp)
je 0xb26f
addq $-0xe10, %rbx           # imm = 0xF1F0
movq %rbx, 0x310(%rsp)
leaq 0x21ad9(%rip), %rsi     # 0x2cd4f
leaq 0x6f0(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x8032
leaq 0x6f0(%rsp), %rsi
movq %r14, %rdi
callq 0x7720
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
leaq 0x348(%rsp), %rdi
movq %rbx, %rsi
callq 0x74f0
leaq 0x6f0(%rsp), %rdi
movq %r14, %rsi
callq 0x7780
leaq 0x6f0(%rsp), %rbx
movq (%rbx), %rdi
leaq 0x21082(%rip), %rsi     # 0x2c359
leaq 0xa8(%rsp), %r15
movq %r15, %rdx
callq 0x70a0
movq %rbx, %rdi
callq 0x79b8
leaq 0x21418(%rip), %rdx     # 0x2c70e
leaq 0x6f0(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %rcx
callq 0x7440
leaq 0x20eb9(%rip), %rsi     # 0x2c1cb
leaq 0x50(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x8032
leaq 0x78(%rsp), %rdi
leaq 0x6f0(%rsp), %rsi
leaq 0xf(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x2a124
leaq 0x78(%rsp), %rdi
callq 0x79b8
leaq 0x50(%rsp), %rdi
callq 0x79b8
leaq 0x219e5(%rip), %rsi     # 0x2cd4f
leaq 0x50(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x8032
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x7720
leaq 0x50(%rsp), %rdi
callq 0x79b8
leaq 0x218(%rsp), %rdi
callq 0x2a2f0
leaq 0x20ea8(%rip), %rsi     # 0x2c24c
leaq 0x50(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x8032
leaq 0x217d6(%rip), %rsi     # 0x2cb90
leaq 0x78(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x2a124
leaq 0x78(%rsp), %rdi
callq 0x79b8
leaq 0x50(%rsp), %rdi
callq 0x79b8
leaq 0x381b5(%rip), %rax     # 0x435b0
movq 0x8(%rax), %rbx
leaq 0x30(%rsp), %r14
pushq $0x2e
popq %rsi
pushq $-0x1
popq %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x7970
leaq 0x1(%rax), %rdx
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movq %r15, %rcx
callq 0x7540
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x13334
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x79b8
testq %rbx, %rbx
je 0xb4a2
leaq 0x20d02(%rip), %rsi     # 0x2c152
leaq 0x50(%rsp), %rdi
leaq 0xe(%rsp), %rdx
callq 0x8032
addq $0x20, %rbx
leaq 0x21236(%rip), %rdx     # 0x2c6a0
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0xc1e9
leaq 0x218(%rsp), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x78(%rsp), %rdx
callq 0x2a124
leaq 0x78(%rsp), %rdi
callq 0x79b8
leaq 0x50(%rsp), %rdi
callq 0x79b8
leaq 0x218(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2a82e
leaq 0x218(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x29f62
leaq 0x348(%rsp), %rdi
callq 0x7140
leaq 0xe0(%rsp), %rdi
jmp 0xb697
callq 0x7060
movl (%rax), %edi
cmpl $0x2, %edi
je 0xb50a
cmpl $0xd, %edi
je 0xb582
cmpl $0x15, %edi
je 0xb582
cmpl $0x14, %edi
jne 0xb5fa
leaq 0x211b8(%rip), %rsi     # 0x2c6c9
leaq 0x178(%rsp), %rdi
leaq 0x6f0(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
movl $0x194, %esi            # imm = 0x194
callq 0x2a818
leaq 0xc38(%rsp), %rdi
movq %rax, %rsi
callq 0x29f62
leaq 0x178(%rsp), %rsi
leaq 0xc38(%rsp), %rdx
pushq $0x3
popq %rcx
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
callq 0xc0bc
leaq 0xc38(%rsp), %rdi
callq 0x29f10
leaq 0x178(%rsp), %rdi
jmp 0xb697
leaq 0x20de7(%rip), %rsi     # 0x2c370
leaq 0x158(%rsp), %rdi
leaq 0x6f0(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
movl $0x193, %esi            # imm = 0x193
callq 0x2a818
leaq 0xb98(%rsp), %rdi
movq %rax, %rsi
callq 0x29f62
leaq 0x158(%rsp), %rsi
leaq 0xb98(%rsp), %rdx
pushq $0x3
popq %rcx
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
callq 0xc0bc
leaq 0xb98(%rsp), %rdi
callq 0x29f10
leaq 0x158(%rsp), %rdi
jmp 0xb697
callq 0x71d0
leaq 0x6f0(%rsp), %rdi
leaq 0x348(%rsp), %rdx
movq %rax, %rsi
callq 0x8032
leaq 0x210c3(%rip), %rsi     # 0x2c6e1
leaq 0x138(%rsp), %rdi
leaq 0x6f0(%rsp), %rdx
callq 0xc30e
leaq 0x218(%rsp), %rdi
movl $0x1f4, %esi            # imm = 0x1F4
callq 0x2a818
leaq 0xaf8(%rsp), %rdi
movq %rax, %rsi
callq 0x29f62
leaq 0x138(%rsp), %rsi
leaq 0xaf8(%rsp), %rdx
pushq $0x3
popq %rcx
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
callq 0xc0bc
leaq 0xaf8(%rsp), %rdi
callq 0x29f10
leaq 0x138(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
leaq 0x4c0(%rsp), %rdi
callq 0x7110
leaq 0x118(%rsp), %rdi
callq 0x79b8
leaq 0x100(%rsp), %rdi
callq 0x8f64
leaq 0x30(%rsp), %rdi
callq 0x79b8
leaq 0x218(%rsp), %rdi
callq 0x29f10
movq 0x10(%rsp), %rax
addq $0xe18, %rsp            # imm = 0xE18
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0xa8(%rsp), %rdi
jmp 0xbb84
jmp 0xbb8f
movq %rax, %r12
leaq 0xaf8(%rsp), %rdi
callq 0x29f10
jmp 0xb75b
movq %rax, %r12
jmp 0xb768
jmp 0xb8a4
jmp 0xb7a0
jmp 0xb7af
jmp 0xb866
movq %rax, %r12
leaq 0xb98(%rsp), %rdi
callq 0x29f10
jmp 0xb80e
movq %rax, %r12
leaq 0xc38(%rsp), %rdi
callq 0x29f10
jmp 0xb81e
movq %rax, %r12
leaq 0x138(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
jmp 0xbbf1
jmp 0xb8a4
jmp 0xb8a4
jmp 0xbbb5
jmp 0xb7af
jmp 0xb866
jmp 0xb7a0
jmp 0xb7af
jmp 0xb866
jmp 0xb866
jmp 0xb7af
jmp 0xb866
movq %rax, %r12
leaq 0x78(%rsp), %rdi
callq 0x79b8
jmp 0xb7b2
movq %rax, %r12
leaq 0x50(%rsp), %rdi
jmp 0xb7f8
jmp 0xb866
jmp 0xb866
jmp 0xb866
jmp 0xb7ed
jmp 0xb866
jmp 0xb866
jmp 0xb7ed
jmp 0xb866
movq %rax, %r12
leaq 0xa8(%rsp), %rdi
callq 0x79b8
jmp 0xb7f0
movq %rax, %r12
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
jmp 0xb869
jmp 0xb866
movq %rax, %r12
jmp 0xb876
jmp 0xb8a4
movq %rax, %r12
leaq 0x158(%rsp), %rdi
jmp 0xbbf1
movq %rax, %r12
leaq 0x178(%rsp), %rdi
jmp 0xbbf1
jmp 0xbc0e
movq %rax, %r12
leaq 0x198(%rsp), %rdi
jmp 0xbbd7
jmp 0xbbb5
movq %rax, %r12
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
jmp 0xb85a
movq %rax, %r12
cmpq %r15, %r14
jmp 0xbbe9
jmp 0xb8a4
jmp 0xb866
movq %rax, %r12
leaq 0x348(%rsp), %rdi
callq 0x7140
leaq 0xe0(%rsp), %rdi
jmp 0xbbf1
jmp 0xb8a4
movq %rdx, %rbx
movq %rax, %r12
leaq 0x348(%rsp), %rdi
callq 0x79b8
jmp 0xb913
jmp 0xb90d
movq %rax, %r12
jmp 0xbbe9
movq %rax, %r12
jmp 0xbbf6
jmp 0xbc3a
movq %rax, %r12
leaq 0xcd8(%rsp), %rdi
callq 0x29f10
jmp 0xb8de
jmp 0xba70
jmp 0xba70
jmp 0xb90d
jmp 0xb90d
jmp 0xb8d3
movq %rdx, %rbx
movq %rax, %r12
jmp 0xb920
movq %rax, %r12
leaq 0x1b8(%rsp), %rdi
jmp 0xba66
movq %rdx, %rbx
movq %rax, %r12
jmp 0xb93d
movq %rax, %r12
leaq 0x4c0(%rsp), %rdi
jmp 0xba66
jmp 0xba70
jmp 0xbc3a
movq %rdx, %rbx
movq %rax, %r12
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
jmp 0xb938
movq %rdx, %rbx
movq %rax, %r12
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
cmpl $0x1, %ebx
jne 0xbc57
movq %r12, %rdi
callq 0x7220
movq 0x18(%rsp), %rdi
callq 0x21672
testb %al, %al
je 0xb975
leaq 0x30(%rsp), %r8
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rdx
callq 0x9da2
jmp 0xba12
movb $0x1, %bl
movq 0x20(%rsp), %rax
cmpb $0x0, 0x118(%rax)
jne 0xba14
leaq 0x207a1(%rip), %rsi     # 0x2c131
leaq 0x6f0(%rsp), %rdi
leaq 0x348(%rsp), %rdx
callq 0x8032
leaq 0x2109c(%rip), %rdx     # 0x2ca48
leaq 0x4c0(%rsp), %rdi
movq %r13, %rsi
callq 0xc1e9
leaq 0x218(%rsp), %rdi
leaq 0x6f0(%rsp), %rsi
leaq 0x4c0(%rsp), %rdx
callq 0x2a124
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
leaq 0x218(%rsp), %rdi
movl $0x12d, %esi            # imm = 0x12D
callq 0x2a818
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x29f62
xorl %ebx, %ebx
callq 0x77f0
testb %bl, %bl
jne 0xaab2
jmp 0xb6c3
movq %rax, %r12
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
jmp 0xba3b
movq %rax, %r12
leaq 0x6f0(%rsp), %rdi
callq 0x79b8
jmp 0xba51
jmp 0xba4e
jmp 0xba70
movq %rax, %r12
callq 0x77f0
jmp 0xbc57
movq %rax, %r12
leaq 0x1d8(%rsp), %rdi
callq 0x79b8
jmp 0xbc57
movq %rax, %r12
jmp 0xbc57
movq %rax, %r12
cmpl $0x1, %edx
jne 0xbc57
movq %r12, %rdi
callq 0x7220
leaq 0x20c1d(%rip), %rsi     # 0x2c6b0
leaq 0x1f8(%rsp), %rdi
leaq 0x6f0(%rsp), %rdx
callq 0x8032
leaq 0x218(%rsp), %rdi
movl $0x190, %esi            # imm = 0x190
callq 0x2a818
leaq 0xd78(%rsp), %rdi
movq %rax, %rsi
callq 0x29f62
leaq 0x1f8(%rsp), %rsi
leaq 0xd78(%rsp), %rdx
pushq $0x3
popq %rcx
movq 0x10(%rsp), %rdi
xorl %r8d, %r8d
callq 0xc0bc
leaq 0xd78(%rsp), %rdi
callq 0x29f10
leaq 0x1f8(%rsp), %rdi
callq 0x79b8
callq 0x77f0
jmp 0xb6c3
jmp 0xba70
movq %rax, %r12
leaq 0xd78(%rsp), %rdi
callq 0x29f10
jmp 0xbb2d
movq %rax, %r12
jmp 0xbb3a
movq %rax, %r12
leaq 0x1f8(%rsp), %rdi
callq 0x79b8
callq 0x77f0
jmp 0xbc57
movq %rax, %rdi
callq 0x8f59
jmp 0xbb4e
movq %rax, %r12
jmp 0xbc61
movq %rax, %r12
jmp 0xbb7f
movq %rax, %r12
leaq 0xa8(%rsp), %rdi
callq 0x79b8
jmp 0xbb72
jmp 0xbb8f
movq %rax, %r12
leaq 0xe0(%rsp), %rdi
callq 0x79b8
leaq 0x50(%rsp), %rdi
callq 0x79b8
jmp 0xbb92
jmp 0xbc09
jmp 0xbc09
movq %rax, %r12
leaq 0x6f0(%rsp), %rdi
callq 0x8ffa
jmp 0xbbdc
movq %rax, %r12
leaq 0x348(%rsp), %rdi
callq 0x79b8
jmp 0xbc11
jmp 0xbc0e
movq %rax, %r12
jmp 0xbbdc
movq %rax, %r12
jmp 0xbbcf
movq %rax, %r12
leaq 0x6f0(%rsp), %rdi
callq 0x81d8
leaq 0xa8(%rsp), %rdi
callq 0x79b8
leaq 0x2b8(%rsp), %rdi
callq 0x79b8
leaq 0x348(%rsp), %rdi
callq 0x79b8
leaq 0x4c0(%rsp), %rdi
callq 0x7110
jmp 0xbc3d
jmp 0xbc0e
jmp 0xbc09
movq %rax, %r12
jmp 0xbc1e
movq %rax, %r12
leaq 0x4c0(%rsp), %rdi
callq 0x79b8
leaq 0x6f0(%rsp), %rdi
jmp 0xbc33
movq %rax, %r12
leaq 0x6d0(%rsp), %rdi
callq 0x79b8
jmp 0xbc3d
movq %rax, %r12
leaq 0x118(%rsp), %rdi
callq 0x79b8
leaq 0x100(%rsp), %rdi
callq 0x8f64
leaq 0x30(%rsp), %rdi
callq 0x79b8
leaq 0x218(%rsp), %rdi
callq 0x29f10
movq %r12, %rdi
callq 0x7860