#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int Tiro(int matriz[6][8], int Tela[6][8], int *Ponto) {
  int i, j;
  printf("\n    Digite a linha que deseja atirar:");
  scanf("%d", &i);
  i = i - 1;
  printf("    Digite a coluna que deseja atirar:");
  scanf("%d", &j);
  j = j - 1;
  getchar();
  if (matriz[i][j] != 0) {
    if (matriz[i][j] == 4) {
      printf("\tVoce acertou parte de um encouracado!\n");
      printf("\t       aperte enter para continuar");
      getchar();
      *Ponto = *Ponto + 1;
      Tela[i][j] = 4;
      return 4;
    } else {
      printf("\tVoce acertou parte de um submarino\n");
      printf("\t      aperte enter para continuar");
      getchar();
      *Ponto = *Ponto + 1;
      Tela[i][j] = 2;
      return 2;
    }
  } else {
    printf("\t      Voce acertou agua\n");
    printf("\taperte enter para continuar");
    getchar();
    Tela[i][j] = 3;
    return 0;
  }
}


x86 assembly (clang, -O0):
<Tiro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1277 <Tiro+0x147>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
cmpl   $0x4,(%rax,%rcx,4)
jne    1223 <Tiro+0xf3>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x4,(%rax,%rcx,4)
movl   $0x4,-0x4(%rbp)
jmp    12b7 <Tiro+0x187>
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x2,(%rax,%rcx,4)
movl   $0x2,-0x4(%rbp)
jmp    12b7 <Tiro+0x187>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x3,(%rax,%rcx,4)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tiro>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rbp
lea    0x4(%rsp),%rsi
mov    %rbp,%rdi
call   1060 <scanf@plt>
addl   $0xffffffff,0x4(%rsp)
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %rbp,%rdi
call   1060 <scanf@plt>
addl   $0xffffffff,(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
movslq 0x4(%rsp),%rax
movslq (%rsp),%rcx
shl    $0x5,%rax
add    %rbx,%rax
mov    (%rax,%rcx,4),%eax
test   %eax,%eax
je     11e4 <Tiro+0xa4>
cmp    $0x4,%eax
jne    120a <Tiro+0xca>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
addl   $0x1,(%r14)
mov    $0x4,%eax
mov    $0x4,%ebp
jmp    1237 <Tiro+0xf7>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x3,%eax
jmp    1237 <Tiro+0xf7>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
addl   $0x1,(%r14)
mov    $0x2,%eax
mov    $0x2,%ebp
movslq 0x4(%rsp),%rcx
movslq (%rsp),%rdx
shl    $0x5,%rcx
add    %rcx,%r15
mov    %eax,(%r15,%rdx,4)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"\0A Digite a linha que deseja atirar:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c" Digite a coluna que deseja atirar:\00"
@.str.3 = [40 x i8] c"\09Voce acertou parte de um encouracado!\0A\00"
@.str.4 = [36 x i8] c"\09 aperte enter para continuar\00"
@.str.5 = [37 x i8] c"\09Voce acertou parte de um submarino\0A\00"
@.str.6 = [35 x i8] c"\09 aperte enter para continuar\00"
@.str.7 = [26 x i8] c"\09 Voce acertou agua\0A\00"
@.str.8 = [29 x i8] c"\09aperte enter para continuar\00"
define i32 @Tiro([8 x i32]* %0, [8 x i32]* %1, i32* %2) {
%4 = alloca i32
%5 = alloca [8 x i32]*
%6 = alloca [8 x i32]*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store [8 x i32]* %0, [8 x i32]** %5
store [8 x i32]* %1, [8 x i32]** %6
store i32* %2, i32** %7
%10 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%12 = load i32, i32* %8
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %8
%14 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%16 = load i32, i32* %9
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %9
%18 = call i32 (...) @getchar()
%19 = load [8 x i32]*, [8 x i32]** %5
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %19, i64 %21
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %22, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %68
28: ; preds = %3
%29 = load [8 x i32]*, [8 x i32]** %5
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %29, i64 %31
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [8 x i32], [8 x i32]* %32, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, 4
br i1 %37, label %38, label %53
38: ; preds = %28
%39 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 (...) @getchar()
%42 = load i32*, i32** %7
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
%45 = load i32*, i32** %7
store i32 %44, i32* %45
%46 = load [8 x i32]*, [8 x i32]** %6
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8 x i32], [8 x i32]* %46, i64 %48
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %49, i64 0, i64 %51
store i32 4, i32* %52
store i32 4, i32* %4
br label %79
53: ; preds = %28
%54 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%56 = call i32 (...) @getchar()
%57 = load i32*, i32** %7
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
%60 = load i32*, i32** %7
store i32 %59, i32* %60
%61 = load [8 x i32]*, [8 x i32]** %6
%62 = load i32, i32* %8
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [8 x i32], [8 x i32]* %61, i64 %63
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [8 x i32], [8 x i32]* %64, i64 0, i64 %66
store i32 2, i32* %67
store i32 2, i32* %4
br label %79
68: ; preds = %3
%69 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%70 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%71 = call i32 (...) @getchar()
%72 = load [8 x i32]*, [8 x i32]** %6
%73 = load i32, i32* %8
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [8 x i32], [8 x i32]* %72, i64 %74
%76 = load i32, i32* %9
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [8 x i32], [8 x i32]* %75, i64 0, i64 %77
store i32 3, i32* %78
store i32 0, i32* %4
br label %79
79: ; preds = %68, %53, %38
%80 = load i32, i32* %4
ret i32 %80
}

LLVM IR (-O2):
@.str = [39 x i8] c"\0A Digite a linha que deseja atirar:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c" Digite a coluna que deseja atirar:\00"
@.str.4 = [36 x i8] c"\09 aperte enter para continuar\00"
@.str.6 = [35 x i8] c"\09 aperte enter para continuar\00"
@.str.8 = [29 x i8] c"\09aperte enter para continuar\00"
@str = [25 x i8] c"\09 Voce acertou agua\00"
@str.9 = [36 x i8] c"\09Voce acertou parte de um submarino\00"
@str.10 = [39 x i8] c"\09Voce acertou parte de um encouracado!\00"
define i32 @Tiro([8 x i32]* nocapture %0, [8 x i32]* nocapture writeonly %1, i32* nocapture %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = bitcast i32* %5 to i8*
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %4
%11 = add nsw i32 %10, -1
store i32 %11, i32* %4
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%14 = load i32, i32* %5
%15 = add nsw i32 %14, -1
store i32 %15, i32* %5
%16 = call i32 (...) @getchar()
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %0, i64 %18, i64 %20
%22 = load i32, i32* %21
switch i32 %22, label %29 [
i32 0, label %35
i32 4, label %23
]
23: ; preds = %3
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0))
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 (...) @getchar()
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %39
29: ; preds = %3
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0))
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%32 = call i32 (...) @getchar()
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %39
35: ; preds = %3
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 (...) @getchar()
br label %39
39: ; preds = %35, %29, %23
%40 = phi i32 [ 3, %35 ], [ 2, %29 ], [ 4, %23 ]
%41 = phi i32 [ 0, %35 ], [ 2, %29 ], [ 4, %23 ]
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %1, i64 %43, i64 %45
store i32 %40, i32* %46
ret i32 %41
}