#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 /*<<< orphan*/ child1(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ child2(int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ child3(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fork();
int mkfifo(char *, int);
int /*<<< orphan*/ parentPart1(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ parentPart2(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ remove(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 6) {
    printf("Usage: ./assignment <input_file> <parent_output_file> "
           "<child1_output_file> <child2_output_file> <child3_output_file>\n");
  } else {
    FILE *inputFile, *parentLogFile, *child1LogFile, *child2LogFile,
        *child3LogFile;
    char *fifoPipeLocation = "/tmp/fifoPipe";
    if ((inputFile = fopen(argv[1], "r")) == NULL) {
      printf("Cannot read from %s. Exiting program.\n", argv[1]);
      exit(1);
    } else if ((parentLogFile = fopen(argv[2], "w")) == NULL) {
      printf("Cannot write to %s for Parent. Exiting program.\n", argv[2]);
      exit(1);
    } else if ((child1LogFile = fopen(argv[3], "w")) == NULL) {
      printf("Cannot write to %s for Child 1. Exiting program.\n", argv[3]);
      exit(1);
    } else if ((child2LogFile = fopen(argv[4], "w")) == NULL) {
      printf("Cannot write to %s for Child 2. Exiting program.\n", argv[4]);
      exit(1);
    } else if ((child3LogFile = fopen(argv[5], "w")) == NULL) {
      printf("Cannot write to %s for Child 3. Exiting program.\n", argv[5]);
      exit(1);
    } else if (mkfifo(fifoPipeLocation, 0666) == -1) {
      printf("Cannot create FIFO pipe file for Child 2 and Child 3. Exiting "
             "program.\n");
      printf("Resolve this by removing \"/tmp/fifoPipe\".\n");
      exit(1);
    } else {
      int parentToChild1[2];
      int i, j, k;
      if (pipe(parentToChild1) == -1) {
        perror("Pipe call error for I/O Pipe between Parent and Child 1.\n");
        exit(1);
      }
      i = fork();
      if (i == -1) {
        perror(
            "There was a problem with forking the Parent. Exiting program.\n");
        exit(1);
      } else if (i == 0) {
        int child1ToChild2[2];
        if (pipe(child1ToChild2) == -1) {
          perror("Pipe call error for I/O Pipe between Child 1 and Child 2. "
                 "Exiting child.\n");
          exit(1);
        }
        j = fork();
        if (j == -1) {
          perror(
              "There was a problem with forking in Child 1. Exiting child.\n");
          exit(1);
        } else if (j == 0) {
          close(child1ToChild2[1]);
          close(parentToChild1[0]);
          close(parentToChild1[1]);
          child2(child1ToChild2[0], fifoPipeLocation, child2LogFile);
          close(child1ToChild2[0]);
          return 0;
        } else {
          close(child1ToChild2[0]);
          close(parentToChild1[1]);
          child1(parentToChild1[0], child1ToChild2[1], child1LogFile);
          close(parentToChild1[0]);
          close(child1ToChild2[1]);
          return 0;
        }
      } else {
        int child3ToParent[2];
        if (pipe(child3ToParent) == -1) {
          perror("Pipe call error for I/O Pipe between Parent and Child 3. "
                 "Exiting program.\n");
          exit(1);
        }
        k = fork();
        if (k == -1) {
          perror("There was a problem with forking the Parent again. Exiting "
                 "program.\n");
          exit(1);
        } else if (k == 0) {
          close(parentToChild1[0]);
          close(parentToChild1[1]);
          close(child3ToParent[0]);
          child3(fifoPipeLocation, child3ToParent[1], child3LogFile);
          close(child3ToParent[1]);
          return 0;
        } else {
          close(parentToChild1[0]);
          close(child3ToParent[1]);
          parentPart1(parentToChild1[1], inputFile, parentLogFile);
          close(parentToChild1[1]);
          wait(NULL);
          parentPart2(child3ToParent[0], parentLogFile);
          close(child3ToParent[0]);
        }
      }
    }
    fclose(inputFile);
    fclose(parentLogFile);
    fclose(child1LogFile);
    fclose(child2LogFile);
    fclose(child3LogFile);
    if (remove(fifoPipeLocation) != 0) {
      perror("Cannot remove FIFO pipe file. Manually remove this file by "
             "deleting \"/tmp//fifoPipe\".");
    }
  }
  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   $0x6,-0x8(%rbp)
je     1233 <main+0x33>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    164f <main+0x44f>
lea    0xe3c(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1280 <main+0x80>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe1e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12c2 <main+0xc2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xddc(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1304 <main+0x104>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xd9a(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1346 <main+0x146>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xd58(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1388 <main+0x188>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rsi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x40(%rbp),%rdi
mov    $0x1b6,%esi
call   10b0 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    13c5 <main+0x1c5>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    -0x48(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    13ed <main+0x1ed>
lea    0xe0b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0xffffffff,-0x4c(%rbp)
jne    1417 <main+0x217>
lea    0xe1b(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x4c(%rbp)
jne    14f4 <main+0x2f4>
lea    -0x5c(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1449 <main+0x249>
lea    0xe28(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0xffffffff,-0x50(%rbp)
jne    1473 <main+0x273>
lea    0xe48(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x50(%rbp)
jne    14b9 <main+0x2b9>
mov    -0x58(%rbp),%edi
call   1090 <close@plt>
mov    -0x48(%rbp),%edi
call   1090 <close@plt>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
mov    -0x5c(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   10c0 <child2@plt>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1656 <main+0x456>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
mov    -0x48(%rbp),%edi
mov    -0x58(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1040 <child1@plt>
mov    -0x48(%rbp),%edi
call   1090 <close@plt>
mov    -0x58(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1656 <main+0x456>
lea    -0x64(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    151c <main+0x31c>
lea    0xddc(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0xffffffff,-0x54(%rbp)
jne    1546 <main+0x346>
lea    0xdfd(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
cmpl   $0x0,-0x54(%rbp)
jne    158c <main+0x38c>
mov    -0x48(%rbp),%edi
call   1090 <close@plt>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
mov    -0x64(%rbp),%edi
call   1090 <close@plt>
mov    -0x40(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1050 <child3@plt>
mov    -0x60(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    1656 <main+0x456>
mov    -0x48(%rbp),%edi
call   1090 <close@plt>
mov    -0x60(%rbp),%edi
call   1090 <close@plt>
mov    -0x44(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <parentPart1@plt>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1110 <wait@plt>
mov    -0x64(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   10d0 <parentPart2@plt>
mov    -0x64(%rbp),%edi
call   1090 <close@plt>
jmp    15d6 <main+0x3d6>
jmp    15db <main+0x3db>
jmp    15e0 <main+0x3e0>
jmp    15e5 <main+0x3e5>
jmp    15ea <main+0x3ea>
jmp    15ef <main+0x3ef>
jmp    15f4 <main+0x3f4>
jmp    15f9 <main+0x3f9>
jmp    15fe <main+0x3fe>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <remove@plt>
cmp    $0x0,%rax
je     164a <main+0x44a>
lea    0xd34(%rip),%rdi
call   10f0 <perror@plt>
jmp    164f <main+0x44f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x6,%edi
jne    13ba <main+0x1aa>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xdd9(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14a0 <main+0x290>
mov    %rax,%r12
mov    0x10(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14ad <main+0x29d>
mov    %rax,%rbx
mov    0x18(%rbp),%rdi
lea    0xdca(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14ba <main+0x2aa>
mov    %rax,%r14
mov    0x20(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14c7 <main+0x2b7>
mov    %rax,%r15
mov    0x28(%rbp),%rdi
lea    0xd92(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     14d4 <main+0x2c4>
mov    %rax,%r13
lea    0xd43(%rip),%rdi
mov    $0x1b6,%esi
call   10c0 <mkfifo@plt>
cmp    $0xffffffff,%eax
je     14f0 <main+0x2e0>
lea    0x10(%rsp),%rdi
call   10b0 <pipe@plt>
cmp    $0xffffffff,%eax
je     1512 <main+0x302>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     13cb <main+0x1bb>
cmp    $0xffffffff,%eax
je     151b <main+0x30b>
lea    0x8(%rsp),%rdi
call   10b0 <pipe@plt>
cmp    $0xffffffff,%eax
je     1524 <main+0x314>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1458 <main+0x248>
cmp    $0xffffffff,%eax
je     1536 <main+0x326>
mov    0x10(%rsp),%edi
call   10a0 <close@plt>
mov    0xc(%rsp),%edi
call   10a0 <close@plt>
mov    0x14(%rsp),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <parentPart1@plt>
mov    0x14(%rsp),%edi
call   10a0 <close@plt>
xor    %edi,%edi
call   1120 <wait@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
call   10e0 <parentPart2@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
mov    %r12,%rdi
call   1080 <fclose@plt>
mov    %rbx,%rdi
call   1080 <fclose@plt>
mov    %r14,%rdi
call   1080 <fclose@plt>
mov    %r15,%rdi
call   1080 <fclose@plt>
mov    %r13,%rdi
call   1080 <fclose@plt>
lea    0xc65(%rip),%rdi
call   1030 <remove@plt>
test   %rax,%rax
je     148f <main+0x27f>
lea    0xee0(%rip),%rdi
call   1100 <perror@plt>
jmp    148f <main+0x27f>
lea    0xf96(%rip),%rdi
call   1060 <puts@plt>
jmp    148f <main+0x27f>
lea    0x8(%rsp),%rdi
call   10b0 <pipe@plt>
cmp    $0xffffffff,%eax
je     152d <main+0x31d>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     141f <main+0x20f>
cmp    $0xffffffff,%eax
je     153f <main+0x32f>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
mov    0x14(%rsp),%edi
call   10a0 <close@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    %r14,%rdx
call   1040 <child1@plt>
mov    0x10(%rsp),%edi
call   10a0 <close@plt>
jmp    1486 <main+0x276>
mov    0xc(%rsp),%edi
call   10a0 <close@plt>
mov    0x10(%rsp),%edi
call   10a0 <close@plt>
mov    0x14(%rsp),%edi
call   10a0 <close@plt>
mov    0x8(%rsp),%edi
lea    0xbbb(%rip),%rsi
mov    %r15,%rdx
call   10d0 <child2@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
jmp    148f <main+0x27f>
mov    0x10(%rsp),%edi
call   10a0 <close@plt>
mov    0x14(%rsp),%edi
call   10a0 <close@plt>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
mov    0xc(%rsp),%esi
lea    0xb82(%rip),%rdi
mov    %r13,%rdx
call   1050 <child3@plt>
mov    0xc(%rsp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbp),%rsi
lea    0xb65(%rip),%rdi
jmp    14df <main+0x2cf>
mov    0x10(%rbp),%rsi
lea    0xb81(%rip),%rdi
jmp    14df <main+0x2cf>
mov    0x18(%rbp),%rsi
lea    0xba5(%rip),%rdi
jmp    14df <main+0x2cf>
mov    0x20(%rbp),%rsi
lea    0xbca(%rip),%rdi
jmp    14df <main+0x2cf>
mov    0x28(%rbp),%rsi
lea    0xbef(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xdef(%rip),%rdi
call   1060 <puts@plt>
lea    0xe2a(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xbe7(%rip),%rdi
jmp    1546 <main+0x336>
lea    0xc18(%rip),%rdi
jmp    1546 <main+0x336>
lea    0xcd5(%rip),%rdi
jmp    1546 <main+0x336>
lea    0xc45(%rip),%rdi
jmp    1546 <main+0x336>
lea    0xd0e(%rip),%rdi
jmp    1546 <main+0x336>
lea    0xc7d(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@.str = [118 x i8] c"Usage: ./assignment <input_file> <parent_output_file> <child1_output_file> <child2_output_file> <child3_output_file>\0A\00"
@.str.1 = [14 x i8] c"/tmp/fifoPipe\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [39 x i8] c"Cannot read from %s. Exiting program.\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [49 x i8] c"Cannot write to %s for Parent. Exiting program.\0A\00"
@.str.6 = [50 x i8] c"Cannot write to %s for Child 1. Exiting program.\0A\00"
@.str.7 = [50 x i8] c"Cannot write to %s for Child 2. Exiting program.\0A\00"
@.str.8 = [50 x i8] c"Cannot write to %s for Child 3. Exiting program.\0A\00"
@.str.9 = [72 x i8] c"Cannot create FIFO pipe file for Child 2 and Child 3. Exiting program.\0A\00"
@.str.10 = [43 x i8] c"Resolve this by removing \22/tmp/fifoPipe\22.\0A\00"
@.str.11 = [58 x i8] c"Pipe call error for I/O Pipe between Parent and Child 1.\0A\00"
@.str.12 = [63 x i8] c"There was a problem with forking the Parent. Exiting program.\0A\00"
@.str.13 = [74 x i8] c"Pipe call error for I/O Pipe between Child 1 and Child 2. Exiting child.\0A\00"
@.str.14 = [61 x i8] c"There was a problem with forking in Child 1. Exiting child.\0A\00"
@.str.15 = [75 x i8] c"Pipe call error for I/O Pipe between Parent and Child 3. Exiting program.\0A\00"
@.str.16 = [69 x i8] c"There was a problem with forking the Parent again. Exiting program.\0A\00"
@.str.17 = [86 x i8] c"Cannot remove FIFO pipe file. Manually remove this file by deleting \22/tmp//fifoPipe\22.\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 i8*
%12 = alloca [2 x i32]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [2 x i32]
%17 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 6
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([118 x i8], [118 x i8]* @.str, i64 0, i64 0))
br label %245
22: ; preds = %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %11
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %6
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %34
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %22
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %38, i32** %7
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %34
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %50, i32** %8
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %58
52: ; preds = %46
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 3
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %46
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 4
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %62, i32** %9
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %70
64: ; preds = %58
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 4
%67 = load i8*, i8** %66
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i8* %67)
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %58
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 5
%73 = load i8*, i8** %72
%74 = call i32* @fopen(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %74, i32** %10
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %82
76: ; preds = %70
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 5
%79 = load i8*, i8** %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i8* %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %70
%83 = load i8*, i8** %11
%84 = call i32 @mkfifo(i8* %83, i32 438)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %90
86: ; preds = %82
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.9, i64 0, i64 0))
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %82
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%92 = call i32 @pipe(i32* %91)
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %97
94: ; preds = %90
%95 = call i32 @perror(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0))
%96 = call i32 @exit(i32 1)
unreachable
97: ; preds = %90
%98 = call i32 (...) @fork()
store i32 %98, i32* %13
%99 = load i32, i32* %13
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %104
101: ; preds = %97
%102 = call i32 @perror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.12, i64 0, i64 0))
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %97
%105 = load i32, i32* %13
%106 = icmp eq i32 %105, 0
br i1 %106, label %107, label %161
107: ; preds = %104
%108 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%109 = call i32 @pipe(i32* %108)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %114
111: ; preds = %107
%112 = call i32 @perror(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.13, i64 0, i64 0))
%113 = call i32 @exit(i32 1)
unreachable
114: ; preds = %107
%115 = call i32 (...) @fork()
store i32 %115, i32* %14
%116 = load i32, i32* %14
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %121
118: ; preds = %114
%119 = call i32 @perror(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0))
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %114
%122 = load i32, i32* %14
%123 = icmp eq i32 %122, 0
br i1 %123, label %124, label %142
124: ; preds = %121
%125 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%126 = load i32, i32* %125
%127 = call i32 @close(i32 %126)
%128 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%129 = load i32, i32* %128
%130 = call i32 @close(i32 %129)
%131 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%132 = load i32, i32* %131
%133 = call i32 @close(i32 %132)
%134 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%135 = load i32, i32* %134
%136 = load i8*, i8** %11
%137 = load i32*, i32** %9
%138 = call i32 @child2(i32 %135, i8* %136, i32* %137)
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%140 = load i32, i32* %139
%141 = call i32 @close(i32 %140)
store i32 0, i32* %3
br label %246
142: ; preds = %121
%143 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 0
%144 = load i32, i32* %143
%145 = call i32 @close(i32 %144)
%146 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%147 = load i32, i32* %146
%148 = call i32 @close(i32 %147)
%149 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%150 = load i32, i32* %149
%151 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%152 = load i32, i32* %151
%153 = load i32*, i32** %8
%154 = call i32 @child1(i32 %150, i32 %152, i32* %153)
%155 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%156 = load i32, i32* %155
%157 = call i32 @close(i32 %156)
%158 = getelementptr inbounds [2 x i32], [2 x i32]* %16, i64 0, i64 1
%159 = load i32, i32* %158
%160 = call i32 @close(i32 %159)
store i32 0, i32* %3
br label %246
161: ; preds = %104
%162 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%163 = call i32 @pipe(i32* %162)
%164 = icmp eq i32 %163, -1
br i1 %164, label %165, label %168
165: ; preds = %161
%166 = call i32 @perror(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.15, i64 0, i64 0))
%167 = call i32 @exit(i32 1)
unreachable
168: ; preds = %161
%169 = call i32 (...) @fork()
store i32 %169, i32* %15
%170 = load i32, i32* %15
%171 = icmp eq i32 %170, -1
br i1 %171, label %172, label %175
172: ; preds = %168
%173 = call i32 @perror(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.16, i64 0, i64 0))
%174 = call i32 @exit(i32 1)
unreachable
175: ; preds = %168
%176 = load i32, i32* %15
%177 = icmp eq i32 %176, 0
br i1 %177, label %178, label %196
178: ; preds = %175
%179 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%180 = load i32, i32* %179
%181 = call i32 @close(i32 %180)
%182 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%183 = load i32, i32* %182
%184 = call i32 @close(i32 %183)
%185 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%186 = load i32, i32* %185
%187 = call i32 @close(i32 %186)
%188 = load i8*, i8** %11
%189 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%190 = load i32, i32* %189
%191 = load i32*, i32** %10
%192 = call i32 @child3(i8* %188, i32 %190, i32* %191)
%193 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%194 = load i32, i32* %193
%195 = call i32 @close(i32 %194)
store i32 0, i32* %3
br label %246
196: ; preds = %175
%197 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%198 = load i32, i32* %197
%199 = call i32 @close(i32 %198)
%200 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 1
%201 = load i32, i32* %200
%202 = call i32 @close(i32 %201)
%203 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%204 = load i32, i32* %203
%205 = load i32*, i32** %6
%206 = load i32*, i32** %7
%207 = call i32 @parentPart1(i32 %204, i32* %205, i32* %206)
%208 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 1
%209 = load i32, i32* %208
%210 = call i32 @close(i32 %209)
%211 = call i32 @wait(i32* null)
%212 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%213 = load i32, i32* %212
%214 = load i32*, i32** %7
%215 = call i32 @parentPart2(i32 %213, i32* %214)
%216 = getelementptr inbounds [2 x i32], [2 x i32]* %17, i64 0, i64 0
%217 = load i32, i32* %216
%218 = call i32 @close(i32 %217)
br label %219
219: ; preds = %196
br label %220
220: ; preds = %219
br label %221
221: ; preds = %220
br label %222
222: ; preds = %221
br label %223
223: ; preds = %222
br label %224
224: ; preds = %223
br label %225
225: ; preds = %224
br label %226
226: ; preds = %225
br label %227
227: ; preds = %226
br label %228
228: ; preds = %227
%229 = load i32*, i32** %6
%230 = call i32 @fclose(i32* %229)
%231 = load i32*, i32** %7
%232 = call i32 @fclose(i32* %231)
%233 = load i32*, i32** %8
%234 = call i32 @fclose(i32* %233)
%235 = load i32*, i32** %9
%236 = call i32 @fclose(i32* %235)
%237 = load i32*, i32** %10
%238 = call i32 @fclose(i32* %237)
%239 = load i8*, i8** %11
%240 = call i64 @remove(i8* %239)
%241 = icmp ne i64 %240, 0
br i1 %241, label %242, label %244
242: ; preds = %228
%243 = call i32 @perror(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.17, i64 0, i64 0))
br label %244
244: ; preds = %242, %228
br label %245
245: ; preds = %244, %20
store i32 0, i32* %3
br label %246
246: ; preds = %245, %178, %142, %124
%247 = load i32, i32* %3
ret i32 %247
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"/tmp/fifoPipe\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [39 x i8] c"Cannot read from %s. Exiting program.\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [49 x i8] c"Cannot write to %s for Parent. Exiting program.\0A\00"
@.str.6 = [50 x i8] c"Cannot write to %s for Child 1. Exiting program.\0A\00"
@.str.7 = [50 x i8] c"Cannot write to %s for Child 2. Exiting program.\0A\00"
@.str.8 = [50 x i8] c"Cannot write to %s for Child 3. Exiting program.\0A\00"
@.str.11 = [58 x i8] c"Pipe call error for I/O Pipe between Parent and Child 1.\0A\00"
@.str.12 = [63 x i8] c"There was a problem with forking the Parent. Exiting program.\0A\00"
@.str.13 = [74 x i8] c"Pipe call error for I/O Pipe between Child 1 and Child 2. Exiting child.\0A\00"
@.str.14 = [61 x i8] c"There was a problem with forking in Child 1. Exiting child.\0A\00"
@.str.15 = [75 x i8] c"Pipe call error for I/O Pipe between Parent and Child 3. Exiting program.\0A\00"
@.str.16 = [69 x i8] c"There was a problem with forking the Parent again. Exiting program.\0A\00"
@.str.17 = [86 x i8] c"Cannot remove FIFO pipe file. Manually remove this file by deleting \22/tmp//fifoPipe\22.\00"
@str = [71 x i8] c"Cannot create FIFO pipe file for Child 2 and Child 3. Exiting program.\00"
@str.18 = [42 x i8] c"Resolve this by removing \22/tmp/fifoPipe\22.\00"
@str.19 = [117 x i8] c"Usage: ./assignment <input_file> <parent_output_file> <child1_output_file> <child2_output_file> <child3_output_file>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = icmp eq i32 %0, 6
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([117 x i8], [117 x i8]* @str.19, i64 0, i64 0))
br label %166
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i8*, i8** %10
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = load i8*, i8** %19
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %18
%28 = getelementptr inbounds i8*, i8** %1, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = load i8*, i8** %28
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %33)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %27
%37 = getelementptr inbounds i8*, i8** %1, i64 4
%38 = load i8*, i8** %37
%39 = tail call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %45
41: ; preds = %36
%42 = load i8*, i8** %37
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.7, i64 0, i64 0), i8* %42)
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %36
%46 = getelementptr inbounds i8*, i8** %1, i64 5
%47 = load i8*, i8** %46
%48 = tail call i32* @fopen(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %54
50: ; preds = %45
%51 = load i8*, i8** %46
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.8, i64 0, i64 0), i8* %51)
%53 = tail call i32 @exit(i32 1)
unreachable
54: ; preds = %45
%55 = tail call i32 @mkfifo(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 438)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.18, i64 0, i64 0))
%60 = tail call i32 @exit(i32 1)
unreachable
61: ; preds = %54
%62 = bitcast [2 x i32]* %3 to i8*
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%64 = call i32 @pipe(i32* %63)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = call i32 @perror(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.11, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %61
%70 = call i32 (...) @fork()
switch i32 %70, label %115 [
i32 -1, label %71
i32 0, label %74
]
71: ; preds = %69
%72 = call i32 @perror(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.12, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %69
%75 = bitcast [2 x i32]* %4 to i8*
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%77 = call i32 @pipe(i32* %76)
%78 = icmp eq i32 %77, -1
br i1 %78, label %79, label %82
79: ; preds = %74
%80 = call i32 @perror(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.13, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %74
%83 = call i32 (...) @fork()
switch i32 %83, label %99 [
i32 -1, label %84
i32 0, label %87
]
84: ; preds = %82
%85 = call i32 @perror(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.14, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %82
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%89 = load i32, i32* %88
%90 = call i32 @close(i32 %89)
%91 = load i32, i32* %63
%92 = call i32 @close(i32 %91)
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%94 = load i32, i32* %93
%95 = call i32 @close(i32 %94)
%96 = load i32, i32* %76
%97 = call i32 @child2(i32 %96, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %39)
%98 = load i32, i32* %76
br label %112
99: ; preds = %82
%100 = load i32, i32* %76
%101 = call i32 @close(i32 %100)
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%103 = load i32, i32* %102
%104 = call i32 @close(i32 %103)
%105 = load i32, i32* %63
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%107 = load i32, i32* %106
%108 = call i32 @child1(i32 %105, i32 %107, i32* %30)
%109 = load i32, i32* %63
%110 = call i32 @close(i32 %109)
%111 = load i32, i32* %106
br label %112
112: ; preds = %87, %99
%113 = phi i32 [ %98, %87 ], [ %111, %99 ]
%114 = call i32 @close(i32 %113)
br label %166
115: ; preds = %69
%116 = bitcast [2 x i32]* %5 to i8*
%117 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%118 = call i32 @pipe(i32* %117)
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %123
120: ; preds = %115
%121 = call i32 @perror(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.15, i64 0, i64 0))
%122 = call i32 @exit(i32 1)
unreachable
123: ; preds = %115
%124 = call i32 (...) @fork()
switch i32 %124, label %141 [
i32 -1, label %125
i32 0, label %128
]
125: ; preds = %123
%126 = call i32 @perror(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.16, i64 0, i64 0))
%127 = call i32 @exit(i32 1)
unreachable
128: ; preds = %123
%129 = load i32, i32* %63
%130 = call i32 @close(i32 %129)
%131 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%132 = load i32, i32* %131
%133 = call i32 @close(i32 %132)
%134 = load i32, i32* %117
%135 = call i32 @close(i32 %134)
%136 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%137 = load i32, i32* %136
%138 = call i32 @child3(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %137, i32* %48)
%139 = load i32, i32* %136
%140 = call i32 @close(i32 %139)
br label %166
141: ; preds = %123
%142 = load i32, i32* %63
%143 = call i32 @close(i32 %142)
%144 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%145 = load i32, i32* %144
%146 = call i32 @close(i32 %145)
%147 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%148 = load i32, i32* %147
%149 = call i32 @parentPart1(i32 %148, i32* %12, i32* %21)
%150 = load i32, i32* %147
%151 = call i32 @close(i32 %150)
%152 = call i32 @wait(i32* null)
%153 = load i32, i32* %117
%154 = call i32 @parentPart2(i32 %153, i32* %21)
%155 = load i32, i32* %117
%156 = call i32 @close(i32 %155)
%157 = call i32 @fclose(i32* %12)
%158 = call i32 @fclose(i32* %21)
%159 = call i32 @fclose(i32* %30)
%160 = call i32 @fclose(i32* %39)
%161 = call i32 @fclose(i32* %48)
%162 = call i64 @remove(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%163 = icmp eq i64 %162, 0
br i1 %163, label %166, label %164
164: ; preds = %141
%165 = call i32 @perror(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.17, i64 0, i64 0))
br label %166
166: ; preds = %128, %112, %164, %141, %7
ret i32 0
}