#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int nome;
  int i;
  int j;
  int batalha[5][5] = {{0, 0, 0, 1, 0},
                       {1, 0, 0, 0, 1},
                       {0, 0, 0, 1, 1},
                       {1, 1, 1, 0, 0},
                       {0, 0, 0, 1, 0}};
  int pontos = 0;
  char continuar;
  printf("Vamos jogar Batalha Naval ?\n");
  printf("Diga seu nome:  ");
  scanf("%d", &nome);
  do {
    printf("Digite a coordenada de linha:(0 a 4)");
    scanf("%d", &i);
    printf("Digite a coordenada de coluna:(0 a 4)");
    scanf("%d", &j);
    if (batalha[i][j] == 1) {
      printf("Bomba!! Você ganhou 1 ponto\n");
      pontos++;
    } else {
      printf("Água !! Que pena !\n");
    }
    printf("Deseja continuar (s/n)?\n");
    scanf(" %c", &continuar);
    if (continuar == 'n') {
      printf("Olá %d, você fez: %d pontos !!\n", nome, pontos);
      break;
    }
  } while (continuar == 's');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x64,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x84(%rbp)
lea    0xefc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0xc(%rbp),%rcx
lea    -0x80(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    120e <main+0xde>
lea    0xeed(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    121c <main+0xec>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
lea    -0x85(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x85(%rbp),%eax
cmp    $0x6e,%eax
jne    126b <main+0x13b>
mov    -0x8(%rbp),%esi
mov    -0x84(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1280 <main+0x150>
jmp    1270 <main+0x140>
movsbl -0x85(%rbp),%eax
cmp    $0x73,%eax
je     118f <main+0x5f>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xfa4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf13(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf16(%rip),%rbx
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe8b(%rip),%r13
lea    0xf9d(%rip),%r14
lea    0xf40(%rip),%r15
lea    0xb(%rsp),%r12
xor    %ebp,%ebp
jmp    11ba <main+0x8a>
nopl   0x0(%rax)
lea    0xf6e(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0xb(%rsp),%eax
cmp    $0x73,%al
jne    122b <main+0xfb>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq 0x10(%rsp),%rax
movslq 0xc(%rsp),%rcx
lea    (%rax,%rax,4),%rax
lea    0x0(,%rax,4),%rax
add    %r13,%rax
cmpl   $0x1,(%rax,%rcx,4)
jne    1190 <main+0x60>
lea    0xf13(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebp
jmp    119c <main+0x6c>
cmp    $0x6e,%al
jne    1243 <main+0x113>
mov    0x14(%rsp),%esi
lea    0xe8d(%rip),%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.batalha = [5 x [5 x i32]] [[5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 0], [5 x i32] [i32 1, i32 0, i32 0, i32 0, i32 1], [5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 1], [5 x i32] [i32 1, i32 1, i32 1, i32 0, i32 0], [5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 0]]
@.str = [29 x i8] c"Vamos jogar Batalha Naval ?\0A\00"
@.str.1 = [17 x i8] c"Diga seu nome: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [37 x i8] c"Digite a coordenada de linha:(0 a 4)\00"
@.str.4 = [38 x i8] c"Digite a coordenada de coluna:(0 a 4)\00"
@.str.5 = [30 x i8] c"Bomba!! Voc\C3\AA ganhou 1 ponto\0A\00"
@.str.6 = [21 x i8] c"\C3\81gua !! Que pena !\0A\00"
@.str.7 = [25 x i8] c"Deseja continuar (s/n)?\0A\00"
@.str.8 = [4 x i8] c" %c\00"
@.str.9 = [34 x i8] c"Ol\C3\A1 %d, voc\C3\AA fez: %d pontos !!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x [5 x i32]]
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %1
%8 = bitcast [5 x [5 x i32]]* %5 to i8*
store i32 0, i32* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
br label %12
12: ; preds = %42, %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 %18
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %19, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %29
25: ; preds = %12
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %31
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %7)
%34 = load i8, i8* %7
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 110
br i1 %36, label %37, label %41
37: ; preds = %31
%38 = load i32, i32* %2
%39 = load i32, i32* %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %38, i32 %39)
br label %46
41: ; preds = %31
br label %42
42: ; preds = %41
%43 = load i8, i8* %7
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 115
br i1 %45, label %12, label %46
46: ; preds = %42, %37
ret i32 0
}

LLVM IR (-O2):
@__const.main.batalha = [5 x [5 x i32]] [[5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 0], [5 x i32] [i32 1, i32 0, i32 0, i32 0, i32 1], [5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 1], [5 x i32] [i32 1, i32 1, i32 1, i32 0, i32 0], [5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 0]]
@.str.1 = [17 x i8] c"Diga seu nome: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [37 x i8] c"Digite a coordenada de linha:(0 a 4)\00"
@.str.4 = [38 x i8] c"Digite a coordenada de coluna:(0 a 4)\00"
@.str.8 = [4 x i8] c" %c\00"
@.str.9 = [34 x i8] c"Ol\C3\A1 %d, voc\C3\AA fez: %d pontos !!\0A\00"
@str = [28 x i8] c"Vamos jogar Batalha Naval ?\00"
@str.10 = [20 x i8] c"\C3\81gua !! Que pena !\00"
@str.11 = [24 x i8] c"Deseja continuar (s/n)?\00"
@str.12 = [29 x i8] c"Bomba!! Voc\C3\AA ganhou 1 ponto\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
br label %11
11: ; preds = %29, %0
%12 = phi i32 [ 0, %0 ], [ %30, %29 ]
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* @__const.main.batalha, i64 0, i64 %18, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %27
24: ; preds = %11
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.12, i64 0, i64 0))
%26 = add nsw i32 %12, 1
br label %29
27: ; preds = %11
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
br label %29
29: ; preds = %27, %24
%30 = phi i32 [ %26, %24 ], [ %12, %27 ]
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.11, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%33 = load i8, i8* %4
switch i8 %33, label %37 [
i8 110, label %34
i8 115, label %11
]
34: ; preds = %29
%35 = load i32, i32* %1
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %35, i32 %30)
br label %37
37: ; preds = %29, %34
ret i32 0
}