#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*/ message;

/* Variables and functions */
scalar_t__ close(int);
int fork();
int /*<<< orphan*/ memcpy(int *, char *, int);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int /*<<< orphan*/ syserr(char *);
int /*<<< orphan*/ write(int, ...);
void foo(int d, int readFrom) {
  printf("foo %d %d\n", d, readFrom);
  char message[100];
  sprintf(message, "Happy holidays from %d", d);
  if (d > 0) {
    int pipe_dsc[2];
    if (pipe(pipe_dsc) == -1) {
      syserr("Error in pipe");
    }
    int pid;
    switch (pid = fork()) {
    case -1:
      syserr("Error in fork\n");
      break;
    case 0:
      printf("I am a child %d, going further\n", d);
      foo(d - 1, pipe_dsc[0]);
      break;
    default:
      printf("I am a parent %d, I've just forked\n", d);
      if (readFrom != -1) {
        char buff[300];
        while (read(readFrom, buff, sizeof(int))) {
          int sz;
          memcpy(&sz, buff, sizeof(int));
          printf("next size is %d\n", sz);
          if (sz == 0) {
            break;
          } else {
            read(readFrom, buff, sz);
            printf("Just read %s\n", buff);
            write(pipe_dsc[1], &sz, 4);
            write(pipe_dsc[1], buff, sz);
          }
        }
        if (close(readFrom)) {
          syserr("Error in close");
        }
      }
      int sz = strlen(message);
      write(pipe_dsc[1], &sz, 4);
      write(pipe_dsc[1], message, sizeof(message));
      close(pipe_dsc[1]);
      break;
    }
  } else {
    if (readFrom != -1) {
      char buff[300];
      while (read(readFrom, buff, sizeof(int))) {
        int sz;
        memcpy(&sz, buff, sizeof(int));
        printf("next size is %d\n", sz);
        if (sz == 0) {
          break;
        } else {
          read(readFrom, buff, sz);
          printf("Just read %s\n", buff);
          puts(buff);
        }
      }
      if (close(readFrom)) {
        syserr("Error in close");
      }
    }
    printf("%s", message);
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe18(%rip),%rsi
call   10d0 <sprintf@plt>
cmpl   $0x0,-0x4(%rbp)
jle    13c8 <foo+0x208>
lea    -0x78(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1220 <foo+0x60>
lea    0xe07(%rip),%rdi
call   1070 <syserr@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
mov    %eax,-0x7c(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x2f8(%rbp)
sub    $0xffffffff,%eax
je     1253 <foo+0x93>
jmp    1240 <foo+0x80>
mov    -0x2f8(%rbp),%eax
test   %eax,%eax
je     1264 <foo+0xa4>
jmp    1288 <foo+0xc8>
lea    0xdd6(%rip),%rdi
call   1070 <syserr@plt>
jmp    13c3 <foo+0x203>
mov    -0x4(%rbp),%esi
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x78(%rbp),%esi
call   10c0 <foo@plt>
jmp    13c3 <foo+0x203>
mov    -0x4(%rbp),%esi
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0xffffffff,-0x8(%rbp)
je     1383 <foo+0x1c3>
jmp    12a8 <foo+0xe8>
mov    -0x8(%rbp),%edi
lea    -0x1b0(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
cmp    $0x0,%rax
je     1360 <foo+0x1a0>
lea    -0x1b0(%rbp),%rsi
lea    -0x1b4(%rbp),%rdi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    -0x1b4(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x1b4(%rbp)
jne    1304 <foo+0x144>
jmp    1360 <foo+0x1a0>
mov    -0x8(%rbp),%edi
lea    -0x1b0(%rbp),%rsi
mov    -0x1b4(%rbp),%edx
call   10a0 <read@plt>
lea    -0x1b0(%rbp),%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x74(%rbp),%edi
lea    -0x1b4(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    -0x74(%rbp),%edi
lea    -0x1b0(%rbp),%rsi
mov    -0x1b4(%rbp),%edx
mov    $0x0,%al
call   1040 <write@plt>
jmp    12a8 <foo+0xe8>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
cmp    $0x0,%rax
je     137e <foo+0x1be>
lea    0xd29(%rip),%rdi
call   1070 <syserr@plt>
jmp    1383 <foo+0x1c3>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1b8(%rbp)
mov    -0x74(%rbp),%edi
lea    -0x1b8(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    -0x74(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x64,%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    -0x74(%rbp),%edi
call   1080 <close@plt>
jmp    14a3 <foo+0x2e3>
cmpl   $0xffffffff,-0x8(%rbp)
je     1491 <foo+0x2d1>
jmp    13d7 <foo+0x217>
mov    -0x8(%rbp),%edi
lea    -0x2f0(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
cmp    $0x0,%rax
je     146e <foo+0x2ae>
lea    -0x2f0(%rbp),%rsi
lea    -0x2f4(%rbp),%rdi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    -0x2f4(%rbp),%esi
lea    0xc69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x2f4(%rbp)
jne    1433 <foo+0x273>
jmp    146e <foo+0x2ae>
mov    -0x8(%rbp),%edi
lea    -0x2f0(%rbp),%rsi
mov    -0x2f4(%rbp),%edx
call   10a0 <read@plt>
lea    -0x2f0(%rbp),%rsi
lea    0xc3e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x2f0(%rbp),%rdi
call   1030 <puts@plt>
jmp    13d7 <foo+0x217>
mov    -0x8(%rbp),%edi
call   1080 <close@plt>
cmp    $0x0,%rax
je     148c <foo+0x2cc>
lea    0xc1b(%rip),%rdi
call   1070 <syserr@plt>
jmp    1491 <foo+0x2d1>
lea    -0x70(%rbp),%rsi
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x300,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1b0,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
lea    0xe26(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1f(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    %ebp,%edx
call   10d0 <sprintf@plt>
test   %ebp,%ebp
jle    1240 <foo+0x80>
lea    0x4(%rsp),%rdi
call   1090 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1217 <foo+0x57>
lea    0xe10(%rip),%rdi
call   1070 <syserr@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     1309 <foo+0x149>
cmp    $0xffffffff,%eax
jne    132c <foo+0x16c>
lea    0xdfa(%rip),%rdi
call   1070 <syserr@plt>
jmp    1456 <foo+0x296>
cmp    $0xffffffff,%ebx
je     12f1 <foo+0x131>
lea    0x80(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   10a0 <read@plt>
test   %rax,%rax
je     12d9 <foo+0x119>
lea    0x4(%rsp),%r14
lea    0x80(%rsp),%rbp
lea    0xe0d(%rip),%r15
lea    0xe17(%rip),%r12
nopl   (%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
je     12d9 <foo+0x119>
mov    %ebx,%edi
mov    %rbp,%rsi
call   10a0 <read@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
test   %rax,%rax
jne    1280 <foo+0xc0>
mov    %ebx,%edi
call   1080 <close@plt>
test   %rax,%rax
je     12f1 <foo+0x131>
lea    0xdb6(%rip),%rdi
call   1070 <syserr@plt>
lea    0xdb9(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1456 <foo+0x296>
lea    0xd2f(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebp
mov    0x4(%rsp),%esi
mov    %ebp,%edi
call   10c0 <foo@plt>
jmp    1456 <foo+0x296>
lea    0xd2c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0xffffffff,%ebx
je     140e <foo+0x24e>
lea    0x80(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   10a0 <read@plt>
test   %rax,%rax
je     13f6 <foo+0x236>
lea    0xc(%rsp),%r14
lea    0x80(%rsp),%rbp
lea    0xd0d(%rip),%r15
lea    0xd17(%rip),%r12
nopl   (%rax)
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x4,%edx
call   10b0 <memcpy@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     13f6 <foo+0x236>
mov    %ebx,%edi
mov    %rbp,%rsi
call   10a0 <read@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%edi
mov    %r14,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <write@plt>
mov    0x8(%rsp),%edi
mov    0xc(%rsp),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
test   %rax,%rax
jne    1380 <foo+0x1c0>
mov    %ebx,%edi
call   1080 <close@plt>
test   %rax,%rax
je     140e <foo+0x24e>
lea    0xc99(%rip),%rdi
call   1070 <syserr@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,0x80(%rsp)
mov    0x8(%rsp),%edi
lea    0x80(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <write@plt>
mov    0x8(%rsp),%edi
mov    $0x64,%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <write@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
add    $0x1b0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"foo %d %d\0A\00"
@.str.1 = [23 x i8] c"Happy holidays from %d\00"
@.str.2 = [14 x i8] c"Error in pipe\00"
@.str.3 = [15 x i8] c"Error in fork\0A\00"
@.str.4 = [32 x i8] c"I am a child %d, going further\0A\00"
@.str.5 = [36 x i8] c"I am a parent %d, I've just forked\0A\00"
@.str.6 = [17 x i8] c"next size is %d\0A\00"
@.str.7 = [14 x i8] c"Just read %s\0A\00"
@.str.8 = [15 x i8] c"Error in close\00"
@.str.9 = [3 x i8] c"%s\00"
define void @foo(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca [300 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca [300 x i8]
%12 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* %3
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %94
21: ; preds = %2
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%23 = call i32 @pipe(i32* %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @syserr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = call i32 (...) @fork()
store i32 %28, i32* %7
switch i32 %28, label %38 [
i32 -1, label %29
i32 0, label %31
]
29: ; preds = %27
%30 = call i32 @syserr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %93
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%37 = load i32, i32* %36
br label %93
38: ; preds = %27
%39 = load i32, i32* %3
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, -1
br i1 %42, label %43, label %80
43: ; preds = %38
br label %44
44: ; preds = %72, %43
%45 = load i32, i32* %4
%46 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%47 = call i64 @read(i32 %45, i8* %46, i32 4)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %73
49: ; preds = %44
%50 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%51 = call i32 @memcpy(i32* %9, i8* %50, i32 4)
%52 = load i32, i32* %9
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = load i32, i32* %9
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %49
br label %73
57: ; preds = %49
%58 = load i32, i32* %4
%59 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%60 = load i32, i32* %9
%61 = call i64 @read(i32 %58, i8* %59, i32 %60)
%62 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %62)
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 (i32, ...) @write(i32 %65, i32* %9, i32 4)
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%68 = load i32, i32* %67
%69 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%70 = load i32, i32* %9
%71 = call i32 (i32, ...) @write(i32 %68, i8* %69, i32 %70)
br label %72
72: ; preds = %57
br label %44
73: ; preds = %56, %44
%74 = load i32, i32* %4
%75 = call i64 @close(i32 %74)
%76 = icmp ne i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 @syserr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %79
79: ; preds = %77, %73
br label %80
80: ; preds = %79, %38
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%82 = call i32 @strlen(i8* %81)
store i32 %82, i32* %10
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%84 = load i32, i32* %83
%85 = call i32 (i32, ...) @write(i32 %84, i32* %10, i32 4)
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%87 = load i32, i32* %86
%88 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%89 = call i32 (i32, ...) @write(i32 %87, i8* %88, i64 100)
%90 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%91 = load i32, i32* %90
%92 = call i64 @close(i32 %91)
br label %93
93: ; preds = %80, %31, %29
br label %131
94: ; preds = %2
%95 = load i32, i32* %4
%96 = icmp ne i32 %95, -1
br i1 %96, label %97, label %128
97: ; preds = %94
br label %98
98: ; preds = %120, %97
%99 = load i32, i32* %4
%100 = getelementptr inbounds [300 x i8], [300 x i8]* %11, i64 0, i64 0
%101 = call i64 @read(i32 %99, i8* %100, i32 4)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %121
103: ; preds = %98
%104 = getelementptr inbounds [300 x i8], [300 x i8]* %11, i64 0, i64 0
%105 = call i32 @memcpy(i32* %12, i8* %104, i32 4)
%106 = load i32, i32* %12
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %12
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %111
110: ; preds = %103
br label %121
111: ; preds = %103
%112 = load i32, i32* %4
%113 = getelementptr inbounds [300 x i8], [300 x i8]* %11, i64 0, i64 0
%114 = load i32, i32* %12
%115 = call i64 @read(i32 %112, i8* %113, i32 %114)
%116 = getelementptr inbounds [300 x i8], [300 x i8]* %11, i64 0, i64 0
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %116)
%118 = getelementptr inbounds [300 x i8], [300 x i8]* %11, i64 0, i64 0
%119 = call i32 @puts(i8* %118)
br label %120
120: ; preds = %111
br label %98
121: ; preds = %110, %98
%122 = load i32, i32* %4
%123 = call i64 @close(i32 %122)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %127
125: ; preds = %121
%126 = call i32 @syserr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %127
127: ; preds = %125, %121
br label %128
128: ; preds = %127, %94
%129 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %129)
br label %131
131: ; preds = %128, %93
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"foo %d %d\0A\00"
@.str.1 = [23 x i8] c"Happy holidays from %d\00"
@.str.2 = [14 x i8] c"Error in pipe\00"
@.str.3 = [15 x i8] c"Error in fork\0A\00"
@.str.4 = [32 x i8] c"I am a child %d, going further\0A\00"
@.str.5 = [36 x i8] c"I am a parent %d, I've just forked\0A\00"
@.str.6 = [17 x i8] c"next size is %d\0A\00"
@.str.7 = [14 x i8] c"Just read %s\0A\00"
@.str.8 = [15 x i8] c"Error in close\00"
@.str.9 = [3 x i8] c"%s\00"
define void @foo(i32 %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = alloca [2 x i32]
%5 = alloca [300 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = alloca [300 x i8]
%9 = alloca i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %73
14: ; preds = %2
%15 = bitcast [2 x i32]* %4 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @syserr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = call i32 (...) @fork()
switch i32 %22, label %29 [
i32 -1, label %23
i32 0, label %25
]
23: ; preds = %21
%24 = call i32 @syserr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %72
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %0)
%27 = add nsw i32 %0, -1
%28 = load i32, i32* %16
br label %72
29: ; preds = %21
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 %0)
%31 = icmp eq i32 %1, -1
br i1 %31, label %62, label %32
32: ; preds = %29
%33 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%34 = call i64 @read(i32 %1, i8* %33, i32 4)
%35 = icmp eq i64 %34, 0
br i1 %35, label %56, label %36
36: ; preds = %32
%37 = bitcast i32* %6 to i8*
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
br label %39
39: ; preds = %36, %46
%40 = call i32 @memcpy(i32* %6, i8* %33, i32 4)
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %39
br label %56
46: ; preds = %39
%47 = call i64 @read(i32 %1, i8* %33, i32 %43)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %33)
%49 = load i32, i32* %38
%50 = call i32 (i32, ...) @write(i32 %49, i32* %6, i32 4)
%51 = load i32, i32* %38
%52 = load i32, i32* %6
%53 = call i32 (i32, ...) @write(i32 %51, i8* %33, i32 %52)
%54 = call i64 @read(i32 %1, i8* %33, i32 4)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %39
56: ; preds = %46, %32, %45
%57 = call i64 @close(i32 %1)
%58 = icmp eq i64 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = call i32 @syserr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %59, %56
br label %62
62: ; preds = %61, %29
%63 = bitcast i32* %7 to i8*
%64 = call i32 @strlen(i8* %11)
store i32 %64, i32* %7
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%66 = load i32, i32* %65
%67 = call i32 (i32, ...) @write(i32 %66, i32* %7, i32 4)
%68 = load i32, i32* %65
%69 = call i32 (i32, ...) @write(i32 %68, i8* %11, i64 100)
%70 = load i32, i32* %65
%71 = call i64 @close(i32 %70)
br label %72
72: ; preds = %62, %25, %23
br label %102
73: ; preds = %2
%74 = icmp eq i32 %1, -1
br i1 %74, label %100, label %75
75: ; preds = %73
%76 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 0
%77 = call i64 @read(i32 %1, i8* %76, i32 4)
%78 = icmp eq i64 %77, 0
br i1 %78, label %94, label %79
79: ; preds = %75
%80 = bitcast i32* %9 to i8*
br label %81
81: ; preds = %79, %88
%82 = call i32 @memcpy(i32* %9, i8* %76, i32 4)
%83 = load i32, i32* %9
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %9
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %81
br label %94
88: ; preds = %81
%89 = call i64 @read(i32 %1, i8* %76, i32 %85)
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %76)
%91 = call i32 @puts(i8* %76)
%92 = call i64 @read(i32 %1, i8* %76, i32 4)
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %81
94: ; preds = %88, %75, %87
%95 = call i64 @close(i32 %1)
%96 = icmp eq i64 %95, 0
br i1 %96, label %99, label %97
97: ; preds = %94
%98 = call i32 @syserr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %99
99: ; preds = %97, %94
br label %100
100: ; preds = %99, %73
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8* %11)
br label %102
102: ; preds = %100, %72
ret void
}