// File: /workspace/github_cpp_makefile_star2_O3/mbourand[P]webserv/srcs/tcp-server.cpp
// Function: main
int	main(int argc, char **argv)
{
	std::cout << "\e[34m" << " __      __      ___.                              \n/  \\    /  \\ ____\\_ |__   ______ ______________  __\n\\   \\/\\/   // __ \\| __ \\ /  ___// __ \\_  __ \\  \\/ /\n \\        /\\  ___/| \\_\\ \\\\___ \\\\  ___/|  | \\/\\   / \n  \\__/\\  /  \\___  >___  /____  >\\___  >__|    \\_/  \n       \\/       \\/    \\/     \\/     \\/         V1.0.0\e[39m" << std::endl;
	std::cout << "\e[34m" << "Available commands are: help|stop|gzip|deflate|info|workers|uptime|logger|types|debug" << "\e[39m" << std::endl;
	Logger::setMode(SILENT);
	Logger::print("Webserv is starting...", NULL, INFO, SILENT);
	if (argc > 2)
	{
		std::cerr << "Format: ./webserv <path_to_config_file>" << std::endl;
		return 1;
	}

	try { g_webserv.init_config(std::string(argc == 1 ? "./config/default.conf" : argv[1])); }
	catch (std::exception& e) { return Logger::print(std::string("Invalid config file: ") + e.what(), 1, ERROR, SILENT); }

	g_webserv.creds = new Credentials();
	Threadpool* workers = new Threadpool(g_webserv.workers_amount);
	sighandler();

	try
	{
		fd_set							read_sockets, read_sockets_z, write_sockets, write_sockets_z, error_sockets, error_sockets_z;
		std::list<Client>				clients;
		std::list<Client>::iterator		it;
		int								highestFd = 0;
		int								serverFd = 0;
		int								readyfd = 0;
		struct timeval 					start_time;

		gettimeofday(&start_time, NULL);
		Logger::print("Webserv is ready, waiting for connection...", NULL, SUCCESS, SILENT);
		FD_ZERO(&read_sockets_z);
		FD_ZERO(&write_sockets_z);
		FD_ZERO(&error_sockets_z);
		for (std::map<int, ServerSocket*>::iterator its = g_webserv.sockets.begin(); its != g_webserv.sockets.end(); its++)
		{
			if (its->second->GetSocket() > serverFd)
				serverFd = its->second->GetSocket();
			FD_SET(its->second->GetSocket(), &read_sockets_z);
		}
		FD_SET(STDIN_FILENO, &read_sockets_z);
		highestFd = serverFd;
		while (g_webserv.run)
		{
			it = clients.begin();
			read_sockets = read_sockets_z;
			write_sockets = write_sockets_z;
			error_sockets = error_sockets_z;
			struct timeval timeout = {30, 0};
			readyfd = select(highestFd + 1, &read_sockets, &write_sockets, &error_sockets, &timeout);
			switch (readyfd)
			{
			case -1:
				if (g_webserv.run)
					Logger::print("Error select(): "+std::string(strerror(errno)), NULL, ERROR, SILENT);
				break;
			case 0:
				Logger::print(std::string("Idle.. Active Connections: ")+ft::toString(clients.size()), NULL, INFO, NORMAL);
				break;//webserv was idling for the past 30s
			default:
				if (FD_ISSET(STDIN_FILENO, &read_sockets))
				{
					std::string line;
					std::getline(std::cin, line);
					handle_terminal_input(line, clients, &start_time, workers);
					readyfd--;
				}
				for (std::map<int, ServerSocket*>::iterator its = g_webserv.sockets.begin(); its != g_webserv.sockets.end(); its++)
				{
					if (FD_ISSET(its->second->GetSocket(), &read_sockets))
					{
						int fd = 0;
						if ((fd = handle_new_connection(*its->second, clients)))
						{
							FD_SET(fd, &read_sockets_z);
							FD_SET(fd, &write_sockets_z);
							FD_SET(fd, &error_sockets_z);
							if (fd > highestFd)
								highestFd = fd;
						}
						readyfd--;
					}
				}
				it = clients.begin();
				while (readyfd && it != clients.end())
				{
					bool	error = false;
					if (FD_ISSET(it->sckt->GetSocket(), &error_sockets))
					{
						error = true;
						Logger::print("FD Error flagged by Select", NULL, WARNING, SILENT);
					}
					if (!error && FD_ISSET(it->sckt->GetSocket(), &read_sockets))
					{
						error = handle_client_request((*it));
						readyfd--;
					}
					if (!error && FD_ISSET(it->sckt->GetSocket(), &write_sockets))
					{
						if (it->req->isfinished())
							error = workers->AddJob((*it));
						readyfd--;
					}
					if (error)
					{
						bool busy = false;
						workers->Lock();
						if (!workers->getJobs().empty())
							for (std::deque<Client*>::const_iterator jobs_it = workers->getJobs().begin(); jobs_it != workers->getJobs().end(); jobs_it++)
								if (it->sckt == (*jobs_it)->sckt)
									busy = true;
						if (!workers->getCurrentJobs().empty())
							for (std::list<Client*>::const_iterator jobs_it = workers->getCurrentJobs().begin(); jobs_it != workers->getCurrentJobs().end(); jobs_it++)
								if (it->sckt == (*jobs_it)->sckt)
									busy = true;
						workers->Unlock();
						if (busy)
							continue;
						Logger::print("Client Disconnected", NULL, SUCCESS, NORMAL);
						FD_CLR(it->sckt->GetSocket(), &read_sockets_z);
						FD_CLR(it->sckt->GetSocket(), &write_sockets_z);
						FD_CLR(it->sckt->GetSocket(), &error_sockets_z);
						if (highestFd == it->sckt->GetSocket())
							highestFd = 0;
						delete it->sckt;
						delete it->req;
						it = clients.erase(it);
					}
					else
					{
						++it;
					}
				}
				if (!highestFd)
				{
					highestFd = serverFd;
					for (std::list<Client>::iterator its = clients.begin(); its != clients.end(); ++its)
					{
						if (its->sckt->GetSocket() > highestFd)
							highestFd = its->sckt->GetSocket();
					}
				}
				break;
			}
		}
		Logger::print("Webserv is shutting down...", NULL, INFO, SILENT);
		delete workers;
		it = clients.begin();
		while (it != clients.end())
		{
			Logger::print("Socket closed", NULL, SUCCESS, SILENT);
			delete it->sckt;
			delete it->req;
			it = clients.erase(it);
		}
	}
	catch(ServerSocket::ServerSocketException& e)
	{
		g_webserv.run = false;
		Logger::print(e.what(), NULL, ERROR, SILENT);
	}

	for (std::map<int, ServerSocket*>::iterator its = g_webserv.sockets.begin(); its != g_webserv.sockets.end(); its++)
		delete its->second;
	delete g_webserv.file_formatname;
	delete g_webserv.languages;
	delete g_webserv.creds;
	Logger::print("Webserv Shutdown complete", NULL, SUCCESS, SILENT);
	std::cout << std::flush;
	return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4f8, %rsp            # imm = 0x4F8
movq %rsi, %rbx
movl %edi, %ebp
movq 0x1e9ef(%rip), %r14     # 0x4dfa8
leaq 0xdc11(%rip), %r15      # 0x3d1d1
movl $0x5, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x7510
leaq 0xdc00(%rip), %rsi      # 0x3d1d7
movl $0x13e, %edx            # imm = 0x13E
movq %r14, %rdi
callq 0x7510
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7490
movsbl %al, %esi
movq %r14, %rdi
callq 0x7050
movq %rax, %rdi
callq 0x7340
movl $0x5, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x7510
leaq 0xdcf4(%rip), %rsi      # 0x3d316
movl $0x55, %edx
movq %r14, %rdi
callq 0x7510
leaq 0xdcda(%rip), %rsi      # 0x3d310
movl $0x5, %edx
movq %r14, %rdi
callq 0x7510
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7490
movsbl %al, %esi
movq %r14, %rdi
callq 0x7050
movq %rax, %rdi
callq 0x7340
leaq 0x1d0(%rsp), %rsi
movl $0x2, (%rsi)
leaq 0x1eed1(%rip), %rdi     # 0x4e550
callq 0x18320
leaq 0x1c0(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xdcd4(%rip), %rsi      # 0x3d36c
leaq 0xdce3(%rip), %rdx      # 0x3d382
leaq 0x1b0(%rsp), %r14
movq %r14, %rdi
callq 0x80f4
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0x1b0(%rsp), %rdi
cmpq %r12, %rdi
je 0x2f6dd
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x74b0
cmpl $0x3, %ebp
jl 0x2f72e
movq 0x1e8ff(%rip), %rbx     # 0x4dfe8
leaq 0xdc93(%rip), %rsi      # 0x3d383
movl $0x27, %edx
movq %rbx, %rdi
callq 0x7510
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x7490
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7050
movq %rax, %rdi
callq 0x7340
movl $0x1, %ebx
jmp 0x30445
cmpl $0x1, %ebp
jne 0x2f73c
leaq 0xdc71(%rip), %rsi      # 0x3d3ab
jmp 0x2f740
movq 0x8(%rbx), %rsi
leaq 0x1d0(%rsp), %rdi
leaq 0x270(%rsp), %rdx
callq 0xde66
leaq 0x1ee0c(%rip), %rdi     # 0x4e568
leaq 0x1d0(%rsp), %rsi
callq 0x2688c
leaq 0x1e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2f78a
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x74b0
movl $0x18, %edi
callq 0x74a0
movq %rax, %rbx
movq %rax, %rdi
callq 0x170a4
movq %rbx, 0x1ee92(%rip)     # 0x4e638
movl $0xb8, %edi
callq 0x74a0
movq %rax, %r14
movl 0x1ee6f(%rip), %esi     # 0x4e628
movq %rax, %rdi
callq 0x18408
callq 0x18328
leaq 0x38(%rsp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x260(%rsp), %rdi
xorl %esi, %esi
callq 0x7740
leaq 0x160(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xdbdb(%rip), %rsi      # 0x3d3d7
leaq 0xdbff(%rip), %rdx      # 0x3d402
leaq 0x150(%rsp), %rdi
callq 0x80f4
leaq 0x150(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0x150(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2f846
movq 0x160(%rsp), %rsi
incq %rsi
callq 0x74b0
xorps %xmm0, %xmm0
movaps %xmm0, 0x2e0(%rsp)
movaps %xmm0, 0x2d0(%rsp)
movaps %xmm0, 0x2c0(%rsp)
movaps %xmm0, 0x2b0(%rsp)
movaps %xmm0, 0x2a0(%rsp)
movaps %xmm0, 0x290(%rsp)
movaps %xmm0, 0x280(%rsp)
movaps %xmm0, 0x270(%rsp)
movaps %xmm0, 0x370(%rsp)
movaps %xmm0, 0x380(%rsp)
movaps %xmm0, 0x390(%rsp)
movaps %xmm0, 0x3a0(%rsp)
movaps %xmm0, 0x3b0(%rsp)
movaps %xmm0, 0x3c0(%rsp)
movaps %xmm0, 0x3d0(%rsp)
movaps %xmm0, 0x3e0(%rsp)
movaps %xmm0, 0x2f0(%rsp)
movaps %xmm0, 0x300(%rsp)
movaps %xmm0, 0x310(%rsp)
movaps %xmm0, 0x320(%rsp)
movaps %xmm0, 0x330(%rsp)
movaps %xmm0, 0x340(%rsp)
movaps %xmm0, 0x350(%rsp)
movaps %xmm0, 0x360(%rsp)
movq 0x1ec88(%rip), %r15     # 0x4e598
leaq 0x1ec71(%rip), %r12     # 0x4e588
cmpq %r12, %r15
je 0x2f9a6
movl $0x0, 0x4(%rsp)
movq 0x28(%r15), %rdi
callq 0x12bfe
cmpl 0x4(%rsp), %eax
jle 0x2f944
movq 0x28(%r15), %rdi
callq 0x12bfe
movl %eax, 0x4(%rsp)
movq 0x28(%r15), %rdi
callq 0x12bfe
movl %eax, %ebx
movq 0x28(%r15), %rdi
callq 0x12bfe
leal 0x3f(%rbx), %ecx
testl %ebx, %ebx
cmovnsl %ebx, %ecx
andl $0xc0, %ecx
subl %ecx, %ebx
movl $0x1, %edx
movl %ebx, %ecx
shlq %cl, %rdx
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
orq %rdx, 0x270(%rsp,%rax,8)
movq %r15, %rdi
callq 0x7350
movq %rax, %r15
cmpq %r12, %rax
jne 0x2f928
movq 0x270(%rsp), %rax
orq $0x1, %rax
jmp 0x2f9b3
movl $0x0, 0x4(%rsp)
movl $0x1, %eax
movq %rax, 0x270(%rsp)
cmpb $0x1, 0x1eba6(%rip)     # 0x4e568
jne 0x301ed
leaq 0x60(%rsp), %rbp
leaq 0xa0(%rsp), %rbx
movl 0x4(%rsp), %eax
movq %rax, 0x8(%rsp)
movl $0x10, %ecx
leaq 0x1d0(%rsp), %rax
movq %rax, %rdi
leaq 0x270(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
leaq 0x478(%rsp), %rdx
movq %rdx, %rdi
leaq 0x370(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movl $0x10, %ecx
leaq 0x3f8(%rsp), %r8
movq %r8, %rdi
leaq 0x2f0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movups 0xdc12(%rip), %xmm0     # 0x3d648
movaps %xmm0, 0x250(%rsp)
movq 0x8(%rsp), %rcx
leal 0x1(%rcx), %edi
movq %rax, %rsi
movq %r8, %rcx
leaq 0x250(%rsp), %r8
callq 0x7480
cmpl $-0x1, %eax
je 0x2fb01
movl %eax, (%rsp)
testl %eax, %eax
jne 0x2fb7b
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd98e(%rip), %rsi      # 0x3d414
leaq 0xd9a2(%rip), %rdx      # 0x3d42f
callq 0x80f4
movl 0x48(%rsp), %esi
leaq 0x70(%rsp), %rdi
callq 0x1bd7d
movq 0x18(%rsp), %rcx
movl $0xf, %edi
leaq 0x28(%rsp), %rax
cmpq %rax, %rcx
je 0x2fab9
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %r8
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
jbe 0x2faf4
movl $0xf, %edi
leaq 0x80(%rsp), %r9
cmpq %r9, %rsi
je 0x2faeb
movq 0x80(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x300cd
movq %rbx, %rdi
callq 0x7190
jmp 0x300db
cmpb $0x1, 0x1ea60(%rip)     # 0x4e568
jne 0x301d8
callq 0x7070
movl (%rax), %edi
callq 0x71d0
leaq 0x18(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
leaq 0x70(%rsp), %rdx
callq 0xde66
movl $0x10, %r8d
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0xd8c0(%rip), %rcx      # 0x3d403
callq 0x7500
movq %rbx, 0x90(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x30165
movq %rdx, 0x90(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xa0(%rsp)
jmp 0x3016b
testb $0x1, 0x1d0(%rsp)
leaq 0x18(%rsp), %rbx
je 0x2fc06
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
movb $0x0, 0x28(%rsp)
movq 0x1e427(%rip), %rcx     # 0x4dfd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x7490
movsbl %al, %edx
movq 0x1e409(%rip), %rdi     # 0x4dfd0
movq %rbx, %rsi
callq 0x7890
movq %rbx, %rdi
leaq 0x38(%rsp), %rsi
leaq 0x260(%rsp), %rdx
movq %r14, %rcx
callq 0x3088f
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x2fc03
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x74b0
decl (%rsp)
movq 0x1e98b(%rip), %r15     # 0x4e598
cmpq %r12, %r15
je 0x2fcb3
movq 0x28(%r15), %rdi
callq 0x12bfe
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
movq 0x1d0(%rsp,%rax,8), %rbx
movq 0x28(%r15), %rdi
callq 0x12bfe
btq %rax, %rbx
jae 0x2fc9f
movq 0x28(%r15), %rdi
leaq 0x38(%rsp), %rsi
callq 0x2e1c0
testl %eax, %eax
je 0x2fc9c
leal 0x3f(%rax), %edx
testl %eax, %eax
cmovnsl %eax, %edx
movl %edx, %esi
andl $-0x40, %esi
movl %eax, %ecx
subl %esi, %ecx
movl $0x1, %esi
shlq %cl, %rsi
sarl $0x6, %edx
movslq %edx, %rcx
orq %rsi, 0x270(%rsp,%rcx,8)
orq %rsi, 0x370(%rsp,%rcx,8)
orq %rsi, 0x2f0(%rsp,%rcx,8)
movq 0x8(%rsp), %rcx
cmpl %ecx, %eax
cmovgl %eax, %ecx
movq %rcx, 0x8(%rsp)
decl (%rsp)
movq %r15, %rdi
callq 0x7350
movq %rax, %r15
cmpq %r12, %rax
jne 0x2fc16
movq 0x38(%rsp), %rdx
cmpl $0x0, (%rsp)
setne %al
leaq 0x38(%rsp), %rcx
movq %rdx, 0x10(%rsp)
cmpq %rcx, %rdx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3006e
movq 0x10(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x12bfe
movq 0x10(%rsp), %rcx
leaq 0x10(%rcx), %r15
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
movq 0x3f8(%rsp,%rax,8), %rbx
movq (%r15), %rdi
callq 0x12bfe
btq %rax, %rbx
jae 0x2fd85
leaq 0xc0(%rsp), %rax
movq %rax, 0xb0(%rsp)
leaq 0xb0(%rsp), %rbx
movq %rbx, %rdi
leaq 0xd6f9(%rip), %rsi      # 0x3d430
leaq 0xd70c(%rip), %rdx      # 0x3d44a
callq 0x80f4
movq %rbx, %rdi
xorl %esi, %esi
movl $0x2, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x2fe1c
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x2fe1c
movq (%r15), %rdi
callq 0x12bfe
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
movq 0x1d0(%rsp,%rax,8), %rbx
movq (%r15), %rdi
callq 0x12bfe
btq %rax, %rbx
jae 0x2fdc0
movq %r15, %rdi
callq 0x2e6a4
decl (%rsp)
testb %al, %al
jne 0x2fe1c
movq (%r15), %rdi
callq 0x12bfe
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
movq 0x478(%rsp,%rax,8), %rbx
movq (%r15), %rdi
callq 0x12bfe
btq %rax, %rbx
jae 0x30048
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x35b94
testb %al, %al
je 0x30045
movq %r14, %rdi
movq %r15, %rsi
callq 0x187ae
decl (%rsp)
testb %al, %al
je 0x30048
movq %r14, %rdi
callq 0x18782
movq %r14, %rdi
callq 0x18a54
movq 0x30(%rax), %rcx
cmpq 0x10(%rax), %rcx
je 0x2fe93
movq %r14, %rdi
callq 0x18a54
movq 0x10(%rax), %rbx
movq 0x20(%rax), %rbp
movq 0x28(%rax), %r12
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x18a54
cmpq 0x30(%rax), %rbx
je 0x2fe85
movq (%r15), %rax
movq (%rbx), %rcx
cmpq (%rcx), %rax
sete %al
orb %al, %r13b
addq $0x8, %rbx
cmpq %rbp, %rbx
jne 0x2fe4d
movq 0x8(%r12), %rbx
addq $0x8, %r12
leaq 0x200(%rbx), %rbp
jmp 0x2fe4d
leaq 0x1e6fc(%rip), %r12     # 0x4e588
leaq 0x60(%rsp), %rbp
jmp 0x2fe96
xorl %r13d, %r13d
movq %r14, %rdi
callq 0x18a5a
cmpq %rax, (%rax)
je 0x2fed0
movq %r14, %rdi
callq 0x18a5a
movq %rax, %rbx
movq (%rbx), %rbx
movq %r14, %rdi
callq 0x18a5a
cmpq %rax, %rbx
je 0x2fed0
movq (%r15), %rax
movq 0x10(%rbx), %rcx
cmpq (%rcx), %rax
sete %al
orb %al, %r13b
jmp 0x2feae
movq %r14, %rdi
callq 0x18798
testb $0x1, %r13b
je 0x2fee8
movq 0x10(%rsp), %rbx
jmp 0x30050
leaq 0x140(%rsp), %rbx
movq %rbx, 0x130(%rsp)
leaq 0x130(%rsp), %r13
movq %r13, %rdi
leaq 0xd541(%rip), %rsi      # 0x3d44b
leaq 0xd54d(%rip), %rdx      # 0x3d45e
callq 0x80f4
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0xdea4
movq 0x130(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2ff47
movq 0x140(%rsp), %rsi
incq %rsi
callq 0x74b0
movq (%r15), %rdi
callq 0x12bfe
movl %eax, %ebx
movq (%r15), %rdi
callq 0x12bfe
movq $-0x2, %rdx
movl %ebx, %ecx
rolq %cl, %rdx
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
andq %rdx, 0x270(%rsp,%rax,8)
movq (%r15), %rdi
callq 0x12bfe
movl %eax, %ebx
movq (%r15), %rdi
callq 0x12bfe
movq $-0x2, %rdx
movl %ebx, %ecx
rolq %cl, %rdx
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
andq %rdx, 0x370(%rsp,%rax,8)
movq (%r15), %rdi
callq 0x12bfe
movl %eax, %ebx
movq (%r15), %rdi
callq 0x12bfe
movq $-0x2, %rdx
movl %ebx, %ecx
rolq %cl, %rdx
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
andq %rdx, 0x2f0(%rsp,%rax,8)
movq (%r15), %rdi
callq 0x12bfe
movq 0x8(%rsp), %rcx
cmpl %eax, %ecx
movl $0x0, %eax
cmovel %eax, %ecx
movq %rcx, 0x8(%rsp)
movq (%r15), %rdi
testq %rdi, %rdi
je 0x3000d
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x30021
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x10(%rsp), %r15
movq (%r15), %rbx
decq 0x48(%rsp)
movq %r15, %rdi
callq 0x7770
movl $0x20, %esi
movq %r15, %rdi
callq 0x74b0
jmp 0x30050
decl (%rsp)
movq 0x10(%rsp), %rbx
movq (%rbx), %rbx
leaq 0x38(%rsp), %rax
movq %rbx, 0x10(%rsp)
cmpq %rax, %rbx
setne %al
cmpl $0x0, (%rsp)
je 0x3006e
testb %al, %al
jne 0x2fcda
cmpl $0x0, 0x8(%rsp)
jne 0x301d8
movq 0x38(%rsp), %rbx
movl 0x4(%rsp), %eax
movq %rax, 0x8(%rsp)
leaq 0x38(%rsp), %rax
cmpq %rax, %rbx
je 0x301d8
movl 0x4(%rsp), %eax
movq %rax, 0x8(%rsp)
movq 0x10(%rbx), %rdi
callq 0x12bfe
cmpl 0x8(%rsp), %eax
jle 0x300bb
movq 0x10(%rbx), %rdi
callq 0x12bfe
movq %rax, 0x8(%rsp)
movq (%rbx), %rbx
leaq 0x38(%rsp), %rax
cmpq %rax, %rbx
jne 0x3009e
jmp 0x301d8
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7500
movq %rbp, 0x50(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x300fb
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x30102
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xdea4
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0x30149
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x301bc
movq 0x80(%rsp), %rsi
jmp 0x301b4
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x98(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x90(%rsp), %rdi
xorl %esi, %esi
movl $0x3, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0x90(%rsp), %rdi
cmpq %rbx, %rdi
je 0x301bc
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x301d8
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x74b0
cmpb $0x0, 0x1e389(%rip)     # 0x4e568
leaq 0xa0(%rsp), %rbx
jne 0x2f9de
leaq 0x120(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xd25f(%rip), %rsi      # 0x3d45f
leaq 0xd273(%rip), %rdx      # 0x3d47a
leaq 0x110(%rsp), %rdi
callq 0x80f4
leaq 0x110(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0x110(%rsp), %rdi
cmpq %rbx, %rdi
je 0x30247
movq 0x120(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %r14, %rdi
callq 0x185c6
movl $0xb8, %esi
movq %r14, %rdi
callq 0x74b0
movq 0x38(%rsp), %r14
leaq 0x38(%rsp), %rax
cmpq %rax, %r14
je 0x30325
leaq 0x100(%rsp), %rbx
leaq 0xd1fd(%rip), %r15      # 0x3d47b
leaq 0xd203(%rip), %r12      # 0x3d488
leaq 0xf0(%rsp), %r13
movq %rbx, 0xf0(%rsp)
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x80f4
movq %r13, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0xf0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x302d4
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x302e3
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x302f2
movq (%rdi), %rax
callq *0x8(%rax)
movq (%r14), %rbp
decq 0x48(%rsp)
movq %r14, %rdi
callq 0x7770
movl $0x20, %esi
movq %r14, %rdi
callq 0x74b0
movq %rbp, %r14
leaq 0x38(%rsp), %rax
cmpq %rax, %rbp
jne 0x3028d
movq 0x38(%rsp), %r14
leaq 0x38(%rsp), %r15
cmpq %r15, %r14
je 0x30347
movq (%r14), %rbx
movl $0x20, %esi
movq %r14, %rdi
callq 0x74b0
movq %rbx, %r14
cmpq %r15, %rbx
jne 0x3032f
movq 0x1e24a(%rip), %rbx     # 0x4e598
leaq 0x1e233(%rip), %r14     # 0x4e588
cmpq %r14, %rbx
je 0x30379
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x30369
movq (%rdi), %rax
callq *0x8(%rax)
movq %rbx, %rdi
callq 0x7350
movq %rax, %rbx
cmpq %r14, %rax
jne 0x3035a
movq 0x1e1f0(%rip), %rbx     # 0x4e570
testq %rbx, %rbx
je 0x3038d
movq %rbx, %rdi
callq 0x17e12
movl $0x10, %esi
movq %rbx, %rdi
callq 0x74b0
movq 0x1e1d7(%rip), %rbx     # 0x4e578
testq %rbx, %rbx
je 0x303ae
movq %rbx, %rdi
callq 0x17e12
movl $0x10, %esi
movq %rbx, %rdi
callq 0x74b0
movq 0x1e276(%rip), %rbx     # 0x4e638
testq %rbx, %rbx
je 0x303cf
movq %rbx, %rdi
callq 0x174f4
movl $0x18, %esi
movq %rbx, %rdi
callq 0x74b0
leaq 0x180(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xd09a(%rip), %rsi      # 0x3d489
leaq 0xd0ac(%rip), %rdx      # 0x3d4a2
leaq 0x170(%rsp), %rbx
movq %rbx, %rdi
callq 0x80f4
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
movl $0x2, %ecx
callq 0xdea4
movq 0x170(%rsp), %rdi
cmpq %r14, %rdi
je 0x30437
movq 0x180(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x1db6a(%rip), %rdi     # 0x4dfa8
callq 0x7340
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x4f8, %rsp            # imm = 0x4F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r14
movq %rax, %r15
movq 0x110(%rsp), %rdi
cmpq %rbx, %rdi
je 0x307b2
movq 0x120(%rsp), %rsi
jmp 0x30794
jmp 0x307ac
movq %rdx, %r14
movq %rax, %r15
movq 0x150(%rsp), %rdi
cmpq %rbx, %rdi
je 0x307b2
movq 0x160(%rsp), %rsi
jmp 0x30794
movq %rax, %r15
movq 0x170(%rsp), %rdi
cmpq %r14, %rdi
je 0x3068f
movq 0x180(%rsp), %rsi
jmp 0x30687
jmp 0x307ac
movq %rax, %r15
movl $0xb8, %esi
movq %r14, %rdi
jmp 0x3068a
movq %rax, %r15
movl $0x18, %esi
movq %rbx, %rdi
jmp 0x3068a
movq %rdx, %rbx
movq %rax, %r15
leaq 0x1e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3051b
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x3051b
movq %rdx, %rbx
movq %rax, %r15
cmpl $0x1, %ebx
jne 0x3068f
movq %r15, %rdi
callq 0x7210
movq %rax, %rbx
leaq 0x1e0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xce7f(%rip), %rsi      # 0x3d3c1
leaq 0xce8d(%rip), %rdx      # 0x3d3d6
leaq 0x1d0(%rsp), %rdi
callq 0x80f4
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
leaq 0x1d0(%rsp), %rdi
movq %rax, %rsi
callq 0x78d0
leaq 0xe0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x305a0
movq %rdx, 0xd0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0xe0(%rsp)
jmp 0x305a8
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
leaq 0xd0(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movl $0x1, %esi
movl $0x3, %edx
movl $0x2, %ecx
callq 0x12c02
movl %eax, %ebx
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x305fa
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x1d0(%rsp), %rdi
cmpq %r14, %rdi
je 0x30617
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x74b0
callq 0x7780
jmp 0x30445
movq %rax, %r15
movq 0xd0(%rsp), %rdi
cmpq %r12, %rdi
je 0x30646
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x30646
movq %rax, %r15
movq 0x1d0(%rsp), %rdi
cmpq %r14, %rdi
je 0x30668
movq 0x1e0(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x30668
movq %rax, %r15
callq 0x7780
jmp 0x3068f
movq %rax, %r15
movq 0x1b0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3068f
movq 0x1c0(%rsp), %rsi
incq %rsi
callq 0x74b0
movq %r15, %rdi
callq 0x7810
movq %rdx, %r14
movq %rax, %r15
movq 0x90(%rsp), %rdi
cmpq %rbx, %rdi
je 0x30711
movq 0xa0(%rsp), %rsi
jmp 0x30701
jmp 0x3070b
jmp 0x307ac
jmp 0x3070b
jmp 0x307ac
movq %rdx, %r14
movq %rax, %r15
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0x306e7
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x306e7
movq %rdx, %r14
movq %rax, %r15
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x30711
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x30711
movq %rdx, %r14
movq %rax, %r15
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x307b2
movq 0x28(%rsp), %rsi
jmp 0x30794
jmp 0x307ac
jmp 0x307ac
movq %rdx, %r14
movq %rax, %r15
movq 0xf0(%rsp), %rdi
cmpq %rbx, %rdi
je 0x307b2
movq 0x100(%rsp), %rsi
jmp 0x30794
movq %rdx, %r14
movq %rax, %r15
movq 0x130(%rsp), %rdi
cmpq %rbx, %rdi
je 0x307b2
movq 0x140(%rsp), %rsi
jmp 0x30794
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
movq %rdx, %r14
movq %rax, %r15
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x307b2
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x307b2
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
jmp 0x307ac
movq %rdx, %r14
movq %rax, %r15
movq 0x38(%rsp), %rdi
leaq 0x38(%rsp), %r12
cmpq %r12, %rdi
je 0x307d6
movq (%rdi), %rbx
movl $0x20, %esi
callq 0x74b0
movq %rbx, %rdi
cmpq %r12, %rbx
jne 0x307c1
cmpl $0x2, %r14d
jne 0x3068f
movq %r15, %rdi
callq 0x7210
movb $0x0, 0x1dd79(%rip)     # 0x4e568
movq (%rax), %rcx
movq %rax, %rdi
callq *0x10(%rcx)
leaq 0x190(%rsp), %rdi
leaq 0x1d0(%rsp), %rdx
movq %rax, %rsi
callq 0xde66
leaq 0x190(%rsp), %rdi
xorl %esi, %esi
movl $0x3, %edx
movl $0x2, %ecx
callq 0xdea4
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3084a
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x74b0
callq 0x7780
jmp 0x30347
movq %rax, %r15
leaq 0x1a0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3087d
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x74b0
jmp 0x3087d
movq %rax, %r15
callq 0x7780
jmp 0x3068f
movq %rax, %rdi
callq 0x96aa