#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ trataCoordenadas(char *, int *, int *);
int **recebeTabuleiro(char *arquivo) {
  FILE *entrada = fopen(arquivo, "r");
  if (entrada == NULL) {
    perror("Arquivo.");
    return NULL;
  }
  int **tabuleiro = (int **)malloc(10 * sizeof(int *));
  for (int i = 0; i < 10; i++)
    tabuleiro[i] = (int *)malloc(10 * sizeof(int));
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      tabuleiro[i][j] = 0;
  char linha[4] = {0};
  while (fgets(linha, 6, entrada) != NULL) {
    int horizontal, vertical;
    trataCoordenadas(linha, &horizontal, &vertical);
    tabuleiro[horizontal][vertical] = 1;
  }
  return tabuleiro;
}


x86 assembly (clang, -O0):
<recebeTabuleiro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a4 <recebeTabuleiro+0x44>
lea    0xe70(%rip),%rdi
call   1080 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    12a5 <recebeTabuleiro+0x145>
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jge    11ea <recebeTabuleiro+0x8a>
mov    $0x28,%edi
call   1050 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b9 <recebeTabuleiro+0x59>
movl   $0x0,-0x28(%rbp)
cmpl   $0xa,-0x28(%rbp)
jge    1244 <recebeTabuleiro+0xe4>
movl   $0x0,-0x2c(%rbp)
cmpl   $0xa,-0x2c(%rbp)
jge    1231 <recebeTabuleiro+0xd1>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x2c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1202 <recebeTabuleiro+0xa2>
jmp    1236 <recebeTabuleiro+0xd6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f1 <recebeTabuleiro+0x91>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x6,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     129d <recebeTabuleiro+0x13d>
lea    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <trataCoordenadas@plt>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x38(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    1254 <recebeTabuleiro+0xf4>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recebeTabuleiro>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1349 <recebeTabuleiro+0x1f9>
mov    %rax,%r14
mov    $0x50,%edi
call   1040 <malloc@plt>
mov    %rax,%r15
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x8(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x10(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x18(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x20(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x28(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x30(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x38(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x40(%r15)
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,0x48(%r15)
mov    (%r15),%rcx
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rcx)
movups %xmm0,(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x8(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x10(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x18(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x20(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x28(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x30(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x38(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
mov    0x40(%r15),%rcx
movups %xmm0,(%rcx)
movups %xmm0,0x10(%rcx)
movq   $0x0,0x20(%rcx)
movups %xmm0,(%rax)
movups %xmm0,0x10(%rax)
movq   $0x0,0x20(%rax)
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x6,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     1338 <recebeTabuleiro+0x1e8>
lea    0x4(%rsp),%rbx
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <trataCoordenadas@plt>
movslq 0xc(%rsp),%rax
mov    (%r15,%rax,8),%rax
movslq 0x8(%rsp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
jne    1300 <recebeTabuleiro+0x1b0>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xcb2(%rip),%rdi
call   1070 <perror@plt>
xor    %r15d,%r15d
jmp    1338 <recebeTabuleiro+0x1e8>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"Arquivo.\00"
define i32** @recebeTabuleiro(i8* %0) {
%2 = alloca i32**
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [4 x i8]
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %3
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %1
%17 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i32** null, i32*** %2
br label %78
18: ; preds = %1
%19 = call i64 @malloc(i32 80)
%20 = inttoptr i64 %19 to i32**
store i32** %20, i32*** %5
store i32 0, i32* %6
br label %21
21: ; preds = %31, %18
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 10
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = call i64 @malloc(i32 40)
%26 = inttoptr i64 %25 to i32*
%27 = load i32**, i32*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32*, i32** %27, i64 %29
store i32* %26, i32** %30
br label %31
31: ; preds = %24
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %21
34: ; preds = %21
store i32 0, i32* %7
br label %35
35: ; preds = %55, %34
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 10
br i1 %37, label %38, label %58
38: ; preds = %35
store i32 0, i32* %8
br label %39
39: ; preds = %51, %38
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 10
br i1 %41, label %42, label %54
42: ; preds = %39
%43 = load i32**, i32*** %5
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32*, i32** %43, i64 %45
%47 = load i32*, i32** %46
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
store i32 0, i32* %50
br label %51
51: ; preds = %42
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
br label %39
54: ; preds = %39
br label %55
55: ; preds = %54
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %35
58: ; preds = %35
%59 = bitcast [4 x i8]* %9 to i8*
br label %60
60: ; preds = %65, %58
%61 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%62 = load i32*, i32** %4
%63 = call i32* @fgets(i8* %61, i32 6, i32* %62)
%64 = icmp ne i32* %63, null
br i1 %64, label %65, label %76
65: ; preds = %60
%66 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%67 = call i32 @trataCoordenadas(i8* %66, i32* %10, i32* %11)
%68 = load i32**, i32*** %5
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32*, i32** %68, i64 %70
%72 = load i32*, i32** %71
%73 = load i32, i32* %11
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
store i32 1, i32* %75
br label %60
76: ; preds = %60
%77 = load i32**, i32*** %5
store i32** %77, i32*** %2
br label %78
78: ; preds = %76, %16
%79 = load i32**, i32*** %2
ret i32** %79
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [9 x i8] c"Arquivo.\00"
define i32** @recebeTabuleiro(i8* nocapture %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %78
9: ; preds = %1
%10 = tail call i64 @malloc(i32 80)
%11 = inttoptr i64 %10 to i32**
%12 = tail call i64 @malloc(i32 40)
%13 = inttoptr i64 %12 to i32*
store i32* %13, i32** %11
%14 = tail call i64 @malloc(i32 40)
%15 = inttoptr i64 %14 to i32*
%16 = getelementptr inbounds i32*, i32** %11, i64 1
store i32* %15, i32** %16
%17 = tail call i64 @malloc(i32 40)
%18 = inttoptr i64 %17 to i32*
%19 = getelementptr inbounds i32*, i32** %11, i64 2
store i32* %18, i32** %19
%20 = tail call i64 @malloc(i32 40)
%21 = inttoptr i64 %20 to i32*
%22 = getelementptr inbounds i32*, i32** %11, i64 3
store i32* %21, i32** %22
%23 = tail call i64 @malloc(i32 40)
%24 = inttoptr i64 %23 to i32*
%25 = getelementptr inbounds i32*, i32** %11, i64 4
store i32* %24, i32** %25
%26 = tail call i64 @malloc(i32 40)
%27 = inttoptr i64 %26 to i32*
%28 = getelementptr inbounds i32*, i32** %11, i64 5
store i32* %27, i32** %28
%29 = tail call i64 @malloc(i32 40)
%30 = inttoptr i64 %29 to i32*
%31 = getelementptr inbounds i32*, i32** %11, i64 6
store i32* %30, i32** %31
%32 = tail call i64 @malloc(i32 40)
%33 = inttoptr i64 %32 to i32*
%34 = getelementptr inbounds i32*, i32** %11, i64 7
store i32* %33, i32** %34
%35 = tail call i64 @malloc(i32 40)
%36 = inttoptr i64 %35 to i32*
%37 = getelementptr inbounds i32*, i32** %11, i64 8
store i32* %36, i32** %37
%38 = tail call i64 @malloc(i32 40)
%39 = inttoptr i64 %38 to i32*
%40 = getelementptr inbounds i32*, i32** %11, i64 9
store i32* %39, i32** %40
%41 = inttoptr i64 %10 to i8**
%42 = load i8*, i8** %41
%43 = bitcast i32** %16 to i8**
%44 = load i8*, i8** %43
%45 = bitcast i32** %19 to i8**
%46 = load i8*, i8** %45
%47 = bitcast i32** %22 to i8**
%48 = load i8*, i8** %47
%49 = bitcast i32** %25 to i8**
%50 = load i8*, i8** %49
%51 = bitcast i32** %28 to i8**
%52 = load i8*, i8** %51
%53 = bitcast i32** %31 to i8**
%54 = load i8*, i8** %53
%55 = bitcast i32** %34 to i8**
%56 = load i8*, i8** %55
%57 = bitcast i32** %37 to i8**
%58 = load i8*, i8** %57
%59 = inttoptr i64 %38 to i8*
%60 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%61 = call i32* @fgets(i8* %60, i32 6, i32* %5)
%62 = icmp eq i32* %61, null
br i1 %62, label %77, label %63
63: ; preds = %9
%64 = bitcast i32* %3 to i8*
%65 = bitcast i32* %4 to i8*
br label %66
66: ; preds = %63, %66
%67 = call i32 @trataCoordenadas(i8* %60, i32* %3, i32* %4)
%68 = load i32, i32* %3
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32*, i32** %11, i64 %69
%71 = load i32*, i32** %70
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i32, i32* %71, i64 %73
store i32 1, i32* %74
%75 = call i32* @fgets(i8* %60, i32 6, i32* %5)
%76 = icmp eq i32* %75, null
br i1 %76, label %77, label %66
77: ; preds = %66, %9
br label %78
78: ; preds = %77, %7
%79 = phi i32** [ null, %7 ], [ %11, %77 ]
ret i32** %79
}