// File: /workspace/github_cpp_makefile_star2_O3/ttencate[P]pickomino/pickomino.cc
// Function: main
int main(int argc, char const *const *argv) {
  // for (Roll roll : Roll::allWithDice(2)) {
  //   cout << roll.dice() << ' ' << roll.probability() << '\n';
  // }
  // for (int i = 1; i <= 8; i++) {
  //   cout << i << ' ' << Roll::allWithDice(i).size() << '\n';
  // }
  // return 0;

  int games = 1;
  if (argc > 1) {
    games = atoi(argv[1]);
  }
  if (argc > 2) {
    seedRandom(atoi(argv[2]));
  }

  int optimalWins = 0;
  int simpleWins = 0;
  int ties = 0;
  while (games--) {
    vector<shared_ptr<Strategy>> strategies;
    strategies.push_back(shared_ptr<Strategy>(new OptimalBot("Alice")));
    strategies.push_back(shared_ptr<Strategy>(new SimpleBot("Bob")));
    Game game(strategies, games % 2);
    game.playToEnd();
    switch (game.winner()) {
      case 0:
        optimalWins++;
        break;
      case 1:
        simpleWins++;
        break;
      default:
        ties++;
        break;
    }
  }
  cout << '\n';
  cout << "Alice wins " << optimalWins << " times\n";
  cout << "Bob wins " << simpleWins << " times\n";
  if (ties) {
    cout << "There were " << ties << " ties\n";
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl $0x1, %r14d
cmpl $0x2, %edi
jl 0x4db3
movq %rsi, %rbx
movl %edi, %ebp
movq 0x8(%rsi), %rdi
callq 0x21e0
movl %eax, %r14d
cmpl $0x2, %ebp
je 0x4daa
movq 0x10(%rbx), %rdi
callq 0x21e0
movl %eax, %edi
callq 0x5fa7
testl %r14d, %r14d
je 0x5055
decl %r14d
movl $0x0, 0xc(%rsp)
leaq 0x50(%rsp), %rbp
leaq 0x70(%rsp), %rbx
leaq 0xc0(%rsp), %r12
movl $0x0, 0x8(%rsp)
movl $0x0, 0x4(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0xa0, %edi
callq 0x2160
movq %rax, %r13
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rbp, %rdi
leaq 0x26ae(%rip), %rsi      # 0x74c0
leaq 0x26ac(%rip), %rdx      # 0x74c5
callq 0x59d8
movq %rbp, %rsi
movb $0x1, %bpl
movq %r13, %rdi
movq %rsi, %r15
callq 0x5122
movq %r13, 0x70(%rsp)
xorl %ebp, %ebp
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
callq 0x5a6e
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b04
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
leaq 0x30(%rsp), %rbp
je 0x4e64
callq 0x5500
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x4e78
callq 0x2140
movl $0x28, %edi
callq 0x2160
movq %rax, %r13
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rbp, %rdi
leaq 0x262d(%rip), %rsi      # 0x74c6
leaq 0x2629(%rip), %rdx      # 0x74c9
callq 0x59d8
movq %rbp, %rsi
movb $0x1, %bpl
movq %r13, %rdi
callq 0x51f8
movq %r13, 0x70(%rsp)
xorl %ebp, %ebp
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
callq 0x5ca6
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x5b04
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
movq %r15, %rbp
je 0x4ee6
callq 0x5500
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x4efa
callq 0x2140
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0x528a
movl %r14d, %eax
shrl $0x1f, %eax
addl %r14d, %eax
andl $-0x2, %eax
movl %r14d, %edx
subl %eax, %edx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5328
movq %r12, %rdi
callq 0x54ba
movq %rbx, %rdi
callq 0x33a8
movq %rbx, %rdi
callq 0x3502
testl %eax, %eax
je 0x4f4a
cmpl $0x1, %eax
jne 0x4f50
incl 0x8(%rsp)
jmp 0x4f54
incl 0x4(%rsp)
jmp 0x4f54
incl 0xc(%rsp)
leaq 0x90(%rsp), %rdi
callq 0x3658
movq %rbx, %rdi
callq 0x5594
leaq 0x10(%rsp), %rdi
callq 0x54ba
addl $-0x1, %r14d
jb 0x4de0
leaq 0x70(%rsp), %rsi
movb $0xa, (%rsi)
movq 0x6044(%rip), %rbx      # 0xafd0
movl $0x1, %edx
movq %rbx, %rdi
callq 0x2180
leaq 0x252a(%rip), %rsi      # 0x74ca
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movl 0x4(%rsp), %esi
callq 0x2230
leaq 0x2516(%rip), %r14      # 0x74d6
movl $0x7, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2180
leaq 0x2507(%rip), %rsi      # 0x74de
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movl 0x8(%rsp), %esi
callq 0x2230
movl $0x7, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2180
movl 0xc(%rsp), %ebp
testl %ebp, %ebp
je 0x5041
movq 0x5fc1(%rip), %rbx      # 0xafd0
leaq 0x24d2(%rip), %rsi      # 0x74e8
movl $0xb, %edx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2230
leaq 0x24c0(%rip), %rsi      # 0x74f4
movl $0x6, %edx
movq %rax, %rdi
callq 0x2180
xorl %eax, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x0, 0x4(%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
jmp 0x4f7d
jmp 0x50a9
jmp 0x508e
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x5088
callq 0x5500
xorl %ebp, %ebp
jmp 0x50df
jmp 0x50a9
movq %rax, %rbx
jmp 0x5107
movq %rax, %rbx
movq 0x78(%rsp), %rdi
testq %rdi, %rdi
je 0x50a5
callq 0x5500
xorl %ebp, %ebp
jmp 0x50ee
movq %rax, %rbx
jmp 0x510f
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x54ba
jmp 0x510f
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x3658
leaq 0x70(%rsp), %rdi
callq 0x5594
jmp 0x510f
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
jmp 0x50f8
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5102
callq 0x2140
testb %bpl, %bpl
je 0x510f
movq %r13, %rdi
callq 0x2140
leaq 0x10(%rsp), %rdi
callq 0x54ba
movq %rbx, %rdi
callq 0x2240
nop