// File: /workspace/github_cpp_makefile_star2_O2/nickgammon[P]tinymudserver/states.cpp
// Function: ProcessNewPlayerName(tPlayer*, std::istream&)
void ProcessNewPlayerName (tPlayer * p, istream & sArgs)
{
  string playername;
  sArgs >> playername;
  
  /* name can't be blank */
  if (playername.empty ())
    throw runtime_error ("Name cannot be blank.");

  if (playername.find_first_not_of (valid_player_name) != string::npos)
    throw runtime_error ("That player name contains disallowed characters.");
        
  // check for bad names here (from list in control file)
  if (badnameset.find (playername) != badnameset.end ())
    throw runtime_error ("That name is not permitted.");
    
  ifstream f ((PLAYER_DIR + tocapitals (playername) + PLAYER_EXT).c_str (), ios::in);
  if (f || FindPlayer (playername))  // player file on disk, or playing without saving yet
    throw runtime_error ("That player already exists, please choose another name.");
  
  p->playername = tocapitals (playername);
  
  p->connstate = eAwaitingNewPassword;
  p->prompt = "Choose a password for " + p->playername + " ... ";  
  p->badPasswordCount = 0;
    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rsi, %rax
movq %rdi, %rbx
leaq -0x28(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
leaq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0x33c0
cmpq $0x0, -0x30(%rbp)
je 0xa786
leaq 0xa13a(%rip), %rsi      # 0x14720
leaq -0x38(%rbp), %rdi
xorl %edx, %edx
callq 0x32c0
cmpq $-0x1, %rax
jne 0xa7a2
leaq 0xa316(%rip), %r14      # 0x14918
leaq -0x38(%rbp), %rsi
movq %r14, %rdi
callq 0x5c3e
addq $0x8, %r14
cmpq %r14, %rax
jne 0xa7be
leaq -0x98(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x45f8
leaq 0xa0ae(%rip), %rsi      # 0x146e0
leaq -0x58(%rbp), %rdi
leaq -0x98(%rbp), %rdx
callq 0xaef5
leaq 0xa0b7(%rip), %rdx      # 0x14700
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x53f1
movq -0x78(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x3540
leaq -0x78(%rbp), %rdi
callq 0x35c8
leaq -0x58(%rbp), %rdi
callq 0x35c8
leaq -0x98(%rbp), %rdi
callq 0x35c8
movq -0x2a0(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x280(%rbp,%rax)
je 0xa756
leaq -0x38(%rbp), %rdi
callq 0x48f8
testq %rax, %rax
jne 0xa756
leaq -0x78(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x45f8
leaq 0x90(%rbx), %r14
leaq -0x78(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x33b0
movq %r15, %rdi
callq 0x35c8
movl $0x3, 0x68(%rbx)
leaq 0x3138(%rip), %rsi      # 0xd823
leaq -0x58(%rbp), %rdi
movq %r14, %rdx
callq 0x90f3
leaq 0x30cb(%rip), %rdx      # 0xd7c9
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x6851
leaq 0x70(%rbx), %rdi
leaq -0x78(%rbp), %r14
movq %r14, %rsi
callq 0x33b0
movq %r14, %rdi
callq 0x35c8
leaq -0x58(%rbp), %rdi
callq 0x35c8
andl $0x0, 0xd0(%rbx)
leaq -0x2a0(%rbp), %rdi
callq 0x30d0
leaq -0x38(%rbp), %rdi
callq 0x35c8
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %r14
leaq 0x3083(%rip), %rsi      # 0xd7eb
movq %rax, %rdi
callq 0x3140
movq 0x9879(%rip), %rsi      # 0x13ff0
movq 0x983a(%rip), %rdx      # 0x13fb8
movq %r14, %rdi
callq 0x34e0
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %r14
leaq 0x2f8b(%rip), %rsi      # 0xd723
movq %rax, %rdi
callq 0x3140
jmp 0xa7d8
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %r14
leaq 0x2f9c(%rip), %rsi      # 0xd750
movq %rax, %rdi
callq 0x3140
jmp 0xa7d8
pushq $0x10
popq %rdi
callq 0x31b0
movq %rax, %r14
leaq 0x2fff(%rip), %rsi      # 0xd7cf
movq %rax, %rdi
callq 0x3140
movq 0x9811(%rip), %rsi      # 0x13ff0
movq 0x97d2(%rip), %rdx      # 0x13fb8
movq %r14, %rdi
callq 0x34e0
jmp 0xa7f2
jmp 0xa7f2
movq %rax, %rbx
movq %r14, %rdi
callq 0x3270
jmp 0xa863
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x35c8
jmp 0xa852
jmp 0xa84f
jmp 0xa84f
movq %rax, %rbx
movq %r14, %rdi
callq 0x3270
jmp 0xa852
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x35c8
jmp 0xa82f
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x35c8
jmp 0xa83d
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x35c8
jmp 0xa863
jmp 0xa860
jmp 0xa860
movq %rax, %rbx
leaq -0x2a0(%rbp), %rdi
callq 0x30d0
jmp 0xa863
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x35c8
movq %rbx, %rdi
callq 0x3500