#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*/ read_buffer_2;
typedef int /*<<< orphan*/ read_buffer_1;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int fork();
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int islower(char);
int isupper(char);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int read(int, char *, int);
char *returnLine(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char tolower(char);
char toupper(char);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int pipe_1[2];
  int pipe_2[2];
  int rc1;
  int rc2;
  int pid;
  int pid2;
  int status;
  char read_buffer_1[150];
  char read_buffer_2[150];
  char *line;
  FILE *fp;
  FILE *fpout;
  rc1 = pipe(pipe_1);
  if (rc1 == -1) {
    perror("Error: pipe_1");
    exit(1);
  }
  rc2 = pipe(pipe_2);
  if (rc2 == -1) {
    perror("Error: pipe_2");
    exit(1);
  }
  fp = fopen("mobydick.txt", "r");
  if (fp == NULL) {
    perror("Error: mobydick.txt");
    return (-1);
  }
  fpout = fopen("mobydicknew.txt", "wb");
  if (fpout == NULL) {
    perror("Error: mobydicknew.txt");
    return (-1);
  }
  line = returnLine(fp);
  while (line != NULL) {
    pid = fork();
    if (pid != 0) {
      rc1 = write(pipe_1[1], line, strlen(line) + 1);
      if (rc1 == -1) {
        perror("Error: writing to pipe 1");
        close(pipe_1[1]);
        exit(1);
      }
      waitpid(pid, &status, 0);
      exit(1);
    } else {
      rc1 = read(pipe_1[0], read_buffer_1, sizeof(read_buffer_1));
      for (int i = 0; i < strlen(read_buffer_1); i++) {
        int test1 = islower(read_buffer_1[i]);
        int test2 = isupper(read_buffer_1[i]);
        if ((test1 != 0) && (test2 == 0)) {
          read_buffer_1[i] = toupper(read_buffer_1[i]);
        } else if ((test1 == 0) && (test2 != 0)) {
          read_buffer_1[i] = tolower(read_buffer_1[i]);
        } else {
          read_buffer_1[i] = read_buffer_1[i];
        }
      }
      rc2 = write(pipe_2[1], read_buffer_1, sizeof(read_buffer_1));
      pid2 = fork();
      if (pid2 != 0) {
        waitpid(pid2, &status, 0);
      } else {
        rc2 = read(pipe_2[0], read_buffer_2, sizeof(read_buffer_2));
        strcat(read_buffer_2, "\n");
        fputs(read_buffer_2, fpout);
        exit(0);
      }
    }
    line = returnLine(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   10a0 <pipe@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1255 <main+0x45>
lea    0xdba(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x20(%rbp),%rdi
call   10a0 <pipe@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1281 <main+0x71>
lea    0xd9c(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xd9d(%rip),%rdi
lea    0xd8d(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x180(%rbp)
cmpq   $0x0,-0x180(%rbp)
jne    12c1 <main+0xb1>
lea    0xd6e(%rip),%rdi
call   1100 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1596 <main+0x386>
lea    0xd74(%rip),%rdi
lea    0xd63(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x188(%rbp)
cmpq   $0x0,-0x188(%rbp)
jne    1301 <main+0xf1>
lea    0xd45(%rip),%rdi
call   1100 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1596 <main+0x386>
mov    -0x180(%rbp),%rdi
call   1060 <returnLine@plt>
mov    %rax,-0x178(%rbp)
cmpq   $0x0,-0x178(%rbp)
je     158f <main+0x37f>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     13b3 <main+0x1a3>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
mov    -0x178(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x178(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x1a4(%rbp),%edi
mov    -0x1a0(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <write@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    139b <main+0x18b>
lea    0xcc8(%rip),%rdi
call   1100 <perror@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x2c(%rbp),%edi
lea    -0x34(%rbp),%rsi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    $0x96,%edx
call   10b0 <read@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x18c(%rbp)
mov    -0x18c(%rbp),%eax
mov    %eax,-0x1a8(%rbp)
lea    -0xd0(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ecx
mov    -0x1a8(%rbp),%eax
cmp    %ecx,%eax
jge    14f0 <main+0x2e0>
movslq -0x18c(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   1030 <islower@plt>
mov    %eax,-0x190(%rbp)
movslq -0x18c(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   10d0 <isupper@plt>
mov    %eax,-0x194(%rbp)
cmpl   $0x0,-0x190(%rbp)
je     1473 <main+0x263>
cmpl   $0x0,-0x194(%rbp)
jne    1473 <main+0x263>
movslq -0x18c(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   1040 <toupper@plt>
mov    %al,%cl
movslq -0x18c(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
jmp    14d7 <main+0x2c7>
cmpl   $0x0,-0x190(%rbp)
jne    14b6 <main+0x2a6>
cmpl   $0x0,-0x194(%rbp)
je     14b6 <main+0x2a6>
movslq -0x18c(%rbp),%rax
movsbl -0xd0(%rbp,%rax,1),%edi
ff
call   10c0 <tolower@plt>
mov    %al,%cl
movslq -0x18c(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
jmp    14d2 <main+0x2c2>
movslq -0x18c(%rbp),%rax
mov    -0xd0(%rbp,%rax,1),%cl
movslq -0x18c(%rbp),%rax
mov    %cl,-0xd0(%rbp,%rax,1)
jmp    14d7 <main+0x2c7>
jmp    14dc <main+0x2cc>
mov    -0x18c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18c(%rbp)
jmp    13d4 <main+0x1c4>
mov    -0x1c(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    $0x96,%edx
call   1050 <write@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1130 <fork@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     152e <main+0x31e>
mov    -0x30(%rbp),%edi
lea    -0x34(%rbp),%rsi
xor    %edx,%edx
call   10e0 <waitpid@plt>
jmp    1572 <main+0x362>
mov    -0x20(%rbp),%edi
lea    -0x170(%rbp),%rsi
mov    $0x96,%edx
call   10b0 <read@plt>
mov    %eax,-0x28(%rbp)
lea    -0x170(%rbp),%rdi
lea    0xb12(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x170(%rbp),%rdi
mov    -0x188(%rbp),%rsi
call   1080 <fputs@plt>
xor    %edi,%edi
call   1120 <exit@plt>
jmp    1577 <main+0x367>
mov    -0x180(%rbp),%rdi
call   1060 <returnLine@plt>
mov    %rax,-0x178(%rbp)
jmp    1314 <main+0x104>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
lea    0x8(%rsp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
je     1466 <main+0x256>
lea    0x10(%rsp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
je     146f <main+0x25f>
lea    0xdd7(%rip),%rdi
lea    0xdc7(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     13e4 <main+0x1d4>
mov    %rax,%r15
lea    0xdcf(%rip),%rdi
lea    0xdbe(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     13ed <main+0x1dd>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <returnLine@plt>
test   %rax,%rax
je     13e0 <main+0x1d0>
mov    %rax,%r13
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
jne    139d <main+0x18d>
mov    %rbx,0x18(%rsp)
lea    0x20(%rsp),%r14
lea    0x4(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%edi
mov    %r14,%rsi
mov    $0x96,%edx
call   10b0 <read@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
test   %eax,%eax
jle    1350 <main+0x140>
xor    %ebx,%ebx
jmp    1311 <main+0x101>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x20(%rsp,%rbx,1),%edi
call   1040 <toupper@plt>
mov    %al,0x20(%rsp,%rbx,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1350 <main+0x140>
movsbl 0x20(%rsp,%rbx,1),%edi
call   1030 <islower@plt>
mov    %eax,%ebp
movsbl 0x20(%rsp,%rbx,1),%edi
call   10d0 <isupper@plt>
test   %ebp,%ebp
je     132f <main+0x11f>
test   %eax,%eax
je     12f0 <main+0xe0>
test   %ebp,%ebp
jne    12fe <main+0xee>
test   %eax,%eax
je     12fe <main+0xee>
movsbl 0x20(%rsp,%rbx,1),%edi
call   10c0 <tolower@plt>
jmp    12fa <main+0xea>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x14(%rsp),%edi
mov    %r14,%rsi
mov    $0x96,%edx
call   1050 <write@plt>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1412 <main+0x202>
xor    %ebp,%ebp
mov    %eax,%edi
mov    %r12,%rsi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    %r15,%rdi
call   1060 <returnLine@plt>
test   %rax,%rax
je     13fe <main+0x1ee>
mov    %rax,%r13
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     12c0 <main+0xb0>
mov    %eax,%ebp
mov    0xc(%rsp),%ebx
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    0x1(%rax),%edx
mov    %ebx,%edi
mov    %r13,%rsi
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    144e <main+0x23e>
lea    0xc84(%rip),%rdi
call   1100 <perror@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
xor    %ebp,%ebp
jmp    13fe <main+0x1ee>
lea    0xc33(%rip),%rdi
jmp    13f4 <main+0x1e4>
lea    0xc41(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x158,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x10(%rsp),%edi
lea    0xc0(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x96,%edx
call   10b0 <read@plt>
lea    0xc33(%rip),%rsi
mov    %rbx,%rdi
call   1110 <strcat@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
call   1080 <fputs@plt>
xor    %edi,%edi
call   1120 <exit@plt>
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    0xb93(%rip),%rdi
jmp    1476 <main+0x266>
lea    0xb98(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Error: pipe_1\00"
@.str.1 = [14 x i8] c"Error: pipe_2\00"
@.str.2 = [13 x i8] c"mobydick.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [20 x i8] c"Error: mobydick.txt\00"
@.str.5 = [16 x i8] c"mobydicknew.txt\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [23 x i8] c"Error: mobydicknew.txt\00"
@.str.8 = [25 x i8] c"Error: writing to pipe 1\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [150 x i8]
%14 = alloca [150 x i8]
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%22 = call i32 @pipe(i32* %21)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%30 = call i32 @pipe(i32* %29)
store i32 %30, i32* %9
%31 = load i32, i32* %9
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %28
%37 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %37, i32** %16
%38 = load i32*, i32** %16
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %168
42: ; preds = %36
%43 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
store i32* %43, i32** %17
%44 = load i32*, i32** %17
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %3
br label %168
48: ; preds = %42
%49 = load i32*, i32** %16
%50 = call i8* @returnLine(i32* %49)
store i8* %50, i8** %15
br label %51
51: ; preds = %164, %48
%52 = load i8*, i8** %15
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %167
54: ; preds = %51
%55 = call i32 (...) @fork()
store i32 %55, i32* %10
%56 = load i32, i32* %10
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %78
58: ; preds = %54
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%60 = load i32, i32* %59
%61 = load i8*, i8** %15
%62 = load i8*, i8** %15
%63 = call i32 @strlen(i8* %62)
%64 = add nsw i32 %63, 1
%65 = call i32 @write(i32 %60, i8* %61, i32 %64)
store i32 %65, i32* %8
%66 = load i32, i32* %8
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %74
68: ; preds = %58
%69 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%71 = load i32, i32* %70
%72 = call i32 @close(i32 %71)
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %58
%75 = load i32, i32* %10
%76 = call i32 @waitpid(i32 %75, i32* %12, i32 0)
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %54
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%80 = load i32, i32* %79
%81 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 0
%82 = call i32 @read(i32 %80, i8* %81, i32 150)
store i32 %82, i32* %8
store i32 0, i32* %18
br label %83
83: ; preds = %138, %78
%84 = load i32, i32* %18
%85 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 0
%86 = call i32 @strlen(i8* %85)
%87 = icmp slt i32 %84, %86
br i1 %87, label %88, label %141
88: ; preds = %83
%89 = load i32, i32* %18
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %90
%92 = load i8, i8* %91
%93 = call i32 @islower(i8 signext %92)
store i32 %93, i32* %19
%94 = load i32, i32* %18
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %95
%97 = load i8, i8* %96
%98 = call i32 @isupper(i8 signext %97)
store i32 %98, i32* %20
%99 = load i32, i32* %19
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %113
101: ; preds = %88
%102 = load i32, i32* %20
%103 = icmp eq i32 %102, 0
br i1 %103, label %104, label %113
104: ; preds = %101
%105 = load i32, i32* %18
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %106
%108 = load i8, i8* %107
%109 = call signext i8 @toupper(i8 signext %108)
%110 = load i32, i32* %18
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %111
store i8 %109, i8* %112
br label %137
113: ; preds = %101, %88
%114 = load i32, i32* %19
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %128
116: ; preds = %113
%117 = load i32, i32* %20
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %128
119: ; preds = %116
%120 = load i32, i32* %18
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %121
%123 = load i8, i8* %122
%124 = call signext i8 @tolower(i8 signext %123)
%125 = load i32, i32* %18
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %126
store i8 %124, i8* %127
br label %136
128: ; preds = %116, %113
%129 = load i32, i32* %18
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %130
%132 = load i8, i8* %131
%133 = load i32, i32* %18
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 %134
store i8 %132, i8* %135
br label %136
136: ; preds = %128, %119
br label %137
137: ; preds = %136, %104
br label %138
138: ; preds = %137
%139 = load i32, i32* %18
%140 = add nsw i32 %139, 1
store i32 %140, i32* %18
br label %83
141: ; preds = %83
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%143 = load i32, i32* %142
%144 = getelementptr inbounds [150 x i8], [150 x i8]* %13, i64 0, i64 0
%145 = call i32 @write(i32 %143, i8* %144, i32 150)
store i32 %145, i32* %9
%146 = call i32 (...) @fork()
store i32 %146, i32* %11
%147 = load i32, i32* %11
%148 = icmp ne i32 %147, 0
br i1 %148, label %149, label %152
149: ; preds = %141
%150 = load i32, i32* %11
%151 = call i32 @waitpid(i32 %150, i32* %12, i32 0)
br label %163
152: ; preds = %141
%153 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%154 = load i32, i32* %153
%155 = getelementptr inbounds [150 x i8], [150 x i8]* %14, i64 0, i64 0
%156 = call i32 @read(i32 %154, i8* %155, i32 150)
store i32 %156, i32* %9
%157 = getelementptr inbounds [150 x i8], [150 x i8]* %14, i64 0, i64 0
%158 = call i32 @strcat(i8* %157, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%159 = getelementptr inbounds [150 x i8], [150 x i8]* %14, i64 0, i64 0
%160 = load i32*, i32** %17
%161 = call i32 @fputs(i8* %159, i32* %160)
%162 = call i32 @exit(i32 0)
unreachable
163: ; preds = %149
br label %164
164: ; preds = %163
%165 = load i32*, i32** %16
%166 = call i8* @returnLine(i32* %165)
store i8* %166, i8** %15
br label %51
167: ; preds = %51
store i32 0, i32* %3
br label %168
168: ; preds = %167, %46, %40
%169 = load i32, i32* %3
ret i32 %169
}

LLVM IR (-O2):
@.str = [14 x i8] c"Error: pipe_1\00"
@.str.1 = [14 x i8] c"Error: pipe_2\00"
@.str.2 = [13 x i8] c"mobydick.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [20 x i8] c"Error: mobydick.txt\00"
@.str.5 = [16 x i8] c"mobydicknew.txt\00"
@.str.6 = [3 x i8] c"wb\00"
@.str.7 = [23 x i8] c"Error: mobydicknew.txt\00"
@.str.8 = [25 x i8] c"Error: writing to pipe 1\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca [150 x i8]
%7 = alloca [150 x i8]
%8 = bitcast [2 x i32]* %3 to i8*
%9 = bitcast [2 x i32]* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = getelementptr inbounds [150 x i8], [150 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [150 x i8], [150 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%14 = call i32 @pipe(i32* %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%21 = call i32 @pipe(i32* %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %106, label %29
29: ; preds = %26
%30 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%31 = icmp eq i32* %30, null
br i1 %31, label %106, label %32
32: ; preds = %29
%33 = call i8* @returnLine(i32* %27)
%34 = icmp eq i8* %33, null
br i1 %34, label %109, label %35
35: ; preds = %32
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%37 = call i32 (...) @fork()
%38 = icmp eq i32 %37, 0
br i1 %38, label %59, label %42
39: ; preds = %96
%40 = call i32 (...) @fork()
%41 = icmp eq i32 %40, 0
br i1 %41, label %59, label %42
42: ; preds = %39, %35
%43 = phi i8* [ %33, %35 ], [ %98, %39 ]
%44 = phi i32 [ %37, %35 ], [ %40, %39 ]
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%46 = load i32, i32* %45
%47 = call i32 @strlen(i8* %43)
%48 = add nsw i32 %47, 1
%49 = call i32 @write(i32 %46, i8* %43, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %56
51: ; preds = %42
%52 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
%53 = load i32, i32* %45
%54 = call i32 @close(i32 %53)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %42
%57 = call i32 @waitpid(i32 %44, i32* %5, i32 0)
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %35, %39
%60 = load i32, i32* %13
%61 = call i32 @read(i32 %60, i8* %11, i32 150)
%62 = call i32 @strlen(i8* %11)
%63 = icmp sgt i32 %62, 0
br i1 %63, label %69, label %64
64: ; preds = %91, %59
%65 = load i32, i32* %36
%66 = call i32 @write(i32 %65, i8* %11, i32 150)
%67 = call i32 (...) @fork()
%68 = icmp eq i32 %67, 0
br i1 %68, label %100, label %96
69: ; preds = %59, %91
%70 = phi i64 [ %92, %91 ], [ 0, %59 ]
%71 = getelementptr inbounds [150 x i8], [150 x i8]* %6, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = call i32 @islower(i8 signext %72)
%74 = load i8, i8* %71
%75 = call i32 @isupper(i8 signext %74)
%76 = icmp ne i32 %73, 0
%77 = icmp eq i32 %75, 0
%78 = select i1 %76, i1 %77, i1 false
br i1 %78, label %79, label %82
79: ; preds = %69
%80 = load i8, i8* %71
%81 = call signext i8 @toupper(i8 signext %80)
br label %89
82: ; preds = %69
%83 = icmp eq i32 %73, 0
%84 = icmp ne i32 %75, 0
%85 = select i1 %83, i1 %84, i1 false
br i1 %85, label %86, label %91
86: ; preds = %82
%87 = load i8, i8* %71
%88 = call signext i8 @tolower(i8 signext %87)
br label %89
89: ; preds = %79, %86
%90 = phi i8 [ %88, %86 ], [ %81, %79 ]
store i8 %90, i8* %71
br label %91
91: ; preds = %89, %82
%92 = add nuw nsw i64 %70, 1
%93 = call i32 @strlen(i8* %11)
%94 = sext i32 %93 to i64
%95 = icmp slt i64 %92, %94
br i1 %95, label %69, label %64
96: ; preds = %64
%97 = call i32 @waitpid(i32 %67, i32* %5, i32 0)
%98 = call i8* @returnLine(i32* %27)
%99 = icmp eq i8* %98, null
br i1 %99, label %109, label %39
100: ; preds = %64
%101 = load i32, i32* %20
%102 = call i32 @read(i32 %101, i8* %12, i32 150)
%103 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%104 = call i32 @fputs(i8* %12, i32* %30)
%105 = call i32 @exit(i32 0)
unreachable
106: ; preds = %29, %26
%107 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), %26 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), %29 ]
%108 = call i32 @perror(i8* %107)
br label %109
109: ; preds = %96, %106, %32
%110 = phi i32 [ 0, %32 ], [ -1, %106 ], [ 0, %96 ]
ret i32 %110
}