#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(int /*<<< orphan*/);
int fork();
int getpid();
int getppid();
int gettid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ ureadline(char *, int, int /*<<< orphan*/);
int main() {
  printf("Press Return to end.\n");
  int f1 = fork();
  int f2 = fork();
  int f3 = fork();
  int f4 = fork();
  int f5 = fork();
  int f6 = fork();
  int pid = getpid();
  int ppid = getppid();
  int tid = gettid();
  printf("[%2d]: pid = %2d, tid = %2d, ppid = %2d, "
         "forkrets = [%2d %2d %2d %2d]\n",
         pid, pid, tid, ppid, f1, f2, f3, f4);
  if (f1 != 0 && f2 != 0 && f3 != 0 && f4 != 0) {
    char s[80];
    ureadline((char *)s, 79, 0);
  }
  long int j;
  for (j = 0; j < 9999999ul; j++)
    ;
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <getppid@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   1030 <gettid@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x8(%rbp),%r9d
mov    -0xc(%rbp),%r11d
mov    -0x10(%rbp),%r10d
mov    -0x14(%rbp),%eax
lea    0xe09(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1259 <main+0xe9>
cmpl   $0x0,-0xc(%rbp)
je     1259 <main+0xe9>
cmpl   $0x0,-0x10(%rbp)
je     1259 <main+0xe9>
cmpl   $0x0,-0x14(%rbp)
je     1259 <main+0xe9>
lea    -0x80(%rbp),%rdi
mov    $0x4f,%esi
xor    %edx,%edx
call   1060 <ureadline@plt>
movq   $0x0,-0x88(%rbp)
cmpq   $0x98967f,-0x88(%rbp)
jae    1291 <main+0x121>
jmp    127a <main+0x10a>
mov    -0x88(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    1264 <main+0xf4>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   10a0 <fork@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   10a0 <fork@plt>
xor    %eax,%eax
call   10a0 <fork@plt>
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <getppid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <gettid@plt>
sub    $0x8,%rsp
lea    0xe0c(%rip),%rdi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %eax,%ecx
mov    %ebx,%r8d
mov    %r13d,%r9d
xor    %eax,%eax
push   %r12
push   %r15
push   %r14
call   1060 <printf@plt>
add    $0x20,%rsp
test   %r13d,%r13d
je     1234 <main+0xb4>
test   %r14d,%r14d
je     1234 <main+0xb4>
test   %r15d,%r15d
je     1234 <main+0xb4>
test   %r12d,%r12d
je     1234 <main+0xb4>
mov    %rsp,%rdi
mov    $0x4f,%esi
xor    %edx,%edx
call   1070 <ureadline@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Press Return to end.\0A\00"
@.str.1 = [71 x i8] c"[%2d]: pid = %2d, tid = %2d, ppid = %2d, forkrets = [%2d %2d %2d %2d]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [80 x i8]
%12 = alloca i64
store i32 0, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (...) @fork()
store i32 %14, i32* %2
%15 = call i32 (...) @fork()
store i32 %15, i32* %3
%16 = call i32 (...) @fork()
store i32 %16, i32* %4
%17 = call i32 (...) @fork()
store i32 %17, i32* %5
%18 = call i32 (...) @fork()
store i32 %18, i32* %6
%19 = call i32 (...) @fork()
store i32 %19, i32* %7
%20 = call i32 (...) @getpid()
store i32 %20, i32* %8
%21 = call i32 (...) @getppid()
store i32 %21, i32* %9
%22 = call i32 (...) @gettid()
store i32 %22, i32* %10
%23 = load i32, i32* %8
%24 = load i32, i32* %8
%25 = load i32, i32* %10
%26 = load i32, i32* %9
%27 = load i32, i32* %2
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %46
34: ; preds = %0
%35 = load i32, i32* %3
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = load i32, i32* %5
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %11, i64 0, i64 0
%45 = call i32 @ureadline(i8* %44, i32 79, i32 0)
br label %46
46: ; preds = %43, %40, %37, %34, %0
store i64 0, i64* %12
br label %47
47: ; preds = %51, %46
%48 = load i64, i64* %12
%49 = icmp ult i64 %48, 9999999
br i1 %49, label %50, label %54
50: ; preds = %47
br label %51
51: ; preds = %50
%52 = load i64, i64* %12
%53 = add nsw i64 %52, 1
store i64 %53, i64* %12
br label %47
54: ; preds = %47
%55 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [71 x i8] c"[%2d]: pid = %2d, tid = %2d, ppid = %2d, forkrets = [%2d %2d %2d %2d]\0A\00"
@str = [21 x i8] c"Press Return to end.\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (...) @fork()
%4 = tail call i32 (...) @fork()
%5 = tail call i32 (...) @fork()
%6 = tail call i32 (...) @fork()
%7 = tail call i32 (...) @fork()
%8 = tail call i32 (...) @fork()
%9 = tail call i32 (...) @getpid()
%10 = tail call i32 (...) @getppid()
%11 = tail call i32 (...) @gettid()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %9, i32 %11, i32 %10, i32 %3, i32 %4, i32 %5, i32 %6)
%13 = icmp ne i32 %3, 0
%14 = icmp ne i32 %4, 0
%15 = select i1 %13, i1 %14, i1 false
%16 = icmp ne i32 %5, 0
%17 = select i1 %15, i1 %16, i1 false
%18 = icmp ne i32 %6, 0
%19 = select i1 %17, i1 %18, i1 false
br i1 %19, label %20, label %23
20: ; preds = %0
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%22 = call i32 @ureadline(i8* %21, i32 79, i32 0)
br label %23
23: ; preds = %20, %0
%24 = call i32 @exit(i32 0)
unreachable
}