#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int main(int argc, char *args[]) {
  int pid, i, j;
  pid = fork();
  if (pid == 0) {
    printf("\nHey ich bin der Kindprozess und meine PID ist %i!\n", getpid());
    sleep(1);
  } else if (pid > 0) {
    printf("\nHey ich bin der Elternprozess und meine PID ist %i!\n", getpid());
    sleep(1);
  } else {
    printf("\n Es ist ein Fehler aufgetreten! \n");
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11a0 <main+0x50>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    11e3 <main+0x93>
cmpl   $0x0,-0x14(%rbp)
jle    11d0 <main+0x80>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    11de <main+0x8e>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e3 <main+0x93>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
jne    117c <main+0x1c>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe86(%rip),%rdi
jmp    118c <main+0x2c>
jle    11a1 <main+0x41>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xea8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    11ad <main+0x4d>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [52 x i8] c"\0AHey ich bin der Kindprozess und meine PID ist %i!\0A\00"
@.str.1 = [54 x i8] c"\0AHey ich bin der Elternprozess und meine PID ist %i!\0A\00"
@.str.2 = [35 x i8] c"\0A Es ist ein Fehler aufgetreten! \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 i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @fork()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = call i32 (...) @getpid()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = call i32 @sleep(i32 1)
br label %26
16: ; preds = %2
%17 = load i32, i32* %6
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = call i32 (...) @getpid()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @sleep(i32 1)
br label %25
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
br label %26
26: ; preds = %25, %12
%27 = load i32, i32* @EXIT_SUCCESS
%28 = call i32 @exit(i32 %27)
unreachable
}

LLVM IR (-O2):
@.str = [52 x i8] c"\0AHey ich bin der Kindprozess und meine PID ist %i!\0A\00"
@.str.1 = [54 x i8] c"\0AHey ich bin der Elternprozess und meine PID ist %i!\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [34 x i8] c"\0A Es ist ein Fehler aufgetreten! \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @fork()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 (...) @getpid()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i32 @sleep(i32 1)
br label %17
9: ; preds = %2
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = tail call i32 (...) @getpid()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @sleep(i32 1)
br label %17
15: ; preds = %9
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %11, %15, %5
%18 = load i32, i32* @EXIT_SUCCESS
%19 = tail call i32 @exit(i32 %18)
unreachable
}