#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 atoi(char *);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  int i, load = 50;
  if (argc == 2) {
    load = atoi(argv[1]);
  }
  printf("Bringing load to %i\n", load);
  for (i = 0; i < load; i++)
    if (fork() == 0)
      break;
  while (1)
    ;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x32,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1167 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11b2 <main+0x82>
mov    $0x0,%al
call   1050 <fork@plt>
cmp    $0x0,%rax
jne    119f <main+0x6f>
jmp    11b2 <main+0x82>
jmp    11a4 <main+0x74>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x4d>
jmp    11b7 <main+0x87>
jmp    11b7 <main+0x87>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1157 <main+0x27>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
lea    0xeb6(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
test   %ebp,%ebp
jg     116d <main+0x3d>
jmp    11a0 <main+0x70>
lea    0xea2(%rip),%rdi
mov    $0x32,%ebp
mov    $0x32,%esi
call   1030 <printf@plt>
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     11a0 <main+0x70>
lea    0x1(%rbx),%eax
cmp    %ebp,%ebx
mov    %eax,%ebx
jl     1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
jmp    11a0 <main+0x70>

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

LLVM IR (-O2):
@.str = [21 x i8] c"Bringing load to %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 50)
br label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %21
12: ; preds = %4, %6
%13 = phi i32 [ 50, %4 ], [ %9, %6 ]
br label %14
14: ; preds = %14, %12
%15 = phi i32 [ 0, %12 ], [ %18, %14 ]
%16 = tail call i64 (...) @fork()
%17 = icmp ne i64 %16, 0
%18 = add nuw nsw i32 %15, 1
%19 = icmp slt i32 %18, %13
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %14, label %21
21: ; preds = %14, %6
br label %22
22: ; preds = %21, %22
br label %22
}