#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*/ P0();
int /*<<< orphan*/ P1();
int /*<<< orphan*/ P2();
int /*<<< orphan*/ execCd(char **, int);
int /*<<< orphan*/ execDiskFormat();
int /*<<< orphan*/ execFork(char **, int);
int /*<<< orphan*/ execMkdir(char **, int);
int /*<<< orphan*/ execRun(char **, int);
int /*<<< orphan*/ execTouch(char **, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ runMultiThreadDemo();
scalar_t__ strcmp(char *, char *);
void command(char **options, int argc) {
  if (argc < 1)
    return;
  char *prog_name = options[0];
  if (strcmp(prog_name, "P0") == 0) {
    P0();
  } else if (strcmp(prog_name, "P1") == 0) {
    P1();
  } else if (strcmp(prog_name, "P2") == 0) {
    P2();
  } else if (strcmp(prog_name, "fork") == 0) {
    execFork(options, argc);
  } else if (strcmp(prog_name, "exit") == 0) {
    printf("\nShell Exit.");
    exit(0);
  } else if (strcmp(prog_name, "multithread") == 0) {
    printf("executing multithreading demo");
    runMultiThreadDemo();
  } else if (strcmp(prog_name, "mkdir") == 0) {
    execMkdir(options, argc);
  } else if (strcmp(prog_name, "run") == 0) {
    execRun(options, argc);
  } else if (strcmp(prog_name, "touch") == 0) {
    execTouch(options, argc);
  } else if (strcmp(prog_name, "cd") == 0) {
    execCd(options, argc);
  } else if (strcmp(prog_name, "diskfmt") == 0) {
    execDiskFormat();
  } else {
    printf("command %s not found\n", prog_name);
  }
}


x86 assembly (clang, -O0):
<command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jge    11ee <command+0x1e>
jmp    140f <command+0x23f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    121f <command+0x4f>
mov    $0x0,%al
call   1040 <P0@plt>
jmp    140f <command+0x23f>
mov    -0x18(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1245 <command+0x75>
mov    $0x0,%al
call   1090 <P1@plt>
jmp    140a <command+0x23a>
mov    -0x18(%rbp),%rdi
lea    0xdb6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    126b <command+0x9b>
mov    $0x0,%al
call   1050 <P2@plt>
jmp    1405 <command+0x235>
mov    -0x18(%rbp),%rdi
lea    0xd93(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1296 <command+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10b0 <execFork@plt>
jmp    1400 <command+0x230>
mov    -0x18(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12c5 <command+0xf5>
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xd50(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12f9 <command+0x129>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10f0 <runMultiThreadDemo@plt>
jmp    13f6 <command+0x226>
mov    -0x18(%rbp),%rdi
lea    0xd46(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1324 <command+0x154>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <execMkdir@plt>
jmp    13f1 <command+0x221>
mov    -0x18(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    134f <command+0x17f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10c0 <execRun@plt>
jmp    13ec <command+0x21c>
mov    -0x18(%rbp),%rdi
lea    0xcfa(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    137a <command+0x1aa>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10d0 <execTouch@plt>
jmp    13e7 <command+0x217>
mov    -0x18(%rbp),%rdi
lea    0xcd5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13a5 <command+0x1d5>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   10a0 <execCd@plt>
jmp    13e2 <command+0x212>
mov    -0x18(%rbp),%rdi
lea    0xcad(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13cb <command+0x1fb>
mov    $0x0,%al
call   1080 <execDiskFormat@plt>
jmp    13dd <command+0x20d>
mov    -0x18(%rbp),%rsi
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13e2 <command+0x212>
jmp    13e7 <command+0x217>
jmp    13ec <command+0x21c>
jmp    13f1 <command+0x221>
jmp    13f6 <command+0x226>
jmp    13fb <command+0x22b>
jmp    1400 <command+0x230>
jmp    1405 <command+0x235>
jmp    140a <command+0x23a>
jmp    140f <command+0x23f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<command>:
push   %rbp
push   %r14
push   %rbx
test   %esi,%esi
jle    1301 <command+0x131>
mov    %esi,%ebp
mov    %rdi,%r14
mov    (%rdi),%rbx
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1306 <command+0x136>
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1311 <command+0x141>
lea    0xdeb(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     131c <command+0x14c>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1327 <command+0x157>
lea    0xdc3(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1391 <command+0x1c1>
lea    0xdbd(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1335 <command+0x165>
lea    0xdcf(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     134e <command+0x17e>
lea    0xdbd(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     135c <command+0x18c>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     136a <command+0x19a>
lea    0xd97(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1378 <command+0x1a8>
lea    0xd82(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1386 <command+0x1b6>
lea    0xd72(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <printf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <P0@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <P1@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <P2@plt>
mov    %r14,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10b0 <execFork@plt>
lea    0xcf0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    10f0 <runMultiThreadDemo@plt>
mov    %r14,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <execMkdir@plt>
mov    %r14,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10c0 <execRun@plt>
mov    %r14,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10d0 <execTouch@plt>
mov    %r14,%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    10a0 <execCd@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <execDiskFormat@plt>
lea    0xc7b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"P0\00"
@.str.1 = [3 x i8] c"P1\00"
@.str.2 = [3 x i8] c"P2\00"
@.str.3 = [5 x i8] c"fork\00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [13 x i8] c"\0AShell Exit.\00"
@.str.6 = [12 x i8] c"multithread\00"
@.str.7 = [30 x i8] c"executing multithreading demo\00"
@.str.8 = [6 x i8] c"mkdir\00"
@.str.9 = [4 x i8] c"run\00"
@.str.10 = [6 x i8] c"touch\00"
@.str.11 = [3 x i8] c"cd\00"
@.str.12 = [8 x i8] c"diskfmt\00"
@.str.13 = [22 x i8] c"command %s not found\0A\00"
define void @command(i8** %0, i32 %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i8*
store i8** %0, i8*** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %2
br label %103
9: ; preds = %2
%10 = load i8**, i8*** %3
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = call i32 (...) @P0()
br label %103
18: ; preds = %9
%19 = load i8*, i8** %5
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (...) @P1()
br label %102
24: ; preds = %18
%25 = load i8*, i8** %5
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (...) @P2()
br label %101
30: ; preds = %24
%31 = load i8*, i8** %5
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %30
%35 = load i8**, i8*** %3
%36 = load i32, i32* %4
%37 = call i32 @execFork(i8** %35, i32 %36)
br label %100
38: ; preds = %30
%39 = load i8*, i8** %5
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %38
%46 = load i8*, i8** %5
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%51 = call i32 (...) @runMultiThreadDemo()
br label %98
52: ; preds = %45
%53 = load i8*, i8** %5
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %52
%57 = load i8**, i8*** %3
%58 = load i32, i32* %4
%59 = call i32 @execMkdir(i8** %57, i32 %58)
br label %97
60: ; preds = %52
%61 = load i8*, i8** %5
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %60
%65 = load i8**, i8*** %3
%66 = load i32, i32* %4
%67 = call i32 @execRun(i8** %65, i32 %66)
br label %96
68: ; preds = %60
%69 = load i8*, i8** %5
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %68
%73 = load i8**, i8*** %3
%74 = load i32, i32* %4
%75 = call i32 @execTouch(i8** %73, i32 %74)
br label %95
76: ; preds = %68
%77 = load i8*, i8** %5
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = load i8**, i8*** %3
%82 = load i32, i32* %4
%83 = call i32 @execCd(i8** %81, i32 %82)
br label %94
84: ; preds = %76
%85 = load i8*, i8** %5
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %84
%89 = call i32 (...) @execDiskFormat()
br label %93
90: ; preds = %84
%91 = load i8*, i8** %5
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %90, %88
br label %94
94: ; preds = %93, %80
br label %95
95: ; preds = %94, %72
br label %96
96: ; preds = %95, %64
br label %97
97: ; preds = %96, %56
br label %98
98: ; preds = %97, %49
br label %99
99: ; preds = %98
br label %100
100: ; preds = %99, %34
br label %101
101: ; preds = %100, %28
br label %102
102: ; preds = %101, %22
br label %103
103: ; preds = %8, %102, %16
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"P0\00"
@.str.1 = [3 x i8] c"P1\00"
@.str.2 = [3 x i8] c"P2\00"
@.str.3 = [5 x i8] c"fork\00"
@.str.4 = [5 x i8] c"exit\00"
@.str.5 = [13 x i8] c"\0AShell Exit.\00"
@.str.6 = [12 x i8] c"multithread\00"
@.str.7 = [30 x i8] c"executing multithreading demo\00"
@.str.8 = [6 x i8] c"mkdir\00"
@.str.9 = [4 x i8] c"run\00"
@.str.10 = [6 x i8] c"touch\00"
@.str.11 = [3 x i8] c"cd\00"
@.str.12 = [8 x i8] c"diskfmt\00"
@.str.13 = [22 x i8] c"command %s not found\0A\00"
define void @command(i8** %0, i32 %1) {
%3 = icmp slt i32 %1, 1
br i1 %3, label %64, label %4
4: ; preds = %2
%5 = load i8*, i8** %0
%6 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 (...) @P0()
br label %64
10: ; preds = %4
%11 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 (...) @P1()
br label %64
15: ; preds = %10
%16 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 (...) @P2()
br label %64
20: ; preds = %15
%21 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @execFork(i8** %0, i32 %1)
br label %64
25: ; preds = %20
%26 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%30 = tail call i32 @exit(i32 0)
unreachable
31: ; preds = %25
%32 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%36 = tail call i32 (...) @runMultiThreadDemo()
br label %64
37: ; preds = %31
%38 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = tail call i32 @execMkdir(i8** %0, i32 %1)
br label %64
42: ; preds = %37
%43 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = tail call i32 @execRun(i8** %0, i32 %1)
br label %64
47: ; preds = %42
%48 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = tail call i32 @execTouch(i8** %0, i32 %1)
br label %64
52: ; preds = %47
%53 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = tail call i32 @execCd(i8** %0, i32 %1)
br label %64
57: ; preds = %52
%58 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = tail call i32 (...) @execDiskFormat()
br label %64
62: ; preds = %57
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %5)
br label %64
64: ; preds = %8, %18, %40, %50, %60, %62, %55, %45, %34, %23, %13, %2
ret void
}