#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 atoi(int /*<<< orphan*/);
int /*<<< orphan*/ calcularVida(int **, int **, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ getchar();
char getopt(int, char **, char *);
int /*<<< orphan*/ limpiar(int **, int);
char *malloc(int);
int /*<<< orphan*/ mostraTablero(int **, int, int);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
char *strcpy(char *, int /*<<< orphan*/);
int strlen(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  int ContadorIteracion = 0;
  int iteraciones;
  char *ruta;
  char c;
  int tamanoX;
  int tamanoY;
  int leido;
  FILE *fichero;
  while ((c = getopt(argc, argv, "f:i:")) != -1) {
    switch (c) {
    case 'i':
      iteraciones = atoi(optarg);
      break;
    case 'f':
      ruta = malloc(strlen(optarg) * sizeof(char));
      ruta = strcpy(ruta, optarg);
      break;
    default:
      printf("Error en los argumentos\n");
      return 0;
      break;
    }
  }
  if (c == 1) {
    return 0;
  }
  printf("Numero de iteraciones: %d\n", iteraciones);
  fichero = fopen(ruta, "r");
  fscanf(fichero, "%d %d", &tamanoX, &tamanoY);
  printf("Tamano x = %d  y = %d\n", tamanoX, tamanoY);
  int **unTablero = (int **)malloc(tamanoX * sizeof(int *));
  int **tableroCopia = (int **)malloc(tamanoX * sizeof(int *));
  for (int i = 0; i < tamanoX; i++) {
    unTablero[i] = (int *)malloc(tamanoY * sizeof(int));
    tableroCopia[i] = (int *)malloc(tamanoY * sizeof(int));
  }
  printf("Bienvenido al juego de la vida....\n");
  printf("Cargando datos del tablero\n");
  printf("Inicia carga del tablero\n");
  for (int i = 0; i < tamanoX; i++) {
    for (int j = 0; j < tamanoY; j++) {
      leido = fgetc(fichero) - 48;
      while (leido < 0 || leido > 1) {
        leido = fgetc(fichero) - 48;
      }
      unTablero[i][j] = leido;
    }
  }
  mostraTablero(unTablero, tamanoY, tamanoY);
  printf("Tablero Cargado con exito...\n");
  printf("Presione una tecla para iniciar el juego de la vida\n");
  fclose(fichero);
  getchar();
  while (ContadorIteracion < iteraciones) {
    system("clear");
    printf("Juego de la vida...\n");
    printf("Iteracion: %d\n", ++ContadorIteracion);
    calcularVida(unTablero, tableroCopia, tamanoX, tamanoY);
    mostraTablero(unTablero, tamanoX, tamanoY);
  }
  limpiar(unTablero, tamanoX);
  limpiar(tableroCopia, tamanoX);
  printf("Fin del programa\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xde5(%rip),%rdx
call   10f0 <getopt@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     12c4 <main+0xd4>
movsbl -0x21(%rbp),%eax
mov    %eax,-0x58(%rbp)
sub    $0x66,%eax
je     126b <main+0x7b>
jmp    1244 <main+0x54>
mov    -0x58(%rbp),%eax
sub    $0x69,%eax
jne    12a5 <main+0xb5>
jmp    1255 <main+0x65>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1100 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    12bf <main+0xcf>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
call   1060 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
call   1030 <strcpy@plt>
mov    %rax,-0x20(%rbp)
jmp    12bf <main+0xcf>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1550 <main+0x360>
jmp    120d <main+0x1d>
movsbl -0x21(%rbp),%eax
cmp    $0x1,%eax
jne    12dd <main+0xed>
movl   $0x0,-0x4(%rbp)
jmp    1550 <main+0x360>
mov    -0x18(%rbp),%esi
lea    0xd37(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x20(%rbp),%rdi
lea    0xe0e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xd2c(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   1090 <fscanf@plt>
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xd18(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x28(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    13b1 <main+0x1c1>
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%rdx
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10c0 <malloc@plt>
mov    %rax,%rdx
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    135b <main+0x16b>
lea    0xc9e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1484 <main+0x294>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1471 <main+0x281>
mov    -0x38(%rbp),%rdi
call   10a0 <fgetc@plt>
sub    $0x30,%eax
mov    %eax,-0x30(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x30(%rbp)
mov    %al,-0x59(%rbp)
jl     1429 <main+0x239>
cmpl   $0x1,-0x30(%rbp)
setg   %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    1439 <main+0x249>
jmp    144d <main+0x25d>
mov    -0x38(%rbp),%rdi
call   10a0 <fgetc@plt>
sub    $0x30,%eax
mov    %eax,-0x30(%rbp)
jmp    1410 <main+0x220>
mov    -0x30(%rbp),%edx
mov    -0x40(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x54(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    13f5 <main+0x205>
jmp    1476 <main+0x286>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    13e2 <main+0x1f2>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1050 <mostraTablero@plt>
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xc26(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   10b0 <getchar@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1523 <main+0x333>
lea    0xc31(%rip),%rdi
call   1070 <system@plt>
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   10d0 <calcularVida@plt>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1050 <mostraTablero@plt>
jmp    14bf <main+0x2cf>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1110 <limpiar@plt>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1110 <limpiar@plt>
lea    0xbeb(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xde6(%rip),%rdx
call   1100 <getopt@plt>
cmp    $0xff,%al
je     128c <main+0x8c>
mov    0x2dce(%rip),%r14
lea    0xdcf(%rip),%r15
jmp    126e <main+0x6e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%edi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    (%r14),%esi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rax,%r12
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1100 <getopt@plt>
cmp    $0xff,%al
je     128c <main+0x8c>
movsbl %al,%eax
cmp    $0x66,%eax
je     1240 <main+0x40>
cmp    $0x69,%eax
jne    14b5 <main+0x2b5>
mov    (%r14),%edi
call   1110 <atoi@plt>
mov    %eax,%r13d
jmp    125d <main+0x5d>
lea    0xd72(%rip),%rdi
mov    %r13,0x10(%rsp)
mov    %r13d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd98(%rip),%rsi
mov    %r12,%rdi
call   10f0 <fopen@plt>
mov    %rax,%rbx
lea    0xd65(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rax,%rdi
call   10a0 <fscanf@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xd4a(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%rsp),%r14d
lea    0x0(,%r14,8),%ebp
mov    %ebp,%edi
call   10d0 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%edi
call   10d0 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1341 <main+0x141>
mov    0xc(%rsp),%r13d
shl    $0x2,%r13d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13d,%edi
call   10d0 <malloc@plt>
mov    %rax,(%r12,%rbp,8)
mov    %r13d,%edi
call   10d0 <malloc@plt>
mov    %rax,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    1320 <main+0x120>
lea    0xd0a(%rip),%rdi
call   1040 <puts@plt>
lea    0xd21(%rip),%rdi
call   1040 <puts@plt>
lea    0xd30(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%edx
test   %eax,%eax
jle    13e2 <main+0x1e2>
xor    %r14d,%r14d
mov    0x10(%rsp),%r13
jmp    1390 <main+0x190>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%eax
add    $0x1,%r14
movslq %eax,%rcx
cmp    %rcx,%r14
jge    13e7 <main+0x1e7>
test   %edx,%edx
jle    1384 <main+0x184>
xor    %ebp,%ebp
jmp    13b5 <main+0x1b5>
nopl   0x0(%rax,%rax,1)
mov    (%r12,%r14,8),%rcx
mov    %eax,(%rcx,%rbp,4)
add    $0x1,%rbp
movslq 0xc(%rsp),%rdx
cmp    %rdx,%rbp
jge    1380 <main+0x180>
mov    %rbx,%rdi
call   10b0 <fgetc@plt>
add    $0xffffffd0,%eax
cmp    $0x2,%eax
jb     13a0 <main+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   10b0 <fgetc@plt>
add    $0xffffffd0,%eax
cmp    $0x1,%eax
ja     13d0 <main+0x1d0>
jmp    13a0 <main+0x1a0>
mov    0x10(%rsp),%r13
mov    %r12,%rdi
mov    %edx,%esi
call   1060 <mostraTablero@plt>
lea    0xcb1(%rip),%rdi
call   1040 <puts@plt>
lea    0xcc2(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   10c0 <getchar@plt>
test   %r13d,%r13d
jle    1494 <main+0x294>
neg    %r13d
mov    $0x1,%ebp
lea    0xcdf(%rip),%rbx
lea    0xc10(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xbf6(%rip),%rdi
call   1080 <system@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
call   10e0 <calcularVida@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r12,%rdi
call   1060 <mostraTablero@plt>
lea    0x1(%r13,%rbp,1),%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1440 <main+0x240>
mov    0x8(%rsp),%esi
mov    %r12,%rdi
call   1120 <limpiar@plt>
mov    0x8(%rsp),%esi
mov    %r15,%rdi
call   1120 <limpiar@plt>
lea    0xc47(%rip),%rdi
jmp    14bc <main+0x2bc>
lea    0xc63(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"f:i:\00"
@optarg = global i32 0
@.str.1 = [25 x i8] c"Error en los argumentos\0A\00"
@.str.2 = [27 x i8] c"Numero de iteraciones: %d\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [23 x i8] c"Tamano x = %d y = %d\0A\00"
@.str.6 = [36 x i8] c"Bienvenido al juego de la vida....\0A\00"
@.str.7 = [28 x i8] c"Cargando datos del tablero\0A\00"
@.str.8 = [26 x i8] c"Inicia carga del tablero\0A\00"
@.str.9 = [30 x i8] c"Tablero Cargado con exito...\0A\00"
@.str.10 = [53 x i8] c"Presione una tecla para iniciar el juego de la vida\0A\00"
@.str.11 = [6 x i8] c"clear\00"
@.str.12 = [21 x i8] c"Juego de la vida...\0A\00"
@.str.13 = [15 x i8] c"Iteracion: %d\0A\00"
@.str.14 = [18 x i8] c"Fin del programa\0A\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 i8*
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32**
%15 = alloca i32**
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %19
19: ; preds = %43, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call signext i8 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 %22, i8* %9
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %44
25: ; preds = %19
%26 = load i8, i8* %9
%27 = sext i8 %26 to i32
switch i32 %27, label %41 [
i32 105, label %28
i32 102, label %31
]
28: ; preds = %25
%29 = load i32, i32* @optarg
%30 = call i32 @atoi(i32 %29)
store i32 %30, i32* %7
br label %43
31: ; preds = %25
%32 = load i32, i32* @optarg
%33 = call i32 @strlen(i32 %32)
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 1
%36 = trunc i64 %35 to i32
%37 = call i8* @malloc(i32 %36)
store i8* %37, i8** %8
%38 = load i8*, i8** %8
%39 = load i32, i32* @optarg
%40 = call i8* @strcpy(i8* %38, i32 %39)
store i8* %40, i8** %8
br label %43
41: ; preds = %25
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %182
43: ; preds = %31, %28
br label %19
44: ; preds = %19
%45 = load i8, i8* %9
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 0, i32* %3
br label %182
49: ; preds = %44
%50 = load i32, i32* %7
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = load i8*, i8** %8
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %53, i32** %13
%54 = load i32*, i32** %13
%55 = call i32 @fscanf(i32* %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %10, i32* %11)
%56 = load i32, i32* %10
%57 = load i32, i32* %11
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %56, i32 %57)
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = mul i64 %60, 8
%62 = trunc i64 %61 to i32
%63 = call i8* @malloc(i32 %62)
%64 = bitcast i8* %63 to i32**
store i32** %64, i32*** %14
%65 = load i32, i32* %10
%66 = sext i32 %65 to i64
%67 = mul i64 %66, 8
%68 = trunc i64 %67 to i32
%69 = call i8* @malloc(i32 %68)
%70 = bitcast i8* %69 to i32**
store i32** %70, i32*** %15
store i32 0, i32* %16
br label %71
71: ; preds = %96, %49
%72 = load i32, i32* %16
%73 = load i32, i32* %10
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %99
75: ; preds = %71
%76 = load i32, i32* %11
%77 = sext i32 %76 to i64
%78 = mul i64 %77, 4
%79 = trunc i64 %78 to i32
%80 = call i8* @malloc(i32 %79)
%81 = bitcast i8* %80 to i32*
%82 = load i32**, i32*** %14
%83 = load i32, i32* %16
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32*, i32** %82, i64 %84
store i32* %81, i32** %85
%86 = load i32, i32* %11
%87 = sext i32 %86 to i64
%88 = mul i64 %87, 4
%89 = trunc i64 %88 to i32
%90 = call i8* @malloc(i32 %89)
%91 = bitcast i8* %90 to i32*
%92 = load i32**, i32*** %15
%93 = load i32, i32* %16
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32*, i32** %92, i64 %94
store i32* %91, i32** %95
br label %96
96: ; preds = %75
%97 = load i32, i32* %16
%98 = add nsw i32 %97, 1
store i32 %98, i32* %16
br label %71
99: ; preds = %71
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %17
br label %103
103: ; preds = %142, %99
%104 = load i32, i32* %17
%105 = load i32, i32* %10
%106 = icmp slt i32 %104, %105
br i1 %106, label %107, label %145
107: ; preds = %103
store i32 0, i32* %18
br label %108
108: ; preds = %138, %107
%109 = load i32, i32* %18
%110 = load i32, i32* %11
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %141
112: ; preds = %108
%113 = load i32*, i32** %13
%114 = call i32 @fgetc(i32* %113)
%115 = sub nsw i32 %114, 48
store i32 %115, i32* %12
br label %116
116: ; preds = %124, %112
%117 = load i32, i32* %12
%118 = icmp slt i32 %117, 0
br i1 %118, label %122, label %119
119: ; preds = %116
%120 = load i32, i32* %12
%121 = icmp sgt i32 %120, 1
br label %122
122: ; preds = %119, %116
%123 = phi i1 [ true, %116 ], [ %121, %119 ]
br i1 %123, label %124, label %128
124: ; preds = %122
%125 = load i32*, i32** %13
%126 = call i32 @fgetc(i32* %125)
%127 = sub nsw i32 %126, 48
store i32 %127, i32* %12
br label %116
128: ; preds = %122
%129 = load i32, i32* %12
%130 = load i32**, i32*** %14
%131 = load i32, i32* %17
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i32*, i32** %130, i64 %132
%134 = load i32*, i32** %133
%135 = load i32, i32* %18
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i32, i32* %134, i64 %136
store i32 %129, i32* %137
br label %138
138: ; preds = %128
%139 = load i32, i32* %18
%140 = add nsw i32 %139, 1
store i32 %140, i32* %18
br label %108
141: ; preds = %108
br label %142
142: ; preds = %141
%143 = load i32, i32* %17
%144 = add nsw i32 %143, 1
store i32 %144, i32* %17
br label %103
145: ; preds = %103
%146 = load i32**, i32*** %14
%147 = load i32, i32* %11
%148 = load i32, i32* %11
%149 = call i32 @mostraTablero(i32** %146, i32 %147, i32 %148)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.10, i64 0, i64 0))
%152 = load i32*, i32** %13
%153 = call i32 @fclose(i32* %152)
%154 = call i32 (...) @getchar()
br label %155
155: ; preds = %159, %145
%156 = load i32, i32* %6
%157 = load i32, i32* %7
%158 = icmp slt i32 %156, %157
br i1 %158, label %159, label %174
159: ; preds = %155
%160 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%162 = load i32, i32* %6
%163 = add nsw i32 %162, 1
store i32 %163, i32* %6
%164 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i32 %163)
%165 = load i32**, i32*** %14
%166 = load i32**, i32*** %15
%167 = load i32, i32* %10
%168 = load i32, i32* %11
%169 = call i32 @calcularVida(i32** %165, i32** %166, i32 %167, i32 %168)
%170 = load i32**, i32*** %14
%171 = load i32, i32* %10
%172 = load i32, i32* %11
%173 = call i32 @mostraTablero(i32** %170, i32 %171, i32 %172)
br label %155
174: ; preds = %155
%175 = load i32**, i32*** %14
%176 = load i32, i32* %10
%177 = call i32 @limpiar(i32** %175, i32 %176)
%178 = load i32**, i32*** %15
%179 = load i32, i32* %10
%180 = call i32 @limpiar(i32** %178, i32 %179)
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.14, i64 0, i64 0))
store i32 0, i32* %3
br label %182
182: ; preds = %174, %48, %41
%183 = load i32, i32* %3
ret i32 %183
}

LLVM IR (-O2):
@.str = [5 x i8] c"f:i:\00"
@optarg = global i32 0
@.str.2 = [27 x i8] c"Numero de iteraciones: %d\0A\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [23 x i8] c"Tamano x = %d y = %d\0A\00"
@.str.11 = [6 x i8] c"clear\00"
@.str.13 = [15 x i8] c"Iteracion: %d\0A\00"
@str = [35 x i8] c"Bienvenido al juego de la vida....\00"
@str.15 = [27 x i8] c"Cargando datos del tablero\00"
@str.16 = [25 x i8] c"Inicia carga del tablero\00"
@str.17 = [29 x i8] c"Tablero Cargado con exito...\00"
@str.18 = [52 x i8] c"Presione una tecla para iniciar el juego de la vida\00"
@str.19 = [17 x i8] c"Fin del programa\00"
@str.20 = [20 x i8] c"Juego de la vida...\00"
@str.21 = [24 x i8] c"Error en los argumentos\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8 %7, -1
br i1 %8, label %30, label %9
9: ; preds = %2, %25
%10 = phi i8 [ %28, %25 ], [ %7, %2 ]
%11 = phi i32 [ %27, %25 ], [ undef, %2 ]
%12 = phi i8* [ %26, %25 ], [ undef, %2 ]
%13 = sext i8 %10 to i32
switch i32 %13, label %23 [
i32 105, label %14
i32 102, label %17
]
14: ; preds = %9
%15 = load i32, i32* @optarg
%16 = tail call i32 @atoi(i32 %15)
br label %25
17: ; preds = %9
%18 = load i32, i32* @optarg
%19 = tail call i32 @strlen(i32 %18)
%20 = tail call i8* @malloc(i32 %19)
%21 = load i32, i32* @optarg
%22 = tail call i8* @strcpy(i8* %20, i32 %21)
br label %25
23: ; preds = %9
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.21, i64 0, i64 0))
br label %126
25: ; preds = %17, %14
%26 = phi i8* [ %22, %17 ], [ %12, %14 ]
%27 = phi i32 [ %11, %17 ], [ %16, %14 ]
%28 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i8 %28, -1
br i1 %29, label %30, label %9
30: ; preds = %25, %2
%31 = phi i8* [ undef, %2 ], [ %26, %25 ]
%32 = phi i32 [ undef, %2 ], [ %27, %25 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = tail call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @fscanf(i32* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %36, i32 %37)
%39 = load i32, i32* %3
%40 = shl i32 %39, 3
%41 = call i8* @malloc(i32 %40)
%42 = bitcast i8* %41 to i32**
%43 = call i8* @malloc(i32 %40)
%44 = bitcast i8* %43 to i32**
%45 = icmp sgt i32 %39, 0
br i1 %45, label %46, label %50
46: ; preds = %30
%47 = load i32, i32* %4
%48 = shl i32 %47, 2
%49 = zext i32 %39 to i64
br label %57
50: ; preds = %57, %30
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.15, i64 0, i64 0))
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%54 = load i32, i32* %3
%55 = icmp sgt i32 %54, 0
%56 = load i32, i32* %4
br i1 %55, label %67, label %74
57: ; preds = %46, %57
%58 = phi i64 [ 0, %46 ], [ %65, %57 ]
%59 = call i8* @malloc(i32 %48)
%60 = getelementptr inbounds i32*, i32** %42, i64 %58
%61 = bitcast i32** %60 to i8**
store i8* %59, i8** %61
%62 = call i8* @malloc(i32 %48)
%63 = getelementptr inbounds i32*, i32** %44, i64 %58
%64 = bitcast i32** %63 to i8**
store i8* %62, i8** %64
%65 = add nuw nsw i64 %58, 1
%66 = icmp eq i64 %65, %49
br i1 %66, label %50, label %57
67: ; preds = %50, %84
%68 = phi i32 [ %85, %84 ], [ %54, %50 ]
%69 = phi i32 [ %86, %84 ], [ %56, %50 ]
%70 = phi i64 [ %87, %84 ], [ 0, %50 ]
%71 = icmp sgt i32 %69, 0
br i1 %71, label %72, label %84
72: ; preds = %67
%73 = getelementptr inbounds i32*, i32** %42, i64 %70
br label %90
74: ; preds = %84, %50
%75 = phi i32 [ %56, %50 ], [ %86, %84 ]
%76 = call i32 @mostraTablero(i32** %42, i32 %75, i32 %75)
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.18, i64 0, i64 0))
%79 = call i32 @fclose(i32* %34)
%80 = call i32 (...) @getchar()
%81 = icmp sgt i32 %32, 0
br i1 %81, label %107, label %120
82: ; preds = %99
%83 = load i32, i32* %3
br label %84
84: ; preds = %82, %67
%85 = phi i32 [ %83, %82 ], [ %68, %67 ]
%86 = phi i32 [ %104, %82 ], [ %69, %67 ]
%87 = add nuw nsw i64 %70, 1
%88 = sext i32 %85 to i64
%89 = icmp slt i64 %87, %88
br i1 %89, label %67, label %74
90: ; preds = %72, %99
%91 = phi i64 [ 0, %72 ], [ %103, %99 ]
%92 = call i32 @fgetc(i32* %34)
%93 = add nsw i32 %92, -48
%94 = icmp ugt i32 %93, 1
br i1 %94, label %95, label %99
95: ; preds = %90, %95
%96 = call i32 @fgetc(i32* %34)
%97 = add nsw i32 %96, -48
%98 = icmp ugt i32 %97, 1
br i1 %98, label %95, label %99
99: ; preds = %95, %90
%100 = phi i32 [ %93, %90 ], [ %97, %95 ]
%101 = load i32*, i32** %73
%102 = getelementptr inbounds i32, i32* %101, i64 %91
store i32 %100, i32* %102
%103 = add nuw nsw i64 %91, 1
%104 = load i32, i32* %4
%105 = sext i32 %104 to i64
%106 = icmp slt i64 %103, %105
br i1 %106, label %90, label %82
107: ; preds = %74, %107
%108 = phi i32 [ %111, %107 ], [ 0, %74 ]
%109 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0))
%110 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.20, i64 0, i64 0))
%111 = add nuw nsw i32 %108, 1
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0), i32 %111)
%113 = load i32, i32* %3
%114 = load i32, i32* %4
%115 = call i32 @calcularVida(i32** %42, i32** %44, i32 %113, i32 %114)
%116 = load i32, i32* %3
%117 = load i32, i32* %4
%118 = call i32 @mostraTablero(i32** %42, i32 %116, i32 %117)
%119 = icmp eq i32 %111, %32
br i1 %119, label %120, label %107
120: ; preds = %107, %74
%121 = load i32, i32* %3
%122 = call i32 @limpiar(i32** %42, i32 %121)
%123 = load i32, i32* %3
%124 = call i32 @limpiar(i32** %44, i32 %123)
%125 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.19, i64 0, i64 0))
br label %126
126: ; preds = %120, %23
ret i32 0
}