#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 rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
scalar_t__ verificaJogadaValida(int **, int);
int nivelfacil(int tab[3][3], int vez) {
  srand(time(NULL));
  int r = rand() % 9;
  while (verificaJogadaValida(tab, r) == 0) {
    r--;
    if (r == -1)
      r = 8;
  }
  return r;
}


x86 assembly (clang, -O0):
<nivelfacil>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <verificaJogadaValida@plt>
cmp    $0x0,%rax
jne    11a6 <nivelfacil+0x66>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    11a1 <nivelfacil+0x61>
movl   $0x8,-0x10(%rbp)
jmp    1171 <nivelfacil+0x31>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nivelfacil>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rbx
imul   $0x38e38e39,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%eax
sub    %eax,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <verificaJogadaValida@plt>
test   %rax,%rax
jne    11a5 <nivelfacil+0x65>
mov    $0x8,%ebp
nopl   0x0(%rax)
sub    $0x1,%ebx
cmovb  %ebp,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <verificaJogadaValida@plt>
test   %rax,%rax
je     1190 <nivelfacil+0x50>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @nivelfacil([3 x i32]* %0, i32 %1) {
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 9
%7 = bitcast [3 x i32]* %0 to i32**
%8 = tail call i64 @verificaJogadaValida(i32** %7, i32 %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %2, %10
%11 = phi i32 [ %14, %10 ], [ %6, %2 ]
%12 = add nsw i32 %11, -1
%13 = icmp eq i32 %11, 0
%14 = select i1 %13, i32 8, i32 %12
%15 = tail call i64 @verificaJogadaValida(i32** %7, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %10, label %17
17: ; preds = %10, %2
%18 = phi i32 [ %6, %2 ], [ %14, %10 ]
ret i32 %18
}