// File: /workspace/github_cpp_makefile_star2_O2/Unreality3D[P]Unreality3D/indie-studio/source/Network/sockets/Server.cpp
// Function: Socket::Server::stateChecker()
void Server::stateChecker()
	{
		int fd;
		int nb_fd;
		fd_set read_set, write_set;
		timeval timeout;

		// event loop
		while (_isRunning)
		{
		  SLEEPMS(0);
		  memcpy(&read_set, &_fd_set, sizeof(_fd_set));
		  memcpy(&write_set, &_fd_set, sizeof(_fd_set));

			// wait for an event
			timeout = _timeout;
			nb_fd = select(_max_fd + 1, &read_set, &write_set, NULL, &timeout);
			if (nb_fd < 0 && errno != EINTR)
				throw SocketIOError(std::string(strerror(getError())));

			if (FD_ISSET(_fd, &read_set))
			{
				// connection event
				while ((fd = ::accept(_fd, NULL, NULL)) != -1)
				{
					if (!setNonBloccking(fd))
						throw SocketCreateError(std::string("server : ") +
												std::string("cannot set non blocking mode for the client fd"));

					_clients.push_back(fd);
					FD_SET(fd, &_fd_set);
					_max_fd = (fd > _max_fd) ? fd : _max_fd;
					if (_OnConnect)
						_OnConnect(*this, fd);
				}
				if (errno != EAGAIN && errno != EWOULDBLOCK)
					throw SocketConnectError(std::string(strerror(getError())));
			}

			for (auto it = _clients.begin(); it != _clients.end() && _clients.size(); ++it)
			{
				// read event
				if (FD_ISSET(*it, &read_set))
				{
				  if (*it == _fd);
				  else
				    {
				      if (!bytesAvailables(*it))
					{
					  disconnect(*it);
					  it = _clients.begin();
					  continue;
					}
				      else if (_OnReadPossible)
					_OnReadPossible(*this, *it, bytesAvailables(*it));
				    }
				}
				// write event
				if (FD_ISSET(*it, &write_set))
				{
					if (*it == _fd);
					else if (_OnWritePossible)
						_OnWritePossible(*this, *it);
					/*
					else
						std::cout << "no callback set for OnWritePossible" << std::endl;
						*/
				}
			}
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdi, %rbx
leaq 0xf0(%rdi), %rax
movq %rax, 0x20(%rsp)
leaq 0x40(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x20(%rdi), %r15
leaq 0x50(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x90(%rdi), %rax
movq %rax, 0x28(%rsp)
leaq 0xb0(%rdi), %rbp
pushq $0x40
popq %r14
movb 0x174(%rbx), %al
testb $0x1, %al
je 0x16d98
xorl %edi, %edi
callq 0xff20
pushq $0x10
popq %rdx
movq %rdx, %rcx
leaq 0xe8(%rsp), %r8
movq %r8, %rdi
movq 0x20(%rsp), %rax
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rdx, %rcx
leaq 0x168(%rsp), %rdx
movq %rdx, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x18(%rsp), %rax
movups (%rax), %xmm0
movaps %xmm0, 0x50(%rsp)
movl 0x170(%rbx), %edi
incl %edi
movq %r8, %rsi
xorl %ecx, %ecx
leaq 0x50(%rsp), %r8
callq 0xfa80
testl %eax, %eax
jns 0x16c1e
callq 0xf070
cmpl $0x4, (%rax)
jne 0x16e81
movl 0x18(%rbx), %edi
movl %edi, %eax
cltd
idivl %r14d
cltq
movq 0xe8(%rsp,%rax,8), %rax
btq %rdx, %rax
movq 0x10(%rsp), %r12
jae 0x16cce
xorl %esi, %esi
xorl %edx, %edx
callq 0xf2f0
movl %eax, 0xc(%rsp)
cmpl $-0x1, %eax
je 0x16cc0
movl %eax, %edi
callq 0x16b2b
testb %al, %al
je 0x16daa
movq %r15, %rdi
leaq 0xc(%rsp), %rsi
callq 0xf120
movl 0xc(%rsp), %r8d
movl %r8d, %eax
cltd
idivl %r14d
movslq %eax, %rdx
shll $0x6, %eax
movl %r8d, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, 0xf0(%rbx,%rdx,8)
movl 0x170(%rbx), %eax
cmpl %eax, %r8d
cmovgl %r8d, %eax
movl %eax, 0x170(%rbx)
cmpq $0x0, 0x60(%rbx)
je 0x16cbb
movq %r12, %rdi
movq %rbx, %rsi
movl %r8d, %edx
callq 0xfbc0
movl 0x18(%rbx), %edi
jmp 0x16c40
callq 0xf070
cmpl $0xb, (%rax)
jne 0x16e2e
movq (%r15), %rax
movq %rax, %r12
movq 0x28(%rbx), %rcx
cmpq %rcx, %r12
je 0x16ba3
cmpq %rax, %rcx
je 0x16ba3
movl (%r12), %r13d
movl %r13d, %eax
cltd
idivl %r14d
cltq
movq 0xe8(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0x16d45
cmpl 0x18(%rbx), %r13d
je 0x16d45
movl %r13d, %esi
callq 0x10370
testq %rax, %rax
je 0x16d7c
cmpq $0x0, 0xa0(%rbx)
movl (%r12), %r13d
je 0x16d45
movl %r13d, %esi
callq 0x10370
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl %r13d, %edx
movq %rax, %rcx
callq 0x10030
movl (%r12), %r13d
movl %r13d, %eax
cltd
idivl %r14d
cltq
movq 0x168(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0x16d8c
cmpl 0x18(%rbx), %r13d
je 0x16d8c
cmpq $0x0, 0xc0(%rbx)
je 0x16d8c
movq %rbp, %rdi
movq %rbx, %rsi
movl %r13d, %edx
callq 0xfbc0
jmp 0x16d8c
movl (%r12), %esi
movq %rbx, %rdi
callq 0xfe60
movq 0x20(%rbx), %r12
addq $0x4, %r12
movq (%r15), %rax
jmp 0x16cd4
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x48
popq %rdi
callq 0xf4d0
movq %rax, %rbx
leaq 0x1832(%rip), %rsi      # 0x185ee
leaq 0x30(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0xf3f0
leaq 0x16be(%rip), %rsi      # 0x18490
leaq 0x88(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0xf3f0
leaq 0xa8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x88(%rsp), %rdx
callq 0xf9a0
movb $0x1, %bpl
leaq 0xa8(%rsp), %rsi
movq %rbx, %rdi
callq 0xfd80
xorl %ebp, %ebp
movq 0x81b6(%rip), %rsi      # 0x1efd0
movq 0x816f(%rip), %rdx      # 0x1ef90
movq %rbx, %rdi
callq 0x10260
jmp 0x16ed8
pushq $0x48
popq %rdi
callq 0xf4d0
movq %rax, %rbx
callq 0x16b21
movl %eax, %edi
callq 0xf330
leaq 0x68(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %rax, %rsi
callq 0xf3f0
movb $0x1, %bpl
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0xfb90
xorl %ebp, %ebp
movq 0x80f8(%rip), %rsi      # 0x1ef68
movq 0x8119(%rip), %rdx      # 0x1ef90
movq %rbx, %rdi
callq 0x10260
jmp 0x16ed8
pushq $0x48
popq %rdi
callq 0xf4d0
movq %rax, %rbx
callq 0x16b21
movl %eax, %edi
callq 0xf330
leaq 0xc8(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %rax, %rsi
callq 0xf3f0
movb $0x1, %bpl
leaq 0xc8(%rsp), %rsi
movq %rbx, %rdi
callq 0x10010
xorl %ebp, %ebp
movq 0x80cf(%rip), %rsi      # 0x1ef98
movq 0x80c0(%rip), %rdx      # 0x1ef90
movq %rbx, %rdi
callq 0x10260
movq %rax, %r14
leaq 0xc8(%rsp), %rdi
jmp 0x16f25
jmp 0x16f31
movq %rax, %r14
leaq 0x68(%rsp), %rdi
jmp 0x16f25
jmp 0x16f31
movq %rax, %r14
leaq 0xa8(%rsp), %rdi
callq 0xf450
jmp 0x16f0b
movq %rax, %r14
movb $0x1, %bpl
leaq 0x88(%rsp), %rdi
callq 0xf450
jmp 0x16f20
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0xf450
testb %bpl, %bpl
jne 0x16f34
jmp 0x16f3c
movq %rax, %r14
movq %rbx, %rdi
callq 0xf820
movq %r14, %rdi
callq 0x102f0