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

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int WEXITSTATUS(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execve(char *, char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int open(char *, int, ...);
int pipe(int *);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ wait(int *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd[2];
  int i = 0;
  int z = 0;
  int k = 0;
  int j = 0;
  int child = 0;
  int child2 = 0;
  int pipe_return = 0;
  int read_return_child = 1;
  int open_file_child = 0;
  int open_data_file = 0;
  int open_return_file = 0;
  int status = 0;
  char file_line[26];
  char alias[10];
  char file1[10];
  char file2[10];
  char byte = ' ';
  int write_pipe = 0;
  char lineStatus = 0;
  char *data_file[3];
  for (i = 0; i < sizeof(file_line); i++) {
    file_line[i] = ' ';
  }
  for (i = 0; i < sizeof(alias); i++) {
    if (i == 0) {
      alias[i] = '.';
      file1[i] = '.';
      file2[i] = '.';
    } else if (i == 1) {
      alias[i] = '/';
      file1[i] = '/';
      file2[i] = '/';
    } else {
      alias[i] = ' ';
      file1[i] = ' ';
      file2[i] = ' ';
    }
  }
  pipe_return = pipe(fd);
  if (pipe_return == -1) {
    printf("Could not create pipe\n");
    return 0;
  }
  z = 2;
  k = 2;
  j = 2;
  i = 0;
  if (argc < 2 || argc > 2) {
    printf("Wrong usage: ./Practica4_1 CmdFile\n");
  } else {
    pipe_return = pipe(fd);
    if (pipe_return == -1) {
      printf("Could not create pipe\n");
      return 0;
    }
    child = fork();
    if (child == 0) {
      close(fd[0]);
      open_file_child = open(argv[1], O_RDONLY);
      if (open_file_child != -1) {
        do {
          read_return_child = read(open_file_child, &byte, 1);
          if (read_return_child == 0) {
            break;
          }
          if (byte != '\n') {
            file_line[i] = byte;
            i = ++i;
          } else {
            for (i = 0; i < sizeof(file_line); i++) {
              if (i < 8) {
                alias[z] = file_line[i];
                z = ++z;
              } else if (i > 8 && i < 17) {
                file1[k] = file_line[i];
                k = ++k;
              } else if (i > 17) {
                file2[j] = file_line[i];
                j = ++j;
              }
            }
            z = 2;
            j = 2;
            k = 2;
            i = 0;
            alias[10] = '\0';
            file1[10] = '\0';
            file2[10] = '\0';
            open_data_file = open(file1, O_RDONLY);
            open_return_file = open(file2, O_CREAT | O_WRONLY, 0777);
            data_file[0] = alias;
            data_file[1] = file1;
            data_file[2] = NULL;
            child2 = fork();
            if (child2 == -1) {
              exit(-1);
            } else if (child2 == 0) {
              dup2(open_return_file, 1);
              dup2(open_return_file, 2);
              close(open_return_file);
              execve(data_file[0], data_file, NULL);
            }
            wait(&status);
            if (WEXITSTATUS(status) == -1) {
              write_pipe = write(fd[1], "2", 1);
            } else if (read_return_child != 0) {
              write_pipe = write(fd[1], "1", 1);
              close(open_return_file);
            }
          }
        } while (read_return_child != 0);
        write_pipe = write(fd[1], "0", 1);
        close(fd[1]);
        exit(0);
      } else {
        exit(1);
      }
    } else if (child == -1) {
      printf("Could not create child\n");
      return 0;
    } else {
      close(fd[1]);
      while (1) {
        pipe_return = read(fd[0], &lineStatus, 1);
        if (lineStatus == '1') {
          printf("Ejecucion correcta\n");
        } else if (lineStatus == '2') {
          printf("Ejecucion incorrecta\n");
        } else {
          close(fd[0]);
          wait(&status);
          if (WEXITSTATUS(status) == 0) {
            printf("FINALIZACION DE PROGRAMA CORRECTA\n");
          } else {
            printf("FINALIZACION DE PROGRAMA INCORRECTA\n");
          }
          break;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movb   $0x20,-0x8f(%rbp)
movl   $0x0,-0x94(%rbp)
movb   $0x0,-0x95(%rbp)
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x1a,%rax
jae    1271 <main+0xb1>
movslq -0x1c(%rbp),%rax
movb   $0x20,-0x70(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    124c <main+0x8c>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0xa,%rax
jae    131f <main+0x15f>
cmpl   $0x0,-0x1c(%rbp)
jne    12b6 <main+0xf6>
movslq -0x1c(%rbp),%rax
movb   $0x2e,-0x7a(%rbp,%rax,1)
movslq -0x1c(%rbp),%rax
movb   $0x2e,-0x84(%rbp,%rax,1)
2e
movslq -0x1c(%rbp),%rax
movb   $0x2e,-0x8e(%rbp,%rax,1)
2e
jmp    130c <main+0x14c>
cmpl   $0x1,-0x1c(%rbp)
jne    12e6 <main+0x126>
movslq -0x1c(%rbp),%rax
movb   $0x2f,-0x7a(%rbp,%rax,1)
movslq -0x1c(%rbp),%rax
movb   $0x2f,-0x84(%rbp,%rax,1)
2f
movslq -0x1c(%rbp),%rax
movb   $0x2f,-0x8e(%rbp,%rax,1)
2f
jmp    1307 <main+0x147>
movslq -0x1c(%rbp),%rax
movb   $0x20,-0x7a(%rbp,%rax,1)
movslq -0x1c(%rbp),%rax
movb   $0x20,-0x84(%rbp,%rax,1)
20
movslq -0x1c(%rbp),%rax
movb   $0x20,-0x8e(%rbp,%rax,1)
20
jmp    130c <main+0x14c>
jmp    1311 <main+0x151>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1278 <main+0xb8>
lea    -0x18(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    134d <main+0x18d>
lea    0xcc4(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17a4 <main+0x5e4>
movl   $0x2,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x2,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     137d <main+0x1bd>
cmpl   $0x2,-0x8(%rbp)
jle    138e <main+0x1ce>
lea    0xc93(%rip),%rdi
call   1050 <printf@plt>
jmp    179d <main+0x5dd>
lea    -0x18(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    13bc <main+0x1fc>
lea    0xc55(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17a4 <main+0x5e4>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    16bd <main+0x4fd>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2bf9(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
je     16b3 <main+0x4f3>
jmp    1402 <main+0x242>
mov    -0x3c(%rbp),%edi
lea    -0x8f(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    1428 <main+0x268>
jmp    168a <main+0x4ca>
movsbl -0x8f(%rbp),%eax
cmp    $0xa,%eax
je     1457 <main+0x297>
mov    -0x8f(%rbp),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    %eax,-0x1c(%rbp)
jmp    167b <main+0x4bb>
movl   $0x0,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    $0x1a,%rax
jae    1515 <main+0x355>
cmpl   $0x8,-0x1c(%rbp)
jge    1497 <main+0x2d7>
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x20(%rbp),%rax
mov    %cl,-0x7a(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    %eax,-0x20(%rbp)
jmp    1502 <main+0x342>
cmpl   $0x8,-0x1c(%rbp)
jle    14cf <main+0x30f>
cmpl   $0x11,-0x1c(%rbp)
jge    14cf <main+0x30f>
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x84(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    %eax,-0x24(%rbp)
jmp    14fd <main+0x33d>
cmpl   $0x11,-0x1c(%rbp)
jle    14f8 <main+0x338>
movslq -0x1c(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x8e(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    %eax,-0x28(%rbp)
jmp    14fd <main+0x33d>
jmp    1502 <main+0x342>
jmp    1507 <main+0x347>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    145e <main+0x29e>
movl   $0x2,-0x20(%rbp)
movl   $0x2,-0x28(%rbp)
movl   $0x2,-0x24(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x0,-0x70(%rbp)
movb   $0x0,-0x7a(%rbp)
movb   $0x0,-0x84(%rbp)
lea    -0x84(%rbp),%rdi
mov    0x2a92(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x40(%rbp)
lea    -0x8e(%rbp),%rdi
mov    0x2a90(%rip),%rax
mov    (%rax),%esi
mov    0x2a57(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x44(%rbp)
lea    -0x7a(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x84(%rbp),%rax
mov    %rax,-0xa8(%rbp)
movq   $0x0,-0xa0(%rbp)
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    15c4 <main+0x404>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x30(%rbp)
jne    1607 <main+0x447>
mov    -0x44(%rbp),%edi
mov    $0x1,%esi
call   1040 <dup2@plt>
mov    -0x44(%rbp),%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
mov    -0xb0(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1090 <execve@plt>
jmp    160c <main+0x44c>
lea    -0x48(%rbp),%rdi
call   10d0 <wait@plt>
mov    -0x48(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
cmp    $0xffffffff,%eax
jne    1645 <main+0x485>
mov    -0x14(%rbp),%edi
lea    0xa0b(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x94(%rbp)
jmp    1676 <main+0x4b6>
cmpl   $0x0,-0x38(%rbp)
je     1671 <main+0x4b1>
mov    -0x14(%rbp),%edi
lea    0x9e4(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x94(%rbp)
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
jmp    1676 <main+0x4b6>
jmp    167b <main+0x4bb>
jmp    1680 <main+0x4c0>
cmpl   $0x0,-0x38(%rbp)
jne    1402 <main+0x242>
mov    -0x14(%rbp),%edi
lea    0x9ab(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x94(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0xffffffff,-0x2c(%rbp)
jne    16df <main+0x51f>
lea    0x973(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    17a4 <main+0x5e4>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%edi
lea    -0x95(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x34(%rbp)
movsbl -0x95(%rbp),%eax
cmp    $0x31,%eax
jne    171f <main+0x55f>
lea    0x944(%rip),%rdi
call   1050 <printf@plt>
jmp    1789 <main+0x5c9>
movsbl -0x95(%rbp),%eax
cmp    $0x32,%eax
jne    1740 <main+0x580>
lea    0x937(%rip),%rdi
call   1050 <printf@plt>
jmp    1784 <main+0x5c4>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
lea    -0x48(%rbp),%rdi
call   10d0 <wait@plt>
mov    -0x48(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
cmp    $0x0,%eax
jne    1773 <main+0x5b3>
lea    0x91a(%rip),%rdi
call   1050 <printf@plt>
jmp    177f <main+0x5bf>
lea    0x92c(%rip),%rdi
call   1050 <printf@plt>
jmp    178e <main+0x5ce>
jmp    1789 <main+0x5c9>
jmp    16e7 <main+0x527>
jmp    1793 <main+0x5d3>
jmp    1798 <main+0x5d8>
jmp    179d <main+0x5dd>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
movl   $0x0,0x4(%rsp)
movb   $0x20,0x2(%rsp)
movb   $0x0,0x3(%rsp)
movaps 0xe14(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movups %xmm0,0x3a(%rsp)
movl   $0x20202f2e,0x26(%rsp)
20
movl   $0x20202f2e,0x1c(%rsp)
20
movl   $0x20202f2e,0x12(%rsp)
20
movb   $0x20,0x2a(%rsp)
movb   $0x20,0x20(%rsp)
movb   $0x20,0x16(%rsp)
movb   $0x20,0x2b(%rsp)
movb   $0x20,0x21(%rsp)
movb   $0x20,0x17(%rsp)
movb   $0x20,0x2c(%rsp)
movb   $0x20,0x22(%rsp)
movb   $0x20,0x18(%rsp)
movb   $0x20,0x2d(%rsp)
movb   $0x20,0x23(%rsp)
movb   $0x20,0x19(%rsp)
movb   $0x20,0x2e(%rsp)
movb   $0x20,0x24(%rsp)
movb   $0x20,0x1a(%rsp)
movb   $0x20,0x2f(%rsp)
movb   $0x20,0x25(%rsp)
movb   $0x20,0x1b(%rsp)
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
lea    0xe45(%rip),%rbx
cmp    $0xffffffff,%eax
je     134b <main+0x18b>
cmp    $0x2,%ebp
jne    133b <main+0x17b>
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     134b <main+0x18b>
xor    %eax,%eax
call   10e0 <fork@plt>
cmp    $0xffffffff,%eax
je     1344 <main+0x184>
test   %eax,%eax
je     1364 <main+0x1a4>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
lea    0x3(%rsp),%rbx
lea    0xda6(%rip),%rbp
lea    0xd8a(%rip),%r14
jmp    12e8 <main+0x128>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1080 <read@plt>
movzbl 0x3(%rsp),%eax
mov    %rbp,%rdi
cmp    $0x31,%al
je     12e3 <main+0x123>
cmp    $0x32,%al
je     12e0 <main+0x120>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
lea    0x4(%rsp),%rdi
call   10d0 <wait@plt>
mov    0x4(%rsp),%edi
call   10a0 <WEXITSTATUS@plt>
test   %eax,%eax
lea    0xd0c(%rip),%rax
lea    0xce1(%rip),%rbx
cmove  %rax,%rbx
jmp    134b <main+0x18b>
lea    0xd59(%rip),%rbx
jmp    134b <main+0x18b>
lea    0xd39(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%r14),%rdi
mov    0x2c68(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
jne    1390 <main+0x1d0>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    %eax,%r15d
lea    0x2(%rsp),%rsi
mov    %eax,%edi
mov    $0x1,%edx
call   1080 <read@plt>
test   %eax,%eax
jne    13cd <main+0x20d>
mov    0xc(%rsp),%edi
lea    0xc61(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
lea    0x1c(%rsp),%r14
lea    0x4(%rsp),%r13
lea    0x2(%rsp),%r12
xor    %ebp,%ebp
jmp    13fe <main+0x23e>
movslq %ebp,%rbp
mov    %al,0x30(%rsp,%rbp,1)
add    $0x1,%ebp
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1080 <read@plt>
test   %eax,%eax
je     13a8 <main+0x1e8>
mov    0x2(%rsp),%al
cmp    $0xa,%al
jne    13e0 <main+0x220>
mov    $0x2,%eax
xor    %ecx,%ecx
mov    $0x2,%edx
mov    $0x2,%esi
jmp    1432 <main+0x272>
movzbl 0x30(%rsp,%rcx,1),%ebx
movslq %esi,%rsi
mov    %bl,0x26(%rsp,%rsi,1)
add    $0x1,%esi
add    $0x1,%rcx
cmp    $0x1a,%rcx
je     146b <main+0x2ab>
cmp    $0x7,%rcx
jbe    1419 <main+0x259>
cmp    $0x8,%rcx
je     1455 <main+0x295>
cmp    $0x10,%rcx
ja     1455 <main+0x295>
movzbl 0x30(%rsp,%rcx,1),%ebx
movslq %edx,%rdx
mov    %bl,0x1c(%rsp,%rdx,1)
add    $0x1,%edx
jmp    1428 <main+0x268>
cmp    $0x12,%rcx
jb     1428 <main+0x268>
movzbl 0x30(%rsp,%rcx,1),%ebx
cltq
mov    %bl,0x12(%rsp,%rax,1)
add    $0x1,%eax
jmp    1428 <main+0x268>
movb   $0x0,0x30(%rsp)
movb   $0x0,0x26(%rsp)
movb   $0x0,0x1c(%rsp)
mov    0x2b5f(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   10b0 <open@plt>
mov    0x2b34(%rip),%rax
mov    (%rax),%esi
mov    0x2b5b(%rip),%rax
or     (%rax),%esi
lea    0x12(%rsp),%rdi
mov    $0x1ff,%edx
xor    %eax,%eax
call   10b0 <open@plt>
mov    %eax,%ebp
lea    0x26(%rsp),%rax
mov    %rax,0x50(%rsp)
mov    %r14,0x58(%rsp)
movq   $0x0,0x60(%rsp)
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     14dc <main+0x31c>
cmp    $0xffffffff,%eax
jne    150c <main+0x34c>
jmp    1558 <main+0x398>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <dup2@plt>
mov    %ebp,%edi
mov    $0x2,%esi
call   1050 <dup2@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    0x50(%rsp),%rdi
lea    0x50(%rsp),%rsi
xor    %edx,%edx
call   1090 <execve@plt>
mov    %r13,%rdi
call   10d0 <wait@plt>
mov    0x4(%rsp),%edi
call   10a0 <WEXITSTATUS@plt>
mov    0xc(%rsp),%edi
cmp    $0xffffffff,%eax
je     1540 <main+0x380>
lea    0xae5(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebp,%edi
call   1060 <close@plt>
jmp    1551 <main+0x391>
lea    0xac9(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
xor    %ebp,%ebp
jmp    13ea <main+0x22a>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Could not create pipe\0A\00"
@.str.1 = [36 x i8] c"Wrong usage: ./Practica4_1 CmdFile\0A\00"
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
@.str.5 = [24 x i8] c"Could not create child\0A\00"
@.str.6 = [20 x i8] c"Ejecucion correcta\0A\00"
@.str.7 = [22 x i8] c"Ejecucion incorrecta\0A\00"
@.str.8 = [35 x i8] c"FINALIZACION DE PROGRAMA CORRECTA\0A\00"
@.str.9 = [37 x i8] c"FINALIZACION DE PROGRAMA INCORRECTA\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 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 [26 x i8]
%20 = alloca [10 x i8]
%21 = alloca [10 x i8]
%22 = alloca [10 x i8]
%23 = alloca i8
%24 = alloca i32
%25 = alloca i8
%26 = alloca [3 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 1, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i8 32, i8* %23
store i32 0, i32* %24
store i8 0, i8* %25
store i32 0, i32* %7
br label %27
27: ; preds = %35, %2
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = icmp ult i64 %29, 26
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [26 x i8], [26 x i8]* %19, i64 0, i64 %33
store i8 32, i8* %34
br label %35
35: ; preds = %31
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %27
38: ; preds = %27
store i32 0, i32* %7
br label %39
39: ; preds = %81, %38
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = icmp ult i64 %41, 10
br i1 %42, label %43, label %84
43: ; preds = %39
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %56
46: ; preds = %43
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 %48
store i8 46, i8* %49
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %51
store i8 46, i8* %52
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 %54
store i8 46, i8* %55
br label %80
56: ; preds = %43
%57 = load i32, i32* %7
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %69
59: ; preds = %56
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 %61
store i8 47, i8* %62
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %64
store i8 47, i8* %65
%66 = load i32, i32* %7
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 %67
store i8 47, i8* %68
br label %79
69: ; preds = %56
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 %71
store i8 32, i8* %72
%73 = load i32, i32* %7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %74
store i8 32, i8* %75
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 %77
store i8 32, i8* %78
br label %79
79: ; preds = %69, %59
br label %80
80: ; preds = %79, %46
br label %81
81: ; preds = %80
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %39
84: ; preds = %39
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%86 = call i32 @pipe(i32* %85)
store i32 %86, i32* %13
%87 = load i32, i32* %13
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %91
89: ; preds = %84
%90 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %306
91: ; preds = %84
store i32 2, i32* %8
store i32 2, i32* %9
store i32 2, i32* %10
store i32 0, i32* %7
%92 = load i32, i32* %4
%93 = icmp slt i32 %92, 2
br i1 %93, label %97, label %94
94: ; preds = %91
%95 = load i32, i32* %4
%96 = icmp sgt i32 %95, 2
br i1 %96, label %97, label %99
97: ; preds = %94, %91
%98 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %305
99: ; preds = %94
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%101 = call i32 @pipe(i32* %100)
store i32 %101, i32* %13
%102 = load i32, i32* %13
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %106
104: ; preds = %99
%105 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %306
106: ; preds = %99
%107 = call i32 (...) @fork()
store i32 %107, i32* %11
%108 = load i32, i32* %11
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %263
110: ; preds = %106
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%112 = load i32, i32* %111
%113 = call i32 @close(i32 %112)
%114 = load i8**, i8*** %5
%115 = getelementptr inbounds i8*, i8** %114, i64 1
%116 = load i8*, i8** %115
%117 = load i32, i32* @O_RDONLY
%118 = call i32 (i8*, i32, ...) @open(i8* %116, i32 %117)
store i32 %118, i32* %15
%119 = load i32, i32* %15
%120 = icmp ne i32 %119, -1
br i1 %120, label %121, label %261
121: ; preds = %110
br label %122
122: ; preds = %250, %121
%123 = load i32, i32* %15
%124 = call i32 @read(i32 %123, i8* %23, i32 1)
store i32 %124, i32* %14
%125 = load i32, i32* %14
%126 = icmp eq i32 %125, 0
br i1 %126, label %127, label %128
127: ; preds = %122
br label %253
128: ; preds = %122
%129 = load i8, i8* %23
%130 = sext i8 %129 to i32
%131 = icmp ne i32 %130, 10
br i1 %131, label %132, label %139
132: ; preds = %128
%133 = load i8, i8* %23
%134 = load i32, i32* %7
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [26 x i8], [26 x i8]* %19, i64 0, i64 %135
store i8 %133, i8* %136
%137 = load i32, i32* %7
%138 = add nsw i32 %137, 1
store i32 %138, i32* %7
store i32 %138, i32* %7
br label %249
139: ; preds = %128
store i32 0, i32* %7
br label %140
140: ; preds = %189, %139
%141 = load i32, i32* %7
%142 = sext i32 %141 to i64
%143 = icmp ult i64 %142, 26
br i1 %143, label %144, label %192
144: ; preds = %140
%145 = load i32, i32* %7
%146 = icmp slt i32 %145, 8
br i1 %146, label %147, label %157
147: ; preds = %144
%148 = load i32, i32* %7
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds [26 x i8], [26 x i8]* %19, i64 0, i64 %149
%151 = load i8, i8* %150
%152 = load i32, i32* %8
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 %153
store i8 %151, i8* %154
%155 = load i32, i32* %8
%156 = add nsw i32 %155, 1
store i32 %156, i32* %8
store i32 %156, i32* %8
br label %188
157: ; preds = %144
%158 = load i32, i32* %7
%159 = icmp sgt i32 %158, 8
br i1 %159, label %160, label %173
160: ; preds = %157
%161 = load i32, i32* %7
%162 = icmp slt i32 %161, 17
br i1 %162, label %163, label %173
163: ; preds = %160
%164 = load i32, i32* %7
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [26 x i8], [26 x i8]* %19, i64 0, i64 %165
%167 = load i8, i8* %166
%168 = load i32, i32* %9
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 %169
store i8 %167, i8* %170
%171 = load i32, i32* %9
%172 = add nsw i32 %171, 1
store i32 %172, i32* %9
store i32 %172, i32* %9
br label %187
173: ; preds = %160, %157
%174 = load i32, i32* %7
%175 = icmp sgt i32 %174, 17
br i1 %175, label %176, label %186
176: ; preds = %173
%177 = load i32, i32* %7
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds [26 x i8], [26 x i8]* %19, i64 0, i64 %178
%180 = load i8, i8* %179
%181 = load i32, i32* %10
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 %182
store i8 %180, i8* %183
%184 = load i32, i32* %10
%185 = add nsw i32 %184, 1
store i32 %185, i32* %10
store i32 %185, i32* %10
br label %186
186: ; preds = %176, %173
br label %187
187: ; preds = %186, %163
br label %188
188: ; preds = %187, %147
br label %189
189: ; preds = %188
%190 = load i32, i32* %7
%191 = add nsw i32 %190, 1
store i32 %191, i32* %7
br label %140
192: ; preds = %140
store i32 2, i32* %8
store i32 2, i32* %10
store i32 2, i32* %9
store i32 0, i32* %7
%193 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 10
store i8 0, i8* %193
%194 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 10
store i8 0, i8* %194
%195 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 10
store i8 0, i8* %195
%196 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%197 = load i32, i32* @O_RDONLY
%198 = call i32 (i8*, i32, ...) @open(i8* %196, i32 %197)
store i32 %198, i32* %16
%199 = getelementptr inbounds [10 x i8], [10 x i8]* %22, i64 0, i64 0
%200 = load i32, i32* @O_CREAT
%201 = load i32, i32* @O_WRONLY
%202 = or i32 %200, %201
%203 = call i32 (i8*, i32, ...) @open(i8* %199, i32 %202, i32 511)
store i32 %203, i32* %17
%204 = getelementptr inbounds [10 x i8], [10 x i8]* %20, i64 0, i64 0
%205 = getelementptr inbounds [3 x i8*], [3 x i8*]* %26, i64 0, i64 0
store i8* %204, i8** %205
%206 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%207 = getelementptr inbounds [3 x i8*], [3 x i8*]* %26, i64 0, i64 1
store i8* %206, i8** %207
%208 = getelementptr inbounds [3 x i8*], [3 x i8*]* %26, i64 0, i64 2
store i8* null, i8** %208
%209 = call i32 (...) @fork()
store i32 %209, i32* %12
%210 = load i32, i32* %12
%211 = icmp eq i32 %210, -1
br i1 %211, label %212, label %214
212: ; preds = %192
%213 = call i32 @exit(i32 -1)
unreachable
214: ; preds = %192
%215 = load i32, i32* %12
%216 = icmp eq i32 %215, 0
br i1 %216, label %217, label %228
217: ; preds = %214
%218 = load i32, i32* %17
%219 = call i32 @dup2(i32 %218, i32 1)
%220 = load i32, i32* %17
%221 = call i32 @dup2(i32 %220, i32 2)
%222 = load i32, i32* %17
%223 = call i32 @close(i32 %222)
%224 = getelementptr inbounds [3 x i8*], [3 x i8*]* %26, i64 0, i64 0
%225 = load i8*, i8** %224
%226 = getelementptr inbounds [3 x i8*], [3 x i8*]* %26, i64 0, i64 0
%227 = call i32 @execve(i8* %225, i8** %226, i32* null)
br label %228
228: ; preds = %217, %214
br label %229
229: ; preds = %228
%230 = call i32 @wait(i32* %18)
%231 = load i32, i32* %18
%232 = call i32 @WEXITSTATUS(i32 %231)
%233 = icmp eq i32 %232, -1
br i1 %233, label %234, label %238
234: ; preds = %229
%235 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%236 = load i32, i32* %235
%237 = call i32 @write(i32 %236, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
store i32 %237, i32* %24
br label %248
238: ; preds = %229
%239 = load i32, i32* %14
%240 = icmp ne i32 %239, 0
br i1 %240, label %241, label %247
241: ; preds = %238
%242 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%243 = load i32, i32* %242
%244 = call i32 @write(i32 %243, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
store i32 %244, i32* %24
%245 = load i32, i32* %17
%246 = call i32 @close(i32 %245)
br label %247
247: ; preds = %241, %238
br label %248
248: ; preds = %247, %234
br label %249
249: ; preds = %248, %132
br label %250
250: ; preds = %249
%251 = load i32, i32* %14
%252 = icmp ne i32 %251, 0
br i1 %252, label %122, label %253
253: ; preds = %250, %127
%254 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%255 = load i32, i32* %254
%256 = call i32 @write(i32 %255, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
store i32 %256, i32* %24
%257 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%258 = load i32, i32* %257
%259 = call i32 @close(i32 %258)
%260 = call i32 @exit(i32 0)
unreachable
261: ; preds = %110
%262 = call i32 @exit(i32 1)
unreachable
263: ; preds = %106
%264 = load i32, i32* %11
%265 = icmp eq i32 %264, -1
br i1 %265, label %266, label %268
266: ; preds = %263
%267 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %306
268: ; preds = %263
%269 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%270 = load i32, i32* %269
%271 = call i32 @close(i32 %270)
br label %272
272: ; preds = %268, %301
%273 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%274 = load i32, i32* %273
%275 = call i32 @read(i32 %274, i8* %25, i32 1)
store i32 %275, i32* %13
%276 = load i8, i8* %25
%277 = sext i8 %276 to i32
%278 = icmp eq i32 %277, 49
br i1 %278, label %279, label %281
279: ; preds = %272
%280 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %301
281: ; preds = %272
%282 = load i8, i8* %25
%283 = sext i8 %282 to i32
%284 = icmp eq i32 %283, 50
br i1 %284, label %285, label %287
285: ; preds = %281
%286 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
br label %300
287: ; preds = %281
%288 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%289 = load i32, i32* %288
%290 = call i32 @close(i32 %289)
%291 = call i32 @wait(i32* %18)
%292 = load i32, i32* %18
%293 = call i32 @WEXITSTATUS(i32 %292)
%294 = icmp eq i32 %293, 0
br i1 %294, label %295, label %297
295: ; preds = %287
%296 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
br label %299
297: ; preds = %287
%298 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %299
299: ; preds = %297, %295
br label %302
300: ; preds = %285
br label %301
301: ; preds = %300, %279
br label %272
302: ; preds = %299
br label %303
303: ; preds = %302
br label %304
304: ; preds = %303
br label %305
305: ; preds = %304, %97
store i32 0, i32* %3
br label %306
306: ; preds = %305, %266, %104, %89
%307 = load i32, i32* %3
ret i32 %307
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@.str.2 = [2 x i8] c"2\00"
@.str.3 = [2 x i8] c"1\00"
@.str.4 = [2 x i8] c"0\00"
@str = [36 x i8] c"FINALIZACION DE PROGRAMA INCORRECTA\00"
@str.10 = [34 x i8] c"FINALIZACION DE PROGRAMA CORRECTA\00"
@str.11 = [21 x i8] c"Ejecucion incorrecta\00"
@str.12 = [19 x i8] c"Ejecucion correcta\00"
@str.13 = [23 x i8] c"Could not create child\00"
@str.15 = [35 x i8] c"Wrong usage: ./Practica4_1 CmdFile\00"
@str.16 = [22 x i8] c"Could not create pipe\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca [26 x i8]
%6 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%7 = alloca [10 x i8]
%8 = alloca [10 x i8]
%9 = alloca [10 x i8]
%10 = alloca i8
%11 = alloca i8
%12 = alloca [3 x i8*]
%13 = bitcast [2 x i32]* %3 to i8*
%14 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%15 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 0
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
store i8 32, i8* %10
store i8 0, i8* %11
%19 = bitcast [3 x i8*]* %12 to i8*
store i8 46, i8* %16
store i8 46, i8* %17
store i8 46, i8* %18
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 1
store i8 47, i8* %20
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 1
store i8 47, i8* %21
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 1
store i8 47, i8* %22
%23 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 2
store i8 32, i8* %23
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 2
store i8 32, i8* %24
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 2
store i8 32, i8* %25
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 3
store i8 32, i8* %26
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 3
store i8 32, i8* %27
%28 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 3
store i8 32, i8* %28
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 4
store i8 32, i8* %29
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 4
store i8 32, i8* %30
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 4
store i8 32, i8* %31
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 5
store i8 32, i8* %32
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 5
store i8 32, i8* %33
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 5
store i8 32, i8* %34
%35 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 6
store i8 32, i8* %35
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 6
store i8 32, i8* %36
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 6
store i8 32, i8* %37
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 7
store i8 32, i8* %38
%39 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 7
store i8 32, i8* %39
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 7
store i8 32, i8* %40
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 8
store i8 32, i8* %41
%42 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 8
store i8 32, i8* %42
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 8
store i8 32, i8* %43
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 9
store i8 32, i8* %44
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 9
store i8 32, i8* %45
%46 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 9
store i8 32, i8* %46
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%48 = call i32 @pipe(i32* %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %180, label %50
50: ; preds = %2
%51 = icmp eq i32 %0, 2
br i1 %51, label %52, label %180
52: ; preds = %50
%53 = call i32 @pipe(i32* %47)
%54 = icmp eq i32 %53, -1
br i1 %54, label %180, label %55
55: ; preds = %52
%56 = call i32 (...) @fork()
switch i32 %56, label %160 [
i32 0, label %57
i32 -1, label %180
]
57: ; preds = %55
%58 = load i32, i32* %47
%59 = call i32 @close(i32 %58)
%60 = getelementptr inbounds i8*, i8** %1, i64 1
%61 = load i8*, i8** %60
%62 = load i32, i32* @O_RDONLY
%63 = call i32 (i8*, i32, ...) @open(i8* %61, i32 %62)
%64 = icmp eq i32 %63, -1
br i1 %64, label %158, label %65
65: ; preds = %57
%66 = call i32 @read(i32 %63, i8* %10, i32 1)
%67 = icmp eq i32 %66, 0
br i1 %67, label %151, label %68
68: ; preds = %65
%69 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 10
%70 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 10
%71 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 10
%72 = getelementptr inbounds [3 x i8*], [3 x i8*]* %12, i64 0, i64 0
%73 = getelementptr inbounds [3 x i8*], [3 x i8*]* %12, i64 0, i64 1
%74 = getelementptr inbounds [3 x i8*], [3 x i8*]* %12, i64 0, i64 2
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
br label %76
76: ; preds = %68, %147
%77 = phi i32 [ 0, %68 ], [ %148, %147 ]
%78 = load i8, i8* %10
%79 = icmp eq i8 %78, 10
br i1 %79, label %84, label %80
80: ; preds = %76
%81 = sext i32 %77 to i64
%82 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %81
store i8 %78, i8* %82
%83 = add nsw i32 %77, 1
br label %147
84: ; preds = %76, %114
%85 = phi i64 [ %118, %114 ], [ 0, %76 ]
%86 = phi i32 [ %117, %114 ], [ 2, %76 ]
%87 = phi i32 [ %116, %114 ], [ 2, %76 ]
%88 = phi i32 [ %115, %114 ], [ 2, %76 ]
%89 = icmp ult i64 %85, 8
br i1 %89, label %90, label %96
90: ; preds = %84
%91 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %85
%92 = load i8, i8* %91
%93 = sext i32 %88 to i64
%94 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 %93
store i8 %92, i8* %94
%95 = add nsw i32 %88, 1
br label %114
96: ; preds = %84
%97 = icmp ne i64 %85, 8
%98 = icmp ult i64 %85, 17
%99 = and i1 %97, %98
br i1 %99, label %100, label %106
100: ; preds = %96
%101 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %85
%102 = load i8, i8* %101
%103 = sext i32 %87 to i64
%104 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 %103
store i8 %102, i8* %104
%105 = add nsw i32 %87, 1
br label %114
106: ; preds = %96
%107 = icmp ugt i64 %85, 17
br i1 %107, label %108, label %114
108: ; preds = %106
%109 = getelementptr inbounds [26 x i8], [26 x i8]* %5, i64 0, i64 %85
%110 = load i8, i8* %109
%111 = sext i32 %86 to i64
%112 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 %111
store i8 %110, i8* %112
%113 = add nsw i32 %86, 1
br label %114
114: ; preds = %90, %106, %108, %100
%115 = phi i32 [ %95, %90 ], [ %88, %100 ], [ %88, %108 ], [ %88, %106 ]
%116 = phi i32 [ %87, %90 ], [ %105, %100 ], [ %87, %108 ], [ %87, %106 ]
%117 = phi i32 [ %86, %90 ], [ %86, %100 ], [ %113, %108 ], [ %86, %106 ]
%118 = add nuw nsw i64 %85, 1
%119 = icmp eq i64 %118, 26
br i1 %119, label %120, label %84
120: ; preds = %114
store i8 0, i8* %69
store i8 0, i8* %70
store i8 0, i8* %71
%121 = load i32, i32* @O_RDONLY
%122 = call i32 (i8*, i32, ...) @open(i8* %17, i32 %121)
%123 = load i32, i32* @O_CREAT
%124 = load i32, i32* @O_WRONLY
%125 = or i32 %124, %123
%126 = call i32 (i8*, i32, ...) @open(i8* %18, i32 %125, i32 511)
store i8* %16, i8** %72
store i8* %17, i8** %73
store i8* null, i8** %74
%127 = call i32 (...) @fork()
switch i32 %127, label %136 [
i32 -1, label %128
i32 0, label %130
]
128: ; preds = %120
%129 = call i32 @exit(i32 -1)
unreachable
130: ; preds = %120
%131 = call i32 @dup2(i32 %126, i32 1)
%132 = call i32 @dup2(i32 %126, i32 2)
%133 = call i32 @close(i32 %126)
%134 = load i8*, i8** %72
%135 = call i32 @execve(i8* %134, i8** %72, i32* null)
br label %136
136: ; preds = %120, %130
%137 = call i32 @wait(i32* %4)
%138 = load i32, i32* %4
%139 = call i32 @WEXITSTATUS(i32 %138)
%140 = icmp eq i32 %139, -1
%141 = load i32, i32* %75
br i1 %140, label %142, label %144
142: ; preds = %136
%143 = call i32 @write(i32 %141, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %147
144: ; preds = %136
%145 = call i32 @write(i32 %141, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 1)
%146 = call i32 @close(i32 %126)
br label %147
147: ; preds = %80, %144, %142
%148 = phi i32 [ %83, %80 ], [ 0, %142 ], [ 0, %144 ]
%149 = call i32 @read(i32 %63, i8* %10, i32 1)
%150 = icmp eq i32 %149, 0
br i1 %150, label %151, label %76
151: ; preds = %147, %65
%152 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%153 = load i32, i32* %152
%154 = call i32 @write(i32 %153, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%155 = load i32, i32* %152
%156 = call i32 @close(i32 %155)
%157 = call i32 @exit(i32 0)
unreachable
158: ; preds = %57
%159 = call i32 @exit(i32 1)
unreachable
160: ; preds = %55
%161 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%162 = load i32, i32* %161
%163 = call i32 @close(i32 %162)
br label %164
164: ; preds = %177, %160
%165 = load i32, i32* %47
%166 = call i32 @read(i32 %165, i8* %11, i32 1)
%167 = load i8, i8* %11
switch i8 %167, label %169 [
i8 49, label %177
i8 50, label %168
]
168: ; preds = %164
br label %177
169: ; preds = %164
%170 = load i32, i32* %47
%171 = call i32 @close(i32 %170)
%172 = call i32 @wait(i32* %4)
%173 = load i32, i32* %4
%174 = call i32 @WEXITSTATUS(i32 %173)
%175 = icmp eq i32 %174, 0
%176 = select i1 %175, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0)
br label %180
177: ; preds = %164, %168
%178 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.11, i64 0, i64 0), %168 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0), %164 ]
%179 = call i32 @puts(i8* dereferenceable(1) %178)
br label %164
180: ; preds = %169, %55, %52, %50, %2
%181 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.16, i64 0, i64 0), %2 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.15, i64 0, i64 0), %50 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @str.16, i64 0, i64 0), %52 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0), %55 ], [ %176, %169 ]
%182 = call i32 @puts(i8* dereferenceable(1) %181)
ret i32 0
}