#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void rover_stats(char winner, int player1, int player2, int wplayer1,
                 int wplayer2, int nreplays, int nstalemates, int mode) {
  int p1stats, p2stats;
  p1stats = wplayer1 * 100 / nreplays;
  p2stats = wplayer2 * 100 / nreplays;
  if (winner == player1) {
    printf("TicTacToe! %c wins!\n", winner);
    printf("Current winner has won %d game(s) out of %d, ", wplayer1, nreplays);
    printf("%d%% win(s) including %d stalemate(s)\n", p1stats, nstalemates);
  } else if (winner == player2) {
    printf("TicTacToe! %c wins!\n", winner);
    printf("Current winner has won %d game(s) out of %d, ", wplayer2, nreplays);
    printf("%d%% win(s) including %d stalemate(s)\n", p2stats, nstalemates);
  } else {
    printf("Stalemate... nobody won :(\n");
    if (mode == 1) {
      printf("Human player has won %d game(s), ", wplayer1);
      printf("Computer player has won %d game(s)\n", wplayer2);
    } else {
      printf("Player 1 has won %d game(s), ", wplayer1);
      printf("Player 2 has won %d game(s)\n", wplayer2);
    }
    printf("Stalemate count is %d time(s)\n", nstalemates);
  }
}


x86 assembly (clang, -O0):
<rover_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    0x18(%rbp),%edi
mov    0x10(%rbp),%edi
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
imul   $0x64,-0x10(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x1c(%rbp)
imul   $0x64,-0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x20(%rbp)
movsbl -0x1(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1197 <rover_stats+0x87>
movsbl -0x1(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    0x10(%rbp),%edx
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <rover_stats+0x14a>
movsbl -0x1(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11e3 <rover_stats+0xd3>
movsbl -0x1(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
mov    0x10(%rbp),%edx
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1255 <rover_stats+0x145>
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,0x18(%rbp)
jne    1222 <rover_stats+0x112>
mov    -0x10(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1244 <rover_stats+0x134>
mov    -0x10(%rbp),%esi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x10(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <rover_stats+0x14a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rover_stats>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%ebx
mov    %ecx,%r15d
mov    %edx,%ecx
mov    0x30(%rsp),%r14d
imul   $0x64,%r8d,%eax
cltd
idiv   %r9d
cmp    %esi,%edi
jne    1176 <rover_stats+0x56>
imul   $0x64,%r15d,%eax
cltd
idiv   %ebx
mov    %eax,%ebp
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    %r15d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
mov    %ebp,%esi
jmp    11ac <rover_stats+0x8c>
mov    %r8d,%ebp
cmp    %ecx,%edi
jne    11be <rover_stats+0x9e>
mov    %eax,%r12d
lea    0xe79(%rip),%rdi
mov    %ecx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    %r12d,%esi
mov    %r14d,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
mov    0x38(%rsp),%ebx
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x1,%ebx
lea    0xe92(%rip),%rax
lea    0xed1(%rip),%rdi
cmove  %rax,%rdi
lea    0xea2(%rip),%rax
lea    0xedd(%rip),%rbx
cmove  %rax,%rbx
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"TicTacToe! %c wins!\0A\00"
@.str.1 = [46 x i8] c"Current winner has won %d game(s) out of %d, \00"
@.str.2 = [39 x i8] c"%d%% win(s) including %d stalemate(s)\0A\00"
@.str.3 = [28 x i8] c"Stalemate... nobody won :(\0A\00"
@.str.4 = [34 x i8] c"Human player has won %d game(s), \00"
@.str.5 = [36 x i8] c"Computer player has won %d game(s)\0A\00"
@.str.6 = [30 x i8] c"Player 1 has won %d game(s), \00"
@.str.7 = [29 x i8] c"Player 2 has won %d game(s)\0A\00"
@.str.8 = [31 x i8] c"Stalemate count is %d time(s)\0A\00"
define void @rover_stats(i8 signext %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8 %0, i8* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%19 = load i32, i32* %12
%20 = mul nsw i32 %19, 100
%21 = load i32, i32* %14
%22 = sdiv i32 %20, %21
store i32 %22, i32* %17
%23 = load i32, i32* %13
%24 = mul nsw i32 %23, 100
%25 = load i32, i32* %14
%26 = sdiv i32 %24, %25
store i32 %26, i32* %18
%27 = load i8, i8* %9
%28 = sext i8 %27 to i32
%29 = load i32, i32* %10
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %41
31: ; preds = %8
%32 = load i8, i8* %9
%33 = sext i8 %32 to i32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %12
%36 = load i32, i32* %14
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %17
%39 = load i32, i32* %15
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %38, i32 %39)
br label %74
41: ; preds = %8
%42 = load i8, i8* %9
%43 = sext i8 %42 to i32
%44 = load i32, i32* %11
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %56
46: ; preds = %41
%47 = load i8, i8* %9
%48 = sext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %13
%51 = load i32, i32* %14
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %50, i32 %51)
%53 = load i32, i32* %18
%54 = load i32, i32* %15
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %53, i32 %54)
br label %73
56: ; preds = %41
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%58 = load i32, i32* %16
%59 = icmp eq i32 %58, 1
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i32, i32* %12
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %13
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %63)
br label %70
65: ; preds = %56
%66 = load i32, i32* %12
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 %66)
%68 = load i32, i32* %13
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %65, %60
%71 = load i32, i32* %15
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %71)
br label %73
73: ; preds = %70, %46
br label %74
74: ; preds = %73, %31
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"TicTacToe! %c wins!\0A\00"
@.str.1 = [46 x i8] c"Current winner has won %d game(s) out of %d, \00"
@.str.2 = [39 x i8] c"%d%% win(s) including %d stalemate(s)\0A\00"
@.str.4 = [34 x i8] c"Human player has won %d game(s), \00"
@.str.5 = [36 x i8] c"Computer player has won %d game(s)\0A\00"
@.str.6 = [30 x i8] c"Player 1 has won %d game(s), \00"
@.str.7 = [29 x i8] c"Player 2 has won %d game(s)\0A\00"
@.str.8 = [31 x i8] c"Stalemate count is %d time(s)\0A\00"
@str = [27 x i8] c"Stalemate... nobody won :(\00"
define void @rover_stats(i8 signext %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = mul nsw i32 %4, 100
%10 = sdiv i32 %9, %5
%11 = sext i8 %0 to i32
%12 = icmp eq i32 %11, %1
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = mul nsw i32 %3, 100
%15 = sdiv i32 %14, %5
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %1)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %5)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %6)
br label %33
19: ; preds = %8
%20 = icmp eq i32 %11, %2
br i1 %20, label %21, label %25
21: ; preds = %19
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %2)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %5)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %6)
br label %33
25: ; preds = %19
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%27 = icmp eq i32 %7, 1
%28 = select i1 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0)
%29 = select i1 %27, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %28, i32 %3)
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %29, i32 %4)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %6)
br label %33
33: ; preds = %21, %25, %13
ret void
}