#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 entrada();
int /*<<< orphan*/ jogada_valida(int *, int);
int /*<<< orphan*/ saida(int, int /*<<< orphan*/);
int jogada_correta(int vetor_posicao[9], int i) {
  int jogada;
  do {
    if (i % 2 == 0) {
      saida(4, 0);
    } else {
      saida(5, 0);
    }
    jogada = entrada();
  } while ((jogada > 9 || jogada < 1) || !jogada_valida(vetor_posicao, jogada));
  return jogada;
}


x86 assembly (clang, -O0):
<jogada_correta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1164 <jogada_correta+0x34>
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <saida@plt>
jmp    1170 <jogada_correta+0x40>
mov    $0x5,%edi
xor    %esi,%esi
call   1030 <saida@plt>
mov    $0x0,%al
call   1040 <entrada@plt>
mov    %eax,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x9,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jg     11af <jogada_correta+0x7f>
mov    $0x1,%al
cmpl   $0x1,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jl     11af <jogada_correta+0x7f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1050 <jogada_valida@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113f <jogada_correta+0xf>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jogada_correta>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
and    $0x1,%ebp
or     $0x4,%ebp
nop
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <saida@plt>
xor    %eax,%eax
call   1040 <entrada@plt>
mov    %eax,%ebx
lea    -0xa(%rbx),%eax
cmp    $0xfffffff7,%eax
jb     1140 <jogada_correta+0x10>
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <jogada_valida@plt>
test   %eax,%eax
je     1140 <jogada_correta+0x10>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @jogada_correta(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %28, %2
%7 = load i32, i32* %4
%8 = srem i32 %7, 2
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @saida(i32 4, i32 0)
br label %14
12: ; preds = %6
%13 = call i32 @saida(i32 5, i32 0)
br label %14
14: ; preds = %12, %10
%15 = call i32 (...) @entrada()
store i32 %15, i32* %5
br label %16
16: ; preds = %14
%17 = load i32, i32* %5
%18 = icmp sgt i32 %17, 9
br i1 %18, label %28, label %19
19: ; preds = %16
%20 = load i32, i32* %5
%21 = icmp slt i32 %20, 1
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = load i32*, i32** %3
%24 = load i32, i32* %5
%25 = call i32 @jogada_valida(i32* %23, i32 %24)
%26 = icmp ne i32 %25, 0
%27 = xor i1 %26, true
br label %28
28: ; preds = %22, %19, %16
%29 = phi i1 [ true, %19 ], [ true, %16 ], [ %27, %22 ]
br i1 %29, label %6, label %30
30: ; preds = %28
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
define i32 @jogada_correta(i32* %0, i32 %1) {
%3 = and i32 %1, 1
%4 = or i32 %3, 4
br label %5
5: ; preds = %13, %2
%6 = tail call i32 @saida(i32 %4, i32 0)
%7 = tail call i32 (...) @entrada()
%8 = add i32 %7, -10
%9 = icmp ult i32 %8, -9
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i32 @jogada_valida(i32* %0, i32 %7)
%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 %7
}