#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 */
scalar_t__ anyWinners(char *);
int /*<<< orphan*/ playAgain(void (*)());
int /*<<< orphan*/ printGameboard(char *);
int /*<<< orphan*/ printf(char *, ...);
void checkForEndOfGame(int *i, int *field, char board[], void (*mode)(void)) {
  if (*i > 3 && anyWinners(board)) {
    printGameboard(board);
    printf("   |                                \"%c\" WINS!                   "
           "            |\n",
           board[*field - 1]);
    playAgain(mode);
  } else if (*i == 8) {
    printGameboard(board);
    printf("   |                              IT'S A TIE!                      "
           "         |\n");
    playAgain(mode);
  }
}


x86 assembly (clang, -O0):
<checkForEndOfGame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x3,(%rax)
jle    11b1 <checkForEndOfGame+0x71>
mov    -0x18(%rbp),%rdi
call   1040 <anyWinners@plt>
cmp    $0x0,%rax
je     11b1 <checkForEndOfGame+0x71>
mov    -0x18(%rbp),%rdi
call   1030 <printGameboard@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <playAgain@plt>
jmp    11e3 <checkForEndOfGame+0xa3>
mov    -0x8(%rbp),%rax
cmpl   $0x8,(%rax)
jne    11de <checkForEndOfGame+0x9e>
mov    -0x18(%rbp),%rdi
call   1030 <printGameboard@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <playAgain@plt>
jmp    11e3 <checkForEndOfGame+0xa3>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkForEndOfGame>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmpl   $0x4,(%rdi)
jl     11c3 <checkForEndOfGame+0x73>
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1050 <anyWinners@plt>
test   %rax,%rax
je     1197 <checkForEndOfGame+0x47>
mov    %r12,%rdi
call   1040 <printGameboard@plt>
movslq (%r15),%rax
movsbl -0x1(%rax,%r12,1),%esi
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11b0 <checkForEndOfGame+0x60>
cmpl   $0x8,(%rbx)
jne    11c3 <checkForEndOfGame+0x73>
mov    %r12,%rdi
call   1040 <printGameboard@plt>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <playAgain@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [80 x i8] c" | \22%c\22 WINS! |\0A\00"
@.str.1 = [79 x i8] c" | IT'S A TIE! |\0A\00"
define void @checkForEndOfGame(i32* %0, i32* %1, i8* %2, void ()* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca void ()*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store void ()* %3, void ()** %8
%9 = load i32*, i32** %5
%10 = load i32, i32* %9
%11 = icmp sgt i32 %10, 3
br i1 %11, label %12, label %31
12: ; preds = %4
%13 = load i8*, i8** %7
%14 = call i64 @anyWinners(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load i8*, i8** %7
%18 = call i32 @printGameboard(i8* %17)
%19 = load i8*, i8** %7
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load void ()*, void ()** %8
%29 = bitcast void ()* %28 to void (...)*
%30 = call i32 @playAgain(void (...)* %29)
br label %43
31: ; preds = %12, %4
%32 = load i32*, i32** %5
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 8
br i1 %34, label %35, label %42
35: ; preds = %31
%36 = load i8*, i8** %7
%37 = call i32 @printGameboard(i8* %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0))
%39 = load void ()*, void ()** %8
%40 = bitcast void ()* %39 to void (...)*
%41 = call i32 @playAgain(void (...)* %40)
br label %42
42: ; preds = %35, %31
br label %43
43: ; preds = %42, %16
ret void
}

LLVM IR (-O2):
@.str = [80 x i8] c" | \22%c\22 WINS! |\0A\00"
@str = [78 x i8] c" | IT'S A TIE! |\00"
define void @checkForEndOfGame(i32* nocapture %0, i32* nocapture %1, i8* %2, void ()* %3) {
%5 = load i32, i32* %0
%6 = icmp sgt i32 %5, 3
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = tail call i64 @anyWinners(i8* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i32 @printGameboard(i8* %2)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %2, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %25
19: ; preds = %7
%20 = load i32, i32* %0
%21 = icmp eq i32 %20, 8
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = tail call i32 @printGameboard(i8* %2)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %10, %22
%26 = bitcast void ()* %3 to void (...)*
%27 = tail call i32 @playAgain(void (...)* %26)
br label %28
28: ; preds = %25, %4, %19
ret void
}