#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 getpid();
scalar_t__ isalnum(char);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
void manage_parent(int pipe[]) {
  char byte;
  printf("Parent process (PID %d)\n", getpid());
  close(pipe[0]);
  while (read(0, &byte, 1) > 0) {
    if (isalnum(byte)) {
      write(pipe[1], &byte, 1);
    }
  }
  close(pipe[1]);
  wait(NULL);
  printf("Parent: has received child termination.\n");
}


x86 assembly (clang, -O0):
<manage_parent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1070 <close@plt>
xor    %edi,%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x0,%rax
jle    11e5 <manage_parent+0x75>
movsbl -0x9(%rbp),%edi
call   1060 <isalnum@plt>
cmp    $0x0,%rax
je     11e0 <manage_parent+0x70>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
jmp    119e <manage_parent+0x2e>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1070 <close@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1090 <wait@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manage_parent>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <getpid@plt>
lea    0xe6b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%r14),%edi
call   1080 <close@plt>
lea    0x7(%rsp),%rsi
xor    %edi,%edi
mov    $0x1,%edx
call   1090 <read@plt>
test   %rax,%rax
jle    1206 <manage_parent+0x86>
lea    0x7(%rsp),%rbx
jmp    11e4 <manage_parent+0x64>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
test   %rax,%rax
jle    1206 <manage_parent+0x86>
movsbl 0x7(%rsp),%edi
call   1070 <isalnum@plt>
test   %rax,%rax
je     11d0 <manage_parent+0x50>
mov    0x4(%r14),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
jmp    11d0 <manage_parent+0x50>
mov    0x4(%r14),%edi
call   1080 <close@plt>
xor    %edi,%edi
call   10a0 <wait@plt>
lea    0xdfc(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Parent process (PID %d)\0A\00"
@.str.1 = [41 x i8] c"Parent: has received child termination.\0A\00"
define void @manage_parent(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
store i32* %0, i32** %2
%4 = call i32 (...) @getpid()
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = load i32*, i32** %2
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
%9 = call i32 @close(i32 %8)
br label %10
10: ; preds = %22, %1
%11 = call i64 @read(i32 0, i8* %3, i32 1)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i8, i8* %3
%15 = call i64 @isalnum(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 1
%20 = load i32, i32* %19
%21 = call i32 @write(i32 %20, i8* %3, i32 1)
br label %22
22: ; preds = %17, %13
br label %10
23: ; preds = %10
%24 = load i32*, i32** %2
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %25
%27 = call i32 @close(i32 %26)
%28 = call i32 @wait(i32* null)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Parent process (PID %d)\0A\00"
@str = [40 x i8] c"Parent: has received child termination.\00"
define void @manage_parent(i32* nocapture %0) {
%2 = alloca i8
%3 = tail call i32 (...) @getpid()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* %0
%6 = tail call i32 @close(i32 %5)
%7 = call i64 @read(i32 0, i8* %2, i32 1)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %1
%10 = getelementptr inbounds i32, i32* %0, i64 1
br label %11
11: ; preds = %9, %18
%12 = load i8, i8* %2
%13 = tail call i64 @isalnum(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i32, i32* %10
%17 = call i32 @write(i32 %16, i8* %2, i32 1)
br label %18
18: ; preds = %15, %11
%19 = call i64 @read(i32 0, i8* %2, i32 1)
%20 = icmp sgt i64 %19, 0
br i1 %20, label %11, label %21
21: ; preds = %18, %1
%22 = getelementptr inbounds i32, i32* %0, i64 1
%23 = load i32, i32* %22
%24 = tail call i32 @close(i32 %23)
%25 = tail call i32 @wait(i32* null)
%26 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
ret void
}