#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 atol(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ pause();
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int n;
  n = (argc == 1) ? 1 : atol(argv[1]);
  if (n <= 0) {
    fprintf(stderr, "Use: %s [<n>]\n", argv[0]);
    return (1);
  }
  if (fork())
    exit(0);
  while (n-- > 0) {
    if (fork() == 0)
      exit(0);
  }
  for (;;)
    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)
cmpl   $0x1,-0x8(%rbp)
jne    117d <main+0x2d>
mov    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11c4 <main+0x74>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe4c(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
je     11dc <main+0x8c>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    11e1 <main+0x91>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    1212 <main+0xc2>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
jne    120d <main+0xbd>
xor    %edi,%edi
call   1060 <exit@plt>
jmp    11e1 <main+0x91>
jmp    1217 <main+0xc7>
mov    $0x0,%al
call   1040 <pause@plt>
jmp    1217 <main+0xc7>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x1,%edi
je     1170 <main+0x20>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1050 <atol@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    11a9 <main+0x59>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jne    1193 <main+0x43>
add    $0x1,%ebx
nop
add    $0xffffffff,%ebx
test   %ebx,%ebx
jle    11a0 <main+0x50>
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
jne    1180 <main+0x30>
xor    %edi,%edi
call   1060 <exit@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <pause@plt>
jmp    11a0 <main+0x50>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xe44(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Use: %s [<n>]\0A\00"
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
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %2
br 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 @atol(i8* %13)
br label %15
15: ; preds = %10, %9
%16 = phi i32 [ 1, %9 ], [ %14, %10 ]
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = icmp sle i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %23)
ret i32 1
25: ; preds = %15
%26 = call i64 (...) @fork()
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = call i32 @exit(i32 0)
unreachable
30: ; preds = %25
br label %31
31: ; preds = %40, %30
%32 = load i32, i32* %6
%33 = add nsw i32 %32, -1
store i32 %33, i32* %6
%34 = icmp sgt i32 %32, 0
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = call i64 (...) @fork()
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %35
br label %31
41: ; preds = %31
br label %42
42: ; preds = %42, %41
%43 = call i32 (...) @pause()
br label %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Use: %s [<n>]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atol(i8* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %1
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %11)
ret i32 1
13: ; preds = %2, %4
%14 = phi i32 [ %7, %4 ], [ 1, %2 ]
%15 = tail call i64 (...) @fork()
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %13, %22
%20 = phi i32 [ %23, %22 ], [ %14, %13 ]
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = add nsw i32 %20, -1
%24 = tail call i64 (...) @fork()
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %19
26: ; preds = %22
%27 = tail call i32 @exit(i32 0)
unreachable
28: ; preds = %19, %28
%29 = tail call i32 (...) @pause()
br label %28
}