// File: /workspace/github_cpp_makefile_star2_O1/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 0x7804(%rip), %rdi      # 0xdfc8
leaq 0x2eb7(%rip), %rsi      # 0x9682
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 0x67ff
movq %rax, 0x30(%r14)
movq 0x20(%r14), %rsi
movq %r14, %rdi
callq 0x6d84
movq 0x8(%r14), %rdi
cmpq %rdi, 0x10(%r14)
je 0x6852
xorl %ebx, %ebx
xorl %ebp, %ebp
addq %rbx, %rdi
movq %r15, %rsi
callq 0x4b98
movq 0x8(%r14), %rdi
addq %rbx, %rdi
callq 0x4c5c
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 0x6819
movq 0x28(%r14), %rsi
movq %r12, %rdi
callq 0x5abc
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
subq %rax, %rcx
xorl %ebx, %ebx
cmpq $0x9, %rcx
jb 0x68b3
xorl %ebx, %ebx
movl $0x1, %ebp
leaq (%rax,%rbp,8), %rsi
movq %r12, %rdi
callq 0x5c04
testb %al, %al
je 0x689c
movq (%r15), %rax
movb 0x4(%rax,%rbp,8), %cl
movb %cl, 0x14(%rsp)
movl (%rax,%rbp,8), %eax
movl %eax, 0x10(%rsp)
movl %ebp, %ebx
incq %rbp
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %rcx, %rbp
jb 0x6878
testl %ebx, %ebx
movl 0xc(%rsp), %ebp
je 0x68e1
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 0x68c7
movq %rcx, 0x20(%r14)
movl 0xc(%rsp), %ebp
movq %r14, %rdi
callq 0x331c
incl %ebp
cmpl $0x9, %ebp
jne 0x67ed
leaq 0x2d9e(%rip), %rsi      # 0x9699
movl $0xd, %edx
movq 0x76c1(%rip), %rbx      # 0xdfc8
movq %rbx, %rdi
callq 0x2290
movq %r14, %rdi
callq 0x6962
leaq 0x2d89(%rip), %rsi      # 0x96a7
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