#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);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ hello(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_mo(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "%s:usage %s n-mo\n", argv[0], argv[0]);
    exit(1);
  }
  int nbmo = atoi(argv[1]);
  int status, i;
  init_mo(nbmo);
  for (i = 0; i < 1000; i++) {
    if (fork() == 0)
      hello(NULL);
    wait(&status);
  }
  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   $0x2,-0x8(%rbp)
je     11bd <main+0x4d>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <init_mo@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    121a <main+0xaa>
mov    $0x0,%al
call   1090 <fork@plt>
cmp    $0x0,%rax
jne    1203 <main+0x93>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <hello@plt>
lea    -0x18(%rbp),%rdi
call   1080 <wait@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11dc <main+0x6c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11cb <main+0x5b>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1030 <init_mo@plt>
mov    $0x3e8,%ebp
lea    0x4(%rsp),%rbx
jmp    11ad <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1080 <wait@plt>
add    $0xffffffff,%ebp
je     11c2 <main+0x52>
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
xor    %edi,%edi
call   1040 <hello@plt>
jmp    11a0 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rcx
lea    0xe22(%rip),%rsi
mov    %rcx,%rdx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [18 x i8] c"%s:usage %s n-mo\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = icmp eq i32 %0, 2
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %7)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = bitcast i32* %3 to i8*
%15 = tail call i32 @init_mo(i32 %13)
br label %16
16: ; preds = %10, %22
%17 = phi i32 [ 0, %10 ], [ %24, %22 ]
%18 = call i64 (...) @fork()
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @hello(i32* null)
br label %22
22: ; preds = %20, %16
%23 = call i32 @wait(i32* %3)
%24 = add nuw nsw i32 %17, 1
%25 = icmp eq i32 %24, 1000
br i1 %25, label %26, label %16
26: ; preds = %22
ret i32 0
}