#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*/ command(char **, int);
int fork();
int /*<<< orphan*/ printf(char *, ...);
void execFork(char **options, int argc) {
  if (argc < 2) {
    printf("fork: usage\n\t fork [command]\n");
    return;
  }
  int tid = fork();
  printf("fork executed. tid=%d", tid);
  if (tid == 0) {
    command(&options[1], ++argc);
  } else {
  }
}


x86 assembly (clang, -O0):
<execFork>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jge    115c <execFork+0x2c>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a1 <execFork+0x71>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    119c <execFork+0x6c>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0xc(%rbp)
call   1030 <command@plt>
jmp    11a1 <execFork+0x71>
jmp    11a1 <execFork+0x71>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<execFork>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%esi
jg     1159 <execFork+0x19>
lea    0xec6(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
mov    %esi,%ebx
mov    %rdi,%r14
xor    %eax,%eax
call   1060 <fork@plt>
mov    %eax,%ebp
lea    0xe92(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
je     1180 <execFork+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret
add    $0x8,%r14
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <command@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"fork: usage\0A\09 fork [command]\0A\00"
@.str.1 = [22 x i8] c"fork executed. tid=%d\00"
define void @execFork(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %23
10: ; preds = %2
%11 = call i32 (...) @fork()
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %5
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %10
%17 = load i8**, i8*** %3
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
%21 = call i32 @command(i8** %18, i32 %20)
br label %23
22: ; preds = %10
br label %23
23: ; preds = %8, %22, %16
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"fork executed. tid=%d\00"
@str = [29 x i8] c"fork: usage\0A\09 fork [command]\00"
define void @execFork(i8** %0, i32 %1) {
%3 = icmp slt i32 %1, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %14
6: ; preds = %2
%7 = tail call i32 (...) @fork()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %7, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = getelementptr inbounds i8*, i8** %0, i64 1
%12 = add nuw nsw i32 %1, 1
%13 = tail call i32 @command(i8** %11, i32 %12)
br label %14
14: ; preds = %10, %6, %4
ret void
}