#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*/ alocaMatriz(int ***, int, int);
int /*<<< orphan*/ copiaMatriz(int **, int **, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ imprimeConway(char *, int, int, int **);
int /*<<< orphan*/ imprimeMatriz(int **, int, int);
int /*<<< orphan*/ liberaMatriz(int **, int);
int /*<<< orphan*/ novaGeracao(int **, int **, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ system(char *);
char toupper(char);
int main(int argc, char const *argv[]) {
  int linha, coluna, i, j;
  int **n0, **n1;
  char controle = 'a';
  char output[10] = "saida.txt";
  FILE *entrada;
  entrada = fopen("dados.txt", "r");
  if (entrada == NULL) {
    printf("Erro de abertura do arquivo.\n");
    return -1;
  }
  fscanf(entrada, "%d %d", &linha, &coluna);
  alocaMatriz(&n0, linha, coluna);
  alocaMatriz(&n1, linha, coluna);
  for (i = 0; i < linha; i++) {
    for (j = 0; j < coluna; j++) {
      fscanf(entrada, "%d", &n0[i][j]);
    }
  }
  fclose(entrada);
  while (toupper(controle) != 'N') {
    system("clear");
    imprimeMatriz(n0, linha, coluna);
    printf("Você gostaria de continuar executando a evolução das "
           "gerações?\nDigite 's' se gostaria e 'n' se não gostaria.\n");
    scanf(" %c", &controle);
    if (toupper(controle) == 'S') {
      novaGeracao(n0, n1, linha, coluna);
      copiaMatriz(n0, n1, linha, coluna);
    }
  }
  imprimeConway(output, linha, coluna, n0);
  liberaMatriz(n0, linha);
  liberaMatriz(n1, linha);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x61,-0x31(%rbp)
mov    0xe0f(%rip),%rax
mov    %rax,-0x3b(%rbp)
mov    0xe0c(%rip),%ax
mov    %ax,-0x33(%rbp)
lea    0xe03(%rip),%rdi
lea    0xe2e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    123a <main+0x6a>
lea    0xdeb(%rip),%rdi
call   1070 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13a9 <main+0x1d9>
mov    -0x48(%rbp),%rdi
lea    0xded(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1090 <fscanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x28(%rbp),%rdi
call   1050 <alocaMatriz@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x30(%rbp),%rdi
call   1050 <alocaMatriz@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12e2 <main+0x112>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12cf <main+0xff>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
movslq -0x20(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   1090 <fscanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    128c <main+0xbc>
jmp    12d4 <main+0x104>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1279 <main+0xa9>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
movsbl -0x31(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x4e,%eax
je     1377 <main+0x1a7>
lea    0xd31(%rip),%rdi
call   1060 <system@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   10b0 <imprimeMatriz@plt>
lea    0xd1c(%rip),%rdi
call   1070 <printf@plt>
lea    0xd84(%rip),%rdi
lea    -0x31(%rbp),%rsi
call   10d0 <scanf@plt>
movsbl -0x31(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x53,%eax
jne    1372 <main+0x1a2>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1080 <novaGeracao@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   10c0 <copiaMatriz@plt>
jmp    12eb <main+0x11b>
lea    -0x3b(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   10f0 <imprimeConway@plt>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <liberaMatriz@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <liberaMatriz@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movb   $0x61,0x7(%rsp)
movabs $0x78742e6164696173,%rax
2e 74 78
mov    %rax,0x20(%rsp)
movw   $0x74,0x28(%rsp)
lea    0xe0b(%rip),%rdi
lea    0xe18(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     130e <main+0x13e>
mov    %rax,%r15
lea    0xdf6(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rax,%rdi
xor    %eax,%eax
call   1090 <fscanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rdi
call   1060 <alocaMatriz@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0x18(%rsp),%rdi
call   1060 <alocaMatriz@plt>
mov    0x8(%rsp),%ecx
test   %ecx,%ecx
jle    12c1 <main+0xf1>
mov    0xc(%rsp),%eax
lea    0xdae(%rip),%r14
xor    %r12d,%r12d
jmp    127c <main+0xac>
xchg   %ax,%ax
add    $0x1,%r12
movslq %ecx,%rdx
cmp    %rdx,%r12
jge    12c1 <main+0xf1>
test   %eax,%eax
jle    1270 <main+0xa0>
xor    %r13d,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%rax
mov    (%rax,%r12,8),%rdx
add    %r13,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <fscanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1290 <main+0xc0>
mov    0x8(%rsp),%ecx
jmp    1270 <main+0xa0>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    $0x61,%edi
call   1030 <toupper@plt>
cmp    $0x4e,%al
jne    132d <main+0x15d>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%rcx
lea    0x20(%rsp),%rdi
call   10f0 <imprimeConway@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%esi
call   10a0 <liberaMatriz@plt>
mov    0x18(%rsp),%rdi
mov    0x8(%rsp),%esi
call   10a0 <liberaMatriz@plt>
xor    %eax,%eax
jmp    131f <main+0x14f>
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xce6(%rip),%r14
lea    0xce9(%rip),%r15
lea    0xcde(%rip),%r12
lea    0x7(%rsp),%rbx
jmp    1362 <main+0x192>
nopl   0x0(%rax)
movsbl 0x7(%rsp),%edi
call   1030 <toupper@plt>
cmp    $0x4e,%al
je     12d7 <main+0x107>
mov    %r14,%rdi
call   1070 <system@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
call   10b0 <imprimeMatriz@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10d0 <scanf@plt>
movsbl 0x7(%rsp),%edi
call   1030 <toupper@plt>
cmp    $0x53,%al
jne    1350 <main+0x180>
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
call   1080 <novaGeracao@plt>
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
call   10c0 <copiaMatriz@plt>
jmp    1350 <main+0x180>

LLVM IR (-O0):
@__const.main.output = [10 x i8] c"saida.txt\00"
@.str = [10 x i8] c"dados.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [30 x i8] c"Erro de abertura do arquivo.\0A\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"clear\00"
@.str.6 = [116 x i8] c"Voc\C3\AA gostaria de continuar executando a evolu\C3\A7\C3\A3o das gera\C3\A7\C3\B5es?\0ADigite 's' se gostaria e 'n' se n\C3\A3o gostaria.\0A\00"
@.str.7 = [4 x i8] c" %c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32**
%11 = alloca i32**
%12 = alloca i8
%13 = alloca [10 x i8]
%14 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 97, i8* %12
%15 = bitcast [10 x i8]* %13 to i8*
%16 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %14
%17 = load i32*, i32** %14
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %101
21: ; preds = %2
%22 = load i32*, i32** %14
%23 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %6, i32* %7)
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = call i32 @alocaMatriz(i32*** %10, i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call i32 @alocaMatriz(i32*** %11, i32 %27, i32 %28)
store i32 0, i32* %8
br label %30
30: ; preds = %54, %21
%31 = load i32, i32* %8
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %57
34: ; preds = %30
store i32 0, i32* %9
br label %35
35: ; preds = %50, %34
%36 = load i32, i32* %9
%37 = load i32, i32* %7
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %53
39: ; preds = %35
%40 = load i32*, i32** %14
%41 = load i32**, i32*** %10
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32*, i32** %41, i64 %43
%45 = load i32*, i32** %44
%46 = load i32, i32* %9
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %48)
br label %50
50: ; preds = %39
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %35
53: ; preds = %35
br label %54
54: ; preds = %53
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %30
57: ; preds = %30
%58 = load i32*, i32** %14
%59 = call i32 @fclose(i32* %58)
br label %60
60: ; preds = %88, %57
%61 = load i8, i8* %12
%62 = call signext i8 @toupper(i8 signext %61)
%63 = sext i8 %62 to i32
%64 = icmp ne i32 %63, 78
br i1 %64, label %65, label %89
65: ; preds = %60
%66 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%67 = load i32**, i32*** %10
%68 = load i32, i32* %6
%69 = load i32, i32* %7
%70 = call i32 @imprimeMatriz(i32** %67, i32 %68, i32 %69)
%71 = call i32 @printf(i8* getelementptr inbounds ([116 x i8], [116 x i8]* @.str.6, i64 0, i64 0))
%72 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %12)
%73 = load i8, i8* %12
%74 = call signext i8 @toupper(i8 signext %73)
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 83
br i1 %76, label %77, label %88
77: ; preds = %65
%78 = load i32**, i32*** %10
%79 = load i32**, i32*** %11
%80 = load i32, i32* %6
%81 = load i32, i32* %7
%82 = call i32 @novaGeracao(i32** %78, i32** %79, i32 %80, i32 %81)
%83 = load i32**, i32*** %10
%84 = load i32**, i32*** %11
%85 = load i32, i32* %6
%86 = load i32, i32* %7
%87 = call i32 @copiaMatriz(i32** %83, i32** %84, i32 %85, i32 %86)
br label %88
88: ; preds = %77, %65
br label %60
89: ; preds = %60
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%91 = load i32, i32* %6
%92 = load i32, i32* %7
%93 = load i32**, i32*** %10
%94 = call i32 @imprimeConway(i8* %90, i32 %91, i32 %92, i32** %93)
%95 = load i32**, i32*** %10
%96 = load i32, i32* %6
%97 = call i32 @liberaMatriz(i32** %95, i32 %96)
%98 = load i32**, i32*** %11
%99 = load i32, i32* %6
%100 = call i32 @liberaMatriz(i32** %98, i32 %99)
store i32 0, i32* %3
br label %101
101: ; preds = %89, %19
%102 = load i32, i32* %3
ret i32 %102
}

LLVM IR (-O2):
@__const.main.output = [10 x i8] c"saida.txt\00"
@.str = [10 x i8] c"dados.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"%d %d\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"clear\00"
@.str.7 = [4 x i8] c" %c\00"
@str = [115 x i8] c"Voc\C3\AA gostaria de continuar executando a evolu\C3\A7\C3\A3o das gera\C3\A7\C3\B5es?\0ADigite 's' se gostaria e 'n' se n\C3\A3o gostaria.\00"
@str.8 = [29 x i8] c"Erro de abertura do arquivo.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32**
%6 = alloca i32**
%7 = alloca i8
%8 = alloca [10 x i8]
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32*** %5 to i8*
%12 = bitcast i32*** %6 to i8*
store i8 97, i8* %7
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
br label %95
18: ; preds = %2
%19 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4)
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @alocaMatriz(i32*** %5, i32 %20, i32 %21)
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @alocaMatriz(i32*** %6, i32 %23, i32 %24)
%26 = load i32, i32* %3
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %54
28: ; preds = %18
%29 = load i32, i32* %4
br label %30
30: ; preds = %28, %48
%31 = phi i32 [ %26, %28 ], [ %49, %48 ]
%32 = phi i32 [ %29, %28 ], [ %50, %48 ]
%33 = phi i64 [ 0, %28 ], [ %51, %48 ]
%34 = icmp sgt i32 %32, 0
br i1 %34, label %35, label %48
35: ; preds = %30, %35
%36 = phi i64 [ %42, %35 ], [ 0, %30 ]
%37 = load i32**, i32*** %5
%38 = getelementptr inbounds i32*, i32** %37, i64 %33
%39 = load i32*, i32** %38
%40 = getelementptr inbounds i32, i32* %39, i64 %36
%41 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %40)
%42 = add nuw nsw i64 %36, 1
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %35, label %46
46: ; preds = %35
%47 = load i32, i32* %3
br label %48
48: ; preds = %46, %30
%49 = phi i32 [ %47, %46 ], [ %31, %30 ]
%50 = phi i32 [ %43, %46 ], [ %32, %30 ]
%51 = add nuw nsw i64 %33, 1
%52 = sext i32 %49 to i64
%53 = icmp slt i64 %51, %52
br i1 %53, label %30, label %54
54: ; preds = %48, %18
%55 = call i32 @fclose(i32* %14)
%56 = call signext i8 @toupper(i8 signext 97)
%57 = icmp eq i8 %56, 78
br i1 %57, label %84, label %58
58: ; preds = %54, %80
%59 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%60 = load i32**, i32*** %5
%61 = load i32, i32* %3
%62 = load i32, i32* %4
%63 = call i32 @imprimeMatriz(i32** %60, i32 %61, i32 %62)
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([115 x i8], [115 x i8]* @str, i64 0, i64 0))
%65 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%66 = load i8, i8* %7
%67 = call signext i8 @toupper(i8 signext %66)
%68 = icmp eq i8 %67, 83
br i1 %68, label %69, label %80
69: ; preds = %58
%70 = load i32**, i32*** %5
%71 = load i32**, i32*** %6
%72 = load i32, i32* %3
%73 = load i32, i32* %4
%74 = call i32 @novaGeracao(i32** %70, i32** %71, i32 %72, i32 %73)
%75 = load i32**, i32*** %5
%76 = load i32**, i32*** %6
%77 = load i32, i32* %3
%78 = load i32, i32* %4
%79 = call i32 @copiaMatriz(i32** %75, i32** %76, i32 %77, i32 %78)
br label %80
80: ; preds = %69, %58
%81 = load i8, i8* %7
%82 = call signext i8 @toupper(i8 signext %81)
%83 = icmp eq i8 %82, 78
br i1 %83, label %84, label %58
84: ; preds = %80, %54
%85 = load i32, i32* %3
%86 = load i32, i32* %4
%87 = load i32**, i32*** %5
%88 = call i32 @imprimeConway(i8* %13, i32 %85, i32 %86, i32** %87)
%89 = load i32**, i32*** %5
%90 = load i32, i32* %3
%91 = call i32 @liberaMatriz(i32** %89, i32 %90)
%92 = load i32**, i32*** %6
%93 = load i32, i32* %3
%94 = call i32 @liberaMatriz(i32** %92, i32 %93)
br label %95
95: ; preds = %84, %16
%96 = phi i32 [ -1, %16 ], [ 0, %84 ]
ret i32 %96
}