#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*/ result;
typedef int /*<<< orphan*/ quit;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int WEXITSTATUS(int);
int /*<<< orphan*/ close(int);
int dup2(int, int);
int /*<<< orphan*/ execvp(char *, char **);
int fork();
int open(char const *, int, ...);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, int);
int read(int, ...);
int /*<<< orphan*/ wait(int *);
int write(int, char *, int);
int main(int argc, char const *argv[]) {
  int fdchild[2];
  int fdparent[2];
  int retopen1 = -99999;
  int retopen2 = -99999;
  int child = -99999;
  int retpipe = -99999;
  int retread = -99999;
  int retreadpipech = -9999;
  int retwritepipech = -9999;
  int retreadpipepar = -9999;
  int retwritepipepar = -9999;
  int retwriteres = -9999;
  int retdup = -9999;
  int i = 0;
  int j = 0;
  int cont = 0;
  int lines = 0;
  int auxlines = 0;
  int operations = 0;
  int status = -999;
  char mander;
  char buffer[1024];
  char result[32];
  char quit[5] = "quit\n";
  int flag = 1;
  for (j = 0; j < sizeof(buffer); j++) {
    buffer[j] = ' ';
  }
  for (j = 0; j < sizeof(result); j++) {
    result[j] = ' ';
  }
  retpipe = pipe(fdchild);
  retpipe = -99999;
  retpipe = pipe(fdparent);
  child = fork();
  if (child == 0) {
    close(fdchild[1]);
    close(fdparent[0]);
    close(1);
    close(0);
    retdup = dup2(fdchild[0], 0);
    retdup = dup2(fdparent[1], 1);
    close(fdchild[0]);
    close(fdparent[1]);
    char *args[] = {"/usr/bin/bc", NULL};
    execvp("/usr/bin/bc", args);
    perror("execve failed");
  } else {
    close(fdchild[0]);
    close(fdparent[1]);
    retopen1 = open(argv[1], O_RDONLY);
    retopen2 = open(argv[2], O_CREAT | O_RDWR | O_TRUNC, 0777);
    do {
      retread = read(retopen1, &mander, 1);
      if (mander == '\n') {
        lines++;
      }
    } while (retread != 0);
    retread = -9999;
    mander = ' ';
    close(retopen1);
    retopen1 = -9999;
    retopen1 = open(argv[1], O_RDONLY);
    do {
      retread = read(retopen1, &mander, 1);
      if (mander != '\n') {
        if (mander == '/') {
          flag = flag * -1;
        }
        if (flag == 1) {
          if (mander != '/') {
            buffer[i] = mander;
            i++;
            flag = 1;
          }
        }
      } else {
        auxlines++;
        buffer[i] = '\n';
        for (j = 0; j < i; j++) {
          if (buffer[j] == 'A') {
            if (buffer[j + 1] == 'D') {
              buffer[j] = ' ';
              buffer[j + 1] = '+';
              buffer[j + 2] = ' ';
              operations++;
            }
          } else if (buffer[j] == 'S') {
            if (buffer[j + 1] == 'U') {
              buffer[j] = ' ';
              buffer[j + 1] = '-';
              buffer[j + 2] = ' ';
              operations++;
            }
          } else if (buffer[j] == 'M') {
            if (buffer[j + 1] == 'U') {
              buffer[j] = ' ';
              buffer[j + 1] = '*';
              buffer[j + 2] = ' ';
              operations++;
            }
          } else if (buffer[j] == 'D') {
            if (buffer[j + 1] == 'I') {
              buffer[j] = ' ';
              buffer[j + 1] = '/';
              buffer[j + 2] = ' ';
              operations++;
            }
          }
        }
        if (retwritepipepar == -99999) {
          cont++;
        }
        if (auxlines == lines) {
          retwritepipepar = write(fdchild[1], quit, sizeof(quit));
        } else {
          if (buffer[0] != '\n') {
            if (cont < lines) {
              retwritepipepar = write(fdchild[1], buffer, i + 1);
              retreadpipepar = read(fdparent[0], &result, sizeof(result));
              buffer[i] = ' ';
              buffer[i + 1] = '=';
              buffer[i + 2] = ' ';
              i = i + 3;
              for (j = 0; j < sizeof(result); j++) {
                if (result[j] != '\n') {
                  buffer[i] = result[j];
                  i++;
                }
              }
              buffer[i + 1] = '\n';
              buffer[i + 2] = '\0';
              retwriteres = write(retopen2, buffer, i + 2);
              for (j = 0; j < sizeof(buffer); j++) {
                buffer[j] = ' ';
              }
              for (j = 0; j < sizeof(result); j++) {
                result[j] = ' ';
              }
            }
          }
          i = 0;
          retwritepipepar = -99999;
          retreadpipepar = -9999;
        }
      }
    } while (retread != 0);
    wait(&status);
    printf("Hay %i lineas en el fichero\n", lines - 1);
    printf("De las cuales %i son operaciones artimeticas\n", operations);
    printf("El valor de retorno del hijo es: %i\n", WEXITSTATUS(status));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xfffe7961,-0x24(%rbp)
movl   $0xfffe7961,-0x28(%rbp)
movl   $0xfffe7961,-0x2c(%rbp)
movl   $0xfffe7961,-0x30(%rbp)
movl   $0xfffe7961,-0x34(%rbp)
movl   $0xffffd8f1,-0x38(%rbp)
movl   $0xffffd8f1,-0x3c(%rbp)
movl   $0xffffd8f1,-0x40(%rbp)
movl   $0xffffd8f1,-0x44(%rbp)
movl   $0xffffd8f1,-0x48(%rbp)
movl   $0xffffd8f1,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0xfffffc19,-0x68(%rbp)
mov    0xda3(%rip),%eax
mov    %eax,-0x495(%rbp)
mov    0xd9b(%rip),%al
mov    %al,-0x491(%rbp)
movl   $0x1,-0x49c(%rbp)
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    $0x400,%rax
jae    12aa <main+0xea>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1280 <main+0xc0>
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    $0x20,%rax
jae    12d9 <main+0x119>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x490(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12b1 <main+0xf1>
lea    -0x18(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,-0x30(%rbp)
movl   $0xfffe7961,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,-0x30(%rbp)
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    139a <main+0x1da>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   1060 <close@plt>
xor    %edi,%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    0x2a8f(%rip),%rax
mov    %rax,-0x4b0(%rbp)
mov    0x2a89(%rip),%rax
mov    %rax,-0x4a8(%rbp)
lea    -0x4b0(%rbp),%rsi
lea    0xc81(%rip),%rdi
call   10c0 <execvp@plt>
lea    0xc81(%rip),%rdi
call   10b0 <perror@plt>
jmp    18fa <main+0x73a>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2c17(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2c24(%rip),%rax
mov    (%rax),%esi
mov    0x2bfb(%rip),%rax
or     (%rax),%esi
mov    0x2c0a(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x69(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x34(%rbp)
movsbl -0x69(%rbp),%eax
cmp    $0xa,%eax
jne    1423 <main+0x263>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1428 <main+0x268>
cmpl   $0x0,-0x34(%rbp)
jne    13f7 <main+0x237>
movl   $0xffffd8f1,-0x34(%rbp)
movb   $0x20,-0x69(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
movl   $0xffffd8f1,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2b75(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x69(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x34(%rbp)
movsbl -0x69(%rbp),%eax
cmp    $0xa,%eax
je     14e9 <main+0x329>
movsbl -0x69(%rbp),%eax
cmp    $0x2f,%eax
jne    14a4 <main+0x2e4>
imul   $0xffffffff,-0x49c(%rbp),%eax
mov    %eax,-0x49c(%rbp)
cmpl   $0x1,-0x49c(%rbp)
jne    14e4 <main+0x324>
movsbl -0x69(%rbp),%eax
cmp    $0x2f,%eax
je     14df <main+0x31f>
mov    -0x69(%rbp),%cl
movslq -0x50(%rbp),%rax
mov    %cl,-0x470(%rbp,%rax,1)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
movl   $0x1,-0x49c(%rbp)
jmp    14e4 <main+0x324>
jmp    18ab <main+0x6eb>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
movslq -0x50(%rbp),%rax
movb   $0xa,-0x470(%rbp,%rax,1)
0a
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x50(%rbp),%eax
jge    16d3 <main+0x513>
movslq -0x54(%rbp),%rax
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x41,%eax
jne    1579 <main+0x3b9>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x44,%eax
jne    1574 <main+0x3b4>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x2b,-0x470(%rbp,%rax,1)
2b
mov    -0x54(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    16c0 <main+0x500>
movslq -0x54(%rbp),%rax
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x53,%eax
jne    15e1 <main+0x421>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x55,%eax
jne    15dc <main+0x41c>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x2d,-0x470(%rbp,%rax,1)
2d
mov    -0x54(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    16bb <main+0x4fb>
movslq -0x54(%rbp),%rax
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x4d,%eax
jne    1649 <main+0x489>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x55,%eax
jne    1644 <main+0x484>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x2a,-0x470(%rbp,%rax,1)
2a
mov    -0x54(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    16b6 <main+0x4f6>
movslq -0x54(%rbp),%rax
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x44,%eax
jne    16b1 <main+0x4f1>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x470(%rbp,%rax,1),%eax
ff
cmp    $0x49,%eax
jne    16ac <main+0x4ec>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x2f,-0x470(%rbp,%rax,1)
2f
mov    -0x54(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    16b1 <main+0x4f1>
jmp    16b6 <main+0x4f6>
jmp    16bb <main+0x4fb>
jmp    16c0 <main+0x500>
jmp    16c5 <main+0x505>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1505 <main+0x345>
cmpl   $0xfffe7961,-0x44(%rbp)
jne    16e9 <main+0x529>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jne    1711 <main+0x551>
mov    -0x14(%rbp),%edi
lea    -0x495(%rbp),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    %eax,-0x44(%rbp)
jmp    18a6 <main+0x6e6>
movsbl -0x470(%rbp),%eax
cmp    $0xa,%eax
je     1891 <main+0x6d1>
mov    -0x58(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jge    188c <main+0x6cc>
mov    -0x14(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    -0x50(%rbp),%edx
add    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x490(%rbp),%rsi
mov    $0x20,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    %eax,-0x40(%rbp)
movslq -0x50(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x50(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x3d,-0x470(%rbp,%rax,1)
3d
mov    -0x50(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x50(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    $0x20,%rax
jae    17ef <main+0x62f>
movslq -0x54(%rbp),%rax
movsbl -0x490(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     17dc <main+0x61c>
movslq -0x54(%rbp),%rax
mov    -0x490(%rbp,%rax,1),%cl
movslq -0x50(%rbp),%rax
mov    %cl,-0x470(%rbp,%rax,1)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    17e1 <main+0x621>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    179a <main+0x5da>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0xa,-0x470(%rbp,%rax,1)
0a
mov    -0x50(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x0,-0x470(%rbp,%rax,1)
mov    -0x28(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    -0x50(%rbp),%edx
add    $0x2,%edx
call   1030 <write@plt>
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    $0x400,%rax
jae    1858 <main+0x698>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x470(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    182e <main+0x66e>
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    $0x20,%rax
jae    1887 <main+0x6c7>
movslq -0x54(%rbp),%rax
movb   $0x20,-0x490(%rbp,%rax,1)
20
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    185f <main+0x69f>
jmp    188c <main+0x6cc>
jmp    1891 <main+0x6d1>
movl   $0x0,-0x50(%rbp)
movl   $0xfffe7961,-0x44(%rbp)
movl   $0xffffd8f1,-0x40(%rbp)
jmp    18ab <main+0x6eb>
jmp    18b0 <main+0x6f0>
cmpl   $0x0,-0x34(%rbp)
jne    1467 <main+0x2a7>
lea    -0x68(%rbp),%rdi
call   10d0 <wait@plt>
mov    -0x5c(%rbp),%esi
sub    $0x1,%esi
lea    0x74f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x64(%rbp),%esi
lea    0x75d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x68(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0x775(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x478,%rsp
mov    %rsi,%r14
movl   $0xfffffc19,0x24(%rsp)
ff
movb   $0xa,0x34(%rsp)
movl   $0x74697571,0x30(%rsp)
74
lea    0x70(%rsp),%rdi
mov    $0x400,%edx
mov    $0x20,%esi
call   1060 <memset@plt>
movaps 0xdec(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
lea    0x18(%rsp),%rdi
call   1080 <pipe@plt>
lea    0x28(%rsp),%rdi
call   1080 <pipe@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     15ea <main+0x41a>
mov    0x18(%rsp),%edi
call   1070 <close@plt>
mov    0x2c(%rsp),%edi
call   1070 <close@plt>
mov    0x8(%r14),%rdi
mov    0x2d72(%rip),%r12
mov    (%r12),%esi
xor    %eax,%eax
call   10b0 <open@plt>
mov    %eax,%ebx
mov    0x2d86(%rip),%rax
mov    0x2d5f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%r14),%rdi
mov    0x2d68(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
xor    %eax,%eax
call   10b0 <open@plt>
mov    %eax,0x38(%rsp)
lea    0x40(%rsp),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1090 <read@plt>
xor    %ecx,%ecx
cmpb   $0xa,0x40(%rsp)
sete   %cl
add    %ecx,%ebp
test   %eax,%eax
jne    12b0 <main+0xe0>
movb   $0x20,0x40(%rsp)
mov    %ebx,%edi
call   1070 <close@plt>
mov    0x8(%r14),%rdi
mov    (%r12),%esi
xor    %eax,%eax
call   10b0 <open@plt>
mov    %eax,%r12d
mov    $0x1,%ecx
movl   $0xffffd8f1,0x10(%rsp)
ff
lea    0xd0d(%rip),%r13
xor    %r14d,%r14d
movl   $0x0,0x20(%rsp)
movl   $0x0,0x14(%rsp)
xor    %ebx,%ebx
mov    %eax,0xc(%rsp)
jmp    132d <main+0x15d>
xchg   %ax,%ax
mov    %r15d,%ecx
neg    %ecx
test   %esi,%esi
je     1596 <main+0x3c6>
mov    %ecx,%r15d
mov    %r12d,%edi
lea    0x40(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1090 <read@plt>
mov    %eax,%esi
mov    0x40(%rsp),%al
cmp    $0xa,%al
je     1370 <main+0x1a0>
cmp    $0x2f,%al
je     1320 <main+0x150>
cmp    $0x1,%r15d
jne    148d <main+0x2bd>
movslq %r14d,%rcx
mov    %al,0x70(%rsp,%rcx,1)
add    $0x1,%r14d
mov    $0x1,%ecx
jmp    1325 <main+0x155>
xchg   %ax,%ax
addl   $0x1,0x14(%rsp)
movslq %r14d,%r12
movb   $0xa,0x70(%rsp,%r12,1)
test   %r12d,%r12d
jle    1450 <main+0x280>
mov    %r14d,%eax
xor    %edx,%edx
jmp    13a4 <main+0x1d4>
xchg   %ax,%ax
movb   $0x20,0x72(%rsp,%rdx,1)
add    $0x1,%ebx
mov    %rcx,%rdx
cmp    %rax,%rcx
je     1450 <main+0x280>
movzbl 0x70(%rsp,%rdx,1),%ecx
add    $0xbf,%cl
cmp    $0x12,%cl
ja     13e0 <main+0x210>
movzbl %cl,%ecx
movslq 0x0(%r13,%rcx,4),%rcx
add    %r13,%rcx
jmp    *%rcx
lea    0x1(%rdx),%rcx
cmpb   $0x44,0x71(%rsp,%rdx,1)
jne    1398 <main+0x1c8>
movw   $0x2b20,0x70(%rsp,%rdx,1)
jmp    1390 <main+0x1c0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rdx
mov    %rdx,%rcx
jmp    1398 <main+0x1c8>
nopl   0x0(%rax)
lea    0x1(%rdx),%rcx
cmpb   $0x49,0x71(%rsp,%rdx,1)
jne    1398 <main+0x1c8>
movw   $0x2f20,0x70(%rsp,%rdx,1)
jmp    1390 <main+0x1c0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rdx),%rcx
cmpb   $0x55,0x71(%rsp,%rdx,1)
jne    1398 <main+0x1c8>
movw   $0x2a20,0x70(%rsp,%rdx,1)
jmp    1390 <main+0x1c0>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rdx),%rcx
cmpb   $0x55,0x71(%rsp,%rdx,1)
jne    1398 <main+0x1c8>
movw   $0x2d20,0x70(%rsp,%rdx,1)
jmp    1390 <main+0x1c0>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
cmpl   $0xfffe7961,0x10(%rsp)
ff
sete   %al
add    %eax,0x20(%rsp)
cmp    %ebp,0x14(%rsp)
jne    1495 <main+0x2c5>
mov    0x1c(%rsp),%edi
mov    %esi,%r12d
lea    0x30(%rsp),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    %r12d,%esi
mov    %eax,0x10(%rsp)
mov    %ebp,0x14(%rsp)
mov    0xc(%rsp),%r12d
mov    %r15d,%ecx
jmp    1325 <main+0x155>
cmpb   $0xa,0x70(%rsp)
movl   $0xfffe7961,0x10(%rsp)
ff
mov    %r15d,%ecx
je     1538 <main+0x368>
cmp    %ebp,0x20(%rsp)
jge    1538 <main+0x368>
mov    %esi,0x3c(%rsp)
mov    0x1c(%rsp),%edi
lea    0x1(%r12),%rdx
lea    0x70(%rsp),%rsi
call   1030 <write@plt>
mov    0x28(%rsp),%edi
mov    $0x20,%edx
lea    0x50(%rsp),%rsi
xor    %eax,%eax
call   1090 <read@plt>
movb   $0x20,0x70(%rsp,%r12,1)
movw   $0x203d,0x71(%rsp,%r12,1)
20
add    $0x3,%r14d
xor    %eax,%eax
mov    0xc(%rsp),%r12d
jmp    150a <main+0x33a>
nopl   0x0(%rax)
add    $0x2,%rax
cmp    $0x20,%rax
je     1545 <main+0x375>
movzbl 0x50(%rsp,%rax,1),%ecx
cmp    $0xa,%cl
je     1520 <main+0x350>
movslq %r14d,%r14
mov    %cl,0x70(%rsp,%r14,1)
add    $0x1,%r14d
movzbl 0x51(%rsp,%rax,1),%ecx
cmp    $0xa,%cl
je     1500 <main+0x330>
movslq %r14d,%r14
mov    %cl,0x70(%rsp,%r14,1)
add    $0x1,%r14d
jmp    1500 <main+0x330>
xor    %r14d,%r14d
mov    0xc(%rsp),%r12d
jmp    1325 <main+0x155>
movslq %r14d,%rdx
lea    0x70(%rsp),%r14
movw   $0xa,0x1(%rdx,%r14,1)
add    $0x2,%edx
mov    0x38(%rsp),%edi
mov    %r14,%rsi
call   1030 <write@plt>
mov    $0x400,%edx
mov    %r14,%rdi
mov    $0x20,%esi
call   1060 <memset@plt>
movaps 0xa83(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
xor    %r14d,%r14d
mov    %r15d,%ecx
mov    0x3c(%rsp),%esi
jmp    1325 <main+0x155>
lea    0x24(%rsp),%rdi
call   10e0 <wait@plt>
add    $0xffffffff,%ebp
lea    0xad1(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
lea    0xae0(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    0x24(%rsp),%edi
call   10a0 <WEXITSTATUS@plt>
lea    0xaf7(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x478,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x1c(%rsp),%edi
call   1070 <close@plt>
mov    0x28(%rsp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   1070 <close@plt>
xor    %edi,%edi
call   1070 <close@plt>
mov    0x18(%rsp),%edi
xor    %esi,%esi
call   1040 <dup2@plt>
mov    0x2c(%rsp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    0x18(%rsp),%edi
call   1070 <close@plt>
mov    0x2c(%rsp),%edi
call   1070 <close@plt>
movaps 0x27b1(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
lea    0xa16(%rip),%rdi
lea    0x40(%rsp),%rsi
call   10d0 <execvp@plt>
lea    0xa11(%rip),%rdi
call   10c0 <perror@plt>
jmp    15d6 <main+0x406>

LLVM IR (-O0):
@__const.main.quit = [5 x i8] c"quit\0A"
@.str = [12 x i8] c"/usr/bin/bc\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [14 x i8] c"execve failed\00"
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [29 x i8] c"Hay %i lineas en el fichero\0A\00"
@.str.3 = [46 x i8] c"De las cuales %i son operaciones artimeticas\0A\00"
@.str.4 = [37 x i8] c"El valor de retorno del hijo es: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i32
%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
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i8
%27 = alloca [1024 x i8]
%28 = alloca [32 x i8]
%29 = alloca [5 x i8]
%30 = alloca i32
%31 = alloca [2 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -99999, i32* %8
store i32 -99999, i32* %9
store i32 -99999, i32* %10
store i32 -99999, i32* %11
store i32 -99999, i32* %12
store i32 -9999, i32* %13
store i32 -9999, i32* %14
store i32 -9999, i32* %15
store i32 -9999, i32* %16
store i32 -9999, i32* %17
store i32 -9999, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
store i32 0, i32* %24
store i32 -999, i32* %25
%32 = bitcast [5 x i8]* %29 to i8*
store i32 1, i32* %30
store i32 0, i32* %20
br label %33
33: ; preds = %41, %2
%34 = load i32, i32* %20
%35 = sext i32 %34 to i64
%36 = icmp ult i64 %35, 1024
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i32, i32* %20
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %39
store i8 32, i8* %40
br label %41
41: ; preds = %37
%42 = load i32, i32* %20
%43 = add nsw i32 %42, 1
store i32 %43, i32* %20
br label %33
44: ; preds = %33
store i32 0, i32* %20
br label %45
45: ; preds = %53, %44
%46 = load i32, i32* %20
%47 = sext i32 %46 to i64
%48 = icmp ult i64 %47, 32
br i1 %48, label %49, label %56
49: ; preds = %45
%50 = load i32, i32* %20
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [32 x i8], [32 x i8]* %28, i64 0, i64 %51
store i8 32, i8* %52
br label %53
53: ; preds = %49
%54 = load i32, i32* %20
%55 = add nsw i32 %54, 1
store i32 %55, i32* %20
br label %45
56: ; preds = %45
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%58 = call i32 @pipe(i32* %57)
store i32 %58, i32* %11
store i32 -99999, i32* %11
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%60 = call i32 @pipe(i32* %59)
store i32 %60, i32* %11
%61 = call i32 (...) @fork()
store i32 %61, i32* %10
%62 = load i32, i32* %10
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %89
64: ; preds = %56
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%66 = load i32, i32* %65
%67 = call i32 @close(i32 %66)
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = call i32 @close(i32 1)
%72 = call i32 @close(i32 0)
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%74 = load i32, i32* %73
%75 = call i32 @dup2(i32 %74, i32 0)
store i32 %75, i32* %18
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%77 = load i32, i32* %76
%78 = call i32 @dup2(i32 %77, i32 1)
store i32 %78, i32* %18
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
%85 = bitcast [2 x i8*]* %31 to i8*
%86 = getelementptr inbounds [2 x i8*], [2 x i8*]* %31, i64 0, i64 0
%87 = call i32 @execvp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %86)
%88 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %424
89: ; preds = %56
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%91 = load i32, i32* %90
%92 = call i32 @close(i32 %91)
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%94 = load i32, i32* %93
%95 = call i32 @close(i32 %94)
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 1
%98 = load i8*, i8** %97
%99 = load i32, i32* @O_RDONLY
%100 = call i32 (i8*, i32, ...) @open(i8* %98, i32 %99)
store i32 %100, i32* %8
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 2
%103 = load i8*, i8** %102
%104 = load i32, i32* @O_CREAT
%105 = load i32, i32* @O_RDWR
%106 = or i32 %104, %105
%107 = load i32, i32* @O_TRUNC
%108 = or i32 %106, %107
%109 = call i32 (i8*, i32, ...) @open(i8* %103, i32 %108, i32 511)
store i32 %109, i32* %9
br label %110
110: ; preds = %120, %89
%111 = load i32, i32* %8
%112 = call i32 (i32, ...) @read(i32 %111, i8* %26, i32 1)
store i32 %112, i32* %12
%113 = load i8, i8* %26
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 10
br i1 %115, label %116, label %119
116: ; preds = %110
%117 = load i32, i32* %22
%118 = add nsw i32 %117, 1
store i32 %118, i32* %22
br label %119
119: ; preds = %116, %110
br label %120
120: ; preds = %119
%121 = load i32, i32* %12
%122 = icmp ne i32 %121, 0
br i1 %122, label %110, label %123
123: ; preds = %120
store i32 -9999, i32* %12
store i8 32, i8* %26
%124 = load i32, i32* %8
%125 = call i32 @close(i32 %124)
store i32 -9999, i32* %8
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 1
%128 = load i8*, i8** %127
%129 = load i32, i32* @O_RDONLY
%130 = call i32 (i8*, i32, ...) @open(i8* %128, i32 %129)
store i32 %130, i32* %8
br label %131
131: ; preds = %411, %123
%132 = load i32, i32* %8
%133 = call i32 (i32, ...) @read(i32 %132, i8* %26, i32 1)
store i32 %133, i32* %12
%134 = load i8, i8* %26
%135 = sext i8 %134 to i32
%136 = icmp ne i32 %135, 10
br i1 %136, label %137, label %160
137: ; preds = %131
%138 = load i8, i8* %26
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 47
br i1 %140, label %141, label %144
141: ; preds = %137
%142 = load i32, i32* %30
%143 = mul nsw i32 %142, -1
store i32 %143, i32* %30
br label %144
144: ; preds = %141, %137
%145 = load i32, i32* %30
%146 = icmp eq i32 %145, 1
br i1 %146, label %147, label %159
147: ; preds = %144
%148 = load i8, i8* %26
%149 = sext i8 %148 to i32
%150 = icmp ne i32 %149, 47
br i1 %150, label %151, label %158
151: ; preds = %147
%152 = load i8, i8* %26
%153 = load i32, i32* %19
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %154
store i8 %152, i8* %155
%156 = load i32, i32* %19
%157 = add nsw i32 %156, 1
store i32 %157, i32* %19
store i32 1, i32* %30
br label %158
158: ; preds = %151, %147
br label %159
159: ; preds = %158, %144
br label %410
160: ; preds = %131
%161 = load i32, i32* %23
%162 = add nsw i32 %161, 1
store i32 %162, i32* %23
%163 = load i32, i32* %19
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %164
store i8 10, i8* %165
store i32 0, i32* %20
br label %166
166: ; preds = %294, %160
%167 = load i32, i32* %20
%168 = load i32, i32* %19
%169 = icmp slt i32 %167, %168
br i1 %169, label %170, label %297
170: ; preds = %166
%171 = load i32, i32* %20
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %172
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = icmp eq i32 %175, 65
br i1 %176, label %177, label %200
177: ; preds = %170
%178 = load i32, i32* %20
%179 = add nsw i32 %178, 1
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %180
%182 = load i8, i8* %181
%183 = sext i8 %182 to i32
%184 = icmp eq i32 %183, 68
br i1 %184, label %185, label %199
185: ; preds = %177
%186 = load i32, i32* %20
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %187
store i8 32, i8* %188
%189 = load i32, i32* %20
%190 = add nsw i32 %189, 1
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %191
store i8 43, i8* %192
%193 = load i32, i32* %20
%194 = add nsw i32 %193, 2
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %195
store i8 32, i8* %196
%197 = load i32, i32* %24
%198 = add nsw i32 %197, 1
store i32 %198, i32* %24
br label %199
199: ; preds = %185, %177
br label %293
200: ; preds = %170
%201 = load i32, i32* %20
%202 = sext i32 %201 to i64
%203 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %202
%204 = load i8, i8* %203
%205 = sext i8 %204 to i32
%206 = icmp eq i32 %205, 83
br i1 %206, label %207, label %230
207: ; preds = %200
%208 = load i32, i32* %20
%209 = add nsw i32 %208, 1
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %210
%212 = load i8, i8* %211
%213 = sext i8 %212 to i32
%214 = icmp eq i32 %213, 85
br i1 %214, label %215, label %229
215: ; preds = %207
%216 = load i32, i32* %20
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %217
store i8 32, i8* %218
%219 = load i32, i32* %20
%220 = add nsw i32 %219, 1
%221 = sext i32 %220 to i64
%222 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %221
store i8 45, i8* %222
%223 = load i32, i32* %20
%224 = add nsw i32 %223, 2
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %225
store i8 32, i8* %226
%227 = load i32, i32* %24
%228 = add nsw i32 %227, 1
store i32 %228, i32* %24
br label %229
229: ; preds = %215, %207
br label %292
230: ; preds = %200
%231 = load i32, i32* %20
%232 = sext i32 %231 to i64
%233 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %232
%234 = load i8, i8* %233
%235 = sext i8 %234 to i32
%236 = icmp eq i32 %235, 77
br i1 %236, label %237, label %260
237: ; preds = %230
%238 = load i32, i32* %20
%239 = add nsw i32 %238, 1
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %240
%242 = load i8, i8* %241
%243 = sext i8 %242 to i32
%244 = icmp eq i32 %243, 85
br i1 %244, label %245, label %259
245: ; preds = %237
%246 = load i32, i32* %20
%247 = sext i32 %246 to i64
%248 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %247
store i8 32, i8* %248
%249 = load i32, i32* %20
%250 = add nsw i32 %249, 1
%251 = sext i32 %250 to i64
%252 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %251
store i8 42, i8* %252
%253 = load i32, i32* %20
%254 = add nsw i32 %253, 2
%255 = sext i32 %254 to i64
%256 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %255
store i8 32, i8* %256
%257 = load i32, i32* %24
%258 = add nsw i32 %257, 1
store i32 %258, i32* %24
br label %259
259: ; preds = %245, %237
br label %291
260: ; preds = %230
%261 = load i32, i32* %20
%262 = sext i32 %261 to i64
%263 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %262
%264 = load i8, i8* %263
%265 = sext i8 %264 to i32
%266 = icmp eq i32 %265, 68
br i1 %266, label %267, label %290
267: ; preds = %260
%268 = load i32, i32* %20
%269 = add nsw i32 %268, 1
%270 = sext i32 %269 to i64
%271 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %270
%272 = load i8, i8* %271
%273 = sext i8 %272 to i32
%274 = icmp eq i32 %273, 73
br i1 %274, label %275, label %289
275: ; preds = %267
%276 = load i32, i32* %20
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %277
store i8 32, i8* %278
%279 = load i32, i32* %20
%280 = add nsw i32 %279, 1
%281 = sext i32 %280 to i64
%282 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %281
store i8 47, i8* %282
%283 = load i32, i32* %20
%284 = add nsw i32 %283, 2
%285 = sext i32 %284 to i64
%286 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %285
store i8 32, i8* %286
%287 = load i32, i32* %24
%288 = add nsw i32 %287, 1
store i32 %288, i32* %24
br label %289
289: ; preds = %275, %267
br label %290
290: ; preds = %289, %260
br label %291
291: ; preds = %290, %259
br label %292
292: ; preds = %291, %229
br label %293
293: ; preds = %292, %199
br label %294
294: ; preds = %293
%295 = load i32, i32* %20
%296 = add nsw i32 %295, 1
store i32 %296, i32* %20
br label %166
297: ; preds = %166
%298 = load i32, i32* %16
%299 = icmp eq i32 %298, -99999
br i1 %299, label %300, label %303
300: ; preds = %297
%301 = load i32, i32* %21
%302 = add nsw i32 %301, 1
store i32 %302, i32* %21
br label %303
303: ; preds = %300, %297
%304 = load i32, i32* %23
%305 = load i32, i32* %22
%306 = icmp eq i32 %304, %305
br i1 %306, label %307, label %312
307: ; preds = %303
%308 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%309 = load i32, i32* %308
%310 = getelementptr inbounds [5 x i8], [5 x i8]* %29, i64 0, i64 0
%311 = call i32 @write(i32 %309, i8* %310, i32 5)
store i32 %311, i32* %16
br label %409
312: ; preds = %303
%313 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 0
%314 = load i8, i8* %313
%315 = sext i8 %314 to i32
%316 = icmp ne i32 %315, 10
br i1 %316, label %317, label %408
317: ; preds = %312
%318 = load i32, i32* %21
%319 = load i32, i32* %22
%320 = icmp slt i32 %318, %319
br i1 %320, label %321, label %407
321: ; preds = %317
%322 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%323 = load i32, i32* %322
%324 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 0
%325 = load i32, i32* %19
%326 = add nsw i32 %325, 1
%327 = call i32 @write(i32 %323, i8* %324, i32 %326)
store i32 %327, i32* %16
%328 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%329 = load i32, i32* %328
%330 = call i32 (i32, ...) @read(i32 %329, [32 x i8]* %28, i64 32)
store i32 %330, i32* %15
%331 = load i32, i32* %19
%332 = sext i32 %331 to i64
%333 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %332
store i8 32, i8* %333
%334 = load i32, i32* %19
%335 = add nsw i32 %334, 1
%336 = sext i32 %335 to i64
%337 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %336
store i8 61, i8* %337
%338 = load i32, i32* %19
%339 = add nsw i32 %338, 2
%340 = sext i32 %339 to i64
%341 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %340
store i8 32, i8* %341
%342 = load i32, i32* %19
%343 = add nsw i32 %342, 3
store i32 %343, i32* %19
store i32 0, i32* %20
br label %344
344: ; preds = %366, %321
%345 = load i32, i32* %20
%346 = sext i32 %345 to i64
%347 = icmp ult i64 %346, 32
br i1 %347, label %348, label %369
348: ; preds = %344
%349 = load i32, i32* %20
%350 = sext i32 %349 to i64
%351 = getelementptr inbounds [32 x i8], [32 x i8]* %28, i64 0, i64 %350
%352 = load i8, i8* %351
%353 = sext i8 %352 to i32
%354 = icmp ne i32 %353, 10
br i1 %354, label %355, label %365
355: ; preds = %348
%356 = load i32, i32* %20
%357 = sext i32 %356 to i64
%358 = getelementptr inbounds [32 x i8], [32 x i8]* %28, i64 0, i64 %357
%359 = load i8, i8* %358
%360 = load i32, i32* %19
%361 = sext i32 %360 to i64
%362 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %361
store i8 %359, i8* %362
%363 = load i32, i32* %19
%364 = add nsw i32 %363, 1
store i32 %364, i32* %19
br label %365
365: ; preds = %355, %348
br label %366
366: ; preds = %365
%367 = load i32, i32* %20
%368 = add nsw i32 %367, 1
store i32 %368, i32* %20
br label %344
369: ; preds = %344
%370 = load i32, i32* %19
%371 = add nsw i32 %370, 1
%372 = sext i32 %371 to i64
%373 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %372
store i8 10, i8* %373
%374 = load i32, i32* %19
%375 = add nsw i32 %374, 2
%376 = sext i32 %375 to i64
%377 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %376
store i8 0, i8* %377
%378 = load i32, i32* %9
%379 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 0
%380 = load i32, i32* %19
%381 = add nsw i32 %380, 2
%382 = call i32 @write(i32 %378, i8* %379, i32 %381)
store i32 %382, i32* %17
store i32 0, i32* %20
br label %383
383: ; preds = %391, %369
%384 = load i32, i32* %20
%385 = sext i32 %384 to i64
%386 = icmp ult i64 %385, 1024
br i1 %386, label %387, label %394
387: ; preds = %383
%388 = load i32, i32* %20
%389 = sext i32 %388 to i64
%390 = getelementptr inbounds [1024 x i8], [1024 x i8]* %27, i64 0, i64 %389
store i8 32, i8* %390
br label %391
391: ; preds = %387
%392 = load i32, i32* %20
%393 = add nsw i32 %392, 1
store i32 %393, i32* %20
br label %383
394: ; preds = %383
store i32 0, i32* %20
br label %395
395: ; preds = %403, %394
%396 = load i32, i32* %20
%397 = sext i32 %396 to i64
%398 = icmp ult i64 %397, 32
br i1 %398, label %399, label %406
399: ; preds = %395
%400 = load i32, i32* %20
%401 = sext i32 %400 to i64
%402 = getelementptr inbounds [32 x i8], [32 x i8]* %28, i64 0, i64 %401
store i8 32, i8* %402
br label %403
403: ; preds = %399
%404 = load i32, i32* %20
%405 = add nsw i32 %404, 1
store i32 %405, i32* %20
br label %395
406: ; preds = %395
br label %407
407: ; preds = %406, %317
br label %408
408: ; preds = %407, %312
store i32 0, i32* %19
store i32 -99999, i32* %16
store i32 -9999, i32* %15
br label %409
409: ; preds = %408, %307
br label %410
410: ; preds = %409, %159
br label %411
411: ; preds = %410
%412 = load i32, i32* %12
%413 = icmp ne i32 %412, 0
br i1 %413, label %131, label %414
414: ; preds = %411
%415 = call i32 @wait(i32* %25)
%416 = load i32, i32* %22
%417 = sub nsw i32 %416, 1
%418 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %417)
%419 = load i32, i32* %24
%420 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %419)
%421 = load i32, i32* %25
%422 = call i32 @WEXITSTATUS(i32 %421)
%423 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %422)
br label %424
424: ; preds = %414, %64
ret i32 0
}

LLVM IR (-O2):
@__const.main.quit = [5 x i8] c"quit\0A"
@.str = [12 x i8] c"/usr/bin/bc\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [14 x i8] c"execve failed\00"
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@.str.2 = [29 x i8] c"Hay %i lineas en el fichero\0A\00"
@.str.3 = [46 x i8] c"De las cuales %i son operaciones artimeticas\0A\00"
@.str.4 = [37 x i8] c"El valor de retorno del hijo es: %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca i8
%7 = alloca [1024 x i8]
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%9 = alloca [32 x i8]
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%11 = alloca [5 x i8]
%12 = alloca [2 x i8*]
%13 = bitcast [2 x i32]* %3 to i8*
%14 = bitcast [2 x i32]* %4 to i8*
%15 = bitcast i32* %5 to i8*
store i32 -999, i32* %5
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %11, i64 0, i64 0
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%20 = call i32 @pipe(i32* %19)
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%22 = call i32 @pipe(i32* %21)
%23 = call i32 (...) @fork()
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %46
25: ; preds = %2
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %21
%30 = call i32 @close(i32 %29)
%31 = call i32 @close(i32 1)
%32 = call i32 @close(i32 0)
%33 = load i32, i32* %19
%34 = call i32 @dup2(i32 %33, i32 0)
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%36 = load i32, i32* %35
%37 = call i32 @dup2(i32 %36, i32 1)
%38 = load i32, i32* %19
%39 = call i32 @close(i32 %38)
%40 = load i32, i32* %35
%41 = call i32 @close(i32 %40)
%42 = bitcast [2 x i8*]* %12 to i8*
%43 = getelementptr inbounds [2 x i8*], [2 x i8*]* %12, i64 0, i64 0
%44 = call i32 @execvp(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %43)
%45 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %223
46: ; preds = %2
%47 = load i32, i32* %19
%48 = call i32 @close(i32 %47)
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%50 = load i32, i32* %49
%51 = call i32 @close(i32 %50)
%52 = getelementptr inbounds i8*, i8** %1, i64 1
%53 = load i8*, i8** %52
%54 = load i32, i32* @O_RDONLY
%55 = call i32 (i8*, i32, ...) @open(i8* %53, i32 %54)
%56 = getelementptr inbounds i8*, i8** %1, i64 2
%57 = load i8*, i8** %56
%58 = load i32, i32* @O_CREAT
%59 = load i32, i32* @O_RDWR
%60 = or i32 %59, %58
%61 = load i32, i32* @O_TRUNC
%62 = or i32 %60, %61
%63 = call i32 (i8*, i32, ...) @open(i8* %57, i32 %62, i32 511)
br label %64
64: ; preds = %64, %46
%65 = phi i32 [ 0, %46 ], [ %70, %64 ]
%66 = call i32 (i32, ...) @read(i32 %55, i8* %6, i32 1)
%67 = load i8, i8* %6
%68 = icmp eq i8 %67, 10
%69 = zext i1 %68 to i32
%70 = add nuw nsw i32 %65, %69
%71 = icmp eq i32 %66, 0
br i1 %71, label %72, label %64
72: ; preds = %64
store i8 32, i8* %6
%73 = call i32 @close(i32 %55)
%74 = load i8*, i8** %52
%75 = load i32, i32* @O_RDONLY
%76 = call i32 (i8*, i32, ...) @open(i8* %74, i32 %75)
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %78
78: ; preds = %207, %72
%79 = phi i32 [ -9999, %72 ], [ %208, %207 ]
%80 = phi i32 [ 0, %72 ], [ %209, %207 ]
%81 = phi i32 [ 0, %72 ], [ %210, %207 ]
%82 = phi i32 [ 0, %72 ], [ %211, %207 ]
%83 = phi i32 [ 0, %72 ], [ %212, %207 ]
%84 = phi i32 [ 1, %72 ], [ %213, %207 ]
%85 = call i32 (i32, ...) @read(i32 %76, i8* %6, i32 1)
%86 = load i8, i8* %6
switch i8 %86, label %89 [
i8 10, label %95
i8 47, label %87
]
87: ; preds = %78
%88 = sub nsw i32 0, %84
br label %207
89: ; preds = %78
%90 = icmp eq i32 %84, 1
br i1 %90, label %91, label %207
91: ; preds = %89
%92 = sext i32 %80 to i64
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %92
store i8 %86, i8* %93
%94 = add nsw i32 %80, 1
br label %207
95: ; preds = %78
%96 = add nsw i32 %82, 1
%97 = sext i32 %80 to i64
%98 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %97
store i8 10, i8* %98
%99 = icmp sgt i32 %80, 0
br i1 %99, label %100, label %149
100: ; preds = %95
%101 = zext i32 %80 to i64
br label %102
102: ; preds = %100, %145
%103 = phi i64 [ 0, %100 ], [ %146, %145 ]
%104 = phi i32 [ %83, %100 ], [ %147, %145 ]
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %103
%106 = load i8, i8* %105
switch i8 %106, label %107 [
i8 65, label %109
i8 83, label %118
i8 77, label %127
i8 68, label %136
]
107: ; preds = %102
%108 = add nuw nsw i64 %103, 1
br label %145
109: ; preds = %102
%110 = add nuw nsw i64 %103, 1
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %110
%112 = load i8, i8* %111
%113 = icmp eq i8 %112, 68
br i1 %113, label %114, label %145
114: ; preds = %109
store i8 32, i8* %105
store i8 43, i8* %111
%115 = add nuw nsw i64 %103, 2
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %115
store i8 32, i8* %116
%117 = add nsw i32 %104, 1
br label %145
118: ; preds = %102
%119 = add nuw nsw i64 %103, 1
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %119
%121 = load i8, i8* %120
%122 = icmp eq i8 %121, 85
br i1 %122, label %123, label %145
123: ; preds = %118
store i8 32, i8* %105
store i8 45, i8* %120
%124 = add nuw nsw i64 %103, 2
%125 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %124
store i8 32, i8* %125
%126 = add nsw i32 %104, 1
br label %145
127: ; preds = %102
%128 = add nuw nsw i64 %103, 1
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %128
%130 = load i8, i8* %129
%131 = icmp eq i8 %130, 85
br i1 %131, label %132, label %145
132: ; preds = %127
store i8 32, i8* %105
store i8 42, i8* %129
%133 = add nuw nsw i64 %103, 2
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %133
store i8 32, i8* %134
%135 = add nsw i32 %104, 1
br label %145
136: ; preds = %102
%137 = add nuw nsw i64 %103, 1
%138 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %137
%139 = load i8, i8* %138
%140 = icmp eq i8 %139, 73
br i1 %140, label %141, label %145
141: ; preds = %136
store i8 32, i8* %105
store i8 47, i8* %138
%142 = add nuw nsw i64 %103, 2
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %142
store i8 32, i8* %143
%144 = add nsw i32 %104, 1
br label %145
145: ; preds = %107, %114, %109, %132, %127, %136, %141, %118, %123
%146 = phi i64 [ %108, %107 ], [ %110, %114 ], [ %110, %109 ], [ %128, %132 ], [ %128, %127 ], [ %137, %136 ], [ %137, %141 ], [ %119, %118 ], [ %119, %123 ]
%147 = phi i32 [ %104, %107 ], [ %117, %114 ], [ %104, %109 ], [ %135, %132 ], [ %104, %127 ], [ %104, %136 ], [ %144, %141 ], [ %104, %118 ], [ %126, %123 ]
%148 = icmp eq i64 %146, %101
br i1 %148, label %149, label %102
149: ; preds = %145, %95
%150 = phi i32 [ %83, %95 ], [ %147, %145 ]
%151 = icmp eq i32 %79, -99999
%152 = zext i1 %151 to i32
%153 = add nsw i32 %81, %152
%154 = icmp eq i32 %96, %70
br i1 %154, label %155, label %158
155: ; preds = %149
%156 = load i32, i32* %77
%157 = call i32 @write(i32 %156, i8* %18, i32 5)
br label %207
158: ; preds = %149
%159 = load i8, i8* %16
%160 = icmp ne i8 %159, 10
%161 = icmp slt i32 %153, %70
%162 = select i1 %160, i1 %161, i1 false
br i1 %162, label %163, label %207
163: ; preds = %158
%164 = load i32, i32* %77
%165 = add nsw i32 %80, 1
%166 = call i32 @write(i32 %164, i8* %16, i32 %165)
%167 = load i32, i32* %21
%168 = call i32 (i32, ...) @read(i32 %167, [32 x i8]* %9, i64 32)
store i8 32, i8* %98
%169 = sext i32 %165 to i64
%170 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %169
store i8 61, i8* %170
%171 = add nsw i32 %80, 2
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %172
store i8 32, i8* %173
%174 = add nsw i32 %80, 3
br label %175
175: ; preds = %195, %163
%176 = phi i64 [ 0, %163 ], [ %197, %195 ]
%177 = phi i32 [ %174, %163 ], [ %196, %195 ]
%178 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %176
%179 = load i8, i8* %178
%180 = icmp eq i8 %179, 10
br i1 %180, label %185, label %181
181: ; preds = %175
%182 = sext i32 %177 to i64
%183 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %182
store i8 %179, i8* %183
%184 = add nsw i32 %177, 1
br label %185
185: ; preds = %175, %181
%186 = phi i32 [ %184, %181 ], [ %177, %175 ]
%187 = or i64 %176, 1
%188 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 %187
%189 = load i8, i8* %188
%190 = icmp eq i8 %189, 10
br i1 %190, label %195, label %191
191: ; preds = %185
%192 = sext i32 %186 to i64
%193 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %192
store i8 %189, i8* %193
%194 = add nsw i32 %186, 1
br label %195
195: ; preds = %191, %185
%196 = phi i32 [ %194, %191 ], [ %186, %185 ]
%197 = add nuw nsw i64 %176, 2
%198 = icmp eq i64 %197, 32
br i1 %198, label %199, label %175
199: ; preds = %195
%200 = add nsw i32 %196, 1
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %201
store i8 10, i8* %202
%203 = add nsw i32 %196, 2
%204 = sext i32 %203 to i64
%205 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %204
store i8 0, i8* %205
%206 = call i32 @write(i32 %63, i8* %16, i32 %203)
br label %207
207: ; preds = %199, %87, %158, %91, %89, %155
%208 = phi i32 [ %79, %91 ], [ %79, %89 ], [ %157, %155 ], [ -99999, %158 ], [ %79, %87 ], [ -99999, %199 ]
%209 = phi i32 [ %94, %91 ], [ %80, %89 ], [ %80, %155 ], [ 0, %158 ], [ %80, %87 ], [ 0, %199 ]
%210 = phi i32 [ %81, %91 ], [ %81, %89 ], [ %153, %155 ], [ %153, %158 ], [ %81, %87 ], [ %153, %199 ]
%211 = phi i32 [ %82, %91 ], [ %82, %89 ], [ %70, %155 ], [ %96, %158 ], [ %82, %87 ], [ %96, %199 ]
%212 = phi i32 [ %83, %91 ], [ %83, %89 ], [ %150, %155 ], [ %150, %158 ], [ %83, %87 ], [ %150, %199 ]
%213 = phi i32 [ 1, %91 ], [ %84, %89 ], [ %84, %155 ], [ %84, %158 ], [ %88, %87 ], [ %84, %199 ]
%214 = icmp eq i32 %85, 0
br i1 %214, label %215, label %78
215: ; preds = %207
%216 = call i32 @wait(i32* %5)
%217 = add nsw i32 %70, -1
%218 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %217)
%219 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %212)
%220 = load i32, i32* %5
%221 = call i32 @WEXITSTATUS(i32 %220)
%222 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %221)
br label %223
223: ; preds = %215, %25
ret i32 0
}