#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*/ batalha();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int teste(int, int, int /*<<< orphan*/, int);
int main(void) {
  int continuar;
  printf("\nBem vindo ao programa Batalha Nautica!\nEste programa simula o "
         "jogo Batalha Naval, com um tabuleiro de tamanho definido\npor voce e "
         "a opcao de preenche-lo automaticamente.\n");
  printf("Deseja jogar? (Sim: 1 | Nao: 0)\n");
  scanf("%i", &continuar);
  continuar = teste(continuar, 1, 0, 1);
  while (continuar == 1) {
    batalha();
    printf("Deseja jogar novamente? (Sim: 1 | Nao: 0)\n");
    scanf("%i", &continuar);
    continuar = teste(continuar, 1, 0, 1);
    if (continuar == 0) {
      printf("\nObrigado por jogar e volte sempre!\n\n");
      return (0);
    }
  }
  printf("Obrigado por usar o programa!\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4a(%rip),%rdi
call   1030 <printf@plt>
lea    0xf5f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%ecx
xor    %edx,%edx
mov    %ecx,%esi
call   1040 <teste@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11f3 <main+0xb3>
mov    $0x0,%al
call   1060 <batalha@plt>
lea    0xf2d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%ecx
xor    %edx,%edx
mov    %ecx,%esi
call   1040 <teste@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11ee <main+0xae>
lea    0xf1e(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1206 <main+0xc6>
jmp    118b <main+0x4b>
lea    0xf27(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe94(%rip),%r14
lea    0xc(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1040 <teste@plt>
mov    %eax,0xc(%rsp)
lea    0xf32(%rip),%r15
lea    0xf49(%rip),%rbx
lea    0xf6c(%rip),%r13
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%eax
jne    11ef <main+0xaf>
xor    %eax,%eax
call   1060 <batalha@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1040 <teste@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
jne    11b0 <main+0x70>
mov    %r13,%r15
mov    %r15,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [172 x i8] c"\0ABem vindo ao programa Batalha Nautica!\0AEste programa simula o jogo Batalha Naval, com um tabuleiro de tamanho definido\0Apor voce e a opcao de preenche-lo automaticamente.\0A\00"
@.str.1 = [33 x i8] c"Deseja jogar? (Sim: 1 | Nao: 0)\0A\00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [43 x i8] c"Deseja jogar novamente? (Sim: 1 | Nao: 0)\0A\00"
@.str.4 = [38 x i8] c"\0AObrigado por jogar e volte sempre!\0A\0A\00"
@.str.5 = [31 x i8] c"Obrigado por usar o programa!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = call i32 @teste(i32 %6, i32 1, i32 0, i32 1)
store i32 %7, i32* %2
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = call i32 (...) @batalha()
%13 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = load i32, i32* %2
%16 = call i32 @teste(i32 %15, i32 1, i32 0, i32 1)
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %24
21: ; preds = %11
br label %8
22: ; preds = %8
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %24
24: ; preds = %22, %19
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%i\00"
@str = [171 x i8] c"\0ABem vindo ao programa Batalha Nautica!\0AEste programa simula o jogo Batalha Naval, com um tabuleiro de tamanho definido\0Apor voce e a opcao de preenche-lo automaticamente.\00"
@str.6 = [32 x i8] c"Deseja jogar? (Sim: 1 | Nao: 0)\00"
@str.7 = [30 x i8] c"Obrigado por usar o programa!\00"
@str.8 = [42 x i8] c"Deseja jogar novamente? (Sim: 1 | Nao: 0)\00"
@str.9 = [37 x i8] c"\0AObrigado por jogar e volte sempre!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([171 x i8], [171 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @teste(i32 %6, i32 1, i32 0, i32 1)
store i32 %7, i32* %1
br label %8
8: ; preds = %11, %0
%9 = phi i32 [ %16, %11 ], [ %7, %0 ]
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = call i32 (...) @batalha()
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = call i32 @teste(i32 %15, i32 1, i32 0, i32 1)
store i32 %16, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %8
18: ; preds = %8, %11
%19 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.9, i64 0, i64 0), %11 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0), %8 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
ret i32 0
}