#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_zero;
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ desenhar(int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ movimentoDoJogador(int *);
int movimentoDoRobo(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ system(char *);
int vencer(int *);
int main() {
  printf("Computer: O, You: X\nPlay (1)st or (2)nd? ");
  int board[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  int player = 0;
  scanf("%d", &player);
  printf("\n");
  unsigned turn;
  char ip[16] = "192.168.0.115";
  char buffer[1024], bufaux[1024], *loc;
  char comandos[] = "/x /mem /disc /time /pros /port /help";
  int tbuf, skt, escolha;
  struct sockaddr_in serv;
  system("clear");
  printf("\n    Robotica Inteligente - UFBA\n\n");
  skt = socket(AF_INET, SOCK_STREAM, 0);
  serv.sin_family = AF_INET;
  serv.sin_addr.s_addr = inet_addr(ip);
  serv.sin_port = htons(23);
  memset(&(serv.sin_zero), 0x00, sizeof(serv.sin_zero));
  if (connect(skt, (struct sockaddr *)&serv, sizeof(struct sockaddr)) != 0) {
    puts("\n> Servidor nao Encontrado\n");
    exit(0);
  }
  printf(">> A Conexao com o Servidor %s foi estabelecida na porta %d \n\n", ip,
         23);
  tbuf = recv(skt, buffer, 1024, 0);
  buffer[tbuf] = 0x00;
  printf(">: %s\n", buffer);
  strcpy(buffer, "Client comunicando OK!!!");
  send(skt, buffer, strlen(buffer), 0);
  desenhar(board);
  for (turn = 0; turn < 9 && vencer(board) == 0; ++turn) {
    int move;
    if ((turn + player) % 2 == 0) {
      move = movimentoDoRobo(board);
      printf("Movimento do Robo: %d\n", move);
      desenhar(board);
      sprintf(buffer, "%d", move);
      send(skt, buffer, strlen(buffer), 0);
      printf("Waiting for response message: \n");
      tbuf = recv(skt, buffer, 1024, 0);
      buffer[tbuf] = 0x00;
      while (strcmp(bufaux, buffer) != 0) {
        printf("Response: %s\n", buffer);
        strcpy(bufaux, buffer);
      }
    } else {
      movimentoDoJogador(board);
      desenhar(board);
    }
  }
  switch (vencer(board)) {
  case 0:
    printf("A draw. How droll.\n");
    break;
  case 1:
    desenhar(board);
    printf("You lose.\n");
    break;
  case -1:
    printf("You win. Inconceivable!\n");
    break;
  }
  close(skt);
  printf(">>A conexao com o servidor foi finalizada!!!\n\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8d0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   10c0 <memset@plt>
movl   $0x0,-0x34(%rbp)
lea    0xd8c(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1130 <scanf@plt>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0xec4(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x880(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x26,%edx
call   1120 <memcpy@plt>
lea    0xd43(%rip),%rdi
call   1080 <system@plt>
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1180 <socket@plt>
mov    %eax,-0x888(%rbp)
mov    0x2cc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x894(%rbp)
lea    -0x50(%rbp),%rdi
call   1100 <inet_addr@plt>
mov    %eax,-0x898(%rbp)
mov    $0x17,%edi
call   1090 <htons@plt>
mov    %eax,-0x89c(%rbp)
lea    -0x8a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   10c0 <memset@plt>
mov    -0x888(%rbp),%edi
lea    -0x8a0(%rbp),%rsi
mov    $0x4,%edx
call   1170 <connect@plt>
cmp    $0x0,%rax
je     1391 <main+0x131>
lea    0xcd1(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1160 <exit@plt>
lea    -0x50(%rbp),%rsi
lea    0xcd6(%rip),%rdi
mov    $0x17,%edx
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x888(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x884(%rbp)
movslq -0x884(%rbp),%rax
movb   $0x0,-0x450(%rbp,%rax,1)
lea    -0x450(%rbp),%rsi
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x450(%rbp),%rdi
lea    0xcbf(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x888(%rbp),%eax
mov    %eax,-0x8b4(%rbp)
lea    -0x450(%rbp),%rax
mov    %rax,-0x8b0(%rbp)
lea    -0x450(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x8b4(%rbp),%edi
mov    -0x8b0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10a0 <send@plt>
lea    -0x30(%rbp),%rdi
call   10f0 <desenhar@plt>
movl   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x38(%rbp)
mov    %al,-0x8b5(%rbp)
jae    1471 <main+0x211>
lea    -0x30(%rbp),%rdi
call   1140 <vencer@plt>
cmp    $0x0,%eax
sete   %al
mov    %al,-0x8b5(%rbp)
mov    -0x8b5(%rbp),%al
test   $0x1,%al
jne    1484 <main+0x224>
jmp    15c7 <main+0x367>
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    15a2 <main+0x342>
lea    -0x30(%rbp),%rdi
call   1070 <movimentoDoRobo@plt>
mov    %eax,-0x8a4(%rbp)
mov    -0x8a4(%rbp),%esi
lea    0xc1f(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x30(%rbp),%rdi
call   10f0 <desenhar@plt>
lea    -0x450(%rbp),%rdi
mov    -0x8a4(%rbp),%edx
lea    0xb54(%rip),%rsi
call   1150 <sprintf@plt>
mov    -0x888(%rbp),%eax
mov    %eax,-0x8c4(%rbp)
lea    -0x450(%rbp),%rax
mov    %rax,-0x8c0(%rbp)
lea    -0x450(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x8c4(%rbp),%edi
mov    -0x8c0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10a0 <send@plt>
lea    0xbca(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x888(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x884(%rbp)
movslq -0x884(%rbp),%rax
movb   $0x0,-0x450(%rbp,%rax,1)
lea    -0x850(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
je     159d <main+0x33d>
lea    -0x450(%rbp),%rsi
lea    0xb8a(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
lea    -0x850(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    1553 <main+0x2f3>
jmp    15b4 <main+0x354>
lea    -0x30(%rbp),%rdi
call   10e0 <movimentoDoJogador@plt>
lea    -0x30(%rbp),%rdi
call   10f0 <desenhar@plt>
jmp    15b9 <main+0x359>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    144a <main+0x1ea>
lea    -0x30(%rbp),%rdi
call   1140 <vencer@plt>
mov    %eax,%ecx
mov    %ecx,-0x8c8(%rbp)
sub    $0xffffffff,%eax
je     163c <main+0x3dc>
jmp    15e6 <main+0x386>
mov    -0x8c8(%rbp),%eax
test   %eax,%eax
je     160d <main+0x3ad>
jmp    15f9 <main+0x399>
mov    -0x8c8(%rbp),%eax
sub    $0x1,%eax
je     1620 <main+0x3c0>
jmp    164a <main+0x3ea>
lea    0xb02(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    164a <main+0x3ea>
lea    -0x30(%rbp),%rdi
call   10f0 <desenhar@plt>
lea    0xafa(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
jmp    164a <main+0x3ea>
lea    0xaf2(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
mov    -0x888(%rbp),%edi
call   10d0 <close@plt>
lea    0xaf2(%rip),%rdi
mov    $0x0,%al
call   10b0 <printf@plt>
xor    %edi,%edi
call   1160 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x868,%rsp
lea    0xd88(%rip),%rdi
xor    %eax,%eax
call   10c0 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movl   $0x0,0x50(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xd87(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1130 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xd63(%rip),%rdi
call   1090 <system@plt>
lea    0xdfd(%rip),%rdi
call   1060 <puts@plt>
mov    0x2d06(%rip),%rbx
mov    (%rbx),%edi
mov    0x2ced(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1180 <socket@plt>
mov    %eax,%r13d
mov    (%rbx),%eax
mov    %eax,0x1c(%rsp)
lea    0x20(%rsp),%rdi
call   1110 <inet_addr@plt>
mov    %eax,0x18(%rsp)
mov    $0x17,%edi
call   10a0 <htons@plt>
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   10d0 <memset@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1170 <connect@plt>
test   %rax,%rax
jne    14be <main+0x25e>
lea    0xd02(%rip),%rdi
lea    0x20(%rsp),%rsi
mov    $0x17,%edx
xor    %eax,%eax
call   10c0 <printf@plt>
lea    0x60(%rsp),%rbx
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cltq
movb   $0x0,0x60(%rsp,%rax,1)
lea    0xd0b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
lea    0xd01(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1100 <desenhar@plt>
lea    0x460(%rsp),%r15
lea    0xcf6(%rip),%r12
xor    %r14d,%r14d
mov    %r13d,0xc(%rsp)
jmp    13fb <main+0x19b>
nopl   0x0(%rax)
call   10f0 <movimentoDoJogador@plt>
mov    %rbp,%rdi
call   1100 <desenhar@plt>
add    $0x1,%r14d
cmp    $0x9,%r14d
je     14c7 <main+0x267>
mov    %rbp,%rdi
call   1140 <vencer@plt>
test   %eax,%eax
jne    14c7 <main+0x267>
mov    0x8(%rsp),%eax
add    %r14d,%eax
mov    %rbp,%rdi
test   $0x1,%al
jne    13e0 <main+0x180>
call   1080 <movimentoDoRobo@plt>
mov    %eax,%r13d
lea    0xc86(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %rbp,%rdi
call   1100 <desenhar@plt>
mov    %rbx,%rdi
lea    0xbe7(%rip),%rsi
mov    %r13d,%edx
mov    0xc(%rsp),%r13d
call   1150 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10b0 <send@plt>
lea    0xcea(%rip),%rdi
call   1060 <puts@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cltq
movb   $0x0,0x60(%rsp,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1120 <strcmp@plt>
test   %rax,%rax
je     13ed <main+0x18d>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10c0 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
jmp    1490 <main+0x230>
lea    0xb6e(%rip),%rdi
jmp    1516 <main+0x2b6>
lea    0x30(%rsp),%rdi
call   1140 <vencer@plt>
cmp    $0xffffffff,%eax
je     14f2 <main+0x292>
test   %eax,%eax
je     14fb <main+0x29b>
cmp    $0x1,%eax
jne    1507 <main+0x2a7>
lea    0x30(%rsp),%rdi
call   1100 <desenhar@plt>
lea    0xc4b(%rip),%rdi
jmp    1502 <main+0x2a2>
lea    0xbfc(%rip),%rdi
jmp    1502 <main+0x2a2>
lea    0xc43(%rip),%rdi
call   1060 <puts@plt>
mov    %r13d,%edi
call   10e0 <close@plt>
lea    0xbf7(%rip),%rdi
call   1060 <puts@plt>
xor    %edi,%edi
call   1160 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [42 x i8] c"Computer: O, You: X\0APlay (1)st or (2)nd? \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@__const.main.ip = [16 x i8] c"192.168.0.115\00\00\00"
@__const.main.comandos = [38 x i8] c"/x /mem /disc /time /pros /port /help\00"
@.str.3 = [6 x i8] c"clear\00"
@.str.4 = [35 x i8] c"\0A Robotica Inteligente - UFBA\0A\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [28 x i8] c"\0A> Servidor nao Encontrado\0A\00"
@.str.6 = [63 x i8] c">> A Conexao com o Servidor %s foi estabelecida na porta %d \0A\0A\00"
@.str.7 = [7 x i8] c">: %s\0A\00"
@.str.8 = [25 x i8] c"Client comunicando OK!!!\00"
@.str.9 = [23 x i8] c"Movimento do Robo: %d\0A\00"
@.str.10 = [32 x i8] c"Waiting for response message: \0A\00"
@.str.11 = [14 x i8] c"Response: %s\0A\00"
@.str.12 = [20 x i8] c"A draw. How droll.\0A\00"
@.str.13 = [11 x i8] c"You lose.\0A\00"
@.str.14 = [25 x i8] c"You win. Inconceivable!\0A\00"
@.str.15 = [47 x i8] c">>A conexao com o servidor foi finalizada!!!\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i8*
%9 = alloca [38 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
store i32 0, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%16 = bitcast [9 x i32]* %2 to i8*
store i32 0, i32* %3
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = bitcast [16 x i8]* %5 to i8*
%20 = bitcast [38 x i8]* %9 to i8*
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = call i32 @socket(i32 %23, i32 %24, i32 0)
store i32 %25, i32* %11
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 3
store i32 %26, i32* %27
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%29 = call i32 @inet_addr(i8* %28)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
store i32 %29, i32* %31
%32 = call i32 @htons(i32 23)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%35 = call i32 @memset(i32* %34, i32 0, i32 4)
%36 = load i32, i32* %11
%37 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%38 = call i64 @connect(i32 %36, %struct.sockaddr* %37, i32 4)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %0
%41 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %0
%44 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0), i8* %44, i32 23)
%46 = load i32, i32* %11
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%48 = call i32 @recv(i32 %46, i8* %47, i32 1024, i32 0)
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %50
store i8 0, i8* %51
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%55 = call i32 @strcpy(i8* %54, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%56 = load i32, i32* %11
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%58 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%59 = call i32 @strlen(i8* %58)
%60 = call i32 @send(i32 %56, i8* %57, i32 %59, i32 0)
%61 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%62 = call i32 @desenhar(i32* %61)
store i32 0, i32* %4
br label %63
63: ; preds = %118, %43
%64 = load i32, i32* %4
%65 = icmp ult i32 %64, 9
br i1 %65, label %66, label %70
66: ; preds = %63
%67 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%68 = call i32 @vencer(i32* %67)
%69 = icmp eq i32 %68, 0
br label %70
70: ; preds = %66, %63
%71 = phi i1 [ false, %63 ], [ %69, %66 ]
br i1 %71, label %72, label %121
72: ; preds = %70
%73 = load i32, i32* %4
%74 = load i32, i32* %3
%75 = add i32 %73, %74
%76 = urem i32 %75, 2
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %112
78: ; preds = %72
%79 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%80 = call i32 @movimentoDoRobo(i32* %79)
store i32 %80, i32* %14
%81 = load i32, i32* %14
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %81)
%83 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%84 = call i32 @desenhar(i32* %83)
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%86 = load i32, i32* %14
%87 = call i32 @sprintf(i8* %85, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %86)
%88 = load i32, i32* %11
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%91 = call i32 @strlen(i8* %90)
%92 = call i32 @send(i32 %88, i8* %89, i32 %91, i32 0)
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%94 = load i32, i32* %11
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%96 = call i32 @recv(i32 %94, i8* %95, i32 1024, i32 0)
store i32 %96, i32* %10
%97 = load i32, i32* %10
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %98
store i8 0, i8* %99
br label %100
100: ; preds = %105, %78
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%103 = call i64 @strcmp(i8* %101, i8* %102)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %111
105: ; preds = %100
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %106)
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%110 = call i32 @strcpy(i8* %108, i8* %109)
br label %100
111: ; preds = %100
br label %117
112: ; preds = %72
%113 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%114 = call i32 @movimentoDoJogador(i32* %113)
%115 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%116 = call i32 @desenhar(i32* %115)
br label %117
117: ; preds = %112, %111
br label %118
118: ; preds = %117
%119 = load i32, i32* %4
%120 = add i32 %119, 1
store i32 %120, i32* %4
br label %63
121: ; preds = %70
%122 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%123 = call i32 @vencer(i32* %122)
switch i32 %123, label %132 [
i32 0, label %124
i32 1, label %126
i32 -1, label %130
]
124: ; preds = %121
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0))
br label %132
126: ; preds = %121
%127 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%128 = call i32 @desenhar(i32* %127)
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
br label %132
130: ; preds = %121
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.14, i64 0, i64 0))
br label %132
132: ; preds = %121, %130, %126, %124
%133 = load i32, i32* %11
%134 = call i32 @close(i32 %133)
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.15, i64 0, i64 0))
%136 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [42 x i8] c"Computer: O, You: X\0APlay (1)st or (2)nd? \00"
@.str.1 = [3 x i8] c"%d\00"
@__const.main.ip = [16 x i8] c"192.168.0.115\00\00\00"
@.str.3 = [6 x i8] c"clear\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [28 x i8] c"\0A> Servidor nao Encontrado\0A\00"
@.str.6 = [63 x i8] c">> A Conexao com o Servidor %s foi estabelecida na porta %d \0A\0A\00"
@.str.7 = [7 x i8] c">: %s\0A\00"
@.str.8 = [25 x i8] c"Client comunicando OK!!!\00"
@.str.9 = [23 x i8] c"Movimento do Robo: %d\0A\00"
@.str.11 = [14 x i8] c"Response: %s\0A\00"
@str = [34 x i8] c"\0A Robotica Inteligente - UFBA\0A\00"
@str.16 = [24 x i8] c"You win. Inconceivable!\00"
@str.17 = [46 x i8] c">>A conexao com o servidor foi finalizada!!!\0A\00"
@str.18 = [10 x i8] c"You lose.\00"
@str.19 = [19 x i8] c"A draw. How droll.\00"
@str.20 = [31 x i8] c"Waiting for response message: \00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca i32
%3 = alloca [16 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca %struct.sockaddr_in
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%8 = bitcast [9 x i32]* %1 to i8*
%9 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 @putchar(i32 10)
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%15 = bitcast %struct.sockaddr_in* %6 to i8*
%16 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%18 = load i32, i32* @AF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = call i32 @socket(i32 %18, i32 %19, i32 0)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 3
store i32 %21, i32* %22
%23 = call i32 @inet_addr(i8* %12)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2, i32 0
store i32 %23, i32* %24
%25 = call i32 @htons(i32 23)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0
%28 = call i32 @memset(i32* %27, i32 0, i32 4)
%29 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%30 = call i64 @connect(i32 %20, %struct.sockaddr* %29, i32 4)
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %0
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %0
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.6, i64 0, i64 0), i8* %12, i32 23)
%37 = call i32 @recv(i32 %20, i8* %13, i32 1024, i32 0)
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %38
store i8 0, i8* %39
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8* %13)
%41 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%42 = call i32 @strlen(i8* %13)
%43 = call i32 @send(i32 %20, i8* %13, i32 %42, i32 0)
%44 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%45 = call i32 @desenhar(i32* %44)
br label %46
46: ; preds = %35, %76
%47 = phi i32 [ 0, %35 ], [ %77, %76 ]
%48 = call i32 @vencer(i32* %44)
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %79
50: ; preds = %46
%51 = load i32, i32* %2
%52 = add i32 %51, %47
%53 = and i32 %52, 1
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %73
55: ; preds = %50
%56 = call i32 @movimentoDoRobo(i32* %44)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %56)
%58 = call i32 @desenhar(i32* %44)
%59 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%60 = call i32 @strlen(i8* %13)
%61 = call i32 @send(i32 %20, i8* %13, i32 %60, i32 0)
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.20, i64 0, i64 0))
%63 = call i32 @recv(i32 %20, i8* %13, i32 1024, i32 0)
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %64
store i8 0, i8* %65
%66 = call i64 @strcmp(i8* %14, i8* %13)
%67 = icmp eq i64 %66, 0
br i1 %67, label %76, label %68
68: ; preds = %55, %68
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0), i8* %13)
%70 = call i32 @strcpy(i8* %14, i8* %13)
%71 = call i64 @strcmp(i8* %14, i8* %13)
%72 = icmp eq i64 %71, 0
br i1 %72, label %76, label %68
73: ; preds = %50
%74 = call i32 @movimentoDoJogador(i32* %44)
%75 = call i32 @desenhar(i32* %44)
br label %76
76: ; preds = %68, %55, %73
%77 = add nuw nsw i32 %47, 1
%78 = icmp eq i32 %77, 9
br i1 %78, label %79, label %46
79: ; preds = %76, %46
%80 = call i32 @vencer(i32* %44)
switch i32 %80, label %87 [
i32 0, label %84
i32 1, label %81
i32 -1, label %83
]
81: ; preds = %79
%82 = call i32 @desenhar(i32* %44)
br label %84
83: ; preds = %79
br label %84
84: ; preds = %79, %81, %83
%85 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @str.16, i64 0, i64 0), %83 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.18, i64 0, i64 0), %81 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.19, i64 0, i64 0), %79 ]
%86 = call i32 @puts(i8* dereferenceable(1) %85)
br label %87
87: ; preds = %84, %79
%88 = call i32 @close(i32 %20)
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.17, i64 0, i64 0))
%90 = call i32 @exit(i32 0)
unreachable
}