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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int STDERR_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int /*<<< orphan*/);
int execlp(char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getpid();
int getppid();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  pid_t p;
  int pipefd[2], e;
  char buf;
  char *b = "MESSAGE: passed from child to parent via pipe\n";
  fprintf(stderr, "parent  PID     = %d\n", getpid());
  fprintf(stderr, "parent  PPID    = %d\n", getppid());
  if (pipe(pipefd) == -1) {
    perror("E: pipe");
    exit(EXIT_FAILURE);
  }
  fprintf(stderr, "--- Let's fork ...\n");
  p = fork();
  if (p == -1) {
    perror("E: Fork error\n");
    exit(EXIT_FAILURE);
  } else if (p == 0) {
    close(pipefd[0]);
    printf("child   PID     = %d\n", getpid());
    printf("child   PPID    = %d\n", getppid());
    printf("child   write to pipe\n");
    write(pipefd[1], b, strlen(b));
    dup2(pipefd[1], STDOUT_FILENO);
    printf("child>  ls -l forkexec.c\n");
    e = execlp("/bin/ls", "ls", "-l", "forkexec.c", NULL);
    close(pipefd[1]);
    _exit(e);
  } else {
    close(pipefd[1]);
    fprintf(stderr, "parent  PID     = %d\n", getpid());
    fprintf(stderr, "parent  PPID    = %d\n", getppid());
    fprintf(stderr, "parent  forked  = %d\n", p);
    fprintf(stderr, "parent  read from pipe\n");
    while (read(pipefd[0], &buf, 1) > 0) {
      write(STDERR_FILENO, &buf, 1);
    }
    close(pipefd[0]);
    wait(NULL);
    fprintf(stderr, "parent  child exited.\n");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xde3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%edx
lea    0xdef(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   10e0 <getppid@plt>
mov    -0x34(%rbp),%edi
mov    %eax,%edx
lea    0xddf(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
lea    -0x1c(%rbp),%rdi
call   10a0 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1299 <main+0x99>
lea    0xdd5(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12de <main+0xde>
lea    0xdac(%rip),%rdi
call   10d0 <perror@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
jne    13a9 <main+0x1a9>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10e0 <getppid@plt>
mov    %eax,%esi
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x18(%rbp),%edi
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
call   1070 <dup2@plt>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xd6c(%rip),%rdi
lea    0xd6a(%rip),%rsi
lea    0xd66(%rip),%rdx
lea    0xd62(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1100 <execlp@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    -0x20(%rbp),%edi
call   1030 <_exit@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
mov    0x2c20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%edx
lea    0xc5f(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2bfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    $0x0,%al
call   10e0 <getppid@plt>
mov    -0x48(%rbp),%edi
mov    %eax,%edx
lea    0xc4f(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
lea    0xce8(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x1c(%rbp),%edi
lea    -0x21(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmp    $0x0,%rax
jle    1465 <main+0x265>
mov    0x2b80(%rip),%rax
mov    (%rax),%edi
lea    -0x21(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    142e <main+0x22e>
mov    -0x1c(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1110 <wait@plt>
mov    0x2b5b(%rip),%rax
mov    (%rax),%edi
lea    0xca1(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
jmp    1492 <main+0x292>
mov    0x2b27(%rip),%rax
mov    (%rax),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2db9(%rip),%r14
mov    (%r14),%ebx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xdff(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r14),%ebx
xor    %eax,%eax
call   10f0 <getppid@plt>
lea    0xdf9(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
lea    0x8(%rsp),%rdi
call   10b0 <pipe@plt>
cmp    $0xffffffff,%eax
je     1379 <main+0x169>
mov    (%r14),%edi
lea    0xdef(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1385 <main+0x175>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     143b <main+0x22b>
mov    0xc(%rsp),%edi
call   10a0 <close@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xd80(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r14),%ebp
xor    %eax,%eax
call   10f0 <getppid@plt>
lea    0xd7a(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r14),%edi
lea    0xddd(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    (%r14),%edi
lea    0xde0(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x8(%rsp),%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
test   %rax,%rax
jle    1346 <main+0x136>
mov    0x2cb7(%rip),%rbp
lea    0x7(%rsp),%rbx
xchg   %ax,%ax
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10c0 <read@plt>
test   %rax,%rax
jg     1320 <main+0x110>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
xor    %edi,%edi
call   1120 <wait@plt>
mov    (%r14),%edi
lea    0xd8b(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcdb(%rip),%rdi
jmp    1442 <main+0x232>
mov    0x8(%rsp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xcea(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   10f0 <getppid@plt>
lea    0xce9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd3f(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%ebx
lea    0xc2d(%rip),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    0xc(%rsp),%edi
mov    0x2bfe(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
lea    0xd18(%rip),%rdi
call   1040 <puts@plt>
lea    0xca6(%rip),%rdi
lea    0xca4(%rip),%rsi
lea    0xca0(%rip),%rdx
lea    0xd05(%rip),%rcx
xor    %r8d,%r8d
call   1110 <execlp@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
call   10a0 <close@plt>
mov    %ebx,%edi
call   1030 <_exit@plt>
lea    0xc35(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2b7a(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"MESSAGE: passed from child to parent via pipe\0A\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"parent PID = %d\0A\00"
@.str.2 = [22 x i8] c"parent PPID = %d\0A\00"
@.str.3 = [8 x i8] c"E: pipe\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [20 x i8] c"--- Let's fork ...\0A\00"
@.str.5 = [15 x i8] c"E: Fork error\0A\00"
@.str.6 = [22 x i8] c"child PID = %d\0A\00"
@.str.7 = [22 x i8] c"child PPID = %d\0A\00"
@.str.8 = [23 x i8] c"child write to pipe\0A\00"
@STDOUT_FILENO = global i32 0
@.str.9 = [26 x i8] c"child> ls -l forkexec.c\0A\00"
@.str.10 = [8 x i8] c"/bin/ls\00"
@.str.11 = [3 x i8] c"ls\00"
@.str.12 = [3 x i8] c"-l\00"
@.str.13 = [11 x i8] c"forkexec.c\00"
@.str.14 = [22 x i8] c"parent forked = %d\0A\00"
@.str.15 = [24 x i8] c"parent read from pipe\0A\00"
@STDERR_FILENO = global i32 0
@.str.16 = [23 x i8] c"parent child exited.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = load i32, i32* @stderr
%12 = call i32 (...) @getpid()
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stderr
%15 = call i32 (...) @getppid()
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%18 = call i32 @pipe(i32* %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (...) @fork()
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %24
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %63
37: ; preds = %34
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%39 = load i32, i32* %38
%40 = call i32 @close(i32 %39)
%41 = call i32 (...) @getpid()
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %41)
%43 = call i32 (...) @getppid()
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%47 = load i32, i32* %46
%48 = load i8*, i8** %10
%49 = load i8*, i8** %10
%50 = call i32 @strlen(i8* %49)
%51 = call i32 @write(i32 %47, i8* %48, i32 %50)
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%53 = load i32, i32* %52
%54 = load i32, i32* @STDOUT_FILENO
%55 = call i32 @dup2(i32 %53, i32 %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%57 = call i32 @execlp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i32* null)
store i32 %57, i32* %8
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%59 = load i32, i32* %58
%60 = call i32 @close(i32 %59)
%61 = load i32, i32* %8
%62 = call i32 @_exit(i32 %61)
unreachable
63: ; preds = %34
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 @close(i32 %65)
%67 = load i32, i32* @stderr
%68 = call i32 (...) @getpid()
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %68)
%70 = load i32, i32* @stderr
%71 = call i32 (...) @getppid()
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %71)
%73 = load i32, i32* @stderr
%74 = load i32, i32* %6
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), i32 %74)
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
br label %78
78: ; preds = %83, %63
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%80 = load i32, i32* %79
%81 = call i64 @read(i32 %80, i8* %9, i32 1)
%82 = icmp sgt i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %78
%84 = load i32, i32* @STDERR_FILENO
%85 = call i32 @write(i32 %84, i8* %9, i32 1)
br label %78
86: ; preds = %78
%87 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%88 = load i32, i32* %87
%89 = call i32 @close(i32 %88)
%90 = call i32 @wait(i32* null)
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
br label %93
93: ; preds = %86
br label %94
94: ; preds = %93
%95 = load i32, i32* @EXIT_SUCCESS
ret i32 %95
}

LLVM IR (-O2):
@.str = [47 x i8] c"MESSAGE: passed from child to parent via pipe\0A\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"parent PID = %d\0A\00"
@.str.2 = [22 x i8] c"parent PPID = %d\0A\00"
@.str.3 = [8 x i8] c"E: pipe\00"
@EXIT_FAILURE = global i32 0
@.str.4 = [20 x i8] c"--- Let's fork ...\0A\00"
@.str.5 = [15 x i8] c"E: Fork error\0A\00"
@.str.6 = [22 x i8] c"child PID = %d\0A\00"
@.str.7 = [22 x i8] c"child PPID = %d\0A\00"
@STDOUT_FILENO = global i32 0
@.str.10 = [8 x i8] c"/bin/ls\00"
@.str.11 = [3 x i8] c"ls\00"
@.str.12 = [3 x i8] c"-l\00"
@.str.13 = [11 x i8] c"forkexec.c\00"
@.str.14 = [22 x i8] c"parent forked = %d\0A\00"
@.str.15 = [24 x i8] c"parent read from pipe\0A\00"
@STDERR_FILENO = global i32 0
@.str.16 = [23 x i8] c"parent child exited.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [22 x i8] c"child write to pipe\00"
@str.17 = [25 x i8] c"child> ls -l forkexec.c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = alloca i8
%5 = bitcast [2 x i32]* %3 to i8*
%6 = load i32, i32* @stderr
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @stderr
%10 = tail call i32 (...) @getppid()
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%13 = call i32 @pipe(i32* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 (...) @fork()
switch i32 %22, label %47 [
i32 -1, label %23
i32 0, label %27
]
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %19
%28 = load i32, i32* %12
%29 = call i32 @close(i32 %28)
%30 = call i32 (...) @getpid()
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = call i32 (...) @getppid()
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%36 = load i32, i32* %35
%37 = call i32 @strlen(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @write(i32 %36, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %35
%40 = load i32, i32* @STDOUT_FILENO
%41 = call i32 @dup2(i32 %39, i32 %40)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.17, i64 0, i64 0))
%43 = call i32 @execlp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0), i32* null)
%44 = load i32, i32* %35
%45 = call i32 @close(i32 %44)
%46 = call i32 @_exit(i32 %43)
unreachable
47: ; preds = %19
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%49 = load i32, i32* %48
%50 = call i32 @close(i32 %49)
%51 = load i32, i32* @stderr
%52 = call i32 (...) @getpid()
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i32, i32* @stderr
%55 = call i32 (...) @getppid()
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %55)
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0), i32 %22)
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
%61 = load i32, i32* %12
%62 = call i64 @read(i32 %61, i8* %4, i32 1)
%63 = icmp sgt i64 %62, 0
br i1 %63, label %64, label %70
64: ; preds = %47, %64
%65 = load i32, i32* @STDERR_FILENO
%66 = call i32 @write(i32 %65, i8* %4, i32 1)
%67 = load i32, i32* %12
%68 = call i64 @read(i32 %67, i8* %4, i32 1)
%69 = icmp sgt i64 %68, 0
br i1 %69, label %64, label %70
70: ; preds = %64, %47
%71 = load i32, i32* %12
%72 = call i32 @close(i32 %71)
%73 = call i32 @wait(i32* null)
%74 = load i32, i32* @stderr
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0))
%76 = load i32, i32* @EXIT_SUCCESS
ret i32 %76
}