#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ doBench(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(void *);
void *growHeap();
int /*<<< orphan*/ helpAndLeave(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  if (argc > 2) {
    helpAndLeave(argv[0], EXIT_FAILURE);
  }
  void *mem = growHeap();
  int forkSyscall = argv[1] == NULL;
  printf("Benchmarking %s\n", (forkSyscall ? "fork" : "vfork"));
  doBench(forkSyscall);
  free(mem);
  exit(EXIT_SUCCESS);
}


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)
jle    1195 <main+0x35>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
call   1070 <helpAndLeave@plt>
mov    $0x0,%al
call   1060 <growHeap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
lea    0xe53(%rip),%rsi
lea    0xe4d(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1050 <doBench@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jl     117d <main+0x1d>
mov    (%rbx),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
call   1070 <helpAndLeave@plt>
xor    %eax,%eax
call   1060 <growHeap@plt>
mov    %rax,%r14
xor    %ebp,%ebp
cmpq   $0x0,0x8(%rbx)
sete   %bpl
lea    0xe79(%rip),%rax
lea    0xe71(%rip),%rsi
cmove  %rax,%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    %ebp,%edi
call   1050 <doBench@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@.str = [17 x i8] c"Benchmarking %s\0A\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [6 x i8] c"vfork\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @helpAndLeave(i8* %13, i32 %14)
br label %16
16: ; preds = %10, %2
%17 = call i8* (...) @growHeap()
store i8* %17, i8** %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
%22 = zext i1 %21 to i32
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i32, i32* %7
%29 = call i32 @doBench(i32 %28)
%30 = load i8*, i8** %6
%31 = call i32 @free(i8* %30)
%32 = load i32, i32* @EXIT_SUCCESS
%33 = call i32 @exit(i32 %32)
unreachable
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str = [17 x i8] c"Benchmarking %s\0A\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [6 x i8] c"vfork\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @helpAndLeave(i8* %5, i32 %6)
br label %8
8: ; preds = %4, %2
%9 = tail call i8* (...) @growHeap()
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
%13 = zext i1 %12 to i32
%14 = select i1 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @doBench(i32 %13)
%17 = tail call i32 @free(i8* %9)
%18 = load i32, i32* @EXIT_SUCCESS
%19 = tail call i32 @exit(i32 %18)
unreachable
}