#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*/ close(int);
int /*<<< orphan*/ exit(int);
int fork();
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
scalar_t__ strcmp(char *, char *);
size_t write(int, char *, int);
int main(int argc, char *argv[], char *env[]) {
  printf("\n--------------------LAB5--------------------\n");
  int fdp[2], fdc[2], p_id;
  size_t size;
  int i = 0;
  int chat = 1;
  char *msg_list[] = {"Hello!", "How are you?", "I was the first!",
                      "It's so funny!", "Bye!"};
  char msg[16];
  if (pipe(fdc) < 0) {
    printf("Can\'t create pipe\n");
    exit(-1);
  }
  if (pipe(fdp) < 0) {
    printf("Can\'t create pipe\n");
    exit(-1);
  }
  p_id = fork();
  if (p_id < 0) {
    printf("Can\'t fork child\n");
    exit(-1);
  } else if (p_id > 0) {
    close(fdc[0]);
    close(fdp[1]);
    while (chat > 0) {
      size = write(fdc[1], msg_list[i], 16);
      while (size = read(fdp[0], msg, 16) < 0)
        ;
      printf("FromChild: %s\n", msg);
      if (strcmp(msg, msg_list[4]) == 0)
        chat = -1;
      i++;
    }
    close(fdc[1]);
    close(fdp[0]);
    printf("\n--------------------LAB5PARENT_END--------------------\n");
  } else {
    close(fdc[1]);
    close(fdp[0]);
    while (chat > 0) {
      while (size = read(fdc[0], msg, 16) < 0)
        ;
      printf("FromParent: %s\n", msg);
      size = write(fdp[1], msg_list[i], 16);
      if (strcmp(msg, msg_list[4]) == 0)
        chat = -1;
      i++;
    }
    close(fdp[1]);
    close(fdc[0]);
    printf("\n--------------------LAB5CHILD_END--------------------\n");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xe4f(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe4b(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe4d(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe53(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe57(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    -0x28(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    123b <main+0xab>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    -0x20(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    1266 <main+0xd6>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1292 <main+0x102>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    1363 <main+0x1d3>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x40(%rbp)
jle    1340 <main+0x1b0>
mov    -0x24(%rbp),%edi
movslq -0x3c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x10,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     1302 <main+0x172>
jmp    12d0 <main+0x140>
lea    -0x80(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1332 <main+0x1a2>
movl   $0xffffffff,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12ac <main+0x11c>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
lea    0xd45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    142a <main+0x29a>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
cmpl   $0x0,-0x40(%rbp)
jle    140c <main+0x27c>
jmp    1382 <main+0x1f2>
mov    -0x28(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x10,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     13b4 <main+0x224>
jmp    1382 <main+0x1f2>
lea    -0x80(%rbp),%rsi
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
movslq -0x3c(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
mov    $0x10,%edx
call   1030 <write@plt>
mov    %rax,-0x38(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    13fe <main+0x26e>
movl   $0xffffffff,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1373 <main+0x1e3>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    142f <main+0x29f>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe51(%rip),%r14
mov    %r14,0x10(%rsp)
lea    0xe4c(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xe4d(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe52(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xe55(%rip),%rax
mov    %rax,0x30(%rsp)
mov    %rsp,%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     1200 <main+0x70>
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
jns    1216 <main+0x86>
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
jns    122a <main+0x9a>
lea    0xecd(%rip),%rdi
jmp    1207 <main+0x77>
jne    12c7 <main+0x137>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    $0x1,%r12d
lea    0x40(%rsp),%rbx
lea    0xdf4(%rip),%r14
lea    0xdd9(%rip),%r15
xor    %ebp,%ebp
nopl   (%rax)
mov    (%rsp),%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1080 <read@plt>
test   %rax,%rax
js     1260 <main+0xd0>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp,%rbp,8),%rsi
mov    $0x10,%edx
call   1040 <write@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcmp@plt>
add    $0x1,%rbp
cmp    $0x1,%rax
sbb    %eax,%eax
or     %eax,%r12d
jg     1260 <main+0xd0>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
lea    0xdc7(%rip),%rbx
mov    (%rsp),%edi
jmp    1362 <main+0x1d2>
mov    (%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
lea    0x40(%rsp),%rbx
lea    0xd55(%rip),%r15
lea    0xd49(%rip),%r12
xor    %ebp,%ebp
nopl   (%rax)
mov    0x4(%rsp),%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   1040 <write@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1080 <read@plt>
test   %rax,%rax
js     1310 <main+0x180>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     134e <main+0x1be>
add    $0x1,%rbp
mov    0x10(%rsp,%rbp,8),%r14
jmp    12f0 <main+0x160>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
lea    0xd5f(%rip),%rbx
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"\0A--------------------LAB5--------------------\0A\00"
@.str.1 = [7 x i8] c"Hello!\00"
@.str.2 = [13 x i8] c"How are you?\00"
@.str.3 = [17 x i8] c"I was the first!\00"
@.str.4 = [15 x i8] c"It's so funny!\00"
@.str.5 = [5 x i8] c"Bye!\00"
@.str.6 = [19 x i8] c"Can't create pipe\0A\00"
@.str.7 = [18 x i8] c"Can't fork child\0A\00"
@.str.8 = [15 x i8] c"FromChild: %s\0A\00"
@.str.9 = [57 x i8] c"\0A--------------------LAB5PARENT_END--------------------\0A\00"
@.str.10 = [16 x i8] c"FromParent: %s\0A\00"
@.str.11 = [56 x i8] c"\0A--------------------LAB5CHILD_END--------------------\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca [2 x i32]
%9 = alloca [2 x i32]
%10 = alloca i32
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca [5 x i8*]
%15 = alloca [16 x i8]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %12
store i32 1, i32* %13
%17 = bitcast [5 x i8*]* %14 to i8*
%18 = bitcast i8* %17 to [5 x i8*]*
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %18, i32 0, i32 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [5 x i8*], [5 x i8*]* %18, i32 0, i32 1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [5 x i8*], [5 x i8*]* %18, i32 0, i32 2
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [5 x i8*], [5 x i8*]* %18, i32 0, i32 3
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [5 x i8*], [5 x i8*]* %18, i32 0, i32 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8** %23
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%25 = call i64 @pipe(i32* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %3
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%32 = call i64 @pipe(i32* %31)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %30
%38 = call i32 (...) @fork()
store i32 %38, i32* %10
%39 = load i32, i32* %10
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%43 = call i32 @exit(i32 -1)
unreachable
44: ; preds = %37
%45 = load i32, i32* %10
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %95
47: ; preds = %44
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%49 = load i32, i32* %48
%50 = call i32 @close(i32 %49)
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%52 = load i32, i32* %51
%53 = call i32 @close(i32 %52)
br label %54
54: ; preds = %84, %47
%55 = load i32, i32* %13
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %87
57: ; preds = %54
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%59 = load i32, i32* %58
%60 = load i32, i32* %12
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i64 0, i64 %61
%63 = load i8*, i8** %62
%64 = call i64 @write(i32 %59, i8* %63, i32 16)
store i64 %64, i64* %11
br label %65
65: ; preds = %74, %57
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%67 = load i32, i32* %66
%68 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%69 = call i64 @read(i32 %67, i8* %68, i32 16)
%70 = icmp slt i64 %69, 0
%71 = zext i1 %70 to i32
%72 = sext i32 %71 to i64
store i64 %72, i64* %11
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %65
br label %65
75: ; preds = %65
%76 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %76)
%78 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%79 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i64 0, i64 4
%80 = load i8*, i8** %79
%81 = call i64 @strcmp(i8* %78, i8* %80)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %75
store i32 -1, i32* %13
br label %84
84: ; preds = %83, %75
%85 = load i32, i32* %12
%86 = add nsw i32 %85, 1
store i32 %86, i32* %12
br label %54
87: ; preds = %54
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%89 = load i32, i32* %88
%90 = call i32 @close(i32 %89)
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%92 = load i32, i32* %91
%93 = call i32 @close(i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0))
br label %143
95: ; preds = %44
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%97 = load i32, i32* %96
%98 = call i32 @close(i32 %97)
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%100 = load i32, i32* %99
%101 = call i32 @close(i32 %100)
br label %102
102: ; preds = %132, %95
%103 = load i32, i32* %13
%104 = icmp sgt i32 %103, 0
br i1 %104, label %105, label %135
105: ; preds = %102
br label %106
106: ; preds = %115, %105
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%108 = load i32, i32* %107
%109 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%110 = call i64 @read(i32 %108, i8* %109, i32 16)
%111 = icmp slt i64 %110, 0
%112 = zext i1 %111 to i32
%113 = sext i32 %112 to i64
store i64 %113, i64* %11
%114 = icmp ne i64 %113, 0
br i1 %114, label %115, label %116
115: ; preds = %106
br label %106
116: ; preds = %106
%117 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %117)
%119 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%120 = load i32, i32* %119
%121 = load i32, i32* %12
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i64 0, i64 %122
%124 = load i8*, i8** %123
%125 = call i64 @write(i32 %120, i8* %124, i32 16)
store i64 %125, i64* %11
%126 = getelementptr inbounds [16 x i8], [16 x i8]* %15, i64 0, i64 0
%127 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i64 0, i64 4
%128 = load i8*, i8** %127
%129 = call i64 @strcmp(i8* %126, i8* %128)
%130 = icmp eq i64 %129, 0
br i1 %130, label %131, label %132
131: ; preds = %116
store i32 -1, i32* %13
br label %132
132: ; preds = %131, %116
%133 = load i32, i32* %12
%134 = add nsw i32 %133, 1
store i32 %134, i32* %12
br label %102
135: ; preds = %102
%136 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%137 = load i32, i32* %136
%138 = call i32 @close(i32 %137)
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%140 = load i32, i32* %139
%141 = call i32 @close(i32 %140)
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.11, i64 0, i64 0))
br label %143
143: ; preds = %135, %87
br label %144
144: ; preds = %143
%145 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"Hello!\00"
@.str.2 = [13 x i8] c"How are you?\00"
@.str.3 = [17 x i8] c"I was the first!\00"
@.str.4 = [15 x i8] c"It's so funny!\00"
@.str.5 = [5 x i8] c"Bye!\00"
@.str.8 = [15 x i8] c"FromChild: %s\0A\00"
@.str.10 = [16 x i8] c"FromParent: %s\0A\00"
@str = [46 x i8] c"\0A--------------------LAB5--------------------\00"
@str.12 = [55 x i8] c"\0A--------------------LAB5CHILD_END--------------------\00"
@str.13 = [56 x i8] c"\0A--------------------LAB5PARENT_END--------------------\00"
@str.14 = [17 x i8] c"Can't fork child\00"
@str.16 = [18 x i8] c"Can't create pipe\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca [5 x i8*]
%7 = alloca [16 x i8]
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%9 = bitcast [2 x i32]* %4 to i8*
%10 = bitcast [2 x i32]* %5 to i8*
%11 = bitcast [5 x i8*]* %6 to i8*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 2
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 3
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%19 = call i64 @pipe(i32* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %3
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %3
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%26 = call i64 @pipe(i32* %25)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %24
%32 = call i32 (...) @fork()
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %31
%38 = icmp eq i32 %32, 0
br i1 %38, label %67, label %39
39: ; preds = %37
%40 = load i32, i32* %18
%41 = call i32 @close(i32 %40)
%42 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%43 = load i32, i32* %42
%44 = call i32 @close(i32 %43)
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
br label %46
46: ; preds = %60, %39
%47 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), %39 ], [ %62, %60 ]
%48 = phi i64 [ 0, %39 ], [ %59, %60 ]
%49 = load i32, i32* %45
%50 = call i64 @write(i32 %49, i8* %47, i32 16)
br label %51
51: ; preds = %51, %46
%52 = load i32, i32* %25
%53 = call i64 @read(i32 %52, i8* %17, i32 16)
%54 = icmp slt i64 %53, 0
br i1 %54, label %51, label %55
55: ; preds = %51
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %17)
%57 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
%59 = add nuw i64 %48, 1
br i1 %58, label %63, label %60
60: ; preds = %55
%61 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 %59
%62 = load i8*, i8** %61
br label %46
63: ; preds = %55
%64 = load i32, i32* %45
%65 = call i32 @close(i32 %64)
%66 = load i32, i32* %25
br label %96
67: ; preds = %37
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = load i32, i32* %25
%72 = call i32 @close(i32 %71)
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
br label %74
74: ; preds = %67, %81
%75 = phi i64 [ 0, %67 ], [ %89, %81 ]
%76 = phi i32 [ 1, %67 ], [ %90, %81 ]
br label %77
77: ; preds = %74, %77
%78 = load i32, i32* %18
%79 = call i64 @read(i32 %78, i8* %17, i32 16)
%80 = icmp slt i64 %79, 0
br i1 %80, label %77, label %81
81: ; preds = %77
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %17)
%83 = load i32, i32* %73
%84 = getelementptr inbounds [5 x i8*], [5 x i8*]* %6, i64 0, i64 %75
%85 = load i8*, i8** %84
%86 = call i64 @write(i32 %83, i8* %85, i32 16)
%87 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%88 = icmp eq i64 %87, 0
%89 = add nuw i64 %75, 1
%90 = select i1 %88, i32 -1, i32 %76
%91 = icmp sgt i32 %90, 0
br i1 %91, label %74, label %92
92: ; preds = %81
%93 = load i32, i32* %73
%94 = call i32 @close(i32 %93)
%95 = load i32, i32* %18
br label %96
96: ; preds = %63, %92
%97 = phi i32 [ %66, %63 ], [ %95, %92 ]
%98 = phi i8* [ getelementptr inbounds ([56 x i8], [56 x i8]* @str.13, i64 0, i64 0), %63 ], [ getelementptr inbounds ([55 x i8], [55 x i8]* @str.12, i64 0, i64 0), %92 ]
%99 = call i32 @close(i32 %97)
%100 = call i32 @puts(i8* dereferenceable(1) %98)
%101 = call i32 @exit(i32 0)
unreachable
}