#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*/ COLOR_PAIR(int);
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int cell_score(size_t, size_t, int);
int /*<<< orphan*/ flip_cell(int, int, int);
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ usleep(int);
void make_computer_move() {
  attron(COLOR_PAIR(4));
  mvprintw((3 + 1) + 8, ((8 + 2) * 4 + 2) + 1, "        Computer Move        ");
  attroff(COLOR_PAIR(4));
  refresh();
  usleep(800000);
  mvprintw((3 + 1) + 8, ((8 + 2) * 4 + 2) + 1, "                             ");
  refresh();
  int max_score = 0;
  int x_max = 0;
  int y_max = 0;
  for (size_t i = 1; i <= 8; i++) {
    for (size_t j = 1; j <= 8; j++) {
      int score = cell_score(i, j, 2);
      if (score > max_score) {
        max_score = score;
        x_max = i;
        y_max = j;
      }
    }
  }
  if (max_score > 0) {
    flip_cell(x_max, y_max, 2);
  }
}


x86 assembly (clang, -O0):
<make_computer_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x4,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
mov    $0xc,%edi
mov    $0x2b,%esi
lea    0xe56(%rip),%rdx
call   1090 <mvprintw@plt>
mov    $0x4,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0xc3500,%edi
call   10a0 <usleep@plt>
mov    $0xc,%edi
mov    $0x2b,%esi
lea    0xe3c(%rip),%rdx
call   1090 <mvprintw@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x1,-0x18(%rbp)
cmpq   $0x8,-0x18(%rbp)
ja     128a <make_computer_move+0x10a>
movq   $0x1,-0x20(%rbp)
cmpq   $0x8,-0x20(%rbp)
ja     1274 <make_computer_move+0xf4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    125e <make_computer_move+0xde>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0xc(%rbp)
jmp    1263 <make_computer_move+0xe3>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    121e <make_computer_move+0x9e>
jmp    1279 <make_computer_move+0xf9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    120b <make_computer_move+0x8b>
cmpl   $0x0,-0x4(%rbp)
jle    12a4 <make_computer_move+0x124>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x2,%edx
call   1080 <flip_cell@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_computer_move>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x4,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1050 <attron@plt>
lea    0xe5a(%rip),%rdx
mov    $0xc,%edi
mov    $0x2b,%esi
call   1090 <mvprintw@plt>
mov    $0x4,%edi
call   1060 <COLOR_PAIR@plt>
mov    %eax,%edi
call   1030 <attroff@plt>
xor    %r13d,%r13d
xor    %eax,%eax
call   1070 <refresh@plt>
mov    $0xc3500,%edi
call   10a0 <usleep@plt>
lea    0xe3d(%rip),%rdx
mov    $0xc,%edi
mov    $0x2b,%esi
call   1090 <mvprintw@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
mov    $0x1,%ebx
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1231 <make_computer_move+0xb1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %r13d,%eax
cmovg  %ebx,%ebp
mov    $0x8,%ecx
cmovg  %ecx,%r14d
cmovg  %eax,%r13d
add    $0x1,%rbx
cmp    $0x9,%rbx
je     1389 <make_computer_move+0x209>
movl   $0x2,(%rsp)
mov    $0x1,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,0x4(%rsp)
mov    $0x2,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,%r12d
mov    $0x3,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,%r15d
mov    $0x4,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,0x8(%rsp)
mov    $0x5,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,0xc(%rsp)
mov    $0x6,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,0x10(%rsp)
mov    $0x7,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    %eax,0x14(%rsp)
mov    $0x8,%esi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1040 <cell_score@plt>
mov    0x4(%rsp),%edx
cmp    %r13d,%edx
mov    $0x1,%ecx
cmovg  %ecx,%r14d
cmovg  %edx,%r13d
cmovg  %ebx,%ebp
mov    %ebx,%edx
cmp    %r13d,%r12d
jg     1309 <make_computer_move+0x189>
mov    %r14d,(%rsp)
mov    %r13d,%r12d
mov    %ebp,%edx
mov    $0x3,%r9d
mov    %ebx,%ebp
cmp    %r12d,%r15d
jg     131f <make_computer_move+0x19f>
mov    (%rsp),%r9d
mov    %r12d,%r15d
mov    %edx,%ebp
mov    $0x4,%r8d
mov    %ebx,%edi
mov    0x8(%rsp),%ecx
cmp    %r15d,%ecx
mov    0x14(%rsp),%r13d
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
jg     1345 <make_computer_move+0x1c5>
mov    %r9d,%r8d
mov    %r15d,%ecx
mov    %ebp,%edi
mov    $0x5,%r9d
mov    %ebx,%ebp
cmp    %ecx,%edx
jg     1358 <make_computer_move+0x1d8>
mov    %r8d,%r9d
mov    %ecx,%edx
mov    %edi,%ebp
mov    $0x6,%r8d
mov    %ebx,%edi
cmp    %edx,%esi
jg     136b <make_computer_move+0x1eb>
mov    %r9d,%r8d
mov    %edx,%esi
mov    %ebp,%edi
mov    $0x7,%r14d
mov    %ebx,%ebp
cmp    %esi,%r13d
jg     1210 <make_computer_move+0x90>
mov    %r8d,%r14d
mov    %esi,%r13d
mov    %edi,%ebp
jmp    1210 <make_computer_move+0x90>
test   %r13d,%r13d
jle    13ab <make_computer_move+0x22b>
mov    %ebp,%edi
mov    %r14d,%esi
mov    $0x2,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <flip_cell@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c" Computer Move \00"
@.str.1 = [30 x i8] c" \00"
define void @make_computer_move() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = call i32 @COLOR_PAIR(i32 4)
%8 = call i32 @attron(i32 %7)
%9 = call i32 @mvprintw(i32 12, i32 43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @COLOR_PAIR(i32 4)
%11 = call i32 @attroff(i32 %10)
%12 = call i32 (...) @refresh()
%13 = call i32 @usleep(i32 800000)
%14 = call i32 @mvprintw(i32 12, i32 43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 (...) @refresh()
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i64 1, i64* %4
br label %16
16: ; preds = %41, %0
%17 = load i64, i64* %4
%18 = icmp ule i64 %17, 8
br i1 %18, label %19, label %44
19: ; preds = %16
store i64 1, i64* %5
br label %20
20: ; preds = %37, %19
%21 = load i64, i64* %5
%22 = icmp ule i64 %21, 8
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = load i64, i64* %4
%25 = load i64, i64* %5
%26 = call i32 @cell_score(i64 %24, i64 %25, i32 2)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = load i32, i32* %1
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %36
30: ; preds = %23
%31 = load i32, i32* %6
store i32 %31, i32* %1
%32 = load i64, i64* %4
%33 = trunc i64 %32 to i32
store i32 %33, i32* %2
%34 = load i64, i64* %5
%35 = trunc i64 %34 to i32
store i32 %35, i32* %3
br label %36
36: ; preds = %30, %23
br label %37
37: ; preds = %36
%38 = load i64, i64* %5
%39 = add i64 %38, 1
store i64 %39, i64* %5
br label %20
40: ; preds = %20
br label %41
41: ; preds = %40
%42 = load i64, i64* %4
%43 = add i64 %42, 1
store i64 %43, i64* %4
br label %16
44: ; preds = %16
%45 = load i32, i32* %1
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32, i32* %2
%49 = load i32, i32* %3
%50 = call i32 @flip_cell(i32 %48, i32 %49, i32 2)
br label %51
51: ; preds = %47, %44
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c" Computer Move \00"
@.str.1 = [30 x i8] c" \00"
define void @make_computer_move() {
%1 = tail call i32 @COLOR_PAIR(i32 4)
%2 = tail call i32 @attron(i32 %1)
%3 = tail call i32 @mvprintw(i32 12, i32 43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @COLOR_PAIR(i32 4)
%5 = tail call i32 @attroff(i32 %4)
%6 = tail call i32 (...) @refresh()
%7 = tail call i32 @usleep(i32 800000)
%8 = tail call i32 @mvprintw(i32 12, i32 43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 (...) @refresh()
br label %10
10: ; preds = %0, %10
%11 = phi i32 [ 0, %0 ], [ %55, %10 ]
%12 = phi i64 [ 1, %0 ], [ %56, %10 ]
%13 = phi i32 [ 0, %0 ], [ %54, %10 ]
%14 = phi i32 [ 0, %0 ], [ %53, %10 ]
%15 = trunc i64 %12 to i32
%16 = tail call i32 @cell_score(i64 %12, i64 1, i32 2)
%17 = icmp sgt i32 %16, %11
%18 = select i1 %17, i32 1, i32 %13
%19 = select i1 %17, i32 %16, i32 %11
%20 = tail call i32 @cell_score(i64 %12, i64 2, i32 2)
%21 = icmp sgt i32 %20, %19
%22 = or i1 %21, %17
%23 = select i1 %21, i32 2, i32 %18
%24 = select i1 %21, i32 %20, i32 %19
%25 = tail call i32 @cell_score(i64 %12, i64 3, i32 2)
%26 = icmp sgt i32 %25, %24
%27 = select i1 %26, i32 3, i32 %23
%28 = select i1 %26, i32 %25, i32 %24
%29 = tail call i32 @cell_score(i64 %12, i64 4, i32 2)
%30 = icmp sgt i32 %29, %28
%31 = or i1 %30, %26
%32 = select i1 %30, i32 4, i32 %27
%33 = select i1 %30, i32 %29, i32 %28
%34 = tail call i32 @cell_score(i64 %12, i64 5, i32 2)
%35 = icmp sgt i32 %34, %33
%36 = select i1 %35, i32 5, i32 %32
%37 = select i1 %35, i32 %34, i32 %33
%38 = tail call i32 @cell_score(i64 %12, i64 6, i32 2)
%39 = icmp sgt i32 %38, %37
%40 = or i1 %39, %35
%41 = select i1 %39, i32 6, i32 %36
%42 = select i1 %39, i32 %38, i32 %37
%43 = tail call i32 @cell_score(i64 %12, i64 7, i32 2)
%44 = icmp sgt i32 %43, %42
%45 = select i1 %44, i32 7, i32 %41
%46 = select i1 %44, i32 %43, i32 %42
%47 = tail call i32 @cell_score(i64 %12, i64 8, i32 2)
%48 = icmp sgt i32 %47, %46
%49 = or i1 %48, %44
%50 = select i1 %49, i1 true, i1 %40
%51 = select i1 %50, i1 true, i1 %31
%52 = select i1 %51, i1 true, i1 %22
%53 = select i1 %52, i32 %15, i32 %14
%54 = select i1 %48, i32 8, i32 %45
%55 = select i1 %48, i32 %47, i32 %46
%56 = add nuw nsw i64 %12, 1
%57 = icmp eq i64 %56, 9
br i1 %57, label %58, label %10
58: ; preds = %10
%59 = icmp sgt i32 %55, 0
br i1 %59, label %60, label %62
60: ; preds = %58
%61 = tail call i32 @flip_cell(i32 %53, i32 %54, i32 2)
br label %62
62: ; preds = %60, %58
ret void
}