#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 *);
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  int count = argc > 1 ? atoi(argv[1]) : 20;
  while (1) {
    int i, s;
    for (i = 0; i < count; i++)
      if (fork() == 0)
        execlp("/bin/true", "true", NULL);
    for (i = 0; i < count; i++)
      wait(&s);
  }
}


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)
cmpl   $0x1,-0x8(%rbp)
jle    1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    1182 <main+0x42>
mov    $0x14,%eax
mov    %eax,-0x20(%rbp)
jmp    1182 <main+0x42>
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d6 <main+0x96>
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
jne    11c3 <main+0x83>
lea    0xe4d(%rip),%rdi
lea    0xe4b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <execlp@plt>
jmp    11c8 <main+0x88>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118f <main+0x4f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1200 <main+0xc0>
lea    -0x1c(%rbp),%rdi
call   1050 <wait@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11dd <main+0x9d>
jmp    1188 <main+0x48>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x14,%r14d
cmp    $0x2,%edi
jl     1163 <main+0x23>
mov    0x8(%rsi),%rdi
call   1030 <atoi@plt>
mov    %eax,%r14d
lea    0xe96(%rip),%r15
lea    0xe94(%rip),%r12
lea    0xc(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%ebp
test   %r14d,%r14d
jg     1195 <main+0x55>
jmp    1180 <main+0x40>
nopw   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
je     11b0 <main+0x70>
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
jne    1190 <main+0x50>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1040 <execlp@plt>
jmp    1190 <main+0x50>
mov    %r14d,%ebp
test   %r14d,%r14d
jle    1180 <main+0x40>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <wait@plt>
add    $0xffffffff,%ebp
jne    11c0 <main+0x80>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/true\00"
@.str.1 = [5 x i8] c"true\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 20, %16 ]
store i32 %18, i32* %6
br label %19
19: ; preds = %17, %43
store i32 0, i32* %7
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = call i64 (...) @fork()
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 @execlp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %29
29: ; preds = %27, %24
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %20
33: ; preds = %20
store i32 0, i32* %7
br label %34
34: ; preds = %40, %33
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = call i32 @wait(i32* %8)
br label %40
40: ; preds = %38
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %34
43: ; preds = %34
br label %19
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/true\00"
@.str.1 = [5 x i8] c"true\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
br label %9
9: ; preds = %2, %5
%10 = phi i32 [ %8, %5 ], [ 20, %2 ]
%11 = bitcast i32* %3 to i8*
%12 = icmp sgt i32 %10, 0
br label %13
13: ; preds = %29, %9
br i1 %12, label %15, label %29
14: ; preds = %21
br i1 %12, label %24, label %29
15: ; preds = %13, %21
%16 = phi i32 [ %22, %21 ], [ 0, %13 ]
%17 = call i64 (...) @fork()
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @execlp(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* null)
br label %21
21: ; preds = %15, %19
%22 = add nuw nsw i32 %16, 1
%23 = icmp eq i32 %22, %10
br i1 %23, label %14, label %15
24: ; preds = %14, %24
%25 = phi i32 [ %27, %24 ], [ 0, %14 ]
%26 = call i32 @wait(i32* %3)
%27 = add nuw nsw i32 %25, 1
%28 = icmp eq i32 %27, %10
br i1 %28, label %29, label %24
29: ; preds = %24, %13, %14
br label %13
}