// File: /workspace/github_cpp_makefile_star2_O1/llefranc[P]42_webserv/srcs/server/HttpServer.cpp
// Function: HttpServer::requestHandler()
void HttpServer::requestHandler()
{
	for (std::list<ClientSocket>::iterator it = _clientSocks.begin(); it != _clientSocks.end() && _nbReadyFds; ++it)
	{
		if (FD_ISSET(it->getFd(), &_readFds))
		{
			char buffer[REQUEST_BUFFER_SIZE + 1];
			bzero(buffer, REQUEST_BUFFER_SIZE + 1);
			int n = recv(it->getFd(), buffer, REQUEST_BUFFER_SIZE, 0);

			if (n < 0)
            {
                printLog(" >> FD " + convertNbToString(it->getFd()) + ": Error on recv function, connection closed\n");
                std::list<ClientSocket>::iterator tmp = it--;
                closeConnection(&tmp);
            }

			// Client closed the connection
			else if (!n)
			{
				printLog(" >> FD " + convertNbToString(it->getFd()) + ": recv function returned 0, connection closed\n");
                std::list<ClientSocket>::iterator tmp = it--;
                closeConnection(&tmp);
			}

			// Concatenate buffer to actual stored request
            else
                it->receiveRequest(buffer);
	
			// Exit for loop if no other sockets are ready
			--_nbReadyFds;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x898, %rsp            # imm = 0x898
leaq 0x18(%rdi), %rax
movq 0x18(%rdi), %r15
movq %rax, -0x90(%rbp)
cmpq %rax, %r15
je 0xb617
movq %rdi, %rbx
leaq -0x58(%rbp), %r14
movq %rdi, -0xb8(%rbp)
cmpl $0x0, 0x130(%rbx)
je 0xb617
leaq 0x10(%r15), %r13
movq %r13, %rdi
callq 0xbfde
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rax
movq 0x30(%rbx,%rax,8), %r12
movq %r13, %rdi
callq 0xbfde
btq %rax, %r12
jae 0xb375
movl $0x7ff, %edx            # imm = 0x7FF
leaq -0x8c0(%rbp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x4250
movq %r13, %rdi
callq 0xbfde
movl $0x7fe, %edx            # imm = 0x7FE
movl %eax, %edi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x4170
testl %eax, %eax
leaq -0x38(%rbp), %r12
js 0xb381
je 0xb3d4
movq %r13, %rdi
leaq -0x8c0(%rbp), %rsi
callq 0xc00c
jmp 0xb5fa
movq -0xb8(%rbp), %rbx
jmp 0xb607
movq %r13, %rdi
callq 0xbfde
movslq %eax, %rsi
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
callq 0x1378a
movl $0x7, %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0xa055(%rip), %rcx      # 0x15404
callq 0x4440
movq %r12, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb42e
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0xb436
movq %r13, %rdi
callq 0xbfde
movslq %eax, %rsi
leaq -0xb0(%rbp), %rbx
movq %rbx, %rdi
callq 0x1378a
movl $0x7, %r8d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
leaq 0xa002(%rip), %rcx      # 0x15404
callq 0x4440
movq %r12, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb4d0
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0xb4d8
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x48(%rbp), %rdi
leaq 0xa027(%rip), %rsi      # 0x1547f
callq 0x4760
movq %r14, -0x68(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x88(%rbp), %rbx
je 0xb484
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0xb48b
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rbx, %rdi
leaq 0xa24a(%rip), %rdx      # 0x15701
movq %rdx, %rsi
callq 0x5790
leaq -0x68(%rbp), %rdi
movq %rbx, %rsi
callq 0x13ed0
jmp 0xb56d
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x48(%rbp), %rdi
leaq 0x9fb2(%rip), %rsi      # 0x154ac
callq 0x4760
movq %r14, -0x68(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
leaq -0x88(%rbp), %rbx
je 0xb526
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0xb52d
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rbx, %rdi
leaq 0xa1a8(%rip), %rdx      # 0x15701
movq %rdx, %rsi
callq 0x5790
leaq -0x68(%rbp), %rdi
movq %rbx, %rsi
callq 0x13ed0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xb589
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0xb59e
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xb5b3
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x43e0
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0xb5d5
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x43e0
movq 0x8(%r15), %r12
movq %r13, %rdi
callq 0xbfde
movl %eax, %edi
callq 0x4780
movq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0xbac2
movq %r12, %r15
movq -0xb8(%rbp), %rbx
decl 0x130(%rbx)
movq (%r15), %r15
cmpq -0x90(%rbp), %r15
jne 0xb2ee
addq $0x898, %rsp            # imm = 0x898
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb631
jmp 0xb652
jmp 0xb66c
jmp 0xb68a
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xb655
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb655
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r14, %rdi
je 0xb66f
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb66f
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0xb68d
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x43e0
jmp 0xb68d
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0xb6af
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x43e0
movq %rbx, %rdi
callq 0x46d0
nop