#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*/ jogada_valida(int *, int);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int play_easy_bot(int vetor_posicao[9]) {
  int jogada;
  srand((unsigned)time(NULL));
  do {
    jogada = 1 + (rand() % 8);
  } while ((jogada > 9 || jogada < 1) || !jogada_valida(vetor_posicao, jogada));
  return jogada;
}


x86 assembly (clang, -O0):
<play_easy_bot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x8,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x9,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jg     11a6 <play_easy_bot+0x66>
mov    $0x1,%al
cmpl   $0x1,-0xc(%rbp)
mov    %al,-0xd(%rbp)
jl     11a6 <play_easy_bot+0x66>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <jogada_valida@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    115c <play_easy_bot+0x1c>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_easy_bot>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x7(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffff8,%ecx
mov    %eax,%edx
sub    %ecx,%edx
neg    %ecx
test   %edx,%edx
js     1160 <play_easy_bot+0x20>
lea    (%rax,%rcx,1),%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <jogada_valida@plt>
test   %eax,%eax
je     1160 <play_easy_bot+0x20>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @play_easy_bot(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i64 @time(i32* null)
%5 = trunc i64 %4 to i32
%6 = call i32 @srand(i32 %5)
br label %7
7: ; preds = %23, %1
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 8
%10 = add nsw i32 1, %9
store i32 %10, i32* %3
br label %11
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 9
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 1
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = load i32*, i32** %2
%19 = load i32, i32* %3
%20 = call i32 @jogada_valida(i32* %18, i32 %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br label %23
23: ; preds = %17, %14, %11
%24 = phi i1 [ true, %14 ], [ true, %11 ], [ %22, %17 ]
br i1 %24, label %7, label %25
25: ; preds = %23
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @play_easy_bot(i32* %0) {
%2 = tail call i64 @time(i32* null)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @srand(i32 %3)
br label %5
5: ; preds = %13, %1
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 8
%8 = add nsw i32 %7, 1
%9 = icmp slt i32 %7, 0
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i32 @jogada_valida(i32* %0, i32 %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %5
br label %5
14: ; preds = %10
ret i32 %8
}