#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 /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int fork();
int getopt(int, char **, char *);
int mkfifo(char *, int);
int open(char *, int /*<<< orphan*/);
char *optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  int cname, res, status, pid, i, max_count = 0;
  char app_name[20][100], fifo_name[100];
  while ((cname = getopt(argc, argv, ":p:")) != -1) {
    switch (cname) {
    case 'p':
      sprintf(app_name[max_count], "%s", optarg);
      max_count++;
    }
  }
  if (max_count > 20) {
    printf("max allowed parms is %d\n", 20);
    exit(2);
  }
  for (i = 0; i < max_count; i++) {
    sprintf(fifo_name, "fifo_%d", i);
    remove(fifo_name);
    res = mkfifo(fifo_name, 0666);
    if (res < 0) {
      perror("mkfifo create error");
      exit(1);
    }
  }
  for (i = 0; i < max_count; i++) {
    int fd_fork;
    switch (pid = fork()) {
    case -1:
      perror("fork error");
      exit(1);
    case 0:
      if (i != 0) {
        sprintf(fifo_name, "fifo_%d", i - 1);
        fd_fork = open(fifo_name, O_RDONLY);
        if (fd_fork < 0) {
          perror("mkfifo open error");
          exit(1);
        }
        if (dup2(fd_fork, STDIN_FILENO) == -1) {
          perror("dup2 error");
          exit(1);
        }
      }
      if (i != (max_count - 1)) {
        sprintf(fifo_name, "fifo_%d", i);
        fd_fork = open(fifo_name, O_WRONLY);
        if (fd_fork < 0) {
          perror("mkfifo open error");
          exit(1);
        }
        if (dup2(fd_fork, STDOUT_FILENO) == -1) {
          perror("dup2 error");
          exit(1);
        }
      }
      execlp(app_name[i], app_name[i], NULL);
      perror("execlp error");
      exit(1);
    }
  }
  for (i = 0; i < max_count; i++) {
    wait(&status);
  }
  for (i = 0; i < max_count; i++) {
    sprintf(fifo_name, "fifo_%d", i);
    remove(fifo_name);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x880,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe12(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     1248 <main+0x88>
mov    -0x14(%rbp),%eax
sub    $0x70,%eax
jne    1243 <main+0x83>
jmp    1210 <main+0x50>
movslq -0x28(%rbp),%rax
lea    -0x800(%rbp),%rdi
imul   $0x64,%rax,%rax
add    %rax,%rdi
mov    0x2dcf(%rip),%rax
mov    (%rax),%rdx
lea    0xdd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e0 <main+0x20>
cmpl   $0x14,-0x28(%rbp)
jle    126d <main+0xad>
lea    0xdae(%rip),%rdi
mov    $0x14,%esi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12eb <main+0x12b>
lea    -0x870(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xd8f(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x870(%rbp),%rdi
call   1030 <remove@plt>
lea    -0x870(%rbp),%rdi
mov    $0x1b6,%esi
call   1060 <mkfifo@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12d8 <main+0x118>
lea    0xd5f(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    12dd <main+0x11d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1274 <main+0xb4>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    14d7 <main+0x317>
xor    %eax,%eax
call   10e0 <fork@plt>
mov    %eax,-0x20(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x878(%rbp)
sub    $0xffffffff,%eax
je     1331 <main+0x171>
jmp    131e <main+0x15e>
mov    -0x878(%rbp),%eax
test   %eax,%eax
je     1347 <main+0x187>
jmp    14c4 <main+0x304>
lea    0xd04(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     13e2 <main+0x222>
lea    -0x870(%rbp),%rdi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
lea    0xcbb(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x870(%rbp),%rdi
mov    0x2c5e(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x874(%rbp)
cmpl   $0x0,-0x874(%rbp)
jge    13aa <main+0x1ea>
lea    0xcac(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x874(%rbp),%edi
mov    0x2c11(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    13dd <main+0x21d>
lea    0xc8b(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    13e2 <main+0x222>
mov    -0x24(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1481 <main+0x2c1>
lea    -0x870(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xc1c(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x870(%rbp),%rdi
mov    0x2b9f(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x874(%rbp)
cmpl   $0x0,-0x874(%rbp)
jge    1449 <main+0x289>
lea    0xc0d(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x874(%rbp),%edi
mov    0x2b92(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    147c <main+0x2bc>
lea    0xbec(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1481 <main+0x2c1>
movslq -0x24(%rbp),%rax
lea    -0x800(%rbp),%rdi
imul   $0x64,%rax,%rax
add    %rax,%rdi
movslq -0x24(%rbp),%rax
lea    -0x800(%rbp),%rsi
imul   $0x64,%rax,%rax
add    %rax,%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10c0 <execlp@plt>
lea    0xbaf(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    14c9 <main+0x309>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12f2 <main+0x132>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1501 <main+0x341>
lea    -0x1c(%rbp),%rdi
call   10d0 <wait@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14de <main+0x31e>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1546 <main+0x386>
lea    -0x870(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xafb(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x870(%rbp),%rdi
call   1030 <remove@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1508 <main+0x348>
xor    %eax,%eax
add    $0x880,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x850,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r15d,%r15d
lea    0xe12(%rip),%r14
mov    0x2e03(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10a0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1238 <main+0x68>
cmp    $0x70,%eax
jne    1200 <main+0x30>
mov    %r15d,%eax
imul   $0x64,%rax,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x80,%rdi
mov    (%r12),%rsi
call   1040 <strcpy@plt>
add    $0x1,%r15d
jmp    1200 <main+0x30>
cmp    $0x14,%r15d
ja     1420 <main+0x250>
test   %r15d,%r15d
je     132f <main+0x15f>
lea    0xdcb(%rip),%r14
lea    0x10(%rsp),%rbp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <remove@plt>
mov    %rbp,%rdi
mov    $0x1b6,%esi
call   1070 <mkfifo@plt>
test   %eax,%eax
js     1341 <main+0x171>
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1260 <main+0x90>
test   %r15d,%r15d
je     132f <main+0x15f>
lea    0x80(%rsp),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10f0 <fork@plt>
test   %eax,%eax
je     134d <main+0x17d>
cmp    $0xffffffff,%eax
je     13b4 <main+0x1e4>
add    $0x64,%rbx
add    $0xffffffff,%ebp
mov    %r15d,%eax
add    %ebp,%eax
jne    12b0 <main+0xe0>
test   %r15d,%r15d
je     132f <main+0x15f>
lea    0xc(%rsp),%rbx
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   10e0 <wait@plt>
add    $0xffffffff,%ebp
jne    12f0 <main+0x120>
test   %r15d,%r15d
je     132f <main+0x15f>
lea    0xd14(%rip),%r14
lea    0x10(%rsp),%rbp
xor    %ebx,%ebx
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <remove@plt>
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1310 <main+0x140>
xor    %eax,%eax
add    $0x850,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcdd(%rip),%rdi
jmp    1411 <main+0x241>
test   %ebp,%ebp
je     1395 <main+0x1c5>
mov    %ebp,%edx
not    %edx
lea    0xcc1(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    0x2c66(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
test   %eax,%eax
js     13ec <main+0x21c>
mov    0x2c41(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
je     140a <main+0x23a>
add    %ebp,%r15d
cmp    $0x1,%r15d
jne    13bd <main+0x1ed>
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   10d0 <execlp@plt>
lea    0xcaf(%rip),%rdi
jmp    1411 <main+0x241>
lea    0xc7e(%rip),%rdi
jmp    1411 <main+0x241>
neg    %ebp
lea    0xc57(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1080 <open@plt>
test   %eax,%eax
jns    13f5 <main+0x225>
lea    0xc51(%rip),%rdi
jmp    1411 <main+0x241>
mov    0x2bec(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    139e <main+0x1ce>
lea    0xc45(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xbdd(%rip),%rdi
mov    $0x14,%esi
call   1060 <printf@plt>
mov    $0x2,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c":p:\00"
@.str.1 = [3 x i8] c"%s\00"
@optarg = global i8* null
@.str.2 = [25 x i8] c"max allowed parms is %d\0A\00"
@.str.3 = [8 x i8] c"fifo_%d\00"
@.str.4 = [20 x i8] c"mkfifo create error\00"
@.str.5 = [11 x i8] c"fork error\00"
@O_RDONLY = global i32 0
@.str.6 = [18 x i8] c"mkfifo open error\00"
@STDIN_FILENO = global i32 0
@.str.7 = [11 x i8] c"dup2 error\00"
@O_WRONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.8 = [13 x i8] c"execlp error\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [20 x [100 x i8]]
%13 = alloca [100 x i8]
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
br label %15
15: ; preds = %31, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %6
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %6
switch i32 %21, label %31 [
i32 112, label %22
]
22: ; preds = %20
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [20 x [100 x i8]], [20 x [100 x i8]]* %12, i64 0, i64 %24
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %25, i64 0, i64 0
%27 = load i8*, i8** @optarg
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %11
%30 = add nsw i32 %29, 1
store i32 %30, i32* %11
br label %31
31: ; preds = %22, %20
br label %15
32: ; preds = %15
%33 = load i32, i32* %11
%34 = icmp sgt i32 %33, 20
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 20)
%37 = call i32 @exit(i32 2)
unreachable
38: ; preds = %32
store i32 0, i32* %10
br label %39
39: ; preds = %57, %38
%40 = load i32, i32* %10
%41 = load i32, i32* %11
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %60
43: ; preds = %39
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%45 = load i32, i32* %10
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%48 = call i32 @remove(i8* %47)
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%50 = call i32 @mkfifo(i8* %49, i32 438)
store i32 %50, i32* %7
%51 = load i32, i32* %7
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %43
%54 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %43
br label %57
57: ; preds = %56
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %39
60: ; preds = %39
store i32 0, i32* %10
br label %61
61: ; preds = %134, %60
%62 = load i32, i32* %10
%63 = load i32, i32* %11
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %137
65: ; preds = %61
%66 = call i32 (...) @fork()
store i32 %66, i32* %9
switch i32 %66, label %133 [
i32 -1, label %67
i32 0, label %70
]
67: ; preds = %65
%68 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %65
%71 = load i32, i32* %10
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %95
73: ; preds = %70
%74 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%75 = load i32, i32* %10
%76 = sub nsw i32 %75, 1
%77 = call i32 (i8*, i8*, ...) @sprintf(i8* %74, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %76)
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%79 = load i32, i32* @O_RDONLY
%80 = call i32 @open(i8* %78, i32 %79)
store i32 %80, i32* %14
%81 = load i32, i32* %14
%82 = icmp slt i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %73
%84 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %73
%87 = load i32, i32* %14
%88 = load i32, i32* @STDIN_FILENO
%89 = call i32 @dup2(i32 %87, i32 %88)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %94
91: ; preds = %86
%92 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %86
br label %95
95: ; preds = %94, %70
%96 = load i32, i32* %10
%97 = load i32, i32* %11
%98 = sub nsw i32 %97, 1
%99 = icmp ne i32 %96, %98
br i1 %99, label %100, label %121
100: ; preds = %95
%101 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%102 = load i32, i32* %10
%103 = call i32 (i8*, i8*, ...) @sprintf(i8* %101, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %102)
%104 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%105 = load i32, i32* @O_WRONLY
%106 = call i32 @open(i8* %104, i32 %105)
store i32 %106, i32* %14
%107 = load i32, i32* %14
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %100
%110 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%111 = call i32 @exit(i32 1)
unreachable
112: ; preds = %100
%113 = load i32, i32* %14
%114 = load i32, i32* @STDOUT_FILENO
%115 = call i32 @dup2(i32 %113, i32 %114)
%116 = icmp eq i32 %115, -1
br i1 %116, label %117, label %120
117: ; preds = %112
%118 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %112
br label %121
121: ; preds = %120, %95
%122 = load i32, i32* %10
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [20 x [100 x i8]], [20 x [100 x i8]]* %12, i64 0, i64 %123
%125 = getelementptr inbounds [100 x i8], [100 x i8]* %124, i64 0, i64 0
%126 = load i32, i32* %10
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [20 x [100 x i8]], [20 x [100 x i8]]* %12, i64 0, i64 %127
%129 = getelementptr inbounds [100 x i8], [100 x i8]* %128, i64 0, i64 0
%130 = call i32 @execlp(i8* %125, i8* %129, i32* null)
%131 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%132 = call i32 @exit(i32 1)
unreachable
133: ; preds = %65
br label %134
134: ; preds = %133
%135 = load i32, i32* %10
%136 = add nsw i32 %135, 1
store i32 %136, i32* %10
br label %61
137: ; preds = %61
store i32 0, i32* %10
br label %138
138: ; preds = %144, %137
%139 = load i32, i32* %10
%140 = load i32, i32* %11
%141 = icmp slt i32 %139, %140
br i1 %141, label %142, label %147
142: ; preds = %138
%143 = call i32 @wait(i32* %8)
br label %144
144: ; preds = %142
%145 = load i32, i32* %10
%146 = add nsw i32 %145, 1
store i32 %146, i32* %10
br label %138
147: ; preds = %138
store i32 0, i32* %10
br label %148
148: ; preds = %158, %147
%149 = load i32, i32* %10
%150 = load i32, i32* %11
%151 = icmp slt i32 %149, %150
br i1 %151, label %152, label %161
152: ; preds = %148
%153 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%154 = load i32, i32* %10
%155 = call i32 (i8*, i8*, ...) @sprintf(i8* %153, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %154)
%156 = getelementptr inbounds [100 x i8], [100 x i8]* %13, i64 0, i64 0
%157 = call i32 @remove(i8* %156)
br label %158
158: ; preds = %152
%159 = load i32, i32* %10
%160 = add nsw i32 %159, 1
store i32 %160, i32* %10
br label %148
161: ; preds = %148
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c":p:\00"
@optarg = global i8* null
@.str.2 = [25 x i8] c"max allowed parms is %d\0A\00"
@.str.3 = [8 x i8] c"fifo_%d\00"
@.str.4 = [20 x i8] c"mkfifo create error\00"
@.str.5 = [11 x i8] c"fork error\00"
@O_RDONLY = global i32 0
@.str.6 = [18 x i8] c"mkfifo open error\00"
@STDIN_FILENO = global i32 0
@.str.7 = [11 x i8] c"dup2 error\00"
@O_WRONLY = global i32 0
@STDOUT_FILENO = global i32 0
@.str.8 = [13 x i8] c"execlp error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca [20 x [100 x i8]]
%5 = alloca [100 x i8]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [20 x [100 x i8]], [20 x [100 x i8]]* %4, i64 0, i64 0, i64 0
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
br label %9
9: ; preds = %13, %2
%10 = phi i32 [ %18, %13 ], [ 0, %2 ]
br label %11
11: ; preds = %9, %11
%12 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %11 [
i32 -1, label %19
i32 112, label %13
]
13: ; preds = %11
%14 = zext i32 %10 to i64
%15 = getelementptr inbounds [20 x [100 x i8]], [20 x [100 x i8]]* %4, i64 0, i64 %14, i64 0
%16 = load i8*, i8** @optarg
%17 = call i8* @strcpy(i8* %15, i8* dereferenceable(1) %16)
%18 = add nuw nsw i32 %10, 1
br label %9
19: ; preds = %11
%20 = icmp ugt i32 %10, 20
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = icmp eq i32 %10, 0
br i1 %22, label %103, label %29
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 20)
%25 = call i32 @exit(i32 2)
unreachable
26: ; preds = %29
%27 = icmp eq i32 %35, %10
br i1 %27, label %28, label %29
28: ; preds = %26
br i1 %22, label %103, label %40
29: ; preds = %21, %26
%30 = phi i32 [ %35, %26 ], [ 0, %21 ]
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = call i32 @remove(i8* %8)
%33 = call i32 @mkfifo(i8* %8, i32 438)
%34 = icmp slt i32 %33, 0
%35 = add nuw nsw i32 %30, 1
br i1 %34, label %36, label %26
36: ; preds = %29
%37 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %88
br i1 %22, label %103, label %92
40: ; preds = %28, %88
%41 = phi i32 [ %89, %88 ], [ 0, %28 ]
%42 = call i32 (...) @fork()
switch i32 %42, label %88 [
i32 -1, label %43
i32 0, label %46
]
43: ; preds = %40
%44 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %40
%47 = icmp eq i32 %41, 0
br i1 %47, label %64, label %48
48: ; preds = %46
%49 = add nsw i32 %41, -1
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load i32, i32* @O_RDONLY
%52 = call i32 @open(i8* %8, i32 %51)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %48
%55 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %48
%58 = load i32, i32* @STDIN_FILENO
%59 = call i32 @dup2(i32 %52, i32 %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %57, %46
%65 = add nsw i32 %10, -1
%66 = icmp eq i32 %41, %65
br i1 %66, label %82, label %67
67: ; preds = %64
%68 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%69 = load i32, i32* @O_WRONLY
%70 = call i32 @open(i8* %8, i32 %69)
%71 = icmp slt i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %67
%76 = load i32, i32* @STDOUT_FILENO
%77 = call i32 @dup2(i32 %70, i32 %76)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %82
79: ; preds = %75
%80 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %75, %64
%83 = zext i32 %41 to i64
%84 = getelementptr inbounds [20 x [100 x i8]], [20 x [100 x i8]]* %4, i64 0, i64 %83, i64 0
%85 = call i32 @execlp(i8* %84, i8* %84, i32* null)
%86 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %40
%89 = add nuw nsw i32 %41, 1
%90 = icmp eq i32 %89, %10
br i1 %90, label %39, label %40
91: ; preds = %92
br i1 %22, label %103, label %97
92: ; preds = %39, %92
%93 = phi i32 [ %95, %92 ], [ 0, %39 ]
%94 = call i32 @wait(i32* %3)
%95 = add nuw nsw i32 %93, 1
%96 = icmp eq i32 %95, %10
br i1 %96, label %91, label %92
97: ; preds = %91, %97
%98 = phi i32 [ %101, %97 ], [ 0, %91 ]
%99 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %98)
%100 = call i32 @remove(i8* %8)
%101 = add nuw nsw i32 %98, 1
%102 = icmp eq i32 %101, %10
br i1 %102, label %103, label %97
103: ; preds = %97, %21, %28, %39, %91
ret i32 0
}