#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 pid_t;

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int WEXITSTATUS(int);
int /*<<< orphan*/ assert(int);
int errno;
int execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read(int, int *, int);
char *strtok(char *, char *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    printf("Usage: %s command1 command2 ... commandN\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  int p2worker[2], i;
  if (pipe(p2worker) == -1) {
    perror("pipe");
    exit(EXIT_FAILURE);
  }
  for (i = 1; i < argc; i++) {
    if (0) {
      printf("DEBUG: ");
      printf("Executing command '%s'\n", argv[i]);
    };
    pid_t worker = fork();
    if (worker == -1) {
      perror("fork worker");
      exit(EXIT_FAILURE);
    }
    if (worker == 0) {
      if (0) {
        printf("DEBUG: ");
        puts("worker process");
      };
      pid_t exec_proc = fork();
      if (exec_proc == -1) {
        perror("fork exec process");
        exit(EXIT_FAILURE);
      }
      if (exec_proc == 0) {
        if (0) {
          printf("DEBUG: ");
          puts("worker exec process");
        };
        int command_len = 1024, j = 0;
        char *command[command_len], *p;
        p = strtok(argv[i], " ");
        while (p != NULL) {
          assert(j < command_len);
          command[j] = p;
          j++;
          p = strtok(NULL, " ");
        }
        int status = execvp(command[0], command);
        if (status == -1) {
          exit(errno);
        }
        exit(EXIT_SUCCESS);
      }
      int exec_proc_status;
      int exit_status;
      waitpid(exec_proc, &exec_proc_status, 0);
      exit_status = WEXITSTATUS(exec_proc_status);
      if (0) {
        printf("DEBUG: ");
        printf("Exec process exited with status=%d and errno=%d\n",
               exec_proc_status, exit_status);
      };
      write(p2worker[1], &exit_status, sizeof(int));
      exit(EXIT_SUCCESS);
    }
    if (0) {
      printf("DEBUG: ");
      puts("parent process");
    };
    int status;
    read(p2worker[0], &status, sizeof(int));
    if (0) {
      printf("DEBUG: ");
      printf("Returned to parent %d\n", status);
    };
    if (status == 0) {
      printf("Command '%s' executed succesfully\n", argv[i]);
    } else {
      printf("Command '%s' failed with errno=%d\n", argv[i], status);
      errno = status;
      perror("");
    }
    int worker_status;
    waitpid(worker, &worker_status, 0);
    puts("");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1213 <main+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    -0x18(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0xffffffff,%eax
jne    123f <main+0x6f>
lea    0xdfe(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1467 <main+0x297>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    1280 <main+0xb0>
lea    0xdc2(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x20(%rbp)
jne    13d0 <main+0x200>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    12b8 <main+0xe8>
lea    0xd96(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
jne    1398 <main+0x1c8>
movl   $0x400,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd43(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1363 <main+0x193>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x68(%rbp),%rax
mov    -0x48(%rbp),%rdx
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xcf8(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x48(%rbp)
jmp    1313 <main+0x143>
mov    -0x68(%rbp),%rsi
mov    (%rsi),%rdi
call   10d0 <execvp@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0xffffffff,-0x4c(%rbp)
jne    138a <main+0x1ba>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x50(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    -0x50(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
mov    %eax,-0x54(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x54(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    0x2c07(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
cmpl   $0x0,-0x58(%rbp)
jne    140a <main+0x23a>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    143f <main+0x26f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x58(%rbp),%edx
lea    0xc52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%ecx
mov    0x2baf(%rip),%rax
mov    %ecx,(%rax)
lea    0xbef(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x20(%rbp),%edi
lea    -0x5c(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
lea    0xbd5(%rip),%rdi
call   1030 <puts@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1246 <main+0x76>
xor    %eax,%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
je     13a2 <main+0x1d2>
mov    %edi,%r14d
lea    -0x38(%rbp),%rdi
call   1060 <pipe@plt>
cmp    $0xffffffff,%eax
je     13b8 <main+0x1e8>
cmp    $0x2,%r14d
jl     12b3 <main+0xe3>
mov    %r14d,%r12d
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     12c4 <main+0xf4>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
je     12e1 <main+0x111>
mov    -0x38(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1070 <read@plt>
mov    -0x2c(%rbp),%r15d
mov    (%rbx,%r14,8),%rsi
test   %r15d,%r15d
jne    128a <main+0xba>
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13d,%edi
lea    -0x30(%rbp),%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    1220 <main+0x50>
jmp    12b3 <main+0xe3>
lea    0xde1(%rip),%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2d3e(%rip),%rax
mov    %r15d,(%rax)
lea    0xd7d(%rip),%rdi
call   10b0 <perror@plt>
jmp    1267 <main+0x97>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     12fb <main+0x12b>
cmp    $0xffffffff,%eax
jne    136b <main+0x19b>
lea    0xd5c(%rip),%rdi
jmp    12e8 <main+0x118>
lea    0xd47(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    %rsp,%r12
add    $0xffffffffffffe000,%r12
mov    %r12,%rsp
mov    (%rbx,%r14,8),%rdi
lea    0xd3a(%rip),%r15
mov    %r15,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r14
xor    %ebx,%ebx
xor    %edi,%edi
cmp    $0x400,%rbx
setb   %dil
call   1080 <assert@plt>
mov    %r14,(%r12,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r14
test   %rax,%rax
jne    1320 <main+0x150>
mov    (%r12),%rdi
mov    %r12,%rsi
call   10d0 <execvp@plt>
cmp    $0xffffffff,%eax
jne    1394 <main+0x1c4>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    -0x2c(%rbp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   10a0 <waitpid@plt>
mov    -0x2c(%rbp),%edi
call   1090 <WEXITSTATUS@plt>
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    (%rbx),%rsi
lea    0xc54(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12ed <main+0x11d>
lea    0xc6b(%rip),%rdi
jmp    12e8 <main+0x118>

LLVM IR (-O0):
@.str = [42 x i8] c"Usage: %s command1 command2 ... commandN\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"pipe\00"
@.str.2 = [12 x i8] c"fork worker\00"
@.str.3 = [18 x i8] c"fork exec process\00"
@.str.4 = [2 x i8] c" \00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [35 x i8] c"Command '%s' executed succesfully\0A\00"
@.str.6 = [35 x i8] c"Command '%s' failed with errno=%d\0A\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %29
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%31 = call i32 @pipe(i32* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %29
store i32 1, i32* %7
br label %38
38: ; preds = %140, %37
%39 = load i32, i32* %7
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %143
42: ; preds = %38
%43 = call i32 (...) @fork()
store i32 %43, i32* %8
%44 = load i32, i32* %8
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %42
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %113
53: ; preds = %50
%54 = call i32 (...) @fork()
store i32 %54, i32* %9
%55 = load i32, i32* %9
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %53
%62 = load i32, i32* %9
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %103
64: ; preds = %61
store i32 1024, i32* %10
store i32 0, i32* %11
%65 = load i32, i32* %10
%66 = zext i32 %65 to i64
%67 = call i8* @llvm.stacksave()
store i8* %67, i8** %12
%68 = alloca i8*, i64 %66
store i64 %66, i64* %13
%69 = load i8**, i8*** %5
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8*, i8** %69, i64 %71
%73 = load i8*, i8** %72
%74 = call i8* @strtok(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %74, i8** %14
br label %75
75: ; preds = %78, %64
%76 = load i8*, i8** %14
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %91
78: ; preds = %75
%79 = load i32, i32* %11
%80 = load i32, i32* %10
%81 = icmp slt i32 %79, %80
%82 = zext i1 %81 to i32
%83 = call i32 @assert(i32 %82)
%84 = load i8*, i8** %14
%85 = load i32, i32* %11
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i8*, i8** %68, i64 %86
store i8* %84, i8** %87
%88 = load i32, i32* %11
%89 = add nsw i32 %88, 1
store i32 %89, i32* %11
%90 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %90, i8** %14
br label %75
91: ; preds = %75
%92 = getelementptr inbounds i8*, i8** %68, i64 0
%93 = load i8*, i8** %92
%94 = call i32 @execvp(i8* %93, i8** %68)
store i32 %94, i32* %15
%95 = load i32, i32* %15
%96 = icmp eq i32 %95, -1
br i1 %96, label %97, label %100
97: ; preds = %91
%98 = load i32, i32* @errno
%99 = call i32 @exit(i32 %98)
unreachable
100: ; preds = %91
%101 = load i32, i32* @EXIT_SUCCESS
%102 = call i32 @exit(i32 %101)
unreachable
103: ; preds = %61
%104 = load i32, i32* %9
%105 = call i32 @waitpid(i32 %104, i32* %16, i32 0)
%106 = load i32, i32* %16
%107 = call i32 @WEXITSTATUS(i32 %106)
store i32 %107, i32* %17
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%109 = load i32, i32* %108
%110 = call i32 @write(i32 %109, i32* %17, i32 4)
%111 = load i32, i32* @EXIT_SUCCESS
%112 = call i32 @exit(i32 %111)
unreachable
113: ; preds = %50
%114 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%115 = load i32, i32* %114
%116 = call i32 @read(i32 %115, i32* %18, i32 4)
%117 = load i32, i32* %18
%118 = icmp eq i32 %117, 0
br i1 %118, label %119, label %126
119: ; preds = %113
%120 = load i8**, i8*** %5
%121 = load i32, i32* %7
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8*, i8** %120, i64 %122
%124 = load i8*, i8** %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %124)
br label %136
126: ; preds = %113
%127 = load i8**, i8*** %5
%128 = load i32, i32* %7
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8*, i8** %127, i64 %129
%131 = load i8*, i8** %130
%132 = load i32, i32* %18
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %131, i32 %132)
%134 = load i32, i32* %18
store i32 %134, i32* @errno
%135 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %136
136: ; preds = %126, %119
%137 = load i32, i32* %8
%138 = call i32 @waitpid(i32 %137, i32* %19, i32 0)
%139 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %140
140: ; preds = %136
%141 = load i32, i32* %7
%142 = add nsw i32 %141, 1
store i32 %142, i32* %7
br label %38
143: ; preds = %38
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"Usage: %s command1 command2 ... commandN\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [5 x i8] c"pipe\00"
@.str.2 = [12 x i8] c"fork worker\00"
@.str.3 = [18 x i8] c"fork exec process\00"
@.str.4 = [2 x i8] c" \00"
@errno = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [35 x i8] c"Command '%s' executed succesfully\0A\00"
@.str.6 = [35 x i8] c"Command '%s' failed with errno=%d\0A\00"
@.str.7 = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = icmp eq i32 %0, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = bitcast [2 x i32]* %3 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %25, label %19
19: ; preds = %14
%20 = icmp sgt i32 %0, 1
br i1 %20, label %21, label %98
21: ; preds = %19
%22 = bitcast i32* %6 to i8*
%23 = bitcast i32* %7 to i8*
%24 = zext i32 %0 to i64
br label %29
25: ; preds = %14
%26 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %21, %93
%30 = phi i64 [ 1, %21 ], [ %96, %93 ]
%31 = call i32 (...) @fork()
switch i32 %31, label %81 [
i32 -1, label %32
i32 0, label %36
]
32: ; preds = %29
%33 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %29
%37 = call i32 (...) @fork()
switch i32 %37, label %70 [
i32 -1, label %38
i32 0, label %42
]
38: ; preds = %36
%39 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %36
%43 = alloca [1024 x i8*]
%44 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %43, i64 0, i64 0
%45 = and i64 %30, 4294967295
%46 = getelementptr inbounds i8*, i8** %1, i64 %45
%47 = load i8*, i8** %46
%48 = call i8* @strtok(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp ne i8* %48, null
br label %50
50: ; preds = %42, %50
%51 = phi i64 [ %57, %50 ], [ 0, %42 ]
%52 = phi i8* [ %58, %50 ], [ %48, %42 ]
%53 = icmp ult i64 %51, 1024
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %43, i64 0, i64 %51
store i8* %52, i8** %56
%57 = add nuw i64 %51, 1
%58 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%59 = icmp eq i8* %58, null
br i1 %59, label %60, label %50
60: ; preds = %50
%61 = load i8*, i8** %44
%62 = call i32 @execvp(i8* %61, i8** %44)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i32, i32* @errno
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %60
%68 = load i32, i32* @EXIT_SUCCESS
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %36
%71 = bitcast i32* %4 to i8*
%72 = bitcast i32* %5 to i8*
%73 = call i32 @waitpid(i32 %37, i32* %4, i32 0)
%74 = load i32, i32* %4
%75 = call i32 @WEXITSTATUS(i32 %74)
store i32 %75, i32* %5
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%77 = load i32, i32* %76
%78 = call i32 @write(i32 %77, i32* %5, i32 4)
%79 = load i32, i32* @EXIT_SUCCESS
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %29
%82 = load i32, i32* %16
%83 = call i32 @read(i32 %82, i32* %6, i32 4)
%84 = load i32, i32* %6
%85 = icmp eq i32 %84, 0
%86 = getelementptr inbounds i8*, i8** %1, i64 %30
%87 = load i8*, i8** %86
br i1 %85, label %88, label %90
88: ; preds = %81
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i8* %87)
br label %93
90: ; preds = %81
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %87, i32 %84)
store i32 %84, i32* @errno
%92 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %93
93: ; preds = %90, %88
%94 = call i32 @waitpid(i32 %31, i32* %7, i32 0)
%95 = call i32 @putchar(i32 10)
%96 = add nuw nsw i64 %30, 1
%97 = icmp eq i64 %96, %24
br i1 %97, label %98, label %29
98: ; preds = %93, %19
ret i32 0
}