#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 fim(char **);
char int_to_char(int);
int joga_minimax(char **);
char **jogada(char **, int, int);
void *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int show_menu();
int /*<<< orphan*/ show_tab(char **);
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main() {
  int jogs;
  jogs = show_menu();
  if (jogs == 3)
    return 0;
  char **mat, **aux;
  mat = malloc(3 * sizeof(char));
  aux = malloc(3 * sizeof(char));
  int i, j, cont = 1, vencedor = 0;
  for (i = 0; i < 3; i++) {
    mat[i] = malloc(3 * sizeof(char));
    aux[i] = malloc(3 * sizeof(char));
  }
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
      mat[i][j] = int_to_char(cont);
      cont++;
    }
  }
  cont = 0;
  int pos, jogador = 1, acabou = 1;
  srand((unsigned)time(NULL));
  while (acabou <= 9) {
    show_tab(mat);
    if (jogador == 1) {
      printf("Jogador 1: ");
      scanf("%d", &pos);
      aux = jogada(mat, pos, 1);
      if (aux[0][0] != ' ') {
        for (i = 0; i < 3; i++) {
          for (j = 0; j < 3; j++) {
            mat[i][j] = aux[i][j];
          }
        }
        jogador = 2;
        acabou++;
      }
    } else {
      if (jogs == 2) {
        printf("Jogador 2: ");
        scanf("%d", &pos);
      }
      if (jogs == 1) {
        pos = rand() % 9;
        pos++;
      }
      if (jogs == 4)
        pos = joga_minimax(mat);
      aux = jogada(mat, pos, 2);
      if (aux[0][0] != ' ') {
        for (i = 0; i < 3; i++) {
          for (j = 0; j < 3; j++) {
            mat[i][j] = aux[i][j];
          }
        }
        jogador = 1;
        acabou++;
      }
    }
    vencedor = fim(mat);
    if (vencedor != 0)
      acabou = 10;
  }
  show_tab(mat);
  if (vencedor == 0)
    printf("\nVelhou!\n");
  else
    printf("\nO jogador %d gannhou\n", vencedor);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   10b0 <show_menu@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11ef <main+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    153b <main+0x37b>
mov    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    126a <main+0xaa>
mov    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1220 <main+0x60>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    12d3 <main+0x113>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    12c0 <main+0x100>
mov    -0x24(%rbp),%edi
call   10d0 <int_to_char@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1282 <main+0xc2>
jmp    12c5 <main+0x105>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1271 <main+0xb1>
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x1,-0x34(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
cmpl   $0x9,-0x34(%rbp)
jg     1504 <main+0x344>
mov    -0x10(%rbp),%rdi
call   1090 <show_tab@plt>
cmpl   $0x1,-0x30(%rbp)
jne    13d9 <main+0x219>
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xce2(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    $0x1,%edx
call   1030 <jogada@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     13d4 <main+0x214>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    13c4 <main+0x204>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    13b1 <main+0x1f1>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1373 <main+0x1b3>
jmp    13b6 <main+0x1f6>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1362 <main+0x1a2>
movl   $0x2,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    14e2 <main+0x322>
cmpl   $0x2,-0x8(%rbp)
jne    1401 <main+0x241>
lea    0xc25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc14(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   10a0 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    1426 <main+0x266>
mov    $0x0,%al
call   10e0 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    143c <main+0x27c>
mov    -0x10(%rbp),%rdi
call   10c0 <joga_minimax@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    $0x2,%edx
call   1030 <jogada@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     14dd <main+0x31d>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    14cd <main+0x30d>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    14ba <main+0x2fa>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    147c <main+0x2bc>
jmp    14bf <main+0x2ff>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    146b <main+0x2ab>
movl   $0x1,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    14e2 <main+0x322>
mov    -0x10(%rbp),%rdi
call   1050 <fim@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     14ff <main+0x33f>
movl   $0xa,-0x34(%rbp)
jmp    12f8 <main+0x138>
mov    -0x10(%rbp),%rdi
call   1090 <show_tab@plt>
cmpl   $0x0,-0x28(%rbp)
jne    152a <main+0x36a>
lea    0xafd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    153b <main+0x37b>
mov    -0x28(%rbp),%esi
lea    0xaf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   10c0 <show_menu@plt>
cmp    $0x3,%eax
je     1496 <main+0x2c6>
mov    %eax,%ebp
mov    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,(%rbx)
mov    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,0x8(%rbx)
mov    $0x3,%edi
call   1090 <malloc@plt>
mov    %rax,0x10(%rbx)
mov    $0x1,%r14d
mov    $0x1,%edi
call   10e0 <int_to_char@plt>
mov    (%rbx),%rcx
mov    %al,(%rcx)
mov    $0x2,%edi
call   10e0 <int_to_char@plt>
mov    (%rbx),%rcx
mov    %al,0x1(%rcx)
mov    $0x3,%edi
call   10e0 <int_to_char@plt>
mov    (%rbx),%rcx
mov    %al,0x2(%rcx)
mov    $0x4,%edi
call   10e0 <int_to_char@plt>
mov    0x8(%rbx),%rcx
mov    %al,(%rcx)
mov    $0x5,%edi
call   10e0 <int_to_char@plt>
mov    0x8(%rbx),%rcx
mov    %al,0x1(%rcx)
mov    $0x6,%edi
call   10e0 <int_to_char@plt>
mov    0x8(%rbx),%rcx
mov    %al,0x2(%rcx)
mov    $0x7,%edi
call   10e0 <int_to_char@plt>
mov    0x10(%rbx),%rcx
mov    %al,(%rcx)
mov    $0x8,%edi
call   10e0 <int_to_char@plt>
mov    0x10(%rbx),%rcx
mov    %al,0x1(%rcx)
mov    $0x9,%edi
call   10e0 <int_to_char@plt>
mov    0x10(%rbx),%rcx
mov    %al,0x2(%rcx)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
lea    0x4(%rsp),%r12
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   10a0 <show_tab@plt>
cmp    $0x1,%r15d
je     1330 <main+0x160>
cmp    $0x1,%ebp
je     137b <main+0x1ab>
cmp    $0x4,%ebp
je     13a4 <main+0x1d4>
cmp    $0x2,%ebp
jne    13b0 <main+0x1e0>
lea    0xcff(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcee(%rip),%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
jmp    13b0 <main+0x1e0>
nopl   0x0(%rax,%rax,1)
lea    0xcc9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xcc7(%rip),%rdi
mov    %r12,%rsi
call   10b0 <scanf@plt>
mov    0x4(%rsp),%esi
mov    $0x1,%r15d
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <jogada@plt>
mov    (%rax),%rcx
movzbl (%rcx),%ecx
cmp    $0x20,%cl
je     1451 <main+0x281>
mov    $0x2,%r15d
jmp    13d8 <main+0x208>
xor    %eax,%eax
call   10f0 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
jmp    13ac <main+0x1dc>
mov    %rbx,%rdi
call   10d0 <joga_minimax@plt>
mov    %eax,0x4(%rsp)
mov    0x4(%rsp),%esi
mov    $0x2,%r15d
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <jogada@plt>
mov    (%rax),%rcx
movzbl (%rcx),%ecx
cmp    $0x20,%cl
je     1451 <main+0x281>
mov    $0x1,%r15d
mov    (%rbx),%rdx
mov    %cl,(%rdx)
mov    (%rax),%rcx
movzbl 0x1(%rcx),%ecx
mov    (%rbx),%rdx
mov    %cl,0x1(%rdx)
mov    (%rax),%rcx
movzbl 0x2(%rcx),%ecx
mov    (%rbx),%rdx
mov    %cl,0x2(%rdx)
mov    0x8(%rax),%rcx
movzbl (%rcx),%ecx
mov    0x8(%rbx),%rdx
mov    %cl,(%rdx)
mov    0x8(%rax),%rcx
movzbl 0x1(%rcx),%ecx
mov    0x8(%rbx),%rdx
mov    %cl,0x1(%rdx)
mov    0x8(%rax),%rcx
movzbl 0x2(%rcx),%ecx
mov    0x8(%rbx),%rdx
mov    %cl,0x2(%rdx)
mov    0x10(%rax),%rcx
movzbl (%rcx),%ecx
mov    0x10(%rbx),%rdx
mov    %cl,(%rdx)
mov    0x10(%rax),%rcx
movzbl 0x1(%rcx),%ecx
mov    0x10(%rbx),%rdx
mov    %cl,0x1(%rdx)
mov    0x10(%rax),%rax
movzbl 0x2(%rax),%eax
mov    0x10(%rbx),%rcx
mov    %al,0x2(%rcx)
add    $0x1,%r14d
mov    %rbx,%rdi
call   1060 <fim@plt>
mov    %eax,%r13d
test   %eax,%eax
jne    146a <main+0x29a>
cmp    $0xa,%r14d
jl     12e0 <main+0x110>
mov    %rbx,%rdi
call   10a0 <show_tab@plt>
test   %r13d,%r13d
je     148a <main+0x2ba>
lea    0xb9d(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1496 <main+0x2c6>
lea    0xba1(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Jogador 1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Jogador 2: \00"
@.str.3 = [10 x i8] c"\0AVelhou!\0A\00"
@.str.4 = [23 x i8] c"\0AO jogador %d gannhou\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 (...) @show_menu()
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 3
br i1 %14, label %15, label %16
15: ; preds = %0
store i32 0, i32* %1
br label %213
16: ; preds = %0
%17 = call i8* @malloc(i32 3)
%18 = bitcast i8* %17 to i8**
store i8** %18, i8*** %3
%19 = call i8* @malloc(i32 3)
%20 = bitcast i8* %19 to i8**
store i8** %20, i8*** %4
store i32 1, i32* %7
store i32 0, i32* %8
store i32 0, i32* %5
br label %21
21: ; preds = %35, %16
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = call i8* @malloc(i32 3)
%26 = load i8**, i8*** %3
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
store i8* %25, i8** %29
%30 = call i8* @malloc(i32 3)
%31 = load i8**, i8*** %4
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
store i8* %30, i8** %34
br label %35
35: ; preds = %24
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %21
38: ; preds = %21
store i32 0, i32* %5
br label %39
39: ; preds = %63, %38
%40 = load i32, i32* %5
%41 = icmp slt i32 %40, 3
br i1 %41, label %42, label %66
42: ; preds = %39
store i32 0, i32* %6
br label %43
43: ; preds = %59, %42
%44 = load i32, i32* %6
%45 = icmp slt i32 %44, 3
br i1 %45, label %46, label %62
46: ; preds = %43
%47 = load i32, i32* %7
%48 = call signext i8 @int_to_char(i32 %47)
%49 = load i8**, i8*** %3
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8 %48, i8* %56
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %59
59: ; preds = %46
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %43
62: ; preds = %43
br label %63
63: ; preds = %62
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %39
66: ; preds = %39
store i32 0, i32* %7
store i32 1, i32* %10
store i32 1, i32* %11
%67 = call i64 @time(i32* null)
%68 = trunc i64 %67 to i32
%69 = call i32 @srand(i32 %68)
br label %70
70: ; preds = %202, %66
%71 = load i32, i32* %11
%72 = icmp sle i32 %71, 9
br i1 %72, label %73, label %203
73: ; preds = %70
%74 = load i8**, i8*** %3
%75 = call i32 @show_tab(i8** %74)
%76 = load i32, i32* %10
%77 = icmp eq i32 %76, 1
br i1 %77, label %78, label %128
78: ; preds = %73
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%80 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%81 = load i8**, i8*** %3
%82 = load i32, i32* %9
%83 = call i8** @jogada(i8** %81, i32 %82, i32 1)
store i8** %83, i8*** %4
%84 = load i8**, i8*** %4
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = getelementptr inbounds i8, i8* %86, i64 0
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 32
br i1 %90, label %91, label %127
91: ; preds = %78
store i32 0, i32* %5
br label %92
92: ; preds = %121, %91
%93 = load i32, i32* %5
%94 = icmp slt i32 %93, 3
br i1 %94, label %95, label %124
95: ; preds = %92
store i32 0, i32* %6
br label %96
96: ; preds = %117, %95
%97 = load i32, i32* %6
%98 = icmp slt i32 %97, 3
br i1 %98, label %99, label %120
99: ; preds = %96
%100 = load i8**, i8*** %4
%101 = load i32, i32* %5
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %100, i64 %102
%104 = load i8*, i8** %103
%105 = load i32, i32* %6
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds i8, i8* %104, i64 %106
%108 = load i8, i8* %107
%109 = load i8**, i8*** %3
%110 = load i32, i32* %5
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8*, i8** %109, i64 %111
%113 = load i8*, i8** %112
%114 = load i32, i32* %6
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
store i8 %108, i8* %116
br label %117
117: ; preds = %99
%118 = load i32, i32* %6
%119 = add nsw i32 %118, 1
store i32 %119, i32* %6
br label %96
120: ; preds = %96
br label %121
121: ; preds = %120
%122 = load i32, i32* %5
%123 = add nsw i32 %122, 1
store i32 %123, i32* %5
br label %92
124: ; preds = %92
store i32 2, i32* %10
%125 = load i32, i32* %11
%126 = add nsw i32 %125, 1
store i32 %126, i32* %11
br label %127
127: ; preds = %124, %78
br label %196
128: ; preds = %73
%129 = load i32, i32* %2
%130 = icmp eq i32 %129, 2
br i1 %130, label %131, label %134
131: ; preds = %128
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%133 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
br label %134
134: ; preds = %131, %128
%135 = load i32, i32* %2
%136 = icmp eq i32 %135, 1
br i1 %136, label %137, label %142
137: ; preds = %134
%138 = call i32 (...) @rand()
%139 = srem i32 %138, 9
store i32 %139, i32* %9
%140 = load i32, i32* %9
%141 = add nsw i32 %140, 1
store i32 %141, i32* %9
br label %142
142: ; preds = %137, %134
%143 = load i32, i32* %2
%144 = icmp eq i32 %143, 4
br i1 %144, label %145, label %148
145: ; preds = %142
%146 = load i8**, i8*** %3
%147 = call i32 @joga_minimax(i8** %146)
store i32 %147, i32* %9
br label %148
148: ; preds = %145, %142
%149 = load i8**, i8*** %3
%150 = load i32, i32* %9
%151 = call i8** @jogada(i8** %149, i32 %150, i32 2)
store i8** %151, i8*** %4
%152 = load i8**, i8*** %4
%153 = getelementptr inbounds i8*, i8** %152, i64 0
%154 = load i8*, i8** %153
%155 = getelementptr inbounds i8, i8* %154, i64 0
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = icmp ne i32 %157, 32
br i1 %158, label %159, label %195
159: ; preds = %148
store i32 0, i32* %5
br label %160
160: ; preds = %189, %159
%161 = load i32, i32* %5
%162 = icmp slt i32 %161, 3
br i1 %162, label %163, label %192
163: ; preds = %160
store i32 0, i32* %6
br label %164
164: ; preds = %185, %163
%165 = load i32, i32* %6
%166 = icmp slt i32 %165, 3
br i1 %166, label %167, label %188
167: ; preds = %164
%168 = load i8**, i8*** %4
%169 = load i32, i32* %5
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i8*, i8** %168, i64 %170
%172 = load i8*, i8** %171
%173 = load i32, i32* %6
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i8, i8* %172, i64 %174
%176 = load i8, i8* %175
%177 = load i8**, i8*** %3
%178 = load i32, i32* %5
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i8*, i8** %177, i64 %179
%181 = load i8*, i8** %180
%182 = load i32, i32* %6
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8, i8* %181, i64 %183
store i8 %176, i8* %184
br label %185
185: ; preds = %167
%186 = load i32, i32* %6
%187 = add nsw i32 %186, 1
store i32 %187, i32* %6
br label %164
188: ; preds = %164
br label %189
189: ; preds = %188
%190 = load i32, i32* %5
%191 = add nsw i32 %190, 1
store i32 %191, i32* %5
br label %160
192: ; preds = %160
store i32 1, i32* %10
%193 = load i32, i32* %11
%194 = add nsw i32 %193, 1
store i32 %194, i32* %11
br label %195
195: ; preds = %192, %148
br label %196
196: ; preds = %195, %127
%197 = load i8**, i8*** %3
%198 = call i32 @fim(i8** %197)
store i32 %198, i32* %8
%199 = load i32, i32* %8
%200 = icmp ne i32 %199, 0
br i1 %200, label %201, label %202
201: ; preds = %196
store i32 10, i32* %11
br label %202
202: ; preds = %201, %196
br label %70
203: ; preds = %70
%204 = load i8**, i8*** %3
%205 = call i32 @show_tab(i8** %204)
%206 = load i32, i32* %8
%207 = icmp eq i32 %206, 0
br i1 %207, label %208, label %210
208: ; preds = %203
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %213
210: ; preds = %203
%211 = load i32, i32* %8
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %211)
br label %213
213: ; preds = %15, %210, %208
%214 = load i32, i32* %1
ret i32 %214
}

LLVM IR (-O2):
@.str = [12 x i8] c"Jogador 1: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"Jogador 2: \00"
@.str.4 = [23 x i8] c"\0AO jogador %d gannhou\0A\00"
@str = [9 x i8] c"\0AVelhou!\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 (...) @show_menu()
%3 = icmp eq i32 %2, 3
br i1 %3, label %127, label %4
4: ; preds = %0
%5 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%6 = bitcast i8* %5 to i8**
%7 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
store i8* %7, i8** %6
%8 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%9 = getelementptr inbounds i8*, i8** %6, i64 1
store i8* %8, i8** %9
%10 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%11 = getelementptr inbounds i8*, i8** %6, i64 2
store i8* %10, i8** %11
%12 = tail call signext i8 @int_to_char(i32 1)
%13 = load i8*, i8** %6
store i8 %12, i8* %13
%14 = tail call signext i8 @int_to_char(i32 2)
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %14, i8* %16
%17 = tail call signext i8 @int_to_char(i32 3)
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 2
store i8 %17, i8* %19
%20 = tail call signext i8 @int_to_char(i32 4)
%21 = load i8*, i8** %9
store i8 %20, i8* %21
%22 = tail call signext i8 @int_to_char(i32 5)
%23 = load i8*, i8** %9
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8 %22, i8* %24
%25 = tail call signext i8 @int_to_char(i32 6)
%26 = load i8*, i8** %9
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8 %25, i8* %27
%28 = tail call signext i8 @int_to_char(i32 7)
%29 = load i8*, i8** %11
store i8 %28, i8* %29
%30 = tail call signext i8 @int_to_char(i32 8)
%31 = load i8*, i8** %11
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8 %30, i8* %32
%33 = tail call signext i8 @int_to_char(i32 9)
%34 = load i8*, i8** %11
%35 = getelementptr inbounds i8, i8* %34, i64 2
store i8 %33, i8* %35
%36 = bitcast i32* %1 to i8*
%37 = tail call i64 @time(i32* null)
%38 = trunc i64 %37 to i32
%39 = tail call i32 @srand(i32 %38)
br label %40
40: ; preds = %4, %113
%41 = phi i32 [ 1, %4 ], [ %115, %113 ]
%42 = phi i32 [ 1, %4 ], [ %114, %113 ]
%43 = call i32 @show_tab(i8** %6)
%44 = icmp eq i32 %42, 1
br i1 %44, label %45, label %53
45: ; preds = %40
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%48 = load i32, i32* %1
%49 = call i8** @jogada(i8** %6, i32 %48, i32 1)
%50 = load i8*, i8** %49
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 32
br i1 %52, label %113, label %69
53: ; preds = %40
switch i32 %2, label %63 [
i32 2, label %54
i32 1, label %57
i32 4, label %61
]
54: ; preds = %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %63
57: ; preds = %53
%58 = call i32 (...) @rand()
%59 = srem i32 %58, 9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %1
br label %63
61: ; preds = %53
%62 = call i32 @joga_minimax(i8** %6)
store i32 %62, i32* %1
br label %63
63: ; preds = %57, %54, %53, %61
%64 = load i32, i32* %1
%65 = call i8** @jogada(i8** %6, i32 %64, i32 2)
%66 = load i8*, i8** %65
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, 32
br i1 %68, label %113, label %69
69: ; preds = %63, %45
%70 = phi i8 [ %51, %45 ], [ %67, %63 ]
%71 = phi i8** [ %49, %45 ], [ %65, %63 ]
%72 = phi i32 [ 2, %45 ], [ 1, %63 ]
%73 = load i8*, i8** %6
store i8 %70, i8* %73
%74 = load i8*, i8** %71
%75 = getelementptr inbounds i8, i8* %74, i64 1
%76 = load i8, i8* %75
%77 = load i8*, i8** %6
%78 = getelementptr inbounds i8, i8* %77, i64 1
store i8 %76, i8* %78
%79 = load i8*, i8** %71
%80 = getelementptr inbounds i8, i8* %79, i64 2
%81 = load i8, i8* %80
%82 = load i8*, i8** %6
%83 = getelementptr inbounds i8, i8* %82, i64 2
store i8 %81, i8* %83
%84 = getelementptr inbounds i8*, i8** %71, i64 1
%85 = load i8*, i8** %84
%86 = load i8, i8* %85
%87 = load i8*, i8** %9
store i8 %86, i8* %87
%88 = load i8*, i8** %84
%89 = getelementptr inbounds i8, i8* %88, i64 1
%90 = load i8, i8* %89
%91 = load i8*, i8** %9
%92 = getelementptr inbounds i8, i8* %91, i64 1
store i8 %90, i8* %92
%93 = load i8*, i8** %84
%94 = getelementptr inbounds i8, i8* %93, i64 2
%95 = load i8, i8* %94
%96 = load i8*, i8** %9
%97 = getelementptr inbounds i8, i8* %96, i64 2
store i8 %95, i8* %97
%98 = getelementptr inbounds i8*, i8** %71, i64 2
%99 = load i8*, i8** %98
%100 = load i8, i8* %99
%101 = load i8*, i8** %11
store i8 %100, i8* %101
%102 = load i8*, i8** %98
%103 = getelementptr inbounds i8, i8* %102, i64 1
%104 = load i8, i8* %103
%105 = load i8*, i8** %11
%106 = getelementptr inbounds i8, i8* %105, i64 1
store i8 %104, i8* %106
%107 = load i8*, i8** %98
%108 = getelementptr inbounds i8, i8* %107, i64 2
%109 = load i8, i8* %108
%110 = load i8*, i8** %11
%111 = getelementptr inbounds i8, i8* %110, i64 2
store i8 %109, i8* %111
%112 = add nsw i32 %41, 1
br label %113
113: ; preds = %69, %63, %45
%114 = phi i32 [ 1, %45 ], [ 2, %63 ], [ %72, %69 ]
%115 = phi i32 [ %41, %45 ], [ %41, %63 ], [ %112, %69 ]
%116 = call i32 @fim(i8** %6)
%117 = icmp eq i32 %116, 0
%118 = icmp slt i32 %115, 10
%119 = select i1 %117, i1 %118, i1 false
br i1 %119, label %40, label %120
120: ; preds = %113
%121 = call i32 @show_tab(i8** %6)
br i1 %117, label %122, label %124
122: ; preds = %120
%123 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
br label %126
124: ; preds = %120
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %116)
br label %126
126: ; preds = %124, %122
br label %127
127: ; preds = %0, %126
ret i32 0
}