#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 int pid_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
scalar_t__ wait(int /*<<< orphan*/ *);
int main(void) {
  int i;
  pid_t pid;
  while (1) {
    for (i = 0; i < 200; i++) {
      pid = fork();
      if (pid == 0) {
        exit(0);
      } else if (pid == -1) {
        continue;
      }
    }
    for (i = 0; i < 200; i++)
      if (wait(NULL) < 0)
        break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xc8,-0x8(%rbp)
jge    1195 <main+0x65>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    116e <main+0x3e>
xor    %edi,%edi
call   1030 <exit@plt>
cmpl   $0xffffffff,-0xc(%rbp)
jne    117d <main+0x4d>
jmp    1187 <main+0x57>
jmp    1182 <main+0x52>
jmp    1187 <main+0x57>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc8,-0x8(%rbp)
jge    11d4 <main+0xa4>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <wait@plt>
cmp    $0x0,%rax
jge    11c1 <main+0x91>
jmp    11d4 <main+0xa4>
jmp    11c6 <main+0x96>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119c <main+0x6c>
jmp    113f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
je     117b <main+0x4b>
add    $0x1,%r14d
cmp    $0xc8,%r14d
jne    1140 <main+0x10>
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   (%rax)
xor    %edi,%edi
call   1040 <wait@plt>
lea    0x1(%rbx),%ecx
test   %rax,%rax
js     1140 <main+0x10>
cmp    $0xc7,%ebx
mov    %ecx,%ebx
jb     1160 <main+0x30>
jmp    1140 <main+0x10>
xor    %edi,%edi
call   1030 <exit@plt>

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

LLVM IR (-O2):
define i32 @main() {
br label %6
1: ; preds = %6
%2 = add nuw nsw i32 %7, 1
%3 = icmp eq i32 %2, 200
br i1 %3, label %12, label %4
4: ; preds = %12, %1
%5 = phi i32 [ %2, %1 ], [ 0, %12 ]
br label %6
6: ; preds = %4, %0
%7 = phi i32 [ 0, %0 ], [ %5, %4 ]
%8 = tail call i32 (...) @fork()
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %1
10: ; preds = %6
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %1, %12
%13 = phi i32 [ %16, %12 ], [ 0, %1 ]
%14 = tail call i64 @wait(i32* null)
%15 = icmp sgt i64 %14, -1
%16 = add nuw nsw i32 %13, 1
%17 = icmp ult i32 %13, 199
%18 = select i1 %15, i1 %17, i1 false
br i1 %18, label %12, label %4
}