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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *);
int read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int strlen(char *);
int /*<<< orphan*/ toUpperCase(char *);
int /*<<< orphan*/ waitpid(scalar_t__, int /*<<< orphan*/ *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("Welcher Text soll den übertragen werden?\n(Argument erwartet)\n");
    return EXIT_FAILURE;
  }
  int n, A[2], B[2], err;
  pid_t pid;
  char line[4096];
  err = pipe(A);
  if (err < 0) {
    perror("pipe error");
    exit(1);
  }
  err = pipe(B);
  if (err < 0) {
    perror("pipe error");
    exit(1);
  }
  pid = fork();
  if (pid < 0) {
    perror("fork error");
    exit(1);
  } else if (pid > 0) {
    close(A[0]);
    close(B[1]);
    char *argument = argv[1];
    write(A[1], argument, strlen(argument) + 1);
    close(A[1]);
    n = read(B[0], line, 4096);
    close(B[0]);
    write(STDOUT_FILENO, line, n);
    printf("\n");
    waitpid(pid, NULL, 0);
  } else {
    close(A[1]);
    close(B[0]);
    n = read(A[0], line, 4096);
    close(A[0]);
    sleep(1);
    toUpperCase(line);
    write(B[1], line, n);
    close(B[1]);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1200 <main+0x40>
lea    0xe16(%rip),%rdi
call   1050 <printf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    13b7 <main+0x1f7>
lea    -0x1c(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    122c <main+0x6c>
lea    0xe22(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x24(%rbp),%rdi
call   1070 <pipe@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1258 <main+0x98>
lea    0xdf6(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jge    1284 <main+0xc4>
lea    0xdd5(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jle    1347 <main+0x187>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1038(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1044(%rbp)
mov    -0x1038(%rbp),%rax
mov    %rax,-0x1040(%rbp)
mov    -0x1038(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1044(%rbp),%edi
mov    -0x1040(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    -0x1030(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
lea    0xd0f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <waitpid@plt>
jmp    13a6 <main+0x1e6>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
lea    -0x1030(%rbp),%rdi
call   10b0 <toUpperCase@plt>
mov    -0x20(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
jmp    13ab <main+0x1eb>
mov    0x2c1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
cmp    $0x1,%edi
jg     11f8 <main+0x28>
lea    0xe2f(%rip),%rdi
call   1040 <puts@plt>
mov    0x2de5(%rip),%rax
jmp    131a <main+0x14a>
mov    %rsi,%rbx
lea    0x8(%rsp),%rdi
call   1080 <pipe@plt>
test   %eax,%eax
js     1328 <main+0x158>
mov    %rsp,%rdi
call   1080 <pipe@plt>
test   %eax,%eax
js     1328 <main+0x158>
xor    %eax,%eax
call   10f0 <fork@plt>
test   %rax,%rax
js     1331 <main+0x161>
je     12b8 <main+0xe8>
mov    %rax,%r14
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
mov    0x8(%rbx),%rbx
mov    0xc(%rsp),%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <write@plt>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    (%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1090 <read@plt>
mov    %eax,%ebp
mov    (%rsp),%edi
call   1070 <close@plt>
mov    0x2d5c(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <write@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10a0 <waitpid@plt>
jmp    1313 <main+0x143>
mov    0xc(%rsp),%edi
call   1070 <close@plt>
mov    (%rsp),%edi
call   1070 <close@plt>
mov    0x8(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1090 <read@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    %rbx,%rdi
call   10c0 <toUpperCase@plt>
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <write@plt>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xcd1(%rip),%rdi
jmp    1338 <main+0x168>
lea    0xcd3(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [63 x i8] c"Welcher Text soll den \C3\BCbertragen werden?\0A(Argument erwartet)\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"pipe error\00"
@.str.2 = [11 x i8] c"fork error\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [2 x i8] c"\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 [2 x i32]
%9 = alloca i32
%10 = alloca i64
%11 = alloca [4096 x i8]
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %106
18: ; preds = %2
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%20 = call i32 @pipe(i32* %19)
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %18
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%28 = call i32 @pipe(i32* %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %26
%35 = call i64 (...) @fork()
store i64 %35, i64* %10
%36 = load i64, i64* %10
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %34
%42 = load i64, i64* %10
%43 = icmp sgt i64 %42, 0
br i1 %43, label %44, label %78
44: ; preds = %41
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%46 = load i32, i32* %45
%47 = call i32 @close(i32 %46)
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%49 = load i32, i32* %48
%50 = call i32 @close(i32 %49)
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 1
%53 = load i8*, i8** %52
store i8* %53, i8** %12
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%55 = load i32, i32* %54
%56 = load i8*, i8** %12
%57 = load i8*, i8** %12
%58 = call i32 @strlen(i8* %57)
%59 = add nsw i32 %58, 1
%60 = call i32 @write(i32 %55, i8* %56, i32 %59)
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%62 = load i32, i32* %61
%63 = call i32 @close(i32 %62)
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%65 = load i32, i32* %64
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%67 = call i32 @read(i32 %65, i8* %66, i32 4096)
store i32 %67, i32* %6
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = load i32, i32* @STDOUT_FILENO
%72 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%73 = load i32, i32* %6
%74 = call i32 @write(i32 %71, i8* %72, i32 %73)
%75 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%76 = load i64, i64* %10
%77 = call i32 @waitpid(i64 %76, i32* null, i32 0)
br label %103
78: ; preds = %41
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%86 = load i32, i32* %85
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%88 = call i32 @read(i32 %86, i8* %87, i32 4096)
store i32 %88, i32* %6
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%90 = load i32, i32* %89
%91 = call i32 @close(i32 %90)
%92 = call i32 @sleep(i32 1)
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%94 = call i32 @toUpperCase(i8* %93)
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%96 = load i32, i32* %95
%97 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%98 = load i32, i32* %6
%99 = call i32 @write(i32 %96, i8* %97, i32 %98)
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%101 = load i32, i32* %100
%102 = call i32 @close(i32 %101)
br label %103
103: ; preds = %78, %44
br label %104
104: ; preds = %103
%105 = load i32, i32* @EXIT_SUCCESS
store i32 %105, i32* %3
br label %106
106: ; preds = %104, %15
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [11 x i8] c"pipe error\00"
@.str.2 = [11 x i8] c"fork error\00"
@STDOUT_FILENO = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [62 x i8] c"Welcher Text soll den \C3\BCbertragen werden?\0A(Argument erwartet)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [4096 x i8]
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
br label %77
10: ; preds = %2
%11 = bitcast [2 x i32]* %3 to i8*
%12 = bitcast [2 x i32]* %4 to i8*
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%15 = call i32 @pipe(i32* %14)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %10
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%22 = call i32 @pipe(i32* %21)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %20
%28 = call i64 (...) @fork()
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %27
%34 = icmp eq i64 %28, 0
br i1 %34, label %58, label %35
35: ; preds = %33
%36 = load i32, i32* %14
%37 = call i32 @close(i32 %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%39 = load i32, i32* %38
%40 = call i32 @close(i32 %39)
%41 = getelementptr inbounds i8*, i8** %1, i64 1
%42 = load i8*, i8** %41
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%44 = load i32, i32* %43
%45 = call i32 @strlen(i8* %42)
%46 = add nsw i32 %45, 1
%47 = call i32 @write(i32 %44, i8* %42, i32 %46)
%48 = load i32, i32* %43
%49 = call i32 @close(i32 %48)
%50 = load i32, i32* %21
%51 = call i32 @read(i32 %50, i8* %13, i32 4096)
%52 = load i32, i32* %21
%53 = call i32 @close(i32 %52)
%54 = load i32, i32* @STDOUT_FILENO
%55 = call i32 @write(i32 %54, i8* %13, i32 %51)
%56 = call i32 @putchar(i32 10)
%57 = call i32 @waitpid(i64 %28, i32* null, i32 0)
br label %75
58: ; preds = %33
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%60 = load i32, i32* %59
%61 = call i32 @close(i32 %60)
%62 = load i32, i32* %21
%63 = call i32 @close(i32 %62)
%64 = load i32, i32* %14
%65 = call i32 @read(i32 %64, i8* %13, i32 4096)
%66 = load i32, i32* %14
%67 = call i32 @close(i32 %66)
%68 = call i32 @sleep(i32 1)
%69 = call i32 @toUpperCase(i8* %13)
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%71 = load i32, i32* %70
%72 = call i32 @write(i32 %71, i8* %13, i32 %65)
%73 = load i32, i32* %70
%74 = call i32 @close(i32 %73)
br label %75
75: ; preds = %35, %58
%76 = load i32, i32* @EXIT_SUCCESS
br label %77
77: ; preds = %75, %7
%78 = phi i32 [ %9, %7 ], [ %76, %75 ]
ret i32 %78
}