#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__ centerFree(char *);
char findBlock(char *);
int /*<<< orphan*/ findDoubleCorner(char *);
char findTwoMiddle(char *);
char findWin(char *);
char selectCorner(char *);
char selectFree(char *);
char selectMiddle(char *);
int player(char *playground, int rnum) {
  char c;
  if (centerFree(playground)) {
    return 4;
  }
  c = findWin(playground);
  if (c < 0) {
    c = findBlock(playground);
    if (c < 0) {
      if (rnum < 4) {
        c = findTwoMiddle(playground);
      }
      if (c < 0) {
        if (rnum < 4 && !findDoubleCorner(playground)) {
          c = selectCorner(playground);
        } else {
          c = selectMiddle(playground);
        }
        if (c < 0) {
          c = selectCorner(playground);
          if (c < 0) {
            c = selectFree(playground);
          }
        }
      }
    }
  }
  return c;
}


x86 assembly (clang, -O0):
<player>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <centerFree@plt>
cmp    $0x0,%rax
je     11ae <player+0x2e>
movl   $0x4,-0x4(%rbp)
jmp    1289 <player+0x109>
mov    -0x10(%rbp),%rdi
call   1050 <findWin@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jge    1282 <player+0x102>
mov    -0x10(%rbp),%rdi
call   10a0 <findBlock@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jge    127d <player+0xfd>
cmpl   $0x4,-0x14(%rbp)
jge    11f6 <player+0x76>
mov    -0x10(%rbp),%rdi
call   1070 <findTwoMiddle@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jge    1278 <player+0xf8>
cmpl   $0x4,-0x14(%rbp)
jge    1230 <player+0xb0>
mov    -0x10(%rbp),%rdi
call   1090 <findDoubleCorner@plt>
cmp    $0x0,%eax
jne    1230 <player+0xb0>
mov    -0x10(%rbp),%rdi
call   1080 <selectCorner@plt>
mov    %al,-0x15(%rbp)
jmp    123c <player+0xbc>
mov    -0x10(%rbp),%rdi
call   1030 <selectMiddle@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jge    1273 <player+0xf3>
mov    -0x10(%rbp),%rdi
call   1080 <selectCorner@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jge    126e <player+0xee>
mov    -0x10(%rbp),%rdi
call   1060 <selectFree@plt>
mov    %al,-0x15(%rbp)
jmp    1273 <player+0xf3>
jmp    1278 <player+0xf8>
jmp    127d <player+0xfd>
jmp    1282 <player+0x102>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<player>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <centerFree@plt>
mov    %rax,%rcx
mov    $0x4,%eax
test   %rcx,%rcx
jne    1200 <player+0x80>
mov    %rbx,%rdi
call   1050 <findWin@plt>
test   %al,%al
jns    11fd <player+0x7d>
mov    %rbx,%rdi
call   10a0 <findBlock@plt>
test   %al,%al
jns    11fd <player+0x7d>
cmp    $0x3,%ebp
jg     11cf <player+0x4f>
mov    %rbx,%rdi
call   1070 <findTwoMiddle@plt>
test   %al,%al
jns    11fd <player+0x7d>
mov    %rbx,%rdi
call   1090 <findDoubleCorner@plt>
test   %eax,%eax
je     11f1 <player+0x71>
mov    %rbx,%rdi
call   1030 <selectMiddle@plt>
test   %al,%al
jns    11fd <player+0x7d>
mov    %rbx,%rdi
call   1080 <selectCorner@plt>
test   %al,%al
jns    11fd <player+0x7d>
mov    %rbx,%rdi
call   1060 <selectFree@plt>
jmp    11fd <player+0x7d>
mov    %rbx,%rdi
call   1080 <selectCorner@plt>
test   %al,%al
js     11db <player+0x5b>
movsbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @player(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = call i64 @centerFree(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 4, i32* %3
br label %66
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call signext i8 @findWin(i8* %12)
store i8 %13, i8* %6
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %63
17: ; preds = %11
%18 = load i8*, i8** %4
%19 = call signext i8 @findBlock(i8* %18)
store i8 %19, i8* %6
%20 = load i8, i8* %6
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %62
23: ; preds = %17
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i8*, i8** %4
%28 = call signext i8 @findTwoMiddle(i8* %27)
store i8 %28, i8* %6
br label %29
29: ; preds = %26, %23
%30 = load i8, i8* %6
%31 = sext i8 %30 to i32
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %61
33: ; preds = %29
%34 = load i32, i32* %5
%35 = icmp slt i32 %34, 4
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i8*, i8** %4
%38 = call i32 @findDoubleCorner(i8* %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %36
%41 = load i8*, i8** %4
%42 = call signext i8 @selectCorner(i8* %41)
store i8 %42, i8* %6
br label %46
43: ; preds = %36, %33
%44 = load i8*, i8** %4
%45 = call signext i8 @selectMiddle(i8* %44)
store i8 %45, i8* %6
br label %46
46: ; preds = %43, %40
%47 = load i8, i8* %6
%48 = sext i8 %47 to i32
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %60
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = call signext i8 @selectCorner(i8* %51)
store i8 %52, i8* %6
%53 = load i8, i8* %6
%54 = sext i8 %53 to i32
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = load i8*, i8** %4
%58 = call signext i8 @selectFree(i8* %57)
store i8 %58, i8* %6
br label %59
59: ; preds = %56, %50
br label %60
60: ; preds = %59, %46
br label %61
61: ; preds = %60, %29
br label %62
62: ; preds = %61, %17
br label %63
63: ; preds = %62, %11
%64 = load i8, i8* %6
%65 = sext i8 %64 to i32
store i32 %65, i32* %3
br label %66
66: ; preds = %63, %10
%67 = load i32, i32* %3
ret i32 %67
}

LLVM IR (-O2):
define i32 @player(i8* %0, i32 %1) {
%3 = tail call i64 @centerFree(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %34
5: ; preds = %2
%6 = tail call signext i8 @findWin(i8* %0)
%7 = icmp slt i8 %6, 0
br i1 %7, label %8, label %31
8: ; preds = %5
%9 = tail call signext i8 @findBlock(i8* %0)
%10 = icmp slt i8 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %8
%12 = icmp slt i32 %1, 4
br i1 %12, label %13, label %21
13: ; preds = %11
%14 = tail call signext i8 @findTwoMiddle(i8* %0)
%15 = icmp slt i8 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %13
%17 = tail call i32 @findDoubleCorner(i8* %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call signext i8 @selectCorner(i8* %0)
br label %23
21: ; preds = %11, %16
%22 = tail call signext i8 @selectMiddle(i8* %0)
br label %23
23: ; preds = %21, %19
%24 = phi i8 [ %22, %21 ], [ %20, %19 ]
%25 = icmp slt i8 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = tail call signext i8 @selectCorner(i8* %0)
%28 = icmp slt i8 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call signext i8 @selectFree(i8* %0)
br label %31
31: ; preds = %8, %23, %29, %26, %13, %5
%32 = phi i8 [ %30, %29 ], [ %27, %26 ], [ %24, %23 ], [ %14, %13 ], [ %9, %8 ], [ %6, %5 ]
%33 = sext i8 %32 to i32
br label %34
34: ; preds = %2, %31
%35 = phi i32 [ %33, %31 ], [ 4, %2 ]
ret i32 %35
}