#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 MAP_ANONYMOUS;
int MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ fork();
int *mmap(int /*<<< orphan*/ *, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(void) {
  int *i = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE,
                MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  fork();
  wait(NULL);
  fork();
  wait(NULL);
  fork();
  wait(NULL);
  fork();
  wait(NULL);
  fork();
  wait(NULL);
  fork();
  wait(NULL);
  fork();
  wait(NULL);
  if (*i < 100)
    printf("%d\n", ++*i);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
mov    0x2e69(%rip),%rax
or     (%rax),%edx
mov    0x2e80(%rip),%rax
mov    (%rax),%ecx
mov    0x2e67(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x4,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    $0x0,%al
call   1060 <fork@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x64,(%rax)
jge    1222 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    %esi,(%rax)
lea    0xde3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2eb0(%rip),%rax
mov    0x2e79(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e8e(%rip),%rax
mov    0x2e77(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    $0x4,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
xor    %eax,%eax
call   1060 <fork@plt>
xor    %edi,%edi
call   1050 <wait@plt>
mov    (%rbx),%esi
cmp    $0x63,%esi
jg     11f7 <main+0xb7>
add    $0x1,%esi
mov    %esi,(%rbx)
lea    0xe0e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @PROT_WRITE
%5 = or i32 %3, %4
%6 = load i32, i32* @MAP_SHARED
%7 = load i32, i32* @MAP_ANONYMOUS
%8 = or i32 %6, %7
%9 = call i32* @mmap(i32* null, i32 4, i32 %5, i32 %8, i32 -1, i32 0)
store i32* %9, i32** %2
%10 = call i32 (...) @fork()
%11 = call i32 @wait(i32* null)
%12 = call i32 (...) @fork()
%13 = call i32 @wait(i32* null)
%14 = call i32 (...) @fork()
%15 = call i32 @wait(i32* null)
%16 = call i32 (...) @fork()
%17 = call i32 @wait(i32* null)
%18 = call i32 (...) @fork()
%19 = call i32 @wait(i32* null)
%20 = call i32 (...) @fork()
%21 = call i32 @wait(i32* null)
%22 = call i32 (...) @fork()
%23 = call i32 @wait(i32* null)
%24 = load i32*, i32** %2
%25 = load i32, i32* %24
%26 = icmp slt i32 %25, 100
br i1 %26, label %27, label %32
27: ; preds = %0
%28 = load i32*, i32** %2
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %27, %0
ret i32 0
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_ANONYMOUS = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = load i32, i32* @PROT_READ
%2 = load i32, i32* @PROT_WRITE
%3 = or i32 %2, %1
%4 = load i32, i32* @MAP_SHARED
%5 = load i32, i32* @MAP_ANONYMOUS
%6 = or i32 %5, %4
%7 = tail call i32* @mmap(i32* null, i32 4, i32 %3, i32 %6, i32 -1, i32 0)
%8 = tail call i32 (...) @fork()
%9 = tail call i32 @wait(i32* null)
%10 = tail call i32 (...) @fork()
%11 = tail call i32 @wait(i32* null)
%12 = tail call i32 (...) @fork()
%13 = tail call i32 @wait(i32* null)
%14 = tail call i32 (...) @fork()
%15 = tail call i32 @wait(i32* null)
%16 = tail call i32 (...) @fork()
%17 = tail call i32 @wait(i32* null)
%18 = tail call i32 (...) @fork()
%19 = tail call i32 @wait(i32* null)
%20 = tail call i32 (...) @fork()
%21 = tail call i32 @wait(i32* null)
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 100
br i1 %23, label %24, label %27
24: ; preds = %0
%25 = add nsw i32 %22, 1
store i32 %25, i32* %7
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %0
ret i32 0
}