#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*/ clear();
int /*<<< orphan*/ printw(char *, int);
int rand();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char ai_move() {
  int dir = 0;
  srand(time(NULL));
  while ((dir < 2) || (dir % 2 != 0)) {
    dir = rand() % 8 + 1;
  }
  dir += 48;
  clear();
  printw("%c\n\n", dir);
  refresh();
  return dir;
}


x86 assembly (clang, -O0):
<ai_move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x1,%al
cmpl   $0x2,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11a2 <ai_move+0x42>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    11b2 <ai_move+0x52>
jmp    11cc <ai_move+0x6c>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
jmp    117f <ai_move+0x1f>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1070 <clear@plt>
mov    -0x4(%rbp),%esi
lea    0xe1a(%rip),%rdi
call   1040 <printw@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
mov    -0x4(%rbp),%eax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_move>:
push   %rbx
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
nop
xor    %eax,%eax
call   1080 <rand@plt>
mov    %eax,%ebx
lea    0x7(%rbx),%eax
test   %ebx,%ebx
cmovns %ebx,%eax
and    $0xfffffff8,%eax
sub    %eax,%ebx
mov    %ebx,%eax
and    $0x1,%eax
test   %ebx,%ebx
jle    1170 <ai_move+0x10>
test   %eax,%eax
je     1170 <ai_move+0x10>
add    $0x31,%ebx
xor    %eax,%eax
call   1070 <clear@plt>
lea    0xe5c(%rip),%rdi
mov    %ebx,%esi
call   1040 <printw@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%c\0A\0A\00"
define signext i8 @ai_move() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @time(i32* null)
%3 = call i32 @srand(i32 %2)
br label %4
4: ; preds = %13, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 2
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = load i32, i32* %1
%9 = srem i32 %8, 2
%10 = icmp ne i32 %9, 0
br label %11
11: ; preds = %7, %4
%12 = phi i1 [ true, %4 ], [ %10, %7 ]
br i1 %12, label %13, label %17
13: ; preds = %11
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 8
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %4
17: ; preds = %11
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 48
store i32 %19, i32* %1
%20 = call i32 (...) @clear()
%21 = load i32, i32* %1
%22 = call i32 @printw(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = call i32 (...) @refresh()
%24 = load i32, i32* %1
%25 = trunc i32 %24 to i8
ret i8 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"%c\0A\0A\00"
define signext i8 @ai_move() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
br label %3
3: ; preds = %0, %3
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 8
%6 = icmp sgt i32 %5, 0
%7 = and i32 %5, 1
%8 = icmp ne i32 %7, 0
%9 = and i1 %6, %8
br i1 %9, label %10, label %3
10: ; preds = %3
%11 = add nuw nsw i32 %5, 49
%12 = tail call i32 (...) @clear()
%13 = tail call i32 @printw(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
%14 = tail call i32 (...) @refresh()
%15 = trunc i32 %11 to i8
ret i8 %15
}