// File: /workspace/github_cpp_makefile_star2_O1/mbourand[P]webserv/srcs/tcp-server.cpp
// Function: handle_new_connection(ServerSocket&, std::__cxx11::list<Client, std::allocator<Client>>&)
int		handle_new_connection(ServerSocket &server, std::list<Client> &clients)
{
	if (clients.size() <= g_webserv.max_connections)
	{
		Client	new_client;
		new_client.sckt = new ServerSocket;
		new_client.req = new Request(server.getServerPort());
		new_client.sckt->setServerPort(server.getServerPort());
		server.Accept(*new_client.sckt);
		clients.push_back(new_client);
		return (Logger::print("New Client Connected ("+new_client.sckt->getIPAddress()+")", new_client.sckt->GetSocket(), SUCCESS, NORMAL));
	}
	else
	{
		return (Logger::print("Connections limit reached, client pending connection.", 0, ERROR, NORMAL));
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl 0x20114(%rip), %eax     # 0x4e62c
cmpq %rax, 0x10(%rsi)
jbe 0x2e570
leaq 0x58(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xec1a(%rip), %rsi      # 0x3d148
leaq 0xec48(%rip), %rdx      # 0x3d17d
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0x80f4
movq %rbx, %rdi
xorl %esi, %esi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x12c94
movl %eax, %ebx
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e73d
movq 0x58(%rsp), %rsi
jmp 0x2e735
movq %rsi, %r14
movq %rdi, %r15
movl $0x60, %edi
callq 0x74a0
movq %rax, %rbx
movq %rax, %rdi
callq 0x1256c
leaq 0x1f556(%rip), %rax     # 0x4dae8
addq $0x10, %rax
movq %rax, (%rbx)
movq %rbx, %rax
addq $0x50, %rax
movq %rax, 0x40(%rbx)
movq $0x0, 0x48(%rbx)
movb $0x0, 0x50(%rbx)
movl $0x1a0, %edi            # imm = 0x1A0
callq 0x74a0
movq %rax, %r12
movq %r15, %rdi
callq 0x12416
movq %r12, %rdi
movl %eax, %esi
callq 0x33810
movq %r15, %rdi
callq 0x12416
movq %rbx, %rdi
movl %eax, %esi
callq 0x12360
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1227e
movl $0x20, %edi
callq 0x74a0
movq %rbx, 0x10(%rax)
movq %r12, 0x18(%rax)
movq %rax, %rdi
movq %r14, %rsi
callq 0x7090
incq 0x10(%r14)
leaq 0x68(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1243e
leaq 0xeb0d(%rip), %rcx      # 0x3d131
movl $0x16, %r8d
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x7500
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2e65d
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
jmp 0x2e664
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0xc7d5(%rip), %rsi      # 0x3ae5c
callq 0x78d0
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x2e6b4
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x2e6bc
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0x12c90
leaq 0x8(%rsp), %rdi
movl %eax, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x12c94
movl %eax, %ebx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e70b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e722
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e73d
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x74b0
movl %ebx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %r14
jmp 0x2e793
movq %rax, %r14
jmp 0x2e7aa
movq %rax, %r14
movl $0x60, %esi
movq %rbx, %rdi
jmp 0x2e7cd
movq %rax, %r14
movq 0x48(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e7d2
movq 0x58(%rsp), %rsi
jmp 0x2e7bd
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x2e793
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x74b0
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x2e7aa
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x74b0
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2e7d2
movq 0x78(%rsp), %rsi
incq %rsi
jmp 0x2e7cd
movq %rax, %r14
movl $0x1a0, %esi            # imm = 0x1A0
movq %r12, %rdi
callq 0x74b0
movq %r14, %rdi
callq 0x7810