#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 */
scalar_t__ fork();
int /*<<< orphan*/ printStuff();
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  pid_t pid = fork();
  if (pid == 0) {
    printStuff();
    return 0;
  } else {
    pid_t pid2 = fork();
    if (pid2 == 0) {
      printStuff();
      return 0;
    }
    pid_t pid3 = fork();
    if (pid3 == 0) {
      printStuff();
      return 0;
    }
    pid_t pid4 = fork();
    if (pid4 == 0) {
      printStuff();
      return 0;
    }
    wait(NULL);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1168 <main+0x38>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <main+0xc3>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1191 <main+0x61>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <main+0xc3>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ba <main+0x8a>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <main+0xc3>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11e3 <main+0xb3>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <main+0xc3>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <wait@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     116a <main+0x3a>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     116a <main+0x3a>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     116a <main+0x3a>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     116a <main+0x3a>
xor    %edi,%edi
call   1040 <wait@plt>
jmp    1171 <main+0x41>
xor    %eax,%eax
call   1030 <printStuff@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
%6 = call i64 (...) @fork()
store i64 %6, i64* %2
%7 = load i64, i64* %2
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %31
11: ; preds = %0
%12 = call i64 (...) @fork()
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %31
17: ; preds = %11
%18 = call i64 (...) @fork()
store i64 %18, i64* %4
%19 = load i64, i64* %4
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %31
23: ; preds = %17
%24 = call i64 (...) @fork()
store i64 %24, i64* %5
%25 = load i64, i64* %5
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %31
29: ; preds = %23
%30 = call i32 @wait(i32* null)
store i32 0, i32* %1
br label %31
31: ; preds = %29, %27, %21, %15, %9
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (...) @printStuff()
br label %22
5: ; preds = %0
%6 = tail call i64 (...) @fork()
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 (...) @printStuff()
br label %22
10: ; preds = %5
%11 = tail call i64 (...) @fork()
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (...) @printStuff()
br label %22
15: ; preds = %10
%16 = tail call i64 (...) @fork()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 (...) @printStuff()
br label %22
20: ; preds = %15
%21 = tail call i32 @wait(i32* null)
br label %22
22: ; preds = %8, %18, %20, %13, %3
ret i32 0
}