#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*/ close(int);
int /*<<< orphan*/ convert(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int fork();
int pipe(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  char s[200];
  scanf("%[^\n]s", s);
  fflush(stdin);
  int length = strlen(s);
  int pipe_send_fd[2];
  int pipe_read_fd[2];
  pid_t pid;
  if (pipe(pipe_send_fd) == -1) {
    printf("Send pipe creation failed.\n");
    exit(-1);
  }
  if (pipe(pipe_read_fd) == -1) {
    printf("Read pipe creation failed.\n");
    exit(-1);
  }
  pid = fork();
  if (pid == -1) {
    printf("Child creation failed.\n");
    exit(-1);
  }
  if (pid > 0) {
    close(pipe_send_fd[0]);
    close(pipe_read_fd[1]);
    write(pipe_send_fd[1], s, length + 1);
    wait(NULL);
    read(pipe_read_fd[0], s, length + 1);
    close(pipe_send_fd[1]);
    close(pipe_read_fd[0]);
    puts(s);
  } else if (pid == 0) {
    close(pipe_send_fd[1]);
    close(pipe_read_fd[0]);
    read(pipe_send_fd[0], s, length + 1);
    convert(s);
    write(pipe_read_fd[1], s, strlen(s) + 1);
    close(pipe_send_fd[0]);
    close(pipe_read_fd[1]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   10c0 <scanf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
lea    -0xd0(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0xd4(%rbp)
lea    -0xdc(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1240 <main+0x70>
lea    0xdd6(%rip),%rdi
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    -0xe4(%rbp),%rdi
call   1090 <pipe@plt>
cmp    $0xffffffff,%eax
jne    126b <main+0x9b>
lea    0xdc7(%rip),%rdi
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0xe8(%rbp)
cmpl   $0xffffffff,-0xe8(%rbp)
jne    129b <main+0xcb>
lea    0xdb3(%rip),%rdi
call   1070 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
cmpl   $0x0,-0xe8(%rbp)
jle    1324 <main+0x154>
mov    -0xdc(%rbp),%edi
call   1080 <close@plt>
mov    -0xe0(%rbp),%edi
call   1080 <close@plt>
mov    -0xd8(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    -0xd4(%rbp),%edx
add    $0x1,%edx
call   1050 <write@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10e0 <wait@plt>
mov    -0xe4(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    -0xd4(%rbp),%edx
add    $0x1,%edx
call   10a0 <read@plt>
mov    -0xd8(%rbp),%edi
call   1080 <close@plt>
mov    -0xe4(%rbp),%edi
call   1080 <close@plt>
lea    -0xd0(%rbp),%rdi
call   1040 <puts@plt>
jmp    13c6 <main+0x1f6>
cmpl   $0x0,-0xe8(%rbp)
jne    13c1 <main+0x1f1>
mov    -0xd8(%rbp),%edi
call   1080 <close@plt>
mov    -0xe4(%rbp),%edi
call   1080 <close@plt>
mov    -0xdc(%rbp),%edi
lea    -0xd0(%rbp),%rsi
mov    -0xd4(%rbp),%edx
add    $0x1,%edx
call   10a0 <read@plt>
lea    -0xd0(%rbp),%rdi
call   1030 <convert@plt>
mov    -0xe0(%rbp),%eax
mov    %eax,-0xf4(%rbp)
lea    -0xd0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    -0xd0(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0xf4(%rbp),%edi
mov    -0xf0(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <write@plt>
mov    -0xdc(%rbp),%edi
call   1080 <close@plt>
mov    -0xe0(%rbp),%edi
call   1080 <close@plt>
jmp    13c6 <main+0x1f6>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
lea    0xe2f(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   10b0 <scanf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
je     12ee <main+0x12e>
mov    %rsp,%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
je     12f7 <main+0x137>
xor    %eax,%eax
call   10e0 <fork@plt>
cmp    $0xffffffff,%eax
je     1300 <main+0x140>
test   %eax,%eax
jle    1285 <main+0xc5>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
mov    0xc(%rsp),%edi
add    $0x1,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <write@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
mov    (%rsp),%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1090 <read@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    (%rsp),%edi
call   1070 <close@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    12e1 <main+0x121>
jne    12e1 <main+0x121>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    (%rsp),%edi
call   1070 <close@plt>
mov    0x8(%rsp),%edi
add    $0x1,%ebx
lea    0x10(%rsp),%r14
mov    %r14,%rsi
mov    %ebx,%edx
call   1090 <read@plt>
mov    %r14,%rdi
call   1030 <convert@plt>
mov    0x4(%rsp),%ebx
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edx
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <write@plt>
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd44(%rip),%rdi
jmp    1307 <main+0x147>
lea    0xd20(%rip),%rdi
jmp    1307 <main+0x147>
lea    0xd00(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%[^\0A]s\00"
@stdin = global i32 0
@.str.1 = [28 x i8] c"Send pipe creation failed.\0A\00"
@.str.2 = [28 x i8] c"Read pipe creation failed.\0A\00"
@.str.3 = [24 x i8] c"Child creation failed.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca i32
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i32, i32* @stdin
%10 = call i32 @fflush(i32 %9)
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%12 = call i32 @strlen(i8* %11)
store i32 %12, i32* %3
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%14 = call i32 @pipe(i32* %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @exit(i32 -1)
unreachable
19: ; preds = %0
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%21 = call i32 @pipe(i32* %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @exit(i32 -1)
unreachable
26: ; preds = %19
%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 %33
30: ; preds = %26
%31 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %26
%34 = load i32, i32* %6
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %64
36: ; preds = %33
%37 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%38 = load i32, i32* %37
%39 = call i32 @close(i32 %38)
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 @close(i32 %41)
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%44 = load i32, i32* %43
%45 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
%48 = call i32 @write(i32 %44, i8* %45, i32 %47)
%49 = call i32 @wait(i32* null)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%51 = load i32, i32* %50
%52 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
%55 = call i32 @read(i32 %51, i8* %52, i32 %54)
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%57 = load i32, i32* %56
%58 = call i32 @close(i32 %57)
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%60 = load i32, i32* %59
%61 = call i32 @close(i32 %60)
%62 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%63 = call i32 @puts(i8* %62)
br label %96
64: ; preds = %33
%65 = load i32, i32* %6
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %95
67: ; preds = %64
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%72 = load i32, i32* %71
%73 = call i32 @close(i32 %72)
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%75 = load i32, i32* %74
%76 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%77 = load i32, i32* %3
%78 = add nsw i32 %77, 1
%79 = call i32 @read(i32 %75, i8* %76, i32 %78)
%80 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%81 = call i32 @convert(i8* %80)
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%83 = load i32, i32* %82
%84 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%85 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%86 = call i32 @strlen(i8* %85)
%87 = add nsw i32 %86, 1
%88 = call i32 @write(i32 %83, i8* %84, i32 %87)
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%90 = load i32, i32* %89
%91 = call i32 @close(i32 %90)
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%93 = load i32, i32* %92
%94 = call i32 @close(i32 %93)
br label %95
95: ; preds = %67, %64
br label %96
96: ; preds = %95, %36
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%[^\0A]s\00"
@stdin = global i32 0
@str = [23 x i8] c"Child creation failed.\00"
@str.4 = [27 x i8] c"Read pipe creation failed.\00"
@str.5 = [27 x i8] c"Send pipe creation failed.\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i32, i32* @stdin
%7 = call i32 @fflush(i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = bitcast [2 x i32]* %2 to i8*
%10 = bitcast [2 x i32]* %3 to i8*
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%12 = call i32 @pipe(i32* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %0
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%19 = call i32 @pipe(i32* %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.4, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %17
%25 = call i32 (...) @fork()
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%29 = call i32 @exit(i32 -1)
unreachable
30: ; preds = %24
%31 = icmp sgt i32 %25, 0
br i1 %31, label %32, label %50
32: ; preds = %30
%33 = load i32, i32* %11
%34 = call i32 @close(i32 %33)
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%36 = load i32, i32* %35
%37 = call i32 @close(i32 %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%39 = load i32, i32* %38
%40 = add nsw i32 %8, 1
%41 = call i32 @write(i32 %39, i8* %4, i32 %40)
%42 = call i32 @wait(i32* null)
%43 = load i32, i32* %18
%44 = call i32 @read(i32 %43, i8* %4, i32 %40)
%45 = load i32, i32* %38
%46 = call i32 @close(i32 %45)
%47 = load i32, i32* %18
%48 = call i32 @close(i32 %47)
%49 = call i32 @puts(i8* %4)
br label %71
50: ; preds = %30
%51 = icmp eq i32 %25, 0
br i1 %51, label %52, label %71
52: ; preds = %50
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%54 = load i32, i32* %53
%55 = call i32 @close(i32 %54)
%56 = load i32, i32* %18
%57 = call i32 @close(i32 %56)
%58 = load i32, i32* %11
%59 = add nsw i32 %8, 1
%60 = call i32 @read(i32 %58, i8* %4, i32 %59)
%61 = call i32 @convert(i8* %4)
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%63 = load i32, i32* %62
%64 = call i32 @strlen(i8* %4)
%65 = add nsw i32 %64, 1
%66 = call i32 @write(i32 %63, i8* %4, i32 %65)
%67 = load i32, i32* %11
%68 = call i32 @close(i32 %67)
%69 = load i32, i32* %62
%70 = call i32 @close(i32 %69)
br label %71
71: ; preds = %50, %52, %32
ret i32 0
}