// File: /workspace/github_cpp_makefile_star2_O3/Thomas1995[P]Rentz/src/table.cpp
// Function: Table::PlayRound()
void Table::PlayRound() {
  std::cout << "\nStarting new round!\n\n";

  // For each of the 8 turns
  for(int roundstep = 1; roundstep <= 8; ++roundstep) {
    cardStack.clear();

    // Play the turn
    PlayTurn(firstPlayer);

    // Trigger EndTurn to all players
    for(size_t i=0;i<players.size();++i) {
      players[i].sendCards(cardStack);
      players[i].turnEnd();
    }

    // check for winner
    int winnerIndex = 0;
    Card winnerCard = cardStack[winnerIndex];

    for(size_t i=1;i<cardStack.size();++i) {
      if(winnerCard.isBeatenBy(cardStack[i])) {
        winnerCard = cardStack[i];
        winnerIndex = i;
      }
    }

    // change the first connection to go
    while(winnerIndex--) {
      ++firstPlayer;
      if(firstPlayer == players.end())
        firstPlayer = players.begin();
    }

    // change score
    ChangeScore();
  }

  std::cout << "Round over!\n\n";

  // print the final scores
  printScores();
  std::cout << "\n--------------------------\n";

  std::cout << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq 0x7808(%rip), %rdi      # 0xdfc8
leaq 0x2eeb(%rip), %rsi      # 0x96b2
movl $0x16, %edx
callq 0x2290
leaq 0x28(%r14), %r15
movl $0x1, %ebp
leaq 0x10(%rsp), %r12
movabsq $-0x34307aae9fc8985d, %r13 # imm = 0xCBCF8551603767A3
movl %ebp, 0xc(%rsp)
movq 0x28(%r14), %rax
cmpq %rax, 0x30(%r14)
je 0x67fb
movq %rax, 0x30(%r14)
movq 0x20(%r14), %rsi
movq %r14, %rdi
callq 0x6d82
movq 0x8(%r14), %rdi
cmpq %rdi, 0x10(%r14)
je 0x684e
xorl %ebx, %ebx
xorl %ebp, %ebp
addq %rbx, %rdi
movq %r15, %rsi
callq 0x4bb2
movq 0x8(%r14), %rdi
addq %rbx, %rdi
callq 0x4c76
incq %rbp
movq 0x8(%r14), %rdi
movq 0x10(%r14), %rax
subq %rdi, %rax
sarq $0x3, %rax
imulq %r13, %rax
addq $0x2058, %rbx           # imm = 0x2058
cmpq %rax, %rbp
jb 0x6815
movq 0x28(%r14), %rsi
movq %r12, %rdi
callq 0x5af4
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rax
subq %rcx, %rax
cmpq $0x9, %rax
movl 0xc(%rsp), %ebp
jb 0x68db
xorl %ebx, %ebx
movl $0x1, %ebp
leaq (%rcx,%rbp,8), %rsi
movq %r12, %rdi
callq 0x5c4a
movq (%r15), %rcx
testb %al, %al
je 0x689a
movb 0x4(%rcx,%rbp,8), %al
movb %al, 0x14(%rsp)
movl (%rcx,%rbp,8), %eax
movl %eax, 0x10(%rsp)
movl %ebp, %ebx
incq %rbp
movq 0x30(%r14), %rax
subq %rcx, %rax
sarq $0x3, %rax
cmpq %rax, %rbp
jb 0x6876
testl %ebx, %ebx
movl 0xc(%rsp), %ebp
je 0x68db
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
movq 0x20(%r14), %rcx
addq $0x2058, %rcx           # imm = 0x2058
cmpq %rdx, %rcx
cmoveq %rax, %rcx
decl %ebx
jne 0x68c1
movq %rcx, 0x20(%r14)
movl 0xc(%rsp), %ebp
movq %r14, %rdi
callq 0x32fc
incl %ebp
cmpl $0x9, %ebp
jne 0x67e9
leaq 0x2dd4(%rip), %rsi      # 0x96c9
movl $0xd, %edx
movq 0x76c7(%rip), %rbx      # 0xdfc8
movq %rbx, %rdi
callq 0x2290
movq %r14, %rdi
callq 0x695c
leaq 0x2dbf(%rip), %rsi      # 0x96d7
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x2290
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2180
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop