// File: /workspace/github_cpp_makefile_star2_O1/Thomas1995[P]Rentz/src/server.cpp
// Function: main
int main(int argc, char ** argv) {

  if(argc != 2) {
    printf("Usage: %s number-of-clients\n", argv[0]);
    exit(1);
  }

  int clientsNumber = atoi(argv[1]);

  require(clientsNumber >= 3 && clientsNumber <= 6,
    "The numbers of clients in a game should be between 3 and 6.\n");

  Table::TABLE_SIZE = clientsNumber;

  Table table;
  Server server;

  while(true) {
    const int n = server.poll();
    //there are n new incoming connections
    for(int i = 0; i < n; ++i) {
      const int client = server.acceptConnection();
      
      if(table.GAME_END) {
          Table newTable;
          table = newTable;
      }

      table.addPlayer(client);
    }

    std::this_thread::sleep_for(std::chrono::milliseconds(100));
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
cmpl $0x2, %edi
jne 0x399e
movq 0x8(%rsi), %rdi
callq 0x2380
movl %eax, %ebx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5891(%rip), %rsi      # 0x90b2
leaq 0x58c6(%rip), %rdx      # 0x90ee
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x477e
leal -0x3(%rbx), %eax
xorl %edi, %edi
cmpl $0x4, %eax
setb %dil
movq %r14, %rsi
callq 0x7cfc
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3860
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
leaq 0xaaa1(%rip), %rax      # 0xe308
movl %ebx, (%rax)
leaq 0x88(%rsp), %rdi
callq 0x5f78
movq %rsp, %rdi
callq 0x3a52
leaq 0x90(%rsp), %rbx
leaq 0x30(%rsp), %r14
movq %rsp, %r15
leaq 0x28(%rsp), %r12
movq %r15, %rdi
callq 0x3bb2
movl %eax, %ebp
testl %eax, %eax
jle 0x3969
movq %r15, %rdi
callq 0x2462
movl %eax, %r13d
cmpb $0x1, 0x88(%rsp)
jne 0x3951
movq %r12, %rdi
callq 0x5f78
movb 0x28(%rsp), %al
movb %al, 0x88(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d54
movq 0x48(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3e2a
leaq 0xc8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3f14
movb 0x54(%r14), %al
movb %al, 0x54(%rbx)
movl 0x50(%r14), %eax
movl %eax, 0x50(%rbx)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x3932
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3949
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq %r14, %rdi
callq 0x474e
leaq 0x88(%rsp), %rdi
movl %r13d, %esi
callq 0x6e00
decl %ebp
jne 0x38a5
movq $0x0, 0x28(%rsp)
movq $0x5f5e100, 0x30(%rsp)  # imm = 0x5F5E100
movq %r12, %rdi
movq %r12, %rsi
callq 0x20b0
cmpl $-0x1, %eax
jne 0x3893
callq 0x2050
cmpl $0x4, (%rax)
je 0x397b
jmp 0x3893
movq (%rsi), %rsi
leaq 0x56ed(%rip), %rdi      # 0x9095
xorl %eax, %eax
callq 0x2060
movl $0x1, %edi
callq 0x22c0
jmp 0x39ce
jmp 0x39ce
jmp 0x39ce
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3c28
jmp 0x39d1
movq %rax, %rbx
movl (%rsp), %edi
callq 0x2430
jmp 0x39e6
movq %rax, %rdi
callq 0x35ff
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x3a03
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x3a20
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
leaq 0x90(%rsp), %rdi
callq 0x474e
jmp 0x3a49
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3a49
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0
nop