#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*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ pause();
int main(int argc, char *argv[]) {
  int n = 1;
  if (argc > 1) {
    n = atoi(argv[1]);
  }
  for (; n > 0; n--) {
    if (fork() == 0) {
      exit(0);
    }
  }
  pause();
  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   $0x1,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1177 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    117c <main+0x3c>
cmpl   $0x0,-0x14(%rbp)
jle    11b1 <main+0x71>
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
jne    119e <main+0x5e>
xor    %edi,%edi
call   1050 <exit@plt>
jmp    11a3 <main+0x63>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <main+0x3c>
mov    $0x0,%al
call   1030 <pause@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%ebx
cmp    $0x2,%edi
jl     115a <main+0x1a>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1174 <main+0x34>
add    $0x1,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     117f <main+0x3f>
add    $0xffffffff,%ebx
cmp    $0x2,%ebx
jge    1160 <main+0x20>
xor    %eax,%eax
call   1030 <pause@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @atoi(i8* %12)
store i32 %13, i32* %6
br label %14
14: ; preds = %9, %2
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %15
%19 = call i64 (...) @fork()
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %18
br label %24
24: ; preds = %23
%25 = load i32, i32* %6
%26 = add nsw i32 %25, -1
store i32 %26, i32* %6
br label %15
27: ; preds = %15
%28 = call i32 (...) @pause()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %2, %4
%10 = phi i32 [ 1, %2 ], [ %7, %4 ]
br label %14
11: ; preds = %14
%12 = add nsw i32 %15, -1
%13 = icmp sgt i32 %15, 1
br i1 %13, label %14, label %20
14: ; preds = %9, %11
%15 = phi i32 [ %12, %11 ], [ %10, %9 ]
%16 = tail call i64 (...) @fork()
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %11
18: ; preds = %14
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %11, %4
%21 = tail call i32 (...) @pause()
ret i32 0
}