#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() {
  char nomeJogador[30];
  char keepPlaying;
  int loopRetry = 0;
  int points = 0;
  int coord_i = 0;
  int coord_y = 0;
  int battlefield[5][5] = {{0, 0, 0, 0, 0},
                           {0, 1, 1, 1, 0},
                           {0, 0, 0, 0, 0},
                           {1, 0, 1, 0, 0},
                           {0, 0, 1, 0, 0}};
  printf("Qual é o seu nome? \n");
  scanf("%s", nomeJogador);
  while (loopRetry == 0) {
    printf("Entre com as coordenadas: \n");
    printf("numero da linha : ");
    scanf("%d", &coord_i);
    printf("numero da coluna : ");
    scanf("%d", &coord_y);
    if (battlefield[coord_i][coord_y] == 1) {
      printf("Bomba!! Você ganhou 1 ponto\n");
      battlefield[coord_i][coord_y] = 0;
      points++;
    } else {
      printf("Água!! Que pena\n");
    }
    printf("Deseja continuar (s/n)?\n");
    scanf(" %c", &keepPlaying);
    if (keepPlaying == 'n' || points == 6) {
      printf("Olá %s, você ganhou! Fez %d pontos.", nomeJogador, points);
      loopRetry = 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
movl   $0x1,-0x98(%rbp)
movl   $0x1,-0x94(%rbp)
movl   $0x1,-0x90(%rbp)
movl   $0x1,-0x74(%rbp)
movl   $0x1,-0x6c(%rbp)
movl   $0x1,-0x58(%rbp)
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x38(%rbp)
jne    12db <main+0x1ab>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe37(%rip),%rdi
lea    -0x44(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0x40(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x44(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1275 <main+0x145>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x40(%rbp),%rcx
lea    -0xb0(%rbp),%rax
imul   $0x14,%rcx,%rcx
add    %rcx,%rax
movslq -0x44(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1283 <main+0x153>
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe10(%rip),%rdi
lea    -0x31(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movsbl -0x31(%rbp),%eax
cmp    $0x6e,%eax
je     12ba <main+0x18a>
cmpl   $0x6,-0x3c(%rbp)
jne    12d6 <main+0x1a6>
lea    -0x30(%rbp),%rsi
mov    -0x3c(%rbp),%edx
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x38(%rbp)
jmp    11c4 <main+0x94>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
movabs $0x100000001,%rax
mov    %rax,0x28(%rsp)
movl   $0x1,0x30(%rsp)
movl   $0x1,0x4c(%rsp)
movl   $0x1,0x54(%rsp)
movl   $0x1,0x68(%rsp)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe44(%rip),%rdi
lea    0x80(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe44(%rip),%rbx
lea    0x8(%rsp),%r14
lea    0xeba(%rip),%r15
lea    0xe48(%rip),%r12
lea    0x7(%rsp),%r13
xor    %ebp,%ebp
nopl   0x0(%rax)
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
lea    0xe00(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xdf9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
cmpl   $0x1,(%rax,%rcx,4)
jne    1280 <main+0x150>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
movslq 0xc(%rsp),%rax
movslq 0x8(%rsp),%rcx
lea    (%rax,%rax,4),%rax
lea    (%rsp,%rax,4),%rax
add    $0x10,%rax
movl   $0x0,(%rax,%rcx,4)
add    $0x1,%ebp
jmp    128c <main+0x15c>
xchg   %ax,%ax
lea    0xe00(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpb   $0x6e,0x7(%rsp)
je     12b1 <main+0x181>
cmp    $0x6,%ebp
jne    11f0 <main+0xc0>
lea    0xd79(%rip),%rdi
lea    0x80(%rsp),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Qual \C3\A9 o seu nome? \0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [28 x i8] c"Entre com as coordenadas: \0A\00"
@.str.3 = [19 x i8] c"numero da linha : \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [20 x i8] c"numero da coluna : \00"
@.str.6 = [30 x i8] c"Bomba!! Voc\C3\AA ganhou 1 ponto\0A\00"
@.str.7 = [18 x i8] c"\C3\81gua!! Que pena\0A\00"
@.str.8 = [25 x i8] c"Deseja continuar (s/n)?\0A\00"
@.str.9 = [4 x i8] c" %c\00"
@.str.10 = [38 x i8] c"Ol\C3\A1 %s, voc\C3\AA ganhou! Fez %d pontos.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [30 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x [5 x i32]]
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%9 = bitcast [5 x [5 x i32]]* %8 to i8*
%10 = bitcast i8* %9 to [5 x [5 x i32]]*
%11 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %10, i32 0, i32 1
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i32 0, i32 1
store i32 1, i32* %12
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i32 0, i32 2
store i32 1, i32* %13
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %11, i32 0, i32 3
store i32 1, i32* %14
%15 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %10, i32 0, i32 3
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %15, i32 0, i32 0
store i32 1, i32* %16
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %15, i32 0, i32 2
store i32 1, i32* %17
%18 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %10, i32 0, i32 4
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %18, i32 0, i32 2
store i32 1, i32* %19
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %65, %0
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %66
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%29 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %8, i64 0, i64 %33
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %34, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %50
40: ; preds = %26
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %8, i64 0, i64 %43
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [5 x i32], [5 x i32]* %44, i64 0, i64 %46
store i32 0, i32* %47
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %52
50: ; preds = %26
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
br label %52
52: ; preds = %50, %40
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%54 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %3)
%55 = load i8, i8* %3
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 110
br i1 %57, label %61, label %58
58: ; preds = %52
%59 = load i32, i32* %5
%60 = icmp eq i32 %59, 6
br i1 %60, label %61, label %65
61: ; preds = %58, %52
%62 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%63 = load i32, i32* %5
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i8* %62, i32 %63)
store i32 1, i32* %4
br label %65
65: ; preds = %61, %58
br label %23
66: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [19 x i8] c"numero da linha : \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [20 x i8] c"numero da coluna : \00"
@.str.9 = [4 x i8] c" %c\00"
@.str.10 = [38 x i8] c"Ol\C3\A1 %s, voc\C3\AA ganhou! Fez %d pontos.\00"
@str = [21 x i8] c"Qual \C3\A9 o seu nome? \00"
@str.11 = [27 x i8] c"Entre com as coordenadas: \00"
@str.12 = [17 x i8] c"\C3\81gua!! Que pena\00"
@str.13 = [24 x i8] c"Deseja continuar (s/n)?\00"
@str.14 = [29 x i8] c"Bomba!! Voc\C3\AA ganhou 1 ponto\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca [5 x [5 x i32]]
%6 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = bitcast [5 x [5 x i32]]* %5 to i8*
%10 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 1, i64 1
store i32 1, i32* %10
%11 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 1, i64 2
store i32 1, i32* %11
%12 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 1, i64 3
store i32 1, i32* %12
%13 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 3, i64 0
store i32 1, i32* %13
%14 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 3, i64 2
store i32 1, i32* %14
%15 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 4, i64 2
store i32 1, i32* %15
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %18
18: ; preds = %42, %0
%19 = phi i32 [ 0, %0 ], [ %43, %42 ]
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.11, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 %26, i64 %28
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %40
32: ; preds = %18
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.14, i64 0, i64 0))
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %5, i64 0, i64 %35, i64 %37
store i32 0, i32* %38
%39 = add nsw i32 %19, 1
br label %42
40: ; preds = %18
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
br label %42
42: ; preds = %40, %32
%43 = phi i32 [ %39, %32 ], [ %19, %40 ]
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.13, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* %2)
%46 = load i8, i8* %2
%47 = icmp eq i8 %46, 110
%48 = icmp eq i32 %43, 6
%49 = select i1 %47, i1 true, i1 %48
br i1 %49, label %50, label %18
50: ; preds = %42
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i8* %6, i32 %43)
ret i32 0
}