#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 mode_t;

/* Variables and functions */
scalar_t__ EEXIST;
scalar_t__ EINTR;
int O_NONBLOCK;
int O_RDONLY;
int O_WRONLY;
int S_IRUSR;
int S_IWUSR;
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int fork();
scalar_t__ getpid();
int /*<<< orphan*/ getppid();
int mkfifo(char *, int);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, long);
int strlen(char *);
int waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
unsigned int write(int, char *, unsigned int);
int main(int argc, char *argv[]) {
  mode_t fifo_mode = S_IRUSR | S_IWUSR;
  int fd, status, child;
  char buf[256];
  unsigned strsize;
  if (argc != 2) {
    printf("\n Usage: %s pipename\n", argv[0]);
    exit(1);
  }
  if ((mkfifo(argv[1], fifo_mode) == -1) && (errno != EEXIST)) {
    perror("Pipe");
    exit(1);
  }
  if ((child = fork()) == -1) {
    perror("Fork");
    exit(1);
  } else if (child == 0) {
    printf("Child %ld is about to open FIFO %s\n", (long)getpid(), argv[1]);
    if ((fd = open(argv[1], O_RDONLY | O_NONBLOCK)) == -1) {
      perror("Child cannot open FIFO");
      exit(1);
    }
    printf("Child is about to read\n");
    (long)getpid();
    while ((waitpid(getppid(), &status, 0) == -1) && (errno == EINTR))
      ;
    if (read(fd, buf, 256) <= 0) {
      perror("Child read from FIFO failed\n");
      exit(1);
    }
    printf("Child %ld received: %s\n", (long)getpid(), buf);
  } else {
    printf("\n Parent %ld is about to open FIFO %s\n", (long)getpid(), argv[1]);
    if ((fd = open(argv[1], O_WRONLY)) == -1) {
      perror("Parent cannot open FIFO");
      exit(1);
    }
    sprintf(buf, "This was written by parent %ld\n", (long)getpid());
    strsize = strlen(buf) + 1;
    if (write(fd, buf, strsize) != strsize) {
      printf("Parent write to FIFO failed\n");
      exit(1);
    }
    printf("Parent %ld is done\n", (long)getpid());
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    0x2ddf(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1227 <main+0x57>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1080 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    1270 <main+0xa0>
mov    0x2d79(%rip),%rax
mov    (%rax),%rax
mov    0x2d77(%rip),%rcx
cmp    (%rcx),%rax
je     1270 <main+0xa0>
lea    0xdb5(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    1299 <main+0xc9>
lea    0xd91(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x20(%rbp)
jne    13cd <main+0x1fd>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    0x2d0d(%rip),%rax
or     (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1304 <main+0x134>
lea    0xd4f(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    $0x0,%al
call   10d0 <getppid@plt>
mov    %eax,%edi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   1090 <waitpid@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x125(%rbp)
jne    135d <main+0x18d>
mov    0x2c79(%rip),%rax
mov    (%rax),%rax
mov    0x2c67(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x125(%rbp)
mov    -0x125(%rbp),%al
test   $0x1,%al
jne    1370 <main+0x1a0>
jmp    1375 <main+0x1a5>
jmp    1319 <main+0x149>
mov    -0x18(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1070 <read@plt>
cmp    $0x0,%rax
jg     13a9 <main+0x1d9>
lea    0xcd9(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rsi
lea    -0x120(%rbp),%rdx
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14b6 <main+0x2e6>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcc2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2ba4(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1425 <main+0x255>
lea    0xcb9(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x130(%rbp),%rdi
mov    %rax,%rdx
lea    0xc9c(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1030 <write@plt>
cmp    -0x124(%rbp),%eax
je     149e <main+0x2ce>
lea    0xc7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %rax,%rsi
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14bb <main+0x2eb>
xor    %edi,%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1247 <main+0x67>
mov    0x2db4(%rip),%rax
mov    (%rax),%esi
mov    0x2dd3(%rip),%rax
or     (%rax),%esi
mov    0x8(%rbx),%rdi
call   1090 <mkfifo@plt>
cmp    $0xffffffff,%eax
jne    122b <main+0x4b>
mov    0x2da4(%rip),%rax
mov    (%rax),%rax
mov    0x2da2(%rip),%rcx
cmp    (%rcx),%rax
jne    1262 <main+0x82>
xor    %eax,%eax
call   1100 <fork@plt>
test   %eax,%eax
je     126e <main+0x8e>
cmp    $0xffffffff,%eax
jne    12b6 <main+0xd6>
lea    0xdd9(%rip),%rdi
jmp    135f <main+0x17f>
mov    (%rbx),%rsi
lea    0xdaf(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xdad(%rip),%rdi
jmp    135f <main+0x17f>
xor    %eax,%eax
call   1050 <getpid@plt>
mov    0x8(%rbx),%rdx
lea    0xda0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x2d4b(%rip),%rax
mov    0x2d4c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
jne    12f6 <main+0x116>
lea    0xd93(%rip),%rdi
jmp    135f <main+0x17f>
xor    %eax,%eax
call   1050 <getpid@plt>
mov    0x8(%rbx),%rdx
lea    0xdc8(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x2cc3(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
jne    136e <main+0x18e>
lea    0xdc3(%rip),%rdi
jmp    135f <main+0x17f>
mov    %eax,%r14d
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xc(%rsp),%r15
mov    0x2ca8(%rip),%rbp
mov    0x2c99(%rip),%rbx
nop
xor    %eax,%eax
call   10e0 <getppid@plt>
mov    %eax,%edi
mov    %r15,%rsi
xor    %edx,%edx
call   10a0 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    1341 <main+0x161>
mov    (%rbx),%rax
cmp    %rax,0x0(%rbp)
je     1320 <main+0x140>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    $0x100,%edx
call   1080 <read@plt>
test   %rax,%rax
jg     13ca <main+0x1ea>
lea    0xcfc(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xd51(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %rax,%rdx
call   10d0 <sprintf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %ebx,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <write@plt>
cmp    %ebp,%eax
jne    13ee <main+0x20e>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xd36(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xca0(%rip),%rdi
lea    0x10(%rsp),%rdx
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <exit@plt>
lea    0xd0e(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str = [22 x i8] c"\0A Usage: %s pipename\0A\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [5 x i8] c"Pipe\00"
@.str.2 = [5 x i8] c"Fork\00"
@.str.3 = [36 x i8] c"Child %ld is about to open FIFO %s\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [23 x i8] c"Child cannot open FIFO\00"
@.str.5 = [24 x i8] c"Child is about to read\0A\00"
@EINTR = global i64 0
@.str.6 = [29 x i8] c"Child read from FIFO failed\0A\00"
@.str.7 = [24 x i8] c"Child %ld received: %s\0A\00"
@.str.8 = [39 x i8] c"\0A Parent %ld is about to open FIFO %s\0A\00"
@O_WRONLY = global i32 0
@.str.9 = [24 x i8] c"Parent cannot open FIFO\00"
@.str.10 = [32 x i8] c"This was written by parent %ld\0A\00"
@.str.11 = [29 x i8] c"Parent write to FIFO failed\0A\00"
@.str.12 = [20 x i8] c"Parent %ld is done\0A\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 [256 x i8]
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @S_IRUSR
%13 = load i32, i32* @S_IWUSR
%14 = or i32 %12, %13
store i32 %14, i32* %6
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* %6
%28 = call i32 @mkfifo(i8* %26, i32 %27)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %37
30: ; preds = %23
%31 = load i64, i64* @errno
%32 = load i64, i64* @EEXIST
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %30, %23
%38 = call i32 (...) @fork()
store i32 %38, i32* %9
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %37
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %89
46: ; preds = %43
%47 = call i64 (...) @getpid()
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 %47, i8* %50)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = load i32, i32* @O_RDONLY
%56 = load i32, i32* @O_NONBLOCK
%57 = or i32 %55, %56
%58 = call i32 @open(i8* %54, i32 %57)
store i32 %58, i32* %7
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %63
60: ; preds = %46
%61 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %46
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%65 = call i64 (...) @getpid()
br label %66
66: ; preds = %76, %63
%67 = call i32 (...) @getppid()
%68 = call i32 @waitpid(i32 %67, i32* %8, i32 0)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %66
%71 = load i64, i64* @errno
%72 = load i64, i64* @EINTR
%73 = icmp eq i64 %71, %72
br label %74
74: ; preds = %70, %66
%75 = phi i1 [ false, %66 ], [ %73, %70 ]
br i1 %75, label %76, label %77
76: ; preds = %74
br label %66
77: ; preds = %74
%78 = load i32, i32* %7
%79 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%80 = call i64 @read(i32 %78, i8* %79, i32 256)
%81 = icmp sle i64 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %77
%83 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %77
%86 = call i64 (...) @getpid()
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i64 %86, i8* %87)
br label %123
89: ; preds = %43
%90 = call i64 (...) @getpid()
%91 = load i8**, i8*** %5
%92 = getelementptr inbounds i8*, i8** %91, i64 1
%93 = load i8*, i8** %92
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i64 %90, i8* %93)
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 1
%97 = load i8*, i8** %96
%98 = load i32, i32* @O_WRONLY
%99 = call i32 @open(i8* %97, i32 %98)
store i32 %99, i32* %7
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %104
101: ; preds = %89
%102 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %89
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%106 = call i64 (...) @getpid()
%107 = call i32 @sprintf(i8* %105, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i64 %106)
%108 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%109 = call i32 @strlen(i8* %108)
%110 = add nsw i32 %109, 1
store i32 %110, i32* %11
%111 = load i32, i32* %7
%112 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%113 = load i32, i32* %11
%114 = call i32 @write(i32 %111, i8* %112, i32 %113)
%115 = load i32, i32* %11
%116 = icmp ne i32 %114, %115
br i1 %116, label %117, label %120
117: ; preds = %104
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %104
%121 = call i64 (...) @getpid()
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i64 %121)
br label %123
123: ; preds = %120, %85
br label %124
124: ; preds = %123
%125 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str = [22 x i8] c"\0A Usage: %s pipename\0A\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [5 x i8] c"Pipe\00"
@.str.2 = [5 x i8] c"Fork\00"
@.str.3 = [36 x i8] c"Child %ld is about to open FIFO %s\0A\00"
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [23 x i8] c"Child cannot open FIFO\00"
@EINTR = global i64 0
@.str.6 = [29 x i8] c"Child read from FIFO failed\0A\00"
@.str.7 = [24 x i8] c"Child %ld received: %s\0A\00"
@.str.8 = [39 x i8] c"\0A Parent %ld is about to open FIFO %s\0A\00"
@O_WRONLY = global i32 0
@.str.9 = [24 x i8] c"Parent cannot open FIFO\00"
@.str.10 = [32 x i8] c"This was written by parent %ld\0A\00"
@.str.12 = [20 x i8] c"Parent %ld is done\0A\00"
@str = [28 x i8] c"Parent write to FIFO failed\00"
@str.13 = [23 x i8] c"Child is about to read\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = load i32, i32* @S_IRUSR
%6 = load i32, i32* @S_IWUSR
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = icmp eq i32 %0, 2
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = or i32 %6, %5
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @mkfifo(i8* %17, i32 %15)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %27
20: ; preds = %14
%21 = load i64, i64* @errno
%22 = load i64, i64* @EEXIST
%23 = icmp eq i64 %21, %22
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %20, %14
%28 = tail call i32 (...) @fork()
switch i32 %28, label %65 [
i32 -1, label %29
i32 0, label %32
]
29: ; preds = %27
%30 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %27
%33 = tail call i64 (...) @getpid()
%34 = load i8*, i8** %16
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 %33, i8* %34)
%36 = load i8*, i8** %16
%37 = load i32, i32* @O_RDONLY
%38 = load i32, i32* @O_NONBLOCK
%39 = or i32 %38, %37
%40 = tail call i32 @open(i8* %36, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %45
42: ; preds = %32
%43 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %32
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
%47 = tail call i64 (...) @getpid()
br label %48
48: ; preds = %48, %45
%49 = call i32 (...) @getppid()
%50 = call i32 @waitpid(i32 %49, i32* %3, i32 0)
%51 = icmp eq i32 %50, -1
%52 = load i64, i64* @errno
%53 = load i64, i64* @EINTR
%54 = icmp eq i64 %52, %53
%55 = select i1 %51, i1 %54, i1 false
br i1 %55, label %48, label %56
56: ; preds = %48
%57 = call i64 @read(i32 %40, i8* %8, i32 256)
%58 = icmp slt i64 %57, 1
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %56
%63 = call i64 (...) @getpid()
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i64 %63, i8* %8)
br label %89
65: ; preds = %27
%66 = tail call i64 (...) @getpid()
%67 = load i8*, i8** %16
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i64 %66, i8* %67)
%69 = load i8*, i8** %16
%70 = load i32, i32* @O_WRONLY
%71 = tail call i32 @open(i8* %69, i32 %70)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %76
73: ; preds = %65
%74 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%75 = tail call i32 @exit(i32 1)
unreachable
76: ; preds = %65
%77 = tail call i64 (...) @getpid()
%78 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i64 %77)
%79 = call i32 @strlen(i8* %8)
%80 = add nsw i32 %79, 1
%81 = call i32 @write(i32 %71, i8* %8, i32 %80)
%82 = icmp eq i32 %81, %80
br i1 %82, label %86, label %83
83: ; preds = %76
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %76
%87 = call i64 (...) @getpid()
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i64 %87)
br label %89
89: ; preds = %62, %86
%90 = call i32 @exit(i32 0)
unreachable
}