// File: /workspace/github_cpp_makefile_star2_O2/solaldunckel[P]webserv/srcs/HTTP/Server.cpp
// Function: Server::newConnection(int)
void Server::newConnection(int fd) {
  struct sockaddr_storage their_addr;
  socklen_t addr_size = sizeof(their_addr);

  FD_CLR(fd, &read_fds_);

  int clientFd = accept(fd, (struct sockaddr *)&their_addr, &addr_size);

  if (clientFd == -1)
    return ;

  Log.print(INFO, head_ + "new connection on " + ft::to_string(running_server_[fd].ip_) + ":" + ft::to_string(running_server_[fd].port_), GREEN);

  fcntl(clientFd, F_SETFL, O_NONBLOCK);

  std::string client_addr = ft::inet_ntop(ft::get_in_addr((struct sockaddr *)&their_addr));
  clients_[clientFd] = new Client(clientFd, client_addr, running_server_[fd], worker_id_, clients_.size() >= MAX_CLIENT);

  add_to_fd_set(clientFd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movl %esi, %ecx
movq %rdi, %rbx
movl %esi, 0x4(%rsp)
leaq 0x34(%rsp), %r8
movl $0x80, (%r8)
pushq $-0x2
popq %rsi
rolq %cl, %rsi
pushq $0x40
popq %rdi
movl %ecx, %eax
cltd
idivl %edi
cltq
andq %rsi, 0xf8(%rbx,%rax,8)
leaq 0x118(%rsp), %rsi
movl %ecx, %edi
movq %r8, %rdx
callq 0x4110
movl %eax, 0xc(%rsp)
cmpl $-0x1, %eax
je 0x13cf4
movl %eax, %ebp
leaq 0x218(%rbx), %rsi
leaq 0x8e96(%rip), %rdx      # 0x1c9c7
leaq 0xb8(%rsp), %rdi
callq 0x60d3
leaq 0x18(%rbx), %r14
leaq 0x4(%rsp), %rsi
movq %r14, %rdi
callq 0x1495e
leaq 0x78(%rsp), %rdi
movq %rax, %rsi
callq 0x45e0
leaq 0x98(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x149cd
leaq 0xd8(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
leaq 0x98(%rsp), %rdx
callq 0x61d5
leaq 0x887a(%rip), %rdx      # 0x1c40c
leaq 0x10(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x5292
leaq 0x4(%rsp), %rsi
movq %r14, %rdi
callq 0x1495e
movl 0x20(%rax), %esi
leaq 0x58(%rsp), %rdi
callq 0xde17
leaq 0xf8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x58(%rsp), %rdx
callq 0x61d5
leaq 0x8de5(%rip), %rsi      # 0x1c9c1
leaq 0x38(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x5328
leaq 0x178f6(%rip), %rdi     # 0x2b4e8
pushq $0x1
popq %rsi
leaq 0xf8(%rsp), %rdx
leaq 0x38(%rsp), %rcx
xorl %r8d, %r8d
callq 0x18e1e
leaq 0x38(%rsp), %rdi
callq 0x4898
leaq 0xf8(%rsp), %rdi
callq 0x4898
leaq 0x58(%rsp), %rdi
callq 0x4898
leaq 0x10(%rsp), %rdi
callq 0x4898
leaq 0xd8(%rsp), %rdi
callq 0x4898
leaq 0x98(%rsp), %rdi
callq 0x4898
leaq 0x78(%rsp), %rdi
callq 0x4898
leaq 0xb8(%rsp), %rdi
callq 0x4898
pushq $0x4
popq %rsi
movl %ebp, %edi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x4260
leaq 0x118(%rsp), %rdi
callq 0x1b9a7
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x1b839
pushq $0x50
popq %rdi
callq 0x4460
movq %rax, %r15
leaq 0x4(%rsp), %rsi
movq %r14, %rdi
callq 0x1495e
movl (%rbx), %r8d
xorl %r9d, %r9d
cmpq $0x3e8, 0x70(%rbx)      # imm = 0x3E8
setae %r9b
leaq 0x10(%rsp), %rdx
movq %r15, %rdi
movl %ebp, %esi
movq %rax, %rcx
callq 0xe014
leaq 0x48(%rbx), %rdi
leaq 0xc(%rsp), %rsi
callq 0x14a54
movq %r15, (%rax)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x13a62
leaq 0x10(%rsp), %rdi
callq 0x4898
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x4898
jmp 0x13d14
movq %rax, %rbx
leaq 0xf8(%rsp), %rdi
callq 0x4898
jmp 0x13d26
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4898
jmp 0x13d54
movq %rax, %rbx
jmp 0x13d5e
movq %rax, %rbx
jmp 0x13d6b
movq %rax, %rbx
jmp 0x13d78
movq %rax, %rbx
pushq $0x50
popq %rsi
movq %r15, %rdi
callq 0x4490
jmp 0x13d94
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4898
leaq 0xd8(%rsp), %rdi
callq 0x4898
leaq 0x98(%rsp), %rdi
callq 0x4898
leaq 0x78(%rsp), %rdi
callq 0x4898
jmp 0x13d87
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
jmp 0x13d99
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x4898
movq %rbx, %rdi
callq 0x4750