#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 */

/* Variables and functions */
int BUFSIZ;
scalar_t__ EINTR;
int WEXITSTATUS(int);
int /*<<< orphan*/ close(int);
int dup(int);
scalar_t__ errno;
int /*<<< orphan*/ execvp(char *, char **);
int fileno(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int wait(int *);
int main(int argc, char **argv) {
  int p[2];
  int f;
  if (argc < 2) {
    fprintf(stderr, "%s: specify a command to execute\n", argv[0]);
    return 1;
  }
  if (pipe(p) != 0) {
    fprintf(stderr,
            "%s: "
            "pipe"
            "() failed: %s\n",
            argv[0], strerror(errno));
    return 1;
  };
  f = fork();
  if (f == -1) {
    fprintf(stderr,
            "%s: "
            "fork"
            "() failed: %s\n",
            argv[0], strerror(errno));
    return 1;
  };
  if (f) {
    int status;
    close(p[1]);
  again:
    errno = 0;
    while (1) {
      int r;
      char buf[BUFSIZ];
      r = read(p[0], buf, BUFSIZ - 1);
      if (r <= 0)
        break;
      buf[r] = 0;
      fprintf(stderr, "%s%s%s", "\033[91m", buf, "\033[0m");
    }
    if (errno == EINTR) {
      fprintf(stderr, "%s: read interrupted, trying again\n", argv[0]);
      goto again;
    }
    if (errno != 0) {
      fprintf(stderr,
              "%s: "
              "read"
              "() failed: %s\n",
              argv[0], strerror(errno));
      return 1;
    };
    if (wait(&status) != f) {
      fprintf(stderr,
              "%s: "
              "wait"
              "() failed: %s\n",
              argv[0], strerror(errno));
      return 1;
    };
    return WEXITSTATUS(status);
  } else {
    int fd;
    close(p[0]);
    close(fileno(stderr));
    fd = dup(p[1]);
    if (fd < 0) {
      printf("%s: dup() failed: %s\n", argv[0], strerror(errno));
      return 1;
    }
    if (fd != fileno(stderr)) {
      printf("%s: dup returned %d instead of %d\n", argv[0], fd,
             fileno(stderr));
      return 1;
    }
    execvp(argv[1], &argv[1]);
    {
      fprintf(stderr,
              "%s: "
              "exec"
              "() failed: %s\n",
              argv[0], strerror(errno));
      return 1;
    };
  }
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    120d <main+0x4d>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
lea    -0x18(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0x0,%rax
je     126a <main+0xaa>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xdcb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12c8 <main+0x108>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d34(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
cmpl   $0x0,-0x1c(%rbp)
je     14a4 <main+0x2e4>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    0x2cef(%rip),%rax
movq   $0x0,(%rax)
mov    0x2ce9(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x68(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%edi
mov    0x2cba(%rip),%rax
mov    (%rax),%edx
sub    $0x1,%edx
call   1070 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     1341 <main+0x181>
movl   $0x4,-0x3c(%rbp)
jmp    1379 <main+0x1b9>
mov    -0x68(%rbp),%rcx
movslq -0x24(%rbp),%rax
movb   $0x0,(%rcx,%rax,1)
mov    0x2c8c(%rip),%rax
mov    (%rax),%edi
lea    0xcf3(%rip),%rsi
lea    0xcf3(%rip),%rdx
lea    0xcf2(%rip),%r8
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x3c(%rbp),%eax
test   %eax,%eax
je     1395 <main+0x1d5>
jmp    1390 <main+0x1d0>
jmp    139a <main+0x1da>
jmp    12e8 <main+0x128>
mov    0x2c2f(%rip),%rax
mov    (%rax),%rax
mov    0x2c1d(%rip),%rcx
cmp    (%rcx),%rax
jne    13d7 <main+0x217>
mov    0x2c25(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc97(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12da <main+0x11a>
mov    0x2bf2(%rip),%rax
cmpq   $0x0,(%rax)
je     1432 <main+0x272>
mov    0x2bf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2bca(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xc67(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
lea    -0x20(%rbp),%rdi
call   10d0 <wait@plt>
cmp    -0x1c(%rbp),%eax
je     1494 <main+0x2d4>
mov    0x2b95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
mov    0x2b6b(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
lea    0xc1c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
mov    -0x20(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
mov    %eax,-0x4(%rbp)
jmp    15f2 <main+0x432>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
call   1090 <fileno@plt>
mov    %eax,%edi
call   1050 <close@plt>
mov    -0x14(%rbp),%edi
call   1040 <dup@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    1517 <main+0x357>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
mov    0x2ae5(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0x90(%rbp),%rsi
mov    %rax,%rdx
lea    0xbb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
mov    -0x40(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    0x2ab9(%rip),%rax
mov    (%rax),%edi
call   1090 <fileno@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
je     158c <main+0x3cc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    0x2a84(%rip),%rax
mov    (%rax),%edi
call   1090 <fileno@plt>
mov    -0xa0(%rbp),%rsi
mov    -0x98(%rbp),%edx
mov    %eax,%ecx
lea    0xb51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f2 <main+0x432>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   10b0 <execvp@plt>
mov    0x2a38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    0x2a0b(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rdx
mov    %rax,%rcx
lea    0xb09(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
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
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11f5 <main+0x35>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe14(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1236 <main+0x76>
lea    -0x30(%rbp),%rdi
call   1060 <pipe@plt>
test   %rax,%rax
je     124a <main+0x8a>
mov    0x2dd6(%rip),%rax
mov    (%rax),%r15d
mov    (%rbx),%r14
mov    0x2db9(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xdfc(%rip),%rsi
mov    %r15d,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     1283 <main+0xc3>
cmp    $0xffffffff,%eax
jne    12f3 <main+0x133>
mov    0x2d7b(%rip),%rax
mov    (%rax),%r15d
mov    (%rbx),%r14
mov    0x2d5e(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xdb8(%rip),%rsi
jmp    1226 <main+0x66>
mov    -0x30(%rbp),%edi
call   1050 <close@plt>
mov    0x2d4e(%rip),%r15
mov    (%r15),%edi
call   1090 <fileno@plt>
mov    %eax,%edi
call   1050 <close@plt>
mov    -0x2c(%rbp),%edi
call   1040 <dup@plt>
test   %eax,%eax
js     141f <main+0x25f>
mov    %eax,%r12d
mov    (%r15),%edi
call   1090 <fileno@plt>
cmp    %eax,%r12d
jne    1465 <main+0x2a5>
lea    0x8(%rbx),%rsi
mov    0x8(%rbx),%rdi
call   10b0 <execvp@plt>
mov    (%r15),%r15d
mov    (%rbx),%r14
mov    0x2cf1(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xdff(%rip),%rsi
jmp    1226 <main+0x66>
mov    %eax,-0x3c(%rbp)
mov    %rbx,-0x38(%rbp)
mov    -0x2c(%rbp),%edi
call   1050 <close@plt>
mov    0x2cc7(%rip),%rbx
mov    0x2cc8(%rip),%r12
lea    0xd40(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rsp,%r13
movq   $0x0,(%rbx)
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x30(%rbp),%edi
mov    (%r12),%edx
add    $0xffffffff,%edx
mov    %r15,%rsi
call   1070 <read@plt>
mov    %r14,%rbx
test   %eax,%eax
jle    13b8 <main+0x1f8>
lea    0xcfe(%rip),%r14
nop
mov    %eax,%eax
movb   $0x0,(%r15,%rax,1)
mov    0x2c72(%rip),%rax
mov    (%rax),%edi
lea    0xcd9(%rip),%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13,%rsp
mov    %rsp,%r13
mov    (%r12),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x30(%rbp),%edi
mov    (%r12),%edx
add    $0xffffffff,%edx
mov    %r15,%rsi
call   1070 <read@plt>
test   %eax,%eax
jg     1360 <main+0x1a0>
mov    %rbx,%r14
mov    %r13,%rsp
mov    0x2c0b(%rip),%rbx
mov    (%rbx),%rdi
mov    0x2bf9(%rip),%rax
cmp    (%rax),%rdi
jne    13f7 <main+0x237>
mov    0x2c05(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
lea    0xc77(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1320 <main+0x160>
test   %rdi,%rdi
je     144a <main+0x28a>
mov    0x2bdd(%rip),%rax
mov    (%rax),%ebx
mov    -0x38(%rbp),%rax
mov    (%rax),%r14
call   10c0 <strerror@plt>
lea    0xc6e(%rip),%rsi
mov    %ebx,%edi
jmp    1229 <main+0x69>
mov    (%rbx),%rbx
mov    0x2ba7(%rip),%rax
mov    (%rax),%rdi
call   10c0 <strerror@plt>
lea    0xc7c(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1236 <main+0x76>
lea    -0x40(%rbp),%rdi
call   10d0 <wait@plt>
cmp    -0x3c(%rbp),%eax
jne    148b <main+0x2cb>
mov    -0x40(%rbp),%edi
call   10a0 <WEXITSTATUS@plt>
jmp    123b <main+0x7b>
mov    (%rbx),%r14
mov    (%r15),%edi
call   1090 <fileno@plt>
lea    0xc53(%rip),%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1236 <main+0x76>
mov    0x2b4e(%rip),%rax
mov    (%rax),%r15d
mov    -0x38(%rbp),%rax
mov    (%rax),%r14
mov    (%rbx),%rdi
call   10c0 <strerror@plt>
lea    0xbf2(%rip),%rsi
jmp    1226 <main+0x66>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"%s: specify a command to execute\0A\00"
@.str.1 = [23 x i8] c"%s: pipe() failed: %s\0A\00"
@errno = global i64 0
@.str.2 = [23 x i8] c"%s: fork() failed: %s\0A\00"
@BUFSIZ = global i32 0
@.str.3 = [7 x i8] c"%s%s%s\00"
@.str.4 = [6 x i8] c"\1B[91m\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
@EINTR = global i64 0
@.str.6 = [36 x i8] c"%s: read interrupted, trying again\0A\00"
@.str.7 = [23 x i8] c"%s: read() failed: %s\0A\00"
@.str.8 = [23 x i8] c"%s: wait() failed: %s\0A\00"
@.str.9 = [22 x i8] c"%s: dup() failed: %s\0A\00"
@.str.10 = [35 x i8] c"%s: dup returned %d instead of %d\0A\00"
@.str.11 = [23 x i8] c"%s: exec() failed: %s\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 i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 1, i32* %3
br label %159
22: ; preds = %2
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%24 = call i64 @pipe(i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = load i64, i64* @errno
%32 = call i8* @strerror(i64 %31)
%33 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %32)
store i32 1, i32* %3
br label %159
34: ; preds = %22
%35 = call i32 (...) @fork()
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = load i64, i64* @errno
%44 = call i8* @strerror(i64 %43)
%45 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %44)
store i32 1, i32* %3
br label %159
46: ; preds = %34
%47 = load i32, i32* %7
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %113
49: ; preds = %46
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%51 = load i32, i32* %50
%52 = call i32 @close(i32 %51)
br label %53
53: ; preds = %81, %49
store i64 0, i64* @errno
br label %54
54: ; preds = %53, %76
%55 = load i32, i32* @BUFSIZ
%56 = zext i32 %55 to i64
%57 = call i8* @llvm.stacksave()
store i8* %57, i8** %10
%58 = alloca i8, i64 %56
store i64 %56, i64* %11
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%60 = load i32, i32* %59
%61 = load i32, i32* @BUFSIZ
%62 = sub nsw i32 %61, 1
%63 = call i32 @read(i32 %60, i8* %58, i32 %62)
store i32 %63, i32* %9
%64 = load i32, i32* %9
%65 = icmp sle i32 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %54
store i32 4, i32* %12
br label %73
67: ; preds = %54
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %58, i64 %69
store i8 0, i8* %70
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %12
br label %73
73: ; preds = %67, %66
%74 = load i8*, i8** %10
%75 = load i32, i32* %12
switch i32 %75, label %161 [
i32 0, label %76
i32 4, label %77
]
76: ; preds = %73
br label %54
77: ; preds = %73
%78 = load i64, i64* @errno
%79 = load i64, i64* @EINTR
%80 = icmp eq i64 %78, %79
br i1 %80, label %81, label %87
81: ; preds = %77
%82 = load i32, i32* @stderr
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 0
%85 = load i8*, i8** %84
%86 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %82, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %85)
br label %53
87: ; preds = %77
%88 = load i64, i64* @errno
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %98
90: ; preds = %87
%91 = load i32, i32* @stderr
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 0
%94 = load i8*, i8** %93
%95 = load i64, i64* @errno
%96 = call i8* @strerror(i64 %95)
%97 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %94, i8* %96)
store i32 1, i32* %3
br label %159
98: ; preds = %87
%99 = call i32 @wait(i32* %8)
%100 = load i32, i32* %7
%101 = icmp ne i32 %99, %100
br i1 %101, label %102, label %110
102: ; preds = %98
%103 = load i32, i32* @stderr
%104 = load i8**, i8*** %5
%105 = getelementptr inbounds i8*, i8** %104, i64 0
%106 = load i8*, i8** %105
%107 = load i64, i64* @errno
%108 = call i8* @strerror(i64 %107)
%109 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %106, i8* %108)
store i32 1, i32* %3
br label %159
110: ; preds = %98
%111 = load i32, i32* %8
%112 = call i32 @WEXITSTATUS(i32 %111)
store i32 %112, i32* %3
br label %159
113: ; preds = %46
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%115 = load i32, i32* %114
%116 = call i32 @close(i32 %115)
%117 = load i32, i32* @stderr
%118 = call i32 @fileno(i32 %117)
%119 = call i32 @close(i32 %118)
%120 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%121 = load i32, i32* %120
%122 = call i32 @dup(i32 %121)
store i32 %122, i32* %13
%123 = load i32, i32* %13
%124 = icmp slt i32 %123, 0
br i1 %124, label %125, label %132
125: ; preds = %113
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 0
%128 = load i8*, i8** %127
%129 = load i64, i64* @errno
%130 = call i8* @strerror(i64 %129)
%131 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %128, i8* %130)
store i32 1, i32* %3
br label %159
132: ; preds = %113
%133 = load i32, i32* %13
%134 = load i32, i32* @stderr
%135 = call i32 @fileno(i32 %134)
%136 = icmp ne i32 %133, %135
br i1 %136, label %137, label %145
137: ; preds = %132
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 0
%140 = load i8*, i8** %139
%141 = load i32, i32* %13
%142 = load i32, i32* @stderr
%143 = call i32 @fileno(i32 %142)
%144 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i8* %140, i32 %141, i32 %143)
store i32 1, i32* %3
br label %159
145: ; preds = %132
%146 = load i8**, i8*** %5
%147 = getelementptr inbounds i8*, i8** %146, i64 1
%148 = load i8*, i8** %147
%149 = load i8**, i8*** %5
%150 = getelementptr inbounds i8*, i8** %149, i64 1
%151 = call i32 @execvp(i8* %148, i8** %150)
%152 = load i32, i32* @stderr
%153 = load i8**, i8*** %5
%154 = getelementptr inbounds i8*, i8** %153, i64 0
%155 = load i8*, i8** %154
%156 = load i64, i64* @errno
%157 = call i8* @strerror(i64 %156)
%158 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %152, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %155, i8* %157)
store i32 1, i32* %3
br label %159
159: ; preds = %145, %137, %125, %110, %102, %90, %38, %26, %16
%160 = load i32, i32* %3
ret i32 %160
161: ; preds = %73
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"%s: specify a command to execute\0A\00"
@.str.1 = [23 x i8] c"%s: pipe() failed: %s\0A\00"
@errno = global i64 0
@.str.2 = [23 x i8] c"%s: fork() failed: %s\0A\00"
@BUFSIZ = global i32 0
@.str.3 = [7 x i8] c"%s%s%s\00"
@.str.4 = [6 x i8] c"\1B[91m\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
@EINTR = global i64 0
@.str.6 = [36 x i8] c"%s: read interrupted, trying again\0A\00"
@.str.7 = [23 x i8] c"%s: read() failed: %s\0A\00"
@.str.8 = [23 x i8] c"%s: wait() failed: %s\0A\00"
@.str.9 = [22 x i8] c"%s: dup() failed: %s\0A\00"
@.str.10 = [35 x i8] c"%s: dup returned %d instead of %d\0A\00"
@.str.11 = [23 x i8] c"%s: exec() failed: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = bitcast [2 x i32]* %3 to i8*
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %124
11: ; preds = %2
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = call i64 @pipe(i32* %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = load i64, i64* @errno
%19 = call i8* @strerror(i64 %18)
%20 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %19)
br label %124
21: ; preds = %11
%22 = call i32 (...) @fork()
switch i32 %22, label %29 [
i32 -1, label %23
i32 0, label %91
]
23: ; preds = %21
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %1
%26 = load i64, i64* @errno
%27 = call i8* @strerror(i64 %26)
%28 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %25, i8* %27)
br label %124
29: ; preds = %21
%30 = bitcast i32* %4 to i8*
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%32 = load i32, i32* %31
%33 = call i32 @close(i32 %32)
br label %34
34: ; preds = %66, %29
store i64 0, i64* @errno
%35 = load i32, i32* @BUFSIZ
%36 = zext i32 %35 to i64
%37 = call i8* @llvm.stacksave()
%38 = alloca i8, i64 %36
%39 = load i32, i32* %12
%40 = load i32, i32* @BUFSIZ
%41 = add nsw i32 %40, -1
%42 = call i32 @read(i32 %39, i8* %38, i32 %41)
%43 = icmp slt i32 %42, 1
br i1 %43, label %61, label %44
44: ; preds = %34, %44
%45 = phi i32 [ %59, %44 ], [ %42, %34 ]
%46 = phi i8* [ %55, %44 ], [ %38, %34 ]
%47 = phi i8* [ %54, %44 ], [ %37, %34 ]
%48 = zext i32 %45 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 0, i8* %49
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%52 = load i32, i32* @BUFSIZ
%53 = zext i32 %52 to i64
%54 = call i8* @llvm.stacksave()
%55 = alloca i8, i64 %53
%56 = load i32, i32* %12
%57 = load i32, i32* @BUFSIZ
%58 = add nsw i32 %57, -1
%59 = call i32 @read(i32 %56, i8* %55, i32 %58)
%60 = icmp slt i32 %59, 1
br i1 %60, label %61, label %44
61: ; preds = %44, %34
%62 = phi i8* [ %37, %34 ], [ %54, %44 ]
%63 = load i64, i64* @errno
%64 = load i64, i64* @EINTR
%65 = icmp eq i64 %63, %64
br i1 %65, label %66, label %70
66: ; preds = %61
%67 = load i32, i32* @stderr
%68 = load i8*, i8** %1
%69 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %68)
br label %34
70: ; preds = %61
%71 = icmp eq i64 %63, 0
br i1 %71, label %77, label %72
72: ; preds = %70
%73 = load i32, i32* @stderr
%74 = load i8*, i8** %1
%75 = call i8* @strerror(i64 %63)
%76 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i8* %74, i8* %75)
br label %89
77: ; preds = %70
%78 = call i32 @wait(i32* %4)
%79 = icmp eq i32 %78, %22
br i1 %79, label %86, label %80
80: ; preds = %77
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %1
%83 = load i64, i64* @errno
%84 = call i8* @strerror(i64 %83)
%85 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %82, i8* %84)
br label %89
86: ; preds = %77
%87 = load i32, i32* %4
%88 = call i32 @WEXITSTATUS(i32 %87)
br label %89
89: ; preds = %86, %80, %72
%90 = phi i32 [ 1, %72 ], [ 1, %80 ], [ %88, %86 ]
br label %124
91: ; preds = %21
%92 = load i32, i32* %12
%93 = call i32 @close(i32 %92)
%94 = load i32, i32* @stderr
%95 = call i32 @fileno(i32 %94)
%96 = call i32 @close(i32 %95)
%97 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%98 = load i32, i32* %97
%99 = call i32 @dup(i32 %98)
%100 = icmp slt i32 %99, 0
br i1 %100, label %101, label %106
101: ; preds = %91
%102 = load i8*, i8** %1
%103 = load i64, i64* @errno
%104 = call i8* @strerror(i64 %103)
%105 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0), i8* %102, i8* %104)
br label %124
106: ; preds = %91
%107 = load i32, i32* @stderr
%108 = call i32 @fileno(i32 %107)
%109 = icmp eq i32 %99, %108
br i1 %109, label %115, label %110
110: ; preds = %106
%111 = load i8*, i8** %1
%112 = load i32, i32* @stderr
%113 = call i32 @fileno(i32 %112)
%114 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.10, i64 0, i64 0), i8* %111, i32 %99, i32 %113)
br label %124
115: ; preds = %106
%116 = getelementptr inbounds i8*, i8** %1, i64 1
%117 = load i8*, i8** %116
%118 = call i32 @execvp(i8* %117, i8** %116)
%119 = load i32, i32* @stderr
%120 = load i8*, i8** %1
%121 = load i64, i64* @errno
%122 = call i8* @strerror(i64 %121)
%123 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %120, i8* %122)
br label %124
124: ; preds = %101, %110, %115, %89, %23, %15, %7
%125 = phi i32 [ 1, %7 ], [ 1, %15 ], [ 1, %23 ], [ %90, %89 ], [ 1, %115 ], [ 1, %110 ], [ 1, %101 ]
ret i32 %125
}