#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) {
    pid_t pid2 = fork();
    if (pid2 == 0) {
      printStuff();
      pid_t pid3 = fork();
      if (pid3 == 0) {
        printStuff();
        return 0;
      } else {
        pid_t pid4 = fork();
        if (pid4 == 0) {
          printStuff();
          return 0;
        }
      }
    }
    wait(NULL);
  } else {
    printStuff();
    pid_t pid5 = fork();
    if (pid5 == 0) {
      printStuff();
      return 0;
    } else {
      pid_t pid6 = fork();
      if (pid6 == 0) {
        printStuff();
        return 0;
      }
    }
    wait(NULL);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11dc <main+0xac>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ce <main+0x9e>
mov    $0x0,%al
call   1030 <printStuff@plt>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119b <main+0x6b>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    1243 <main+0x113>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11c4 <main+0x94>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    1243 <main+0x113>
jmp    11c9 <main+0x99>
jmp    11ce <main+0x9e>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <wait@plt>
jmp    1243 <main+0x113>
mov    $0x0,%al
call   1030 <printStuff@plt>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    120c <main+0xdc>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    1243 <main+0x113>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1235 <main+0x105>
mov    $0x0,%al
call   1030 <printStuff@plt>
movl   $0x0,-0x4(%rbp)
jmp    1243 <main+0x113>
jmp    123a <main+0x10a>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <wait@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
jle    1149 <main+0x19>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
jne    1168 <main+0x38>
xor    %eax,%eax
call   1030 <printStuff@plt>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     1171 <main+0x41>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     1171 <main+0x41>
xor    %edi,%edi
call   1040 <wait@plt>
jmp    1178 <main+0x48>
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
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i64 (...) @fork()
store i64 %8, i64* %2
%9 = load i64, i64* %2
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %32
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 %30
15: ; preds = %11
%16 = call i32 (...) @printStuff()
%17 = call i64 (...) @fork()
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %48
22: ; preds = %15
%23 = call i64 (...) @fork()
store i64 %23, i64* %5
%24 = load i64, i64* %5
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %48
28: ; preds = %22
br label %29
29: ; preds = %28
br label %30
30: ; preds = %29, %11
%31 = call i32 @wait(i32* null)
br label %48
32: ; preds = %0
%33 = call i32 (...) @printStuff()
%34 = call i64 (...) @fork()
store i64 %34, i64* %6
%35 = load i64, i64* %6
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %48
39: ; preds = %32
%40 = call i64 (...) @fork()
store i64 %40, i64* %7
%41 = load i64, i64* %7
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %39
%44 = call i32 (...) @printStuff()
store i32 0, i32* %1
br label %48
45: ; preds = %39
br label %46
46: ; preds = %45
%47 = call i32 @wait(i32* null)
br label %48
48: ; preds = %20, %26, %37, %43, %46, %30
%49 = load i32, i32* %1
ret i32 %49
}

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