#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int STDIN_FILENO;
int STDOUT_FILENO;
int close(int);
int dup2(int, int);
int /*<<< orphan*/ execlp(char *, char *, char *, ...);
int fork();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int wait(int /*<<< orphan*/ *);
int main() {
  int fds[2];
  if (pipe(fds) == -1) {
    perror("pipe");
    return EXIT_FAILURE;
  }
  switch (fork()) {
  case -1:
    perror("fork1");
    return EXIT_FAILURE;
  case 0:
    if (close(fds[0]) == -1) {
      perror("close 1");
      return EXIT_FAILURE;
    }
    if (fds[1] != STDOUT_FILENO) {
      if (dup2(fds[1], STDOUT_FILENO) == -1) {
        perror("dup2 1");
        return EXIT_FAILURE;
      }
      if (close(fds[1]) == -1) {
        perror("close 2");
        return EXIT_FAILURE;
      }
    }
    execlp("ls", "ls", (char *)NULL);
    return EXIT_FAILURE;
  default:
    break;
  }
  switch (fork()) {
  case -1:
    perror("fork2");
    return EXIT_FAILURE;
  case 0:
    if (close(fds[1]) == -1) {
      perror("close 3");
      return EXIT_FAILURE;
    }
    if (fds[0] != STDIN_FILENO) {
      if (dup2(fds[0], STDIN_FILENO) == -1) {
        perror("dup2 2");
        return EXIT_FAILURE;
      }
      if (close(fds[0]) == -1) {
        perror("close 4");
        return EXIT_FAILURE;
      }
    }
    execlp("wc", "wc", "-l", (char *)NULL);
    return EXIT_FAILURE;
  default:
    break;
  }
  if (close(fds[0]) == -1) {
    perror("close 5");
    return EXIT_FAILURE;
  }
  if (close(fds[1]) == -1) {
    perror("close 6");
    return EXIT_FAILURE;
  }
  if (wait(NULL) == -1) {
    perror("wait 1");
    return EXIT_FAILURE;
  }
  if (wait(NULL) == -1) {
    perror("wait 2");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <pipe@plt>
cmp    $0xffffffff,%eax
jne    11ae <main+0x3e>
lea    0xe68(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
xor    %eax,%eax
call   1090 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
sub    $0xffffffff,%eax
je     11d8 <main+0x68>
jmp    11c8 <main+0x58>
mov    -0x10(%rbp),%eax
test   %eax,%eax
je     11f5 <main+0x85>
jmp    12c5 <main+0x155>
lea    0xe26(%rip),%rdi
call   1060 <perror@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    1223 <main+0xb3>
lea    0xdfe(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0x8(%rbp),%eax
mov    0x2dc3(%rip),%rcx
cmp    (%rcx),%eax
je     129f <main+0x12f>
mov    -0x8(%rbp),%edi
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    126c <main+0xfc>
lea    0xdbd(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    129a <main+0x12a>
lea    0xd96(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
jmp    129f <main+0x12f>
lea    0xd7c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    %rsi,%rdi
mov    $0x0,%al
call   1070 <execlp@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
jmp    12ca <main+0x15a>
xor    %eax,%eax
call   1090 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0xffffffff,%eax
je     12f4 <main+0x184>
jmp    12e4 <main+0x174>
mov    -0x14(%rbp),%eax
test   %eax,%eax
je     1311 <main+0x1a1>
jmp    13e8 <main+0x278>
lea    0xd2a(%rip),%rdi
call   1060 <perror@plt>
mov    0x2cd1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    133f <main+0x1cf>
lea    0xd02(%rip),%rdi
call   1060 <perror@plt>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0xc(%rbp),%eax
mov    0x2c7f(%rip),%rcx
cmp    (%rcx),%eax
je     13bb <main+0x24b>
mov    -0xc(%rbp),%edi
mov    0x2c6d(%rip),%rax
mov    (%rax),%esi
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
jne    1388 <main+0x218>
lea    0xcc1(%rip),%rdi
call   1060 <perror@plt>
mov    0x2c5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    13b6 <main+0x246>
lea    0xc9a(%rip),%rdi
call   1060 <perror@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
jmp    13bb <main+0x24b>
lea    0xc80(%rip),%rsi
lea    0xc7c(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
mov    $0x0,%al
call   1070 <execlp@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
jmp    13ed <main+0x27d>
mov    -0xc(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    141b <main+0x2ab>
lea    0xc43(%rip),%rdi
call   1060 <perror@plt>
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
jne    1449 <main+0x2d9>
lea    0xc1d(%rip),%rdi
call   1060 <perror@plt>
mov    0x2b99(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
jne    1478 <main+0x308>
lea    0xbf6(%rip),%rdi
call   1060 <perror@plt>
mov    0x2b6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
jne    14a7 <main+0x337>
lea    0xbce(%rip),%rdi
call   1060 <perror@plt>
mov    0x2b3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14b3 <main+0x343>
mov    0x2b22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
call   1050 <pipe@plt>
cmp    $0xffffffff,%eax
je     12b0 <main+0x140>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     11fd <main+0x8d>
cmp    $0xffffffff,%eax
je     12b9 <main+0x149>
xor    %eax,%eax
call   1090 <fork@plt>
test   %eax,%eax
je     1257 <main+0xe7>
cmp    $0xffffffff,%eax
je     12cb <main+0x15b>
mov    (%rsp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     12d4 <main+0x164>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     12ef <main+0x17f>
xor    %edi,%edi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
je     12f8 <main+0x188>
xor    %edi,%edi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
je     130a <main+0x19a>
mov    0x2dd8(%rip),%rax
jmp    132f <main+0x1bf>
mov    (%rsp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     12c2 <main+0x152>
mov    0x4(%rsp),%edi
mov    0x2dd7(%rip),%rax
mov    (%rax),%esi
cmp    %esi,%edi
je     123f <main+0xcf>
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
je     12e6 <main+0x176>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     1301 <main+0x191>
lea    0xddc(%rip),%rdi
mov    %rdi,%rsi
xor    %edx,%edx
xor    %eax,%eax
call   1070 <execlp@plt>
jmp    1328 <main+0x1b8>
mov    0x4(%rsp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     12dd <main+0x16d>
mov    (%rsp),%edi
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
cmp    %esi,%edi
je     1294 <main+0x124>
call   1030 <dup2@plt>
cmp    $0xffffffff,%eax
je     1313 <main+0x1a3>
mov    (%rsp),%edi
call   1040 <close@plt>
cmp    $0xffffffff,%eax
je     131c <main+0x1ac>
lea    0xda7(%rip),%rdi
lea    0xda3(%rip),%rdx
mov    %rdi,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1070 <execlp@plt>
jmp    1328 <main+0x1b8>
lea    0xd49(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd45(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd42(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd53(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd6d(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd47(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd26(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd5a(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd59(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd12(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd4e(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd19(%rip),%rdi
jmp    1323 <main+0x1b3>
lea    0xd17(%rip),%rdi
call   1060 <perror@plt>
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"pipe\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"fork1\00"
@.str.2 = [8 x i8] c"close 1\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [7 x i8] c"dup2 1\00"
@.str.4 = [8 x i8] c"close 2\00"
@.str.5 = [3 x i8] c"ls\00"
@.str.6 = [6 x i8] c"fork2\00"
@.str.7 = [8 x i8] c"close 3\00"
@STDIN_FILENO = global i32 0
@.str.8 = [7 x i8] c"dup2 2\00"
@.str.9 = [8 x i8] c"close 4\00"
@.str.10 = [3 x i8] c"wc\00"
@.str.11 = [3 x i8] c"-l\00"
@.str.12 = [8 x i8] c"close 5\00"
@.str.13 = [8 x i8] c"close 6\00"
@.str.14 = [7 x i8] c"wait 1\00"
@.str.15 = [7 x i8] c"wait 2\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
store i32 0, i32* %1
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%4 = call i32 @pipe(i32* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
store i32 %8, i32* %1
br label %119
9: ; preds = %0
%10 = call i32 (...) @fork()
switch i32 %10, label %48 [
i32 -1, label %11
i32 0, label %14
]
11: ; preds = %9
%12 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %1
br label %119
14: ; preds = %9
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%16 = load i32, i32* %15
%17 = call i32 @close(i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %1
br label %119
22: ; preds = %14
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%24 = load i32, i32* %23
%25 = load i32, i32* @STDOUT_FILENO
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %45
27: ; preds = %22
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%29 = load i32, i32* %28
%30 = load i32, i32* @STDOUT_FILENO
%31 = call i32 @dup2(i32 %29, i32 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
store i32 %35, i32* %1
br label %119
36: ; preds = %27
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%38 = load i32, i32* %37
%39 = call i32 @close(i32 %38)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %36
%42 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
store i32 %43, i32* %1
br label %119
44: ; preds = %36
br label %45
45: ; preds = %44, %22
%46 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* null)
%47 = load i32, i32* @EXIT_FAILURE
store i32 %47, i32* %1
br label %119
48: ; preds = %9
br label %49
49: ; preds = %48
%50 = call i32 (...) @fork()
switch i32 %50, label %88 [
i32 -1, label %51
i32 0, label %54
]
51: ; preds = %49
%52 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%53 = load i32, i32* @EXIT_FAILURE
store i32 %53, i32* %1
br label %119
54: ; preds = %49
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%56 = load i32, i32* %55
%57 = call i32 @close(i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %62
59: ; preds = %54
%60 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%61 = load i32, i32* @EXIT_FAILURE
store i32 %61, i32* %1
br label %119
62: ; preds = %54
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%64 = load i32, i32* %63
%65 = load i32, i32* @STDIN_FILENO
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %85
67: ; preds = %62
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%69 = load i32, i32* %68
%70 = load i32, i32* @STDIN_FILENO
%71 = call i32 @dup2(i32 %69, i32 %70)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %76
73: ; preds = %67
%74 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
store i32 %75, i32* %1
br label %119
76: ; preds = %67
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%78 = load i32, i32* %77
%79 = call i32 @close(i32 %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %84
81: ; preds = %76
%82 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%83 = load i32, i32* @EXIT_FAILURE
store i32 %83, i32* %1
br label %119
84: ; preds = %76
br label %85
85: ; preds = %84, %62
%86 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* null)
%87 = load i32, i32* @EXIT_FAILURE
store i32 %87, i32* %1
br label %119
88: ; preds = %49
br label %89
89: ; preds = %88
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%91 = load i32, i32* %90
%92 = call i32 @close(i32 %91)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %97
94: ; preds = %89
%95 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%96 = load i32, i32* @EXIT_FAILURE
store i32 %96, i32* %1
br label %119
97: ; preds = %89
%98 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%99 = load i32, i32* %98
%100 = call i32 @close(i32 %99)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %105
102: ; preds = %97
%103 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%104 = load i32, i32* @EXIT_FAILURE
store i32 %104, i32* %1
br label %119
105: ; preds = %97
%106 = call i32 @wait(i32* null)
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %111
108: ; preds = %105
%109 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
%110 = load i32, i32* @EXIT_FAILURE
store i32 %110, i32* %1
br label %119
111: ; preds = %105
%112 = call i32 @wait(i32* null)
%113 = icmp eq i32 %112, -1
br i1 %113, label %114, label %117
114: ; preds = %111
%115 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
%116 = load i32, i32* @EXIT_FAILURE
store i32 %116, i32* %1
br label %119
117: ; preds = %111
%118 = load i32, i32* @EXIT_SUCCESS
store i32 %118, i32* %1
br label %119
119: ; preds = %117, %114, %108, %102, %94, %85, %81, %73, %59, %51, %45, %41, %33, %19, %11, %6
%120 = load i32, i32* %1
ret i32 %120
}

LLVM IR (-O2):
@.str = [5 x i8] c"pipe\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"fork1\00"
@.str.2 = [8 x i8] c"close 1\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [7 x i8] c"dup2 1\00"
@.str.4 = [8 x i8] c"close 2\00"
@.str.5 = [3 x i8] c"ls\00"
@.str.6 = [6 x i8] c"fork2\00"
@.str.7 = [8 x i8] c"close 3\00"
@STDIN_FILENO = global i32 0
@.str.8 = [7 x i8] c"dup2 2\00"
@.str.9 = [8 x i8] c"close 4\00"
@.str.10 = [3 x i8] c"wc\00"
@.str.11 = [3 x i8] c"-l\00"
@.str.12 = [8 x i8] c"close 5\00"
@.str.13 = [8 x i8] c"close 6\00"
@.str.14 = [7 x i8] c"wait 1\00"
@.str.15 = [7 x i8] c"wait 2\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [2 x i32]
%2 = bitcast [2 x i32]* %1 to i8*
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%4 = call i32 @pipe(i32* %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %87
8: ; preds = %0
%9 = call i32 (...) @fork()
switch i32 %9, label %36 [
i32 -1, label %10
i32 0, label %12
]
10: ; preds = %8
%11 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %87
12: ; preds = %8
%13 = load i32, i32* %3
%14 = call i32 @close(i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %87
18: ; preds = %12
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%20 = load i32, i32* %19
%21 = load i32, i32* @STDOUT_FILENO
%22 = icmp eq i32 %20, %21
br i1 %22, label %34, label %23
23: ; preds = %18
%24 = call i32 @dup2(i32 %20, i32 %21)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %87
28: ; preds = %23
%29 = load i32, i32* %19
%30 = call i32 @close(i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %87
34: ; preds = %28, %18
%35 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* null)
br label %87
36: ; preds = %8
%37 = call i32 (...) @fork()
switch i32 %37, label %64 [
i32 -1, label %38
i32 0, label %40
]
38: ; preds = %36
%39 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %87
40: ; preds = %36
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %87
47: ; preds = %40
%48 = load i32, i32* %3
%49 = load i32, i32* @STDIN_FILENO
%50 = icmp eq i32 %48, %49
br i1 %50, label %62, label %51
51: ; preds = %47
%52 = call i32 @dup2(i32 %48, i32 %49)
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
br label %87
56: ; preds = %51
%57 = load i32, i32* %3
%58 = call i32 @close(i32 %57)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %87
62: ; preds = %56, %47
%63 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* null)
br label %87
64: ; preds = %36
%65 = load i32, i32* %3
%66 = call i32 @close(i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
br label %87
70: ; preds = %64
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%72 = load i32, i32* %71
%73 = call i32 @close(i32 %72)
%74 = icmp eq i32 %73, -1
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %87
77: ; preds = %70
%78 = call i32 @wait(i32* null)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.14, i64 0, i64 0))
br label %87
82: ; preds = %77
%83 = call i32 @wait(i32* null)
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %87
85: ; preds = %82
%86 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
br label %87
87: ; preds = %82, %85, %80, %75, %68, %62, %60, %54, %45, %38, %34, %32, %26, %16, %10, %6
%88 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_FAILURE, %68 ], [ @EXIT_FAILURE, %75 ], [ @EXIT_FAILURE, %80 ], [ @EXIT_FAILURE, %85 ], [ @EXIT_FAILURE, %45 ], [ @EXIT_FAILURE, %54 ], [ @EXIT_FAILURE, %60 ], [ @EXIT_FAILURE, %62 ], [ @EXIT_FAILURE, %38 ], [ @EXIT_FAILURE, %16 ], [ @EXIT_FAILURE, %26 ], [ @EXIT_FAILURE, %32 ], [ @EXIT_FAILURE, %34 ], [ @EXIT_FAILURE, %10 ], [ @EXIT_SUCCESS, %82 ]
%89 = load i32, i32* %88
ret i32 %89
}