// File: /workspace/github_cpp_makefile_star2_O3/nickgammon[P]tinymudserver/comms.cpp
// Function: ProcessNewConnection()
void ProcessNewConnection ()
  {
  static struct sockaddr_in sa;
  socklen_t sa_len = sizeof sa;   

  int s;    /* incoming socket */

  /* loop until all outstanding connections are accepted */
  while (true)
    {
    s = accept ( iControl, (struct sockaddr *) &sa, &sa_len);

    /* a bad socket probably means no more connections are outstanding */
    if (s == NO_SOCKET)
      {

      /* blocking is OK - we have accepted all outstanding connections */
      if ( errno == EWOULDBLOCK )
        return;

      perror ("accept");
      return;
      }
        
    /* here on successful accept - make sure socket doesn't block */
    
    if (fcntl (s, F_SETFL, FNDELAY) == -1)
      {
      perror ("fcntl on player socket");
      return;
      }

    string address = inet_ntoa ( sa.sin_addr);
    int port = ntohs (sa.sin_port);
            
    // immediately close connections from blocked IP addresses
    if (blockedIP.find (address) != blockedIP.end ())
      {
      cerr << "Rejected connection from " << address << endl;
      close (s);
      continue;      
      }
      
    tPlayer * p = new tPlayer (s, port, address);
    playerlist.push_back (p);
    
    cout << "New player accepted on socket " << s << 
            ", from address " << address << 
            ", port " << port << endl;
      
    *p << "\nWelcome to the Tiny MUD Server version " << VERSION << "\n"; 
    *p << messagemap ["welcome"];   // message from message file
    *p << p->prompt;    // initial prompt (Enter your name ...)
    
    } /* end of processing *all* new connections */

  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
leaq -0x2c(%rbp), %rdx
movl $0x10, (%rdx)
leaq 0x8331(%rip), %rax      # 0x16300
movl (%rax), %edi
leaq 0x8a68(%rip), %rsi      # 0x16a40
callq 0x3100
cmpl $-0x1, %eax
je 0xe2b1
movl %eax, %r13d
leaq 0x8958(%rip), %rax      # 0x16948
addq $0x8, %rax
movq %rax, -0x98(%rbp)
leaq -0x90(%rbp), %r15
movl %r13d, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x31c0
cmpl $-0x1, %eax
je 0xe2d3
movl 0x8a1f(%rip), %edi      # 0x16a44
callq 0x3160
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
movq %rax, %rsi
leaq -0x70(%rbp), %rdx
callq 0xe6ae
movzwl 0x89fd(%rip), %r12d     # 0x16a42
leaq 0x88fc(%rip), %rdi      # 0x16948
movq %rbx, %rsi
callq 0xed04
cmpq -0x98(%rbp), %rax
je 0xe0c0
movl $0x19, %edx
movq 0x7f7f(%rip), %rdi      # 0x15fe8
leaq 0x2a03(%rip), %rsi      # 0x10a73
callq 0x3370
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x7f64(%rip), %rdi      # 0x15fe8
callq 0x3370
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3220
movl %r13d, %edi
callq 0x35b0
jmp 0xe273
movl $0x110, %edi            # imm = 0x110
callq 0x32e0
movq %rax, %rbx
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %r14
movq %r15, %rdi
callq 0x5170
rolw $0x8, %r12w
movzwl %r12w, %r12d
movq %rbx, %rdi
movl %r13d, %esi
movl %r12d, %edx
movq %r14, %rcx
callq 0xe776
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0xe124
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x32f0
movl $0x18, %edi
callq 0x32e0
movq %rbx, 0x10(%rax)
movq %rax, %rdi
leaq 0x86d4(%rip), %r14      # 0x16810
movq %r14, %rsi
callq 0x3060
incq 0x10(%r14)
movl $0x1e, %edx
movq 0x7e6c(%rip), %rdi      # 0x15fc0
leaq 0x2932(%rip), %rsi      # 0x10a8d
callq 0x3370
movq 0x7e59(%rip), %rdi      # 0x15fc0
movl %r13d, %esi
callq 0x3510
movq %rax, %r13
movl $0xf, %edx
movq %rax, %rdi
leaq 0x292b(%rip), %rsi      # 0x10aac
callq 0x3370
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r13, %rdi
callq 0x3370
movq %rax, %r13
movl $0x7, %edx
movq %rax, %rdi
leaq 0x2914(%rip), %rsi      # 0x10abc
callq 0x3370
movq %r13, %rdi
movl %r12d, %esi
callq 0x3510
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %r12, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3220
movq %rbx, %rdi
leaq 0x28d8(%rip), %rsi      # 0x10ac4
callq 0xe95e
movq %rax, %rdi
leaq 0x8785(%rip), %rsi      # 0x16980
callq 0x6a0a
movq %rax, %rdi
leaq 0x1ec2(%rip), %rsi      # 0x100cc
callq 0xb044
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %r12
movq %r12, %rdi
leaq 0x28c8(%rip), %rsi      # 0x10aed
leaq 0x28c8(%rip), %rdx      # 0x10af4
callq 0x4bc4
leaq 0x8680(%rip), %rdi      # 0x168b8
movq %r12, %rsi
callq 0x796a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a0a
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xe264
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %rbx, %rsi
addq $0x70, %rsi
movq %rbx, %rdi
callq 0x6a0a
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xe28c
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32f0
leaq 0x806d(%rip), %rax      # 0x16300
movl (%rax), %edi
leaq 0x87a4(%rip), %rsi      # 0x16a40
leaq -0x2c(%rbp), %rdx
callq 0x3100
movl %eax, %r13d
cmpl $-0x1, %eax
jne 0xe002
callq 0x3050
cmpl $0xb, (%rax)
jne 0xe2ca
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2784(%rip), %rdi      # 0x10a55
jmp 0xe2da
leaq 0x2782(%rip), %rdi      # 0x10a5c
callq 0x3270
jmp 0xe2bb
movq %rax, %r14
jmp 0xe307
jmp 0xe333
movq %rax, %r14
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0xe307
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x32f0
movl $0x110, %esi            # imm = 0x110
movq %rbx, %rdi
jmp 0xe328
movq %rax, %r14
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0xe336
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32f0
jmp 0xe336
jmp 0xe333
jmp 0xe333
movq %rax, %r14
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xe34f
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %r14, %rdi
callq 0x3530