// File: /workspace/github_cpp_makefile_star2_O3/nickgammon[P]tinymudserver/player.cpp
// Function: tPlayer::ProcessRead()
void tPlayer::ProcessRead ()
{
  
  if (closing)
    return;   // once closed, don't handle any pending input
  
  // I make it static to save allocating a buffer each time.
  // Hopefully this function won't be called recursively.
  static vector<char> buf (1000);  // reserve 1000 bytes for reading into
  
  int nRead = read (s, &buf [0], buf.size ());
  
  if (nRead == -1)
    {
    if (errno != EWOULDBLOCK)
      perror ("read from player");
    return;
    }

  if (nRead <= 0)
    {
    close (s);
    cerr << "Connection " << s << " closed" << endl;
    s = NO_SOCKET;
    DoCommand ("quit");  // tell others the s/he has left
    return;
    }

  inbuf += string (&buf [0], nRead);    /* add to input buffer */

  /* try to extract lines from the input buffer */
  for ( ; ; )
    {
    string::size_type i = inbuf.find ('\n');
    if (i == string::npos)
      break;  /* no more at present */

    string sLine = inbuf.substr (0, i);  /* extract first line */
    inbuf = inbuf.substr (i + 1, string::npos); /* get rest of string */

    ProcessPlayerInput (this, Trim (sLine));  /* now, do something with it */        
    }
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, -0x50(%rbp)
cmpb $0x0, 0xd8(%rdi)
jne 0x5ef4
movb 0x1082a(%rip), %al      # 0x164e0
testb %al, %al
je 0x5f03
movq -0x50(%rbp), %r15
movl (%r15), %edi
movq 0x107fc(%rip), %rsi     # 0x164c8
movq 0x107fd(%rip), %rdx     # 0x164d0
subq %rsi, %rdx
callq 0x3400
cmpl $-0x1, %eax
je 0x5e19
testl %eax, %eax
jle 0x5e41
movq 0x107d5(%rip), %rsi     # 0x164c8
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
leaq -0x38(%rbp), %rcx
movq %rcx, -0x10(%rcx)
addq %rsi, %rax
leaq -0x48(%rbp), %rdi
movq %rax, %rdx
callq 0x4bc4
leaq 0x28(%r15), %r14
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r14, %rdi
callq 0x30f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5d3c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %r14, %rdi
movl $0xa, %esi
xorl %edx, %edx
callq 0x33c0
cmpq $-0x1, %rax
je 0x5ef4
movq %rax, %r13
leaq -0x60(%rbp), %rbx
leaq -0x48(%rbp), %r15
leaq -0x70(%rbp), %r12
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x3320
incq %r13
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movq $-0x1, %rcx
callq 0x3320
movq %r14, %rdi
movq %r12, %rsi
callq 0x33a0
movq -0x70(%rbp), %rdi
cmpq %rbx, %rdi
je 0x5dac
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %r12, %rdi
movq %r15, %rsi
leaq 0x106ef(%rip), %rdx     # 0x164a8
callq 0x4d19
movq -0x50(%rbp), %rdi
movq %r12, %rsi
callq 0xe3ca
movq -0x70(%rbp), %rdi
cmpq %rbx, %rdi
je 0x5ddf
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32f0
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5df8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %r14, %rdi
movl $0xa, %esi
xorl %edx, %edx
callq 0x33c0
movq %rax, %r13
cmpq $-0x1, %rax
jne 0x5d64
jmp 0x5ef4
callq 0x3050
cmpl $0xb, (%rax)
je 0x5ef4
leaq 0xa3fc(%rip), %rdi      # 0x1022a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3270
movl (%r15), %edi
callq 0x35b0
movq 0x10198(%rip), %r14     # 0x15fe8
leaq 0xa3e4(%rip), %rsi      # 0x1023b
movl $0xb, %edx
movq %r14, %rdi
callq 0x3370
movl (%r15), %esi
movq %r14, %rdi
callq 0x3510
movq %rax, %r14
leaq 0xa3ce(%rip), %rsi      # 0x10247
movl $0x7, %edx
movq %rax, %rdi
callq 0x3370
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %esi
movq %r14, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3220
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
leaq -0x38(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0xa38c(%rip), %rsi      # 0x1024f
leaq 0xa389(%rip), %rdx      # 0x10253
leaq -0x48(%rbp), %rdi
callq 0x4bc4
leaq -0x48(%rbp), %rsi
movq %r15, %rdi
callq 0x5b06
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
je 0x5ef4
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x105d6(%rip), %rdi     # 0x164e0
callq 0x3560
testl %eax, %eax
je 0x5cbe
xorps %xmm0, %xmm0
movups %xmm0, 0x105a7(%rip)    # 0x164c8
movq $0x0, 0x105ac(%rip) # 0x164d8
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x32e0
movq %rax, 0x1058b(%rip)     # 0x164c8
leaq 0x10584(%rip), %r14     # 0x164c8
movq %rax, %rbx
addq $0x3e8, %rbx            # imm = 0x3E8
movq %rbx, 0x10583(%rip)     # 0x164d8
movl $0x3e8, %edx            # imm = 0x3E8
movq %rax, %rdi
xorl %esi, %esi
callq 0x31b0
movq %rbx, 0x10565(%rip)     # 0x164d0
leaq 0x55a(%rip), %rdi       # 0x64cc
leaq 0x1036f(%rip), %rdx     # 0x162e8
movq %r14, %rsi
callq 0x32a0
leaq 0x10558(%rip), %rdi     # 0x164e0
callq 0x3210
jmp 0x5cbe
movq %rax, %r14
leaq 0x10544(%rip), %rdi     # 0x164e0
callq 0x31f0
jmp 0x5fd8
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x5fcc
jmp 0x5fd8
jmp 0x5fb5
jmp 0x5fbc
movq %rax, %r14
jmp 0x5fd8
jmp 0x5fbc
movq %rax, %r14
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5fd8
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x32f0
movq %r14, %rdi
callq 0x3530
movq %rax, %r14
movq -0x70(%rbp), %rdi
cmpq %rbx, %rdi
je 0x5fbf
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x32f0
jmp 0x5fbf