#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 O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
scalar_t__ close(int);
int dup(int);
scalar_t__ dup2(int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
int open(char *, int, ...);
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ *stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ write(int, char *, int);
int main(int argc, char *argv[]) {
  int i, pos = 0;
  char *args[argc];
  char *stdin_path = NULL, *stdout_path = NULL, *stderr_path = NULL;
  int stderr_fd = 0;
  if (argc <= 1) {
    fprintf(stderr, "%s: Takes at least one agrument!\n", argv[0]);
    return 1;
  }
  for (i = 1; i < argc; i++) {
    if (argv[i][0] == '>') {
      if (argv[i][1]) {
        stdout_path = argv[i] + 1;
      } else {
        if (++i >= argc) {
          fprintf(stderr, "%s: Missing filename after >\n", argv[0]);
          return 1;
        }
        stdout_path = argv[i];
      }
      continue;
    }
    if (argv[i][0] == '<') {
      if (argv[i][1]) {
        stdin_path = argv[i] + 1;
      } else {
        if (++i >= argc) {
          fprintf(stderr, "%s: Missing filename after <\n", argv[0]);
          return 1;
        }
        stdin_path = argv[i];
      }
      continue;
    }
    if (argv[i][0] == '2' && argv[i][1] == '>') {
      if (argv[i][2]) {
        stderr_path = argv[i] + 2;
      } else {
        if (++i >= argc) {
          fprintf(stderr, "%s: Missing filename after 2>\n", argv[0]);
          return 1;
        }
        stderr_path = argv[i];
      }
      continue;
    }
    args[pos++] = argv[i];
  }
  args[pos] = NULL;
  if (stdin_path) {
    if (close(0)) {
      fprintf(stderr, "%s: Failed to close stdin: %s\n", argv[0],
              strerror(errno));
      return 1;
    }
    if (open(stdin_path, O_RDONLY) < 0) {
      fprintf(stderr, "%s: Failed to open '%s' for reading: %s\n", argv[0],
              stdin_path, strerror(errno));
      return 1;
    }
  }
  if (stdout_path) {
    if (close(1)) {
      fprintf(stderr, "%s: Failed to close stdout: %s\n", argv[0],
              strerror(errno));
      return 1;
    }
    if (open(stdout_path, O_CREAT | O_WRONLY | O_TRUNC, 0777) < 0) {
      fprintf(stderr, "%s: Failed to open '%s' for writing: %s\n", argv[0],
              stdin_path, strerror(errno));
      return 1;
    }
  }
  if (stderr_path) {
    int fd = open(stderr_path, O_CREAT | O_WRONLY | O_TRUNC, 0777);
    int stderr_fd = dup(2);
    if (stderr_fd < 0) {
      fprintf(stderr, "%s: Failed to dup() stderr: %s\n", argv[0],
              strerror(errno));
      return 1;
    }
    if (fd < 0) {
      fprintf(stderr, "%s: Failed to open '%s' for writing: %s\n", argv[0],
              stdin_path, strerror(errno));
      return 1;
    }
    if (dup2(fd, 2) < 0) {
      fprintf(stderr, "%s: Failed to dup2 stderr: %s\n", argv[0],
              strerror(errno));
      if (write(stderr_fd, "Failed to dup2 stderr\n",
                sizeof("Failed to dup2 stderr\n") - 1)) {
      };
      return 1;
    }
  }
  execvp(argv[1], args);
  FILE *sin = popen("/bin/sh", "w");
  if (!sin) {
    if (stderr_fd) {
      if (write(stderr_fd, "Failed to popen /bin/sh\n",
                sizeof("Failed to popen /bin/sh\n") - 1)) {
      };
    } else {
      fprintf(stderr, "%s: Failed to popen /bin/sh: %s\n", argv[0],
              strerror(errno));
    }
    return 1;
  }
  for (i = 0; args[i]; i++)
    fprintf(sin, "%s ", args[i]);
  return pclose(sin);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     1242 <main+0xa2>
mov    0x2db1(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    147e <main+0x2de>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
jne    12f5 <main+0x155>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpb   $0x0,0x1(%rax)
je     129c <main+0xfc>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    12f0 <main+0x150>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jl     12e0 <main+0x140>
mov    0x2d13(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd5c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
jmp    1470 <main+0x2d0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
jne    1395 <main+0x1f5>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpb   $0x0,0x1(%rax)
je     133c <main+0x19c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1390 <main+0x1f0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jl     1380 <main+0x1e0>
mov    0x2c73(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcda(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
jmp    1470 <main+0x2d0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x32,%eax
jne    144e <main+0x2ae>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl 0x1(%rax),%eax
cmp    $0x3e,%eax
jne    144e <main+0x2ae>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpb   $0x0,0x2(%rax)
je     13f5 <main+0x255>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
jmp    1449 <main+0x2a9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmp    -0x8(%rbp),%eax
jl     1439 <main+0x299>
mov    0x2bba(%rip),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc3f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
jmp    1470 <main+0x2d0>
mov    -0x60(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
mov    (%rcx,%rdx,8),%rdx
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1249 <main+0xa9>
mov    -0x60(%rbp),%rax
movslq -0x18(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
cmpq   $0x0,-0x30(%rbp)
je     1584 <main+0x3e4>
xor    %edi,%edi
call   1070 <close@plt>
cmp    $0x0,%rax
je     14fd <main+0x35d>
mov    0x2b17(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    0x2af6(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xb9a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
mov    -0x30(%rbp),%rdi
mov    0x2ad0(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open@plt>
cmp    $0x0,%eax
jge    157f <main+0x3df>
mov    0x2aa7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2a7b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    %rax,%r8
lea    0xb37(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
jmp    1584 <main+0x3e4>
cmpq   $0x0,-0x38(%rbp)
je     16ac <main+0x50c>
mov    $0x1,%edi
call   1070 <close@plt>
cmp    $0x0,%rax
je     1602 <main+0x462>
mov    0x2a1e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
mov    0x29f7(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    %rax,%rcx
lea    0xadd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
mov    -0x38(%rbp),%rdi
mov    0x29eb(%rip),%rax
mov    (%rax),%esi
mov    0x299a(%rip),%rax
or     (%rax),%esi
mov    0x29d1(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
mov    $0x0,%al
call   1090 <open@plt>
cmp    $0x0,%eax
jge    16a7 <main+0x507>
mov    0x298b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2959(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xb0(%rbp),%rdi
mov    -0xa8(%rbp),%rdx
mov    -0xa0(%rbp),%rcx
mov    %rax,%r8
lea    0xa58(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
jmp    16ac <main+0x50c>
cmpq   $0x0,-0x40(%rbp)
je     1874 <main+0x6d4>
mov    -0x40(%rbp),%rdi
mov    0x2936(%rip),%rax
mov    (%rax),%esi
mov    0x28e5(%rip),%rax
or     (%rax),%esi
mov    0x291c(%rip),%rax
or     (%rax),%esi
mov    $0x1ff,%edx
mov    $0x0,%al
call   1090 <open@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x2,%edi
call   1060 <dup@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
jge    175b <main+0x5bb>
mov    0x28c5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xb8(%rbp)
mov    0x289e(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xc0(%rbp),%rdi
mov    -0xb8(%rbp),%rdx
mov    %rax,%rcx
lea    0x9cd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
cmpl   $0x0,-0x4c(%rbp)
jge    17d6 <main+0x636>
mov    0x285c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    0x282a(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xd0(%rbp),%rdx
mov    -0xc8(%rbp),%rcx
mov    %rax,%r8
lea    0x929(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
mov    -0x4c(%rbp),%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
cmp    $0x0,%rax
jge    186f <main+0x6cf>
mov    0x27d4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xe0(%rbp)
mov    0x27ad(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xe8(%rbp),%rdi
mov    -0xe0(%rbp),%rdx
mov    %rax,%rcx
lea    0x8fc(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x50(%rbp),%edi
lea    0x90a(%rip),%rsi
mov    $0x16,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
je     185c <main+0x6bc>
jmp    185c <main+0x6bc>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
jmp    1874 <main+0x6d4>
mov    -0x60(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <execvp@plt>
lea    0x8d8(%rip),%rdi
lea    0x8d9(%rip),%rsi
call   10a0 <popen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1938 <main+0x798>
cmpl   $0x0,-0x44(%rbp)
je     18d9 <main+0x739>
mov    -0x44(%rbp),%edi
lea    0x8b3(%rip),%rsi
mov    $0x18,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
je     18d4 <main+0x734>
jmp    18d4 <main+0x734>
jmp    1925 <main+0x785>
mov    0x26e8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xf8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xf0(%rbp)
mov    0x26c1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0xf8(%rbp),%rdi
mov    -0xf0(%rbp),%rdx
mov    %rax,%rcx
lea    0x869(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
jmp    1991 <main+0x7f1>
movl   $0x0,-0x14(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     197e <main+0x7de>
mov    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rdi
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0x83f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    193f <main+0x79f>
mov    -0x58(%rbp),%rdi
call   1050 <pclose@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%eax
mov    %rsp,%r14
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmp    $0x2,%edi
jge    11ed <main+0x4d>
mov    0x2df4(%rip),%rax
mov    (%rax),%rdi
mov    (%r15),%rdx
lea    0xe1f(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    15c0 <main+0x420>
xor    %eax,%eax
mov    $0x1,%ecx
xor    %r12d,%r12d
xor    %r8d,%r8d
xor    %r13d,%r13d
jmp    1215 <main+0x75>
nop
movslq %eax,%rsi
add    $0x1,%eax
mov    %rdx,(%r14,%rsi,8)
add    $0x1,%ecx
cmp    %edi,%ecx
jge    12b1 <main+0x111>
movslq %ecx,%rdx
mov    (%r15,%rdx,8),%rdx
movzbl (%rdx),%ebx
cmp    $0x32,%bl
je     1240 <main+0xa0>
cmp    $0x3c,%bl
je     1260 <main+0xc0>
cmp    $0x3e,%bl
jne    1200 <main+0x60>
cmpb   $0x0,0x1(%rdx)
je     126f <main+0xcf>
add    $0x1,%rdx
mov    %rdx,%r13
jmp    120a <main+0x6a>
nopl   (%rax)
cmpb   $0x3e,0x1(%rdx)
jne    1200 <main+0x60>
cmpb   $0x0,0x2(%rdx)
je     129a <main+0xfa>
add    $0x2,%rdx
mov    %rdx,%r8
jmp    120a <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,0x1(%rdx)
je     1283 <main+0xe3>
add    $0x1,%rdx
mov    %rdx,%r12
jmp    120a <main+0x6a>
add    $0x1,%ecx
cmp    %edi,%ecx
jge    1489 <main+0x2e9>
movslq %ecx,%rdx
mov    (%r15,%rdx,8),%r13
jmp    120a <main+0x6a>
add    $0x1,%ecx
cmp    %edi,%ecx
jge    14a2 <main+0x302>
movslq %ecx,%rdx
mov    (%r15,%rdx,8),%r12
jmp    120a <main+0x6a>
add    $0x1,%ecx
cmp    %edi,%ecx
jge    1539 <main+0x399>
movslq %ecx,%rdx
mov    (%r15,%rdx,8),%r8
jmp    120a <main+0x6a>
cltq
movq   $0x0,(%r14,%rax,8)
test   %r12,%r12
je     1324 <main+0x184>
mov    %r8,%rbx
xor    %edi,%edi
call   1070 <close@plt>
test   %rax,%rax
je     1306 <main+0x166>
mov    0x2cf2(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%rbx
mov    0x2cdd(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd8c(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    15c0 <main+0x420>
mov    0x2ccb(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
mov    %rbx,%r8
js     14bb <main+0x31b>
mov    %r12,-0x30(%rbp)
test   %r13,%r13
je     13b5 <main+0x215>
mov    %r8,%rbx
mov    $0x1,%r12d
mov    $0x1,%edi
call   1070 <close@plt>
test   %rax,%rax
je     1380 <main+0x1e0>
mov    0x2c78(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%rbx
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xd5a(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    15c6 <main+0x426>
mov    0x2c71(%rip),%rax
mov    0x2c22(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2c57(%rip),%rax
or     (%rax),%esi
mov    %r13,%rdi
mov    $0x1ff,%edx
xor    %eax,%eax
call   1090 <open@plt>
test   %eax,%eax
mov    %rbx,%r8
js     1552 <main+0x3b2>
test   %r8,%r8
je     141b <main+0x27b>
mov    0x2c37(%rip),%rax
mov    0x2be8(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2c1d(%rip),%rax
or     (%rax),%esi
mov    %r8,%rdi
mov    $0x1ff,%edx
xor    %eax,%eax
call   1090 <open@plt>
mov    %eax,%r13d
mov    $0x2,%edi
call   1060 <dup@plt>
test   %eax,%eax
js     14eb <main+0x34b>
test   %r13d,%r13d
js     158a <main+0x3ea>
mov    %eax,%r12d
mov    %r13d,%edi
mov    $0x2,%esi
call   1040 <dup2@plt>
test   %rax,%rax
js     15d8 <main+0x438>
mov    0x8(%r15),%rdi
mov    %r14,%rsi
call   10b0 <execvp@plt>
lea    0xd36(%rip),%rdi
lea    0xd37(%rip),%rsi
call   10a0 <popen@plt>
test   %rax,%rax
je     1512 <main+0x372>
mov    %rax,%rbx
mov    (%r14),%rdx
test   %rdx,%rdx
je     1479 <main+0x2d9>
add    $0x8,%r14
lea    0xd36(%rip),%r15
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%r14),%rdx
add    $0x8,%r14
test   %rdx,%rdx
jne    1460 <main+0x2c0>
mov    %rbx,%rdi
call   1050 <pclose@plt>
mov    %eax,%r12d
jmp    15c6 <main+0x426>
mov    0x2b38(%rip),%rax
mov    (%rax),%rdi
mov    (%r15),%rdx
lea    0xb85(%rip),%rsi
jmp    11e1 <main+0x41>
mov    0x2b1f(%rip),%rax
mov    (%rax),%rdi
mov    (%r15),%rdx
lea    0xb8a(%rip),%rsi
jmp    11e1 <main+0x41>
mov    0x2b06(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%rbx
mov    0x2af1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xbbf(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %r12,%rcx
jmp    15b6 <main+0x416>
mov    0x2ad6(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%rbx
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc01(%rip),%rsi
jmp    12f1 <main+0x151>
mov    0x2aaf(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%rbx
mov    0x2a9a(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xc3a(%rip),%rsi
jmp    12f1 <main+0x151>
mov    0x2a88(%rip),%rax
mov    (%rax),%rdi
mov    (%r15),%rdx
lea    0xb11(%rip),%rsi
jmp    11e1 <main+0x41>
mov    0x2a6f(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%r15
mov    0x2a5a(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb71(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    -0x30(%rbp),%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    15c6 <main+0x426>
mov    0x2a37(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%r15
mov    0x2a22(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb39(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
mov    -0x30(%rbp),%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x29e9(%rip),%rax
mov    (%rax),%r14
mov    (%r15),%rbx
mov    0x29d4(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xb34(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xb3c(%rip),%rsi
mov    %r12d,%edi
mov    $0x16,%edx
call   1030 <write@plt>
jmp    15c0 <main+0x420>

LLVM IR (-O0):
@stderr = global i32* null
@.str = [34 x i8] c"%s: Takes at least one agrument!\0A\00"
@.str.1 = [30 x i8] c"%s: Missing filename after >\0A\00"
@.str.2 = [30 x i8] c"%s: Missing filename after <\0A\00"
@.str.3 = [31 x i8] c"%s: Missing filename after 2>\0A\00"
@.str.4 = [31 x i8] c"%s: Failed to close stdin: %s\0A\00"
@errno = global i32 0
@O_RDONLY = global i32 0
@.str.5 = [41 x i8] c"%s: Failed to open '%s' for reading: %s\0A\00"
@.str.6 = [32 x i8] c"%s: Failed to close stdout: %s\0A\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@.str.7 = [41 x i8] c"%s: Failed to open '%s' for writing: %s\0A\00"
@.str.8 = [32 x i8] c"%s: Failed to dup() stderr: %s\0A\00"
@.str.9 = [31 x i8] c"%s: Failed to dup2 stderr: %s\0A\00"
@.str.10 = [23 x i8] c"Failed to dup2 stderr\0A\00"
@.str.11 = [8 x i8] c"/bin/sh\00"
@.str.12 = [2 x i8] c"w\00"
@.str.13 = [25 x i8] c"Failed to popen /bin/sh\0A\00"
@.str.14 = [33 x i8] c"%s: Failed to popen /bin/sh: %s\0A\00"
@.str.15 = [4 x i8] c"%s \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 i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%18 = load i32, i32* %4
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %8
%21 = alloca i8*, i64 %19
store i64 %19, i64* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i32 0, i32* %13
%22 = load i32, i32* %4
%23 = icmp sle i32 %22, 1
br i1 %23, label %24, label %30
24: ; preds = %2
%25 = load i32*, i32** @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %28)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
30: ; preds = %2
store i32 1, i32* %6
br label %31
31: ; preds = %187, %30
%32 = load i32, i32* %6
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %190
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8*, i8** %36, i64 %38
%40 = load i8*, i8** %39
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 62
br i1 %44, label %45, label %79
45: ; preds = %35
%46 = load i8**, i8*** %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %46, i64 %48
%50 = load i8*, i8** %49
%51 = getelementptr inbounds i8, i8* %50, i64 1
%52 = load i8, i8* %51
%53 = icmp ne i8 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %45
%55 = load i8**, i8*** %5
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = getelementptr inbounds i8, i8* %59, i64 1
store i8* %60, i8** %11
br label %78
61: ; preds = %45
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
%64 = load i32, i32* %4
%65 = icmp sge i32 %63, %64
br i1 %65, label %66, label %72
66: ; preds = %61
%67 = load i32*, i32** @stderr
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 0
%70 = load i8*, i8** %69
%71 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %67, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %70)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
72: ; preds = %61
%73 = load i8**, i8*** %5
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8*, i8** %73, i64 %75
%77 = load i8*, i8** %76
store i8* %77, i8** %11
br label %78
78: ; preds = %72, %54
br label %187
79: ; preds = %35
%80 = load i8**, i8*** %5
%81 = load i32, i32* %6
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = getelementptr inbounds i8, i8* %84, i64 0
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 60
br i1 %88, label %89, label %123
89: ; preds = %79
%90 = load i8**, i8*** %5
%91 = load i32, i32* %6
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8*, i8** %90, i64 %92
%94 = load i8*, i8** %93
%95 = getelementptr inbounds i8, i8* %94, i64 1
%96 = load i8, i8* %95
%97 = icmp ne i8 %96, 0
br i1 %97, label %98, label %105
98: ; preds = %89
%99 = load i8**, i8*** %5
%100 = load i32, i32* %6
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8*, i8** %99, i64 %101
%103 = load i8*, i8** %102
%104 = getelementptr inbounds i8, i8* %103, i64 1
store i8* %104, i8** %10
br label %122
105: ; preds = %89
%106 = load i32, i32* %6
%107 = add nsw i32 %106, 1
store i32 %107, i32* %6
%108 = load i32, i32* %4
%109 = icmp sge i32 %107, %108
br i1 %109, label %110, label %116
110: ; preds = %105
%111 = load i32*, i32** @stderr
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 0
%114 = load i8*, i8** %113
%115 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %111, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %114)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
116: ; preds = %105
%117 = load i8**, i8*** %5
%118 = load i32, i32* %6
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8*, i8** %117, i64 %119
%121 = load i8*, i8** %120
store i8* %121, i8** %10
br label %122
122: ; preds = %116, %98
br label %187
123: ; preds = %79
%124 = load i8**, i8*** %5
%125 = load i32, i32* %6
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8*, i8** %124, i64 %126
%128 = load i8*, i8** %127
%129 = getelementptr inbounds i8, i8* %128, i64 0
%130 = load i8, i8* %129
%131 = sext i8 %130 to i32
%132 = icmp eq i32 %131, 50
br i1 %132, label %133, label %177
133: ; preds = %123
%134 = load i8**, i8*** %5
%135 = load i32, i32* %6
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8*, i8** %134, i64 %136
%138 = load i8*, i8** %137
%139 = getelementptr inbounds i8, i8* %138, i64 1
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = icmp eq i32 %141, 62
br i1 %142, label %143, label %177
143: ; preds = %133
%144 = load i8**, i8*** %5
%145 = load i32, i32* %6
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds i8*, i8** %144, i64 %146
%148 = load i8*, i8** %147
%149 = getelementptr inbounds i8, i8* %148, i64 2
%150 = load i8, i8* %149
%151 = icmp ne i8 %150, 0
br i1 %151, label %152, label %159
152: ; preds = %143
%153 = load i8**, i8*** %5
%154 = load i32, i32* %6
%155 = sext i32 %154 to i64
%156 = getelementptr inbounds i8*, i8** %153, i64 %155
%157 = load i8*, i8** %156
%158 = getelementptr inbounds i8, i8* %157, i64 2
store i8* %158, i8** %12
br label %176
159: ; preds = %143
%160 = load i32, i32* %6
%161 = add nsw i32 %160, 1
store i32 %161, i32* %6
%162 = load i32, i32* %4
%163 = icmp sge i32 %161, %162
br i1 %163, label %164, label %170
164: ; preds = %159
%165 = load i32*, i32** @stderr
%166 = load i8**, i8*** %5
%167 = getelementptr inbounds i8*, i8** %166, i64 0
%168 = load i8*, i8** %167
%169 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %165, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %168)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
170: ; preds = %159
%171 = load i8**, i8*** %5
%172 = load i32, i32* %6
%173 = sext i32 %172 to i64
%174 = getelementptr inbounds i8*, i8** %171, i64 %173
%175 = load i8*, i8** %174
store i8* %175, i8** %12
br label %176
176: ; preds = %170, %152
br label %187
177: ; preds = %133, %123
%178 = load i8**, i8*** %5
%179 = load i32, i32* %6
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8*, i8** %178, i64 %180
%182 = load i8*, i8** %181
%183 = load i32, i32* %7
%184 = add nsw i32 %183, 1
store i32 %184, i32* %7
%185 = sext i32 %183 to i64
%186 = getelementptr inbounds i8*, i8** %21, i64 %185
store i8* %182, i8** %186
br label %187
187: ; preds = %177, %176, %122, %78
%188 = load i32, i32* %6
%189 = add nsw i32 %188, 1
store i32 %189, i32* %6
br label %31
190: ; preds = %31
%191 = load i32, i32* %7
%192 = sext i32 %191 to i64
%193 = getelementptr inbounds i8*, i8** %21, i64 %192
store i8* null, i8** %193
%194 = load i8*, i8** %10
%195 = icmp ne i8* %194, null
br i1 %195, label %196, label %222
196: ; preds = %190
%197 = call i64 @close(i32 0)
%198 = icmp ne i64 %197, 0
br i1 %198, label %199, label %207
199: ; preds = %196
%200 = load i32*, i32** @stderr
%201 = load i8**, i8*** %5
%202 = getelementptr inbounds i8*, i8** %201, i64 0
%203 = load i8*, i8** %202
%204 = load i32, i32* @errno
%205 = call i8* @strerror(i32 %204)
%206 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %200, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %203, i8* %205)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
207: ; preds = %196
%208 = load i8*, i8** %10
%209 = load i32, i32* @O_RDONLY
%210 = call i32 (i8*, i32, ...) @open(i8* %208, i32 %209)
%211 = icmp slt i32 %210, 0
br i1 %211, label %212, label %221
212: ; preds = %207
%213 = load i32*, i32** @stderr
%214 = load i8**, i8*** %5
%215 = getelementptr inbounds i8*, i8** %214, i64 0
%216 = load i8*, i8** %215
%217 = load i8*, i8** %10
%218 = load i32, i32* @errno
%219 = call i8* @strerror(i32 %218)
%220 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %213, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %216, i8* %217, i8* %219)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
221: ; preds = %207
br label %222
222: ; preds = %221, %190
%223 = load i8*, i8** %11
%224 = icmp ne i8* %223, null
br i1 %224, label %225, label %255
225: ; preds = %222
%226 = call i64 @close(i32 1)
%227 = icmp ne i64 %226, 0
br i1 %227, label %228, label %236
228: ; preds = %225
%229 = load i32*, i32** @stderr
%230 = load i8**, i8*** %5
%231 = getelementptr inbounds i8*, i8** %230, i64 0
%232 = load i8*, i8** %231
%233 = load i32, i32* @errno
%234 = call i8* @strerror(i32 %233)
%235 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %229, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %232, i8* %234)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
236: ; preds = %225
%237 = load i8*, i8** %11
%238 = load i32, i32* @O_CREAT
%239 = load i32, i32* @O_WRONLY
%240 = or i32 %238, %239
%241 = load i32, i32* @O_TRUNC
%242 = or i32 %240, %241
%243 = call i32 (i8*, i32, ...) @open(i8* %237, i32 %242, i32 511)
%244 = icmp slt i32 %243, 0
br i1 %244, label %245, label %254
245: ; preds = %236
%246 = load i32*, i32** @stderr
%247 = load i8**, i8*** %5
%248 = getelementptr inbounds i8*, i8** %247, i64 0
%249 = load i8*, i8** %248
%250 = load i8*, i8** %10
%251 = load i32, i32* @errno
%252 = call i8* @strerror(i32 %251)
%253 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %246, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %249, i8* %250, i8* %252)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
254: ; preds = %236
br label %255
255: ; preds = %254, %222
%256 = load i8*, i8** %12
%257 = icmp ne i8* %256, null
br i1 %257, label %258, label %307
258: ; preds = %255
%259 = load i8*, i8** %12
%260 = load i32, i32* @O_CREAT
%261 = load i32, i32* @O_WRONLY
%262 = or i32 %260, %261
%263 = load i32, i32* @O_TRUNC
%264 = or i32 %262, %263
%265 = call i32 (i8*, i32, ...) @open(i8* %259, i32 %264, i32 511)
store i32 %265, i32* %15
%266 = call i32 @dup(i32 2)
store i32 %266, i32* %16
%267 = load i32, i32* %16
%268 = icmp slt i32 %267, 0
br i1 %268, label %269, label %277
269: ; preds = %258
%270 = load i32*, i32** @stderr
%271 = load i8**, i8*** %5
%272 = getelementptr inbounds i8*, i8** %271, i64 0
%273 = load i8*, i8** %272
%274 = load i32, i32* @errno
%275 = call i8* @strerror(i32 %274)
%276 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %270, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %273, i8* %275)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
277: ; preds = %258
%278 = load i32, i32* %15
%279 = icmp slt i32 %278, 0
br i1 %279, label %280, label %289
280: ; preds = %277
%281 = load i32*, i32** @stderr
%282 = load i8**, i8*** %5
%283 = getelementptr inbounds i8*, i8** %282, i64 0
%284 = load i8*, i8** %283
%285 = load i8*, i8** %10
%286 = load i32, i32* @errno
%287 = call i8* @strerror(i32 %286)
%288 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %281, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %284, i8* %285, i8* %287)
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
289: ; preds = %277
%290 = load i32, i32* %15
%291 = call i64 @dup2(i32 %290, i32 2)
%292 = icmp slt i64 %291, 0
br i1 %292, label %293, label %306
293: ; preds = %289
%294 = load i32*, i32** @stderr
%295 = load i8**, i8*** %5
%296 = getelementptr inbounds i8*, i8** %295, i64 0
%297 = load i8*, i8** %296
%298 = load i32, i32* @errno
%299 = call i8* @strerror(i32 %298)
%300 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %294, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %297, i8* %299)
%301 = load i32, i32* %16
%302 = call i64 @write(i32 %301, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 22)
%303 = icmp ne i64 %302, 0
br i1 %303, label %304, label %305
304: ; preds = %293
br label %305
305: ; preds = %304, %293
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
306: ; preds = %289
br label %307
307: ; preds = %306, %255
%308 = load i8**, i8*** %5
%309 = getelementptr inbounds i8*, i8** %308, i64 1
%310 = load i8*, i8** %309
%311 = call i32 @execvp(i8* %310, i8** %21)
%312 = call i32* @popen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i32* %312, i32** %17
%313 = load i32*, i32** %17
%314 = icmp ne i32* %313, null
br i1 %314, label %333, label %315
315: ; preds = %307
%316 = load i32, i32* %13
%317 = icmp ne i32 %316, 0
br i1 %317, label %318, label %324
318: ; preds = %315
%319 = load i32, i32* %13
%320 = call i64 @write(i32 %319, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), i32 24)
%321 = icmp ne i64 %320, 0
br i1 %321, label %322, label %323
322: ; preds = %318
br label %323
323: ; preds = %322, %318
br label %332
324: ; preds = %315
%325 = load i32*, i32** @stderr
%326 = load i8**, i8*** %5
%327 = getelementptr inbounds i8*, i8** %326, i64 0
%328 = load i8*, i8** %327
%329 = load i32, i32* @errno
%330 = call i8* @strerror(i32 %329)
%331 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %325, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i8* %328, i8* %330)
br label %332
332: ; preds = %324, %323
store i32 1, i32* %3
store i32 1, i32* %14
br label %353
333: ; preds = %307
store i32 0, i32* %6
br label %334
334: ; preds = %347, %333
%335 = load i32, i32* %6
%336 = sext i32 %335 to i64
%337 = getelementptr inbounds i8*, i8** %21, i64 %336
%338 = load i8*, i8** %337
%339 = icmp ne i8* %338, null
br i1 %339, label %340, label %350
340: ; preds = %334
%341 = load i32*, i32** %17
%342 = load i32, i32* %6
%343 = sext i32 %342 to i64
%344 = getelementptr inbounds i8*, i8** %21, i64 %343
%345 = load i8*, i8** %344
%346 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %341, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %345)
br label %347
347: ; preds = %340
%348 = load i32, i32* %6
%349 = add nsw i32 %348, 1
store i32 %349, i32* %6
br label %334
350: ; preds = %334
%351 = load i32*, i32** %17
%352 = call i32 @pclose(i32* %351)
store i32 %352, i32* %3
store i32 1, i32* %14
br label %353
353: ; preds = %350, %332, %305, %280, %269, %245, %228, %212, %199, %164, %110, %66, %24
%354 = load i8*, i8** %8
%355 = load i32, i32* %3
ret i32 %355
}

LLVM IR (-O2):
@stderr = global i32* null
@.str = [34 x i8] c"%s: Takes at least one agrument!\0A\00"
@.str.1 = [30 x i8] c"%s: Missing filename after >\0A\00"
@.str.2 = [30 x i8] c"%s: Missing filename after <\0A\00"
@.str.3 = [31 x i8] c"%s: Missing filename after 2>\0A\00"
@.str.4 = [31 x i8] c"%s: Failed to close stdin: %s\0A\00"
@errno = global i32 0
@O_RDONLY = global i32 0
@.str.5 = [41 x i8] c"%s: Failed to open '%s' for reading: %s\0A\00"
@.str.6 = [32 x i8] c"%s: Failed to close stdout: %s\0A\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@.str.7 = [41 x i8] c"%s: Failed to open '%s' for writing: %s\0A\00"
@.str.8 = [32 x i8] c"%s: Failed to dup() stderr: %s\0A\00"
@.str.9 = [31 x i8] c"%s: Failed to dup2 stderr: %s\0A\00"
@.str.10 = [23 x i8] c"Failed to dup2 stderr\0A\00"
@.str.11 = [8 x i8] c"/bin/sh\00"
@.str.12 = [2 x i8] c"w\00"
@.str.14 = [33 x i8] c"%s: Failed to popen /bin/sh: %s\0A\00"
@.str.15 = [4 x i8] c"%s \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = zext i32 %0 to i64
%4 = alloca i8*, i64 %3
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i32*, i32** @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %189
10: ; preds = %2, %73
%11 = phi i32 [ %79, %73 ], [ 1, %2 ]
%12 = phi i32 [ %77, %73 ], [ 0, %2 ]
%13 = phi i8* [ %76, %73 ], [ null, %2 ]
%14 = phi i8* [ %75, %73 ], [ null, %2 ]
%15 = phi i8* [ %74, %73 ], [ null, %2 ]
%16 = sext i32 %11 to i64
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
switch i8 %19, label %69 [
i8 62, label %20
i8 60, label %35
i8 50, label %50
]
20: ; preds = %10
%21 = getelementptr inbounds i8, i8* %18, i64 1
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %73
24: ; preds = %20
%25 = add nsw i32 %11, 1
%26 = icmp slt i32 %25, %0
br i1 %26, label %31, label %27
27: ; preds = %24
%28 = load i32*, i32** @stderr
%29 = load i8*, i8** %1
%30 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %189
31: ; preds = %24
%32 = sext i32 %25 to i64
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
br label %73
35: ; preds = %10
%36 = getelementptr inbounds i8, i8* %18, i64 1
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
br i1 %38, label %39, label %73
39: ; preds = %35
%40 = add nsw i32 %11, 1
%41 = icmp slt i32 %40, %0
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = load i32*, i32** @stderr
%44 = load i8*, i8** %1
%45 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %44)
br label %189
46: ; preds = %39
%47 = sext i32 %40 to i64
%48 = getelementptr inbounds i8*, i8** %1, i64 %47
%49 = load i8*, i8** %48
br label %73
50: ; preds = %10
%51 = getelementptr inbounds i8, i8* %18, i64 1
%52 = load i8, i8* %51
%53 = icmp eq i8 %52, 62
br i1 %53, label %54, label %69
54: ; preds = %50
%55 = getelementptr inbounds i8, i8* %18, i64 2
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 0
br i1 %57, label %58, label %73
58: ; preds = %54
%59 = add nsw i32 %11, 1
%60 = icmp slt i32 %59, %0
br i1 %60, label %65, label %61
61: ; preds = %58
%62 = load i32*, i32** @stderr
%63 = load i8*, i8** %1
%64 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %62, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %63)
br label %189
65: ; preds = %58
%66 = sext i32 %59 to i64
%67 = getelementptr inbounds i8*, i8** %1, i64 %66
%68 = load i8*, i8** %67
br label %73
69: ; preds = %10, %50
%70 = add nsw i32 %12, 1
%71 = sext i32 %12 to i64
%72 = getelementptr inbounds i8*, i8** %4, i64 %71
store i8* %18, i8** %72
br label %73
73: ; preds = %54, %35, %20, %65, %46, %31, %69
%74 = phi i8* [ %34, %31 ], [ %15, %46 ], [ %15, %65 ], [ %15, %69 ], [ %21, %20 ], [ %15, %35 ], [ %15, %54 ]
%75 = phi i8* [ %14, %31 ], [ %14, %46 ], [ %68, %65 ], [ %14, %69 ], [ %14, %20 ], [ %14, %35 ], [ %55, %54 ]
%76 = phi i8* [ %13, %31 ], [ %49, %46 ], [ %13, %65 ], [ %13, %69 ], [ %13, %20 ], [ %36, %35 ], [ %13, %54 ]
%77 = phi i32 [ %12, %31 ], [ %12, %46 ], [ %12, %65 ], [ %70, %69 ], [ %12, %20 ], [ %12, %35 ], [ %12, %54 ]
%78 = phi i32 [ %25, %31 ], [ %40, %46 ], [ %59, %65 ], [ %11, %69 ], [ %11, %20 ], [ %11, %35 ], [ %11, %54 ]
%79 = add nsw i32 %78, 1
%80 = icmp slt i32 %79, %0
br i1 %80, label %10, label %81
81: ; preds = %73
%82 = sext i32 %77 to i64
%83 = getelementptr inbounds i8*, i8** %4, i64 %82
store i8* null, i8** %83
%84 = icmp eq i8* %76, null
br i1 %84, label %104, label %85
85: ; preds = %81
%86 = tail call i64 @close(i32 0)
%87 = icmp eq i64 %86, 0
br i1 %87, label %94, label %88
88: ; preds = %85
%89 = load i32*, i32** @stderr
%90 = load i8*, i8** %1
%91 = load i32, i32* @errno
%92 = tail call i8* @strerror(i32 %91)
%93 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %90, i8* %92)
br label %189
94: ; preds = %85
%95 = load i32, i32* @O_RDONLY
%96 = tail call i32 (i8*, i32, ...) @open(i8* %76, i32 %95)
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %104
98: ; preds = %94
%99 = load i32*, i32** @stderr
%100 = load i8*, i8** %1
%101 = load i32, i32* @errno
%102 = tail call i8* @strerror(i32 %101)
%103 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %99, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i8* %100, i8* %76, i8* %102)
br label %189
104: ; preds = %94, %81
%105 = icmp eq i8* %74, null
br i1 %105, label %129, label %106
106: ; preds = %104
%107 = tail call i64 @close(i32 1)
%108 = icmp eq i64 %107, 0
br i1 %108, label %115, label %109
109: ; preds = %106
%110 = load i32*, i32** @stderr
%111 = load i8*, i8** %1
%112 = load i32, i32* @errno
%113 = tail call i8* @strerror(i32 %112)
%114 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %110, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %111, i8* %113)
br label %189
115: ; preds = %106
%116 = load i32, i32* @O_CREAT
%117 = load i32, i32* @O_WRONLY
%118 = or i32 %117, %116
%119 = load i32, i32* @O_TRUNC
%120 = or i32 %118, %119
%121 = tail call i32 (i8*, i32, ...) @open(i8* %74, i32 %120, i32 511)
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %129
123: ; preds = %115
%124 = load i32*, i32** @stderr
%125 = load i8*, i8** %1
%126 = load i32, i32* @errno
%127 = tail call i8* @strerror(i32 %126)
%128 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %124, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %125, i8* %76, i8* %127)
br label %189
129: ; preds = %115, %104
%130 = icmp eq i8* %75, null
br i1 %130, label %164, label %131
131: ; preds = %129
%132 = load i32, i32* @O_CREAT
%133 = load i32, i32* @O_WRONLY
%134 = or i32 %133, %132
%135 = load i32, i32* @O_TRUNC
%136 = or i32 %134, %135
%137 = tail call i32 (i8*, i32, ...) @open(i8* %75, i32 %136, i32 511)
%138 = tail call i32 @dup(i32 2)
%139 = icmp slt i32 %138, 0
br i1 %139, label %140, label %146
140: ; preds = %131
%141 = load i32*, i32** @stderr
%142 = load i8*, i8** %1
%143 = load i32, i32* @errno
%144 = tail call i8* @strerror(i32 %143)
%145 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %141, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0), i8* %142, i8* %144)
br label %189
146: ; preds = %131
%147 = icmp slt i32 %137, 0
br i1 %147, label %148, label %154
148: ; preds = %146
%149 = load i32*, i32** @stderr
%150 = load i8*, i8** %1
%151 = load i32, i32* @errno
%152 = tail call i8* @strerror(i32 %151)
%153 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %149, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i8* %150, i8* %76, i8* %152)
br label %189
154: ; preds = %146
%155 = tail call i64 @dup2(i32 %137, i32 2)
%156 = icmp slt i64 %155, 0
br i1 %156, label %157, label %164
157: ; preds = %154
%158 = load i32*, i32** @stderr
%159 = load i8*, i8** %1
%160 = load i32, i32* @errno
%161 = tail call i8* @strerror(i32 %160)
%162 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %158, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i8* %159, i8* %161)
%163 = tail call i64 @write(i32 %138, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0), i32 22)
br label %189
164: ; preds = %154, %129
%165 = getelementptr inbounds i8*, i8** %1, i64 1
%166 = load i8*, i8** %165
%167 = call i32 @execvp(i8* %166, i8** %4)
%168 = call i32* @popen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%169 = icmp eq i32* %168, null
br i1 %169, label %173, label %170
170: ; preds = %164
%171 = load i8*, i8** %4
%172 = icmp eq i8* %171, null
br i1 %172, label %187, label %179
173: ; preds = %164
%174 = load i32*, i32** @stderr
%175 = load i8*, i8** %1
%176 = load i32, i32* @errno
%177 = call i8* @strerror(i32 %176)
%178 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %174, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.14, i64 0, i64 0), i8* %175, i8* %177)
br label %189
179: ; preds = %170, %179
%180 = phi i64 [ %183, %179 ], [ 0, %170 ]
%181 = phi i8* [ %185, %179 ], [ %171, %170 ]
%182 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %168, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.15, i64 0, i64 0), i8* %181)
%183 = add nuw i64 %180, 1
%184 = getelementptr inbounds i8*, i8** %4, i64 %183
%185 = load i8*, i8** %184
%186 = icmp eq i8* %185, null
br i1 %186, label %187, label %179
187: ; preds = %179, %170
%188 = call i32 @pclose(i32* %168)
br label %189
189: ; preds = %140, %148, %157, %173, %187, %123, %109, %98, %88, %61, %42, %27, %6
%190 = phi i32 [ 1, %6 ], [ 1, %27 ], [ 1, %42 ], [ 1, %61 ], [ 1, %88 ], [ 1, %98 ], [ 1, %109 ], [ 1, %123 ], [ %188, %187 ], [ 1, %173 ], [ 1, %157 ], [ 1, %148 ], [ 1, %140 ]
ret i32 %190
}