// File: /workspace/github_cpp_makefile_star2_O3/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 0x3992
movq 0x8(%rsi), %rdi
callq 0x2380
movl %eax, %ebx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x589d(%rip), %rsi      # 0x90b2
leaq 0x58d2(%rip), %rdx      # 0x90ee
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x4794
leal -0x3(%rbx), %eax
xorl %edi, %edi
cmpl $0x4, %eax
setb %dil
movq %r14, %rsi
callq 0x80b8
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3854
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
leaq 0xaaad(%rip), %rax      # 0xe308
movl %ebx, (%rax)
leaq 0x88(%rsp), %rdi
callq 0x5fa0
movq %rsp, %rdi
callq 0x3a46
leaq 0x90(%rsp), %rbx
leaq 0x30(%rsp), %r14
movq %rsp, %r15
leaq 0x28(%rsp), %r12
movq %r15, %rdi
callq 0x3b98
movl %eax, %ebp
testl %eax, %eax
jle 0x395d
movq %r15, %rdi
callq 0x2462
movl %eax, %r13d
cmpb $0x1, 0x88(%rsp)
jne 0x3945
movq %r12, %rdi
callq 0x5fa0
movb 0x28(%rsp), %al
movb %al, 0x88(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d4a
movq 0x48(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x3e20
leaq 0xc8(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x3f1c
movb 0x54(%r14), %al
movb %al, 0x54(%rbx)
movl 0x50(%r14), %eax
movl %eax, 0x50(%rbx)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x3926
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x393d
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq %r14, %rdi
callq 0x4764
leaq 0x88(%rsp), %rdi
movl %r13d, %esi
callq 0x6dfe
decl %ebp
jne 0x3899
movq $0x0, 0x28(%rsp)
movq $0x5f5e100, 0x30(%rsp)  # imm = 0x5F5E100
movq %r12, %rdi
movq %r12, %rsi
callq 0x20b0
cmpl $-0x1, %eax
jne 0x3887
callq 0x2050
cmpl $0x4, (%rax)
je 0x396f
jmp 0x3887
movq (%rsi), %rsi
leaq 0x56f9(%rip), %rdi      # 0x9095
xorl %eax, %eax
callq 0x2060
movl $0x1, %edi
callq 0x22c0
jmp 0x39c2
jmp 0x39c2
jmp 0x39c2
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x3c0e
jmp 0x39c5
movq %rax, %rbx
movl (%rsp), %edi
callq 0x2430
jmp 0x39da
movq %rax, %rdi
callq 0x35ea
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x39f7
movq 0xd8(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x3a14
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x2230
leaq 0x90(%rsp), %rdi
callq 0x4764
jmp 0x3a3d
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x3a3d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0
nop