#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*/ fflush(int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ system(char *);
int jogo_da_velha() {
  char tabuleiro[3][3];
  int ganhou = 0;
  int l, c;
  int numJogadas = 0;
  char saida = '0';
  for (l = 0; l < 3; l++) {
    for (c = 0; c < 3; c++) {
      tabuleiro[l][c] = '*';
    }
  }
  while ((numJogadas < 9) && (ganhou == 0)) {
    system("cls");
    printf("\n********** JOGO DA VELHA **********\n\n");
    fflush(stdin);
    saida = getchar();
    if (saida == '0')
      break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<jogo_da_velha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x30,-0x1d(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11b4 <jogo_da_velha+0x74>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11a1 <jogo_da_velha+0x61>
movslq -0x14(%rbp),%rcx
lea    -0x9(%rbp),%rax
imul   $0x3,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movb   $0x2a,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <jogo_da_velha+0x32>
jmp    11a6 <jogo_da_velha+0x66>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <jogo_da_velha+0x21>
jmp    11b9 <jogo_da_velha+0x79>
xor    %eax,%eax
cmpl   $0x9,-0x1c(%rbp)
mov    %al,-0x1e(%rbp)
jge    11d2 <jogo_da_velha+0x92>
cmpl   $0x0,-0x10(%rbp)
sete   %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    11e2 <jogo_da_velha+0xa2>
jmp    1229 <jogo_da_velha+0xe9>
lea    0xe17(%rip),%rdi
call   1030 <system@plt>
lea    0xe0f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%eax
cmp    $0x30,%eax
jne    1224 <jogo_da_velha+0xe4>
jmp    1229 <jogo_da_velha+0xe9>
jmp    11b9 <jogo_da_velha+0x79>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jogo_da_velha>:
push   %r15
push   %r14
push   %rbx
lea    0xeb4(%rip),%r14
lea    0xeb1(%rip),%r15
mov    0x2e8e(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    (%rbx),%edi
call   1060 <fflush@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0x30,%al
jne    1160 <jogo_da_velha+0x20>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"cls\00"
@.str.1 = [39 x i8] c"\0A********** JOGO DA VELHA **********\0A\0A\00"
@stdin = global i32 0
define i32 @jogo_da_velha() {
%1 = alloca [3 x [3 x i8]]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %2
store i32 0, i32* %5
store i8 48, i8* %6
store i32 0, i32* %3
br label %7
7: ; preds = %25, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %28
10: ; preds = %7
store i32 0, i32* %4
br label %11
11: ; preds = %21, %10
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [3 x [3 x i8]], [3 x [3 x i8]]* %1, i64 0, i64 %16
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %17, i64 0, i64 %19
store i8 42, i8* %20
br label %21
21: ; preds = %14
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %11
24: ; preds = %11
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %7
28: ; preds = %7
br label %29
29: ; preds = %47, %28
%30 = load i32, i32* %5
%31 = icmp slt i32 %30, 9
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 0
br label %35
35: ; preds = %32, %29
%36 = phi i1 [ false, %29 ], [ %34, %32 ]
br i1 %36, label %37, label %48
37: ; preds = %35
%38 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%40 = load i32, i32* @stdin
%41 = call i32 @fflush(i32 %40)
%42 = call signext i8 (...) @getchar()
store i8 %42, i8* %6
%43 = load i8, i8* %6
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 48
br i1 %45, label %46, label %47
46: ; preds = %37
br label %48
47: ; preds = %37
br label %29
48: ; preds = %46, %35
ret i32 1
}

LLVM IR (-O2):
@.str = [4 x i8] c"cls\00"
@stdin = global i32 0
@str = [38 x i8] c"\0A********** JOGO DA VELHA **********\0A\00"
define i32 @jogo_da_velha() {
br label %1
1: ; preds = %0, %1
%2 = tail call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = tail call i32 @fflush(i32 %4)
%6 = tail call signext i8 (...) @getchar()
%7 = icmp eq i8 %6, 48
br i1 %7, label %8, label %1
8: ; preds = %1
ret i32 1
}