#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 /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ read(int, ...);
scalar_t__ scanf(char *, char *);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, ...);
int main() {
  int p2c[2];
  int c2p[2];
  int cnt = 0;
  int i;
  pipe(p2c);
  pipe(c2p);
  if (fork() == 0) {
    close(p2c[1]);
    close(c2p[0]);
    char ch;
    while (read(p2c[0], &ch, sizeof(char)))
      if (strchr("aeiou", ch))
        ++cnt;
    close(p2c[0]);
    write(c2p[1], &cnt, sizeof(int));
    close(c2p[1]);
    printf("Child got %d", cnt);
    exit(0);
  }
  close(p2c[0]);
  close(c2p[1]);
  char ch;
  while (scanf("%c", &ch) && ch != '\n')
    write(p2c[1], &ch, sizeof(char));
  close(p2c[1]);
  read(c2p[0], &cnt, sizeof(int));
  close(c2p[0]);
  printf("Parent received: %d\n", cnt);
  wait(0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
call   1070 <pipe@plt>
lea    -0x14(%rbp),%rdi
call   1070 <pipe@plt>
mov    $0x0,%al
call   10c0 <fork@plt>
cmp    $0x0,%rax
jne    1267 <main+0xc7>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0xc(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1080 <read@plt>
cmp    $0x0,%rax
je     122e <main+0x8e>
lea    0xdf3(%rip),%rdi
movsbl -0x1d(%rbp),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1229 <main+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e9 <main+0x49>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1030 <write@plt>
mov    -0x10(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%esi
lea    0xdab(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%edi
call   1060 <close@plt>
lea    0xd95(%rip),%rdi
lea    -0x1e(%rbp),%rsi
call   1090 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x1f(%rbp)
je     12a6 <main+0x106>
movsbl -0x1e(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
test   $0x1,%al
jne    12b6 <main+0x116>
jmp    12ce <main+0x12e>
mov    -0x8(%rbp),%edi
lea    -0x1e(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <write@plt>
jmp    1277 <main+0xd7>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1080 <read@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%esi
lea    0xd1b(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
call   1070 <pipe@plt>
lea    0x18(%rsp),%rdi
call   1070 <pipe@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
je     1283 <main+0xe3>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    0x1c(%rsp),%edi
call   1060 <close@plt>
lea    0xe26(%rip),%rdi
lea    0xb(%rsp),%rsi
call   1090 <scanf@plt>
test   %rax,%rax
je     123a <main+0x9a>
cmpb   $0xa,0xb(%rsp)
je     123a <main+0x9a>
lea    0xb(%rsp),%rbx
lea    0xe04(%rip),%r14
nop
mov    0x14(%rsp),%edi
mov    $0x1,%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <write@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
test   %rax,%rax
je     123a <main+0x9a>
cmpb   $0xa,0xb(%rsp)
jne    1210 <main+0x70>
mov    0x14(%rsp),%edi
call   1060 <close@plt>
mov    0x18(%rsp),%edi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1080 <read@plt>
mov    0x18(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%esi
lea    0xdaa(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <wait@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x14(%rsp),%edi
call   1060 <close@plt>
mov    0x18(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
lea    0xb(%rsp),%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1080 <read@plt>
test   %rax,%rax
jne    12ed <main+0x14d>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    0x1c(%rsp),%edi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    0x1c(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%esi
lea    0xd25(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
lea    0xd0c(%rip),%r14
lea    0xb(%rsp),%rbx
xor    %ebp,%ebp
jmp    1318 <main+0x178>
nopl   (%rax)
mov    0x10(%rsp),%edi
mov    $0x1,%edx
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <read@plt>
test   %rax,%rax
je     12af <main+0x10f>
movsbl 0xb(%rsp),%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     1300 <main+0x160>
add    $0x1,%ebp
mov    %ebp,0xc(%rsp)
jmp    1300 <main+0x160>

LLVM IR (-O0):
@.str = [6 x i8] c"aeiou\00"
@.str.1 = [13 x i8] c"Child got %d\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [21 x i8] c"Parent received: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %4
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%9 = call i32 @pipe(i32* %8)
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%11 = call i32 @pipe(i32* %10)
%12 = call i64 (...) @fork()
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %47
14: ; preds = %0
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%16 = load i32, i32* %15
%17 = call i32 @close(i32 %16)
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%19 = load i32, i32* %18
%20 = call i32 @close(i32 %19)
br label %21
21: ; preds = %33, %14
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%23 = load i32, i32* %22
%24 = call i64 (i32, ...) @read(i32 %23, i8* %6, i64 1)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %21
%27 = load i8, i8* %6
%28 = call i64 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %33
33: ; preds = %30, %26
br label %21
34: ; preds = %21
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%36 = load i32, i32* %35
%37 = call i32 @close(i32 %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%39 = load i32, i32* %38
%40 = call i32 (i32, ...) @write(i32 %39, i32* %4, i64 4)
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* %4
%45 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %0
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%49 = load i32, i32* %48
%50 = call i32 @close(i32 %49)
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%52 = load i32, i32* %51
%53 = call i32 @close(i32 %52)
br label %54
54: ; preds = %63, %47
%55 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = load i8, i8* %7
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 10
br label %61
61: ; preds = %57, %54
%62 = phi i1 [ false, %54 ], [ %60, %57 ]
br i1 %62, label %63, label %67
63: ; preds = %61
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 (i32, ...) @write(i32 %65, i8* %7, i64 1)
br label %54
67: ; preds = %61
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%72 = load i32, i32* %71
%73 = call i64 (i32, ...) @read(i32 %72, i32* %4, i64 4)
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%75 = load i32, i32* %74
%76 = call i32 @close(i32 %75)
%77 = load i32, i32* %4
%78 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %77)
%79 = call i32 @wait(i32 0)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"aeiou\00"
@.str.1 = [13 x i8] c"Child got %d\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [21 x i8] c"Parent received: %d\0A\00"
define i32 @main() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8
%6 = bitcast [2 x i32]* %1 to i8*
%7 = bitcast [2 x i32]* %2 to i8*
%8 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%10 = call i32 @pipe(i32* %9)
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = call i32 @pipe(i32* %11)
%13 = call i64 (...) @fork()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %47
15: ; preds = %0
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%17 = load i32, i32* %16
%18 = call i32 @close(i32 %17)
%19 = load i32, i32* %11
%20 = call i32 @close(i32 %19)
%21 = load i32, i32* %9
%22 = call i64 (i32, ...) @read(i32 %21, i8* %4, i64 1)
%23 = icmp eq i64 %22, 0
br i1 %23, label %36, label %24
24: ; preds = %15, %31
%25 = phi i32 [ %32, %31 ], [ 0, %15 ]
%26 = load i8, i8* %4
%27 = call i64 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %24
%30 = add nsw i32 %25, 1
store i32 %30, i32* %3
br label %31
31: ; preds = %29, %24
%32 = phi i32 [ %30, %29 ], [ %25, %24 ]
%33 = load i32, i32* %9
%34 = call i64 (i32, ...) @read(i32 %33, i8* %4, i64 1)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %24
36: ; preds = %31, %15
%37 = load i32, i32* %9
%38 = call i32 @close(i32 %37)
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%40 = load i32, i32* %39
%41 = call i32 (i32, ...) @write(i32 %40, i32* %3, i64 4)
%42 = load i32, i32* %39
%43 = call i32 @close(i32 %42)
%44 = load i32, i32* %3
%45 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %0
%48 = load i32, i32* %9
%49 = call i32 @close(i32 %48)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%51 = load i32, i32* %50
%52 = call i32 @close(i32 %51)
%53 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%54 = icmp ne i64 %53, 0
%55 = load i8, i8* %5
%56 = icmp ne i8 %55, 10
%57 = select i1 %54, i1 %56, i1 false
br i1 %57, label %58, label %68
58: ; preds = %47
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
br label %60
60: ; preds = %58, %60
%61 = load i32, i32* %59
%62 = call i32 (i32, ...) @write(i32 %61, i8* %5, i64 1)
%63 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%64 = icmp ne i64 %63, 0
%65 = load i8, i8* %5
%66 = icmp ne i8 %65, 10
%67 = select i1 %64, i1 %66, i1 false
br i1 %67, label %60, label %68
68: ; preds = %60, %47
%69 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%70 = load i32, i32* %69
%71 = call i32 @close(i32 %70)
%72 = load i32, i32* %11
%73 = call i64 (i32, ...) @read(i32 %72, i32* %3, i64 4)
%74 = load i32, i32* %11
%75 = call i32 @close(i32 %74)
%76 = load i32, i32* %3
%77 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %76)
%78 = call i32 @wait(i32 0)
ret i32 0
}