#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*/ actionForkTree();
int /*<<< orphan*/ actionNames(char *);
int /*<<< orphan*/ actionPids(char *);
int /*<<< orphan*/ actionPs(char *, char *);
int /*<<< orphan*/ actionPsext(char *, char *);
int /*<<< orphan*/ actionSys(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  if (argc <= 1) {
    printf("No arguments provided.\n");
  } else {
    char *dir = (char *)malloc(sizeof(char) * 256 + 1);
    strcpy(dir, "/proc");
    if (argc > 2) {
      strcpy(dir, argv[2]);
    }
    if (strcmp(argv[1], "sys") == 0) {
      actionSys(dir);
    } else if (strcmp(argv[1], "pids") == 0) {
      actionPids(dir);
    } else if (strcmp(argv[1], "names") == 0) {
      actionNames(dir);
    } else if (strcmp(argv[1], "ps") == 0) {
      if (argc > 3) {
        actionPs(dir, argv[3]);
      } else {
        actionPs(dir, "");
      }
    } else if (strcmp(argv[1], "psext") == 0) {
      if (argc > 3) {
        actionPsext(dir, argv[3]);
      } else {
        actionPsext(dir, "");
      }
    } else if (strcmp(argv[1], "forktree") == 0) {
      actionForkTree();
    } else {
      printf("You did not provide the proper arguments.\n");
    }
  }
}


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)
jg     11d1 <main+0x31>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
jmp    1388 <main+0x1e8>
mov    $0x101,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcpy@plt>
cmpl   $0x2,-0x8(%rbp)
jle    120a <main+0x6a>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe05(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1236 <main+0x96>
mov    -0x18(%rbp),%rdi
call   10b0 <actionSys@plt>
jmp    1383 <main+0x1e3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xddd(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1262 <main+0xc2>
mov    -0x18(%rbp),%rdi
call   1070 <actionPids@plt>
jmp    137e <main+0x1de>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb6(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    128e <main+0xee>
mov    -0x18(%rbp),%rdi
call   10a0 <actionNames@plt>
jmp    1379 <main+0x1d9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd90(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12e1 <main+0x141>
cmpl   $0x3,-0x8(%rbp)
jle    12cc <main+0x12c>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   10c0 <actionPs@plt>
jmp    12dc <main+0x13c>
mov    -0x18(%rbp),%rdi
lea    0xd40(%rip),%rsi
call   10c0 <actionPs@plt>
jmp    1374 <main+0x1d4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd40(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1334 <main+0x194>
cmpl   $0x3,-0x8(%rbp)
jle    131f <main+0x17f>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1030 <actionPsext@plt>
jmp    132f <main+0x18f>
mov    -0x18(%rbp),%rdi
lea    0xced(%rip),%rsi
call   1030 <actionPsext@plt>
jmp    136f <main+0x1cf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcf3(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    135e <main+0x1be>
mov    $0x0,%al
call   1090 <actionForkTree@plt>
jmp    136a <main+0x1ca>
lea    0xcda(%rip),%rdi
call   1050 <printf@plt>
jmp    136f <main+0x1cf>
jmp    1374 <main+0x1d4>
jmp    1379 <main+0x1d9>
jmp    137e <main+0x1de>
jmp    1383 <main+0x1e3>
jmp    1388 <main+0x1e8>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     11ba <main+0x1a>
lea    0xea1(%rip),%rdi
call   1050 <puts@plt>
jmp    12d3 <main+0x133>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x101,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
lea    0xe2d(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
cmp    $0x2,%ebp
je     11ec <main+0x4c>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    0x8(%rbx),%rdi
lea    0xe0f(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1276 <main+0xd6>
mov    0x8(%rbx),%rdi
lea    0xdfe(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1280 <main+0xe0>
mov    0x8(%rbx),%rdi
lea    0xdee(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     128a <main+0xea>
mov    0x8(%rbx),%rdi
lea    0xddf(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1294 <main+0xf4>
mov    0x8(%rbx),%rdi
lea    0xdcd(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     129f <main+0xff>
mov    0x8(%rbx),%rdi
lea    0xdbe(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12bb <main+0x11b>
lea    0xdb6(%rip),%rdi
jmp    11b0 <main+0x10>
mov    %r14,%rdi
call   10b0 <actionSys@plt>
jmp    12d3 <main+0x133>
mov    %r14,%rdi
call   1070 <actionPids@plt>
jmp    12d3 <main+0x133>
mov    %r14,%rdi
call   10a0 <actionNames@plt>
jmp    12d3 <main+0x133>
cmp    $0x4,%ebp
jb     12aa <main+0x10a>
mov    0x18(%rbx),%rsi
jmp    12b1 <main+0x111>
cmp    $0x4,%ebp
jb     12c4 <main+0x124>
mov    0x18(%rbx),%rsi
jmp    12cb <main+0x12b>
lea    0xdb6(%rip),%rsi
mov    %r14,%rdi
call   10c0 <actionPs@plt>
jmp    12d3 <main+0x133>
xor    %eax,%eax
call   1090 <actionForkTree@plt>
jmp    12d3 <main+0x133>
lea    0xd9c(%rip),%rsi
mov    %r14,%rdi
call   1030 <actionPsext@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"No arguments provided.\0A\00"
@.str.1 = [6 x i8] c"/proc\00"
@.str.2 = [4 x i8] c"sys\00"
@.str.3 = [5 x i8] c"pids\00"
@.str.4 = [6 x i8] c"names\00"
@.str.5 = [3 x i8] c"ps\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [6 x i8] c"psext\00"
@.str.8 = [9 x i8] c"forktree\00"
@.str.9 = [43 x i8] c"You did not provide the proper arguments.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %105
11: ; preds = %2
%12 = call i64 @malloc(i32 257)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 2
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = load i8*, i8** %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @strcpy(i8* %19, i8* %22)
br label %24
24: ; preds = %18, %11
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i8*, i8** %6
%32 = call i32 @actionSys(i8* %31)
br label %104
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i8*, i8** %6
%41 = call i32 @actionPids(i8* %40)
br label %103
42: ; preds = %33
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = load i8*, i8** %6
%50 = call i32 @actionNames(i8* %49)
br label %102
51: ; preds = %42
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %70
57: ; preds = %51
%58 = load i32, i32* %4
%59 = icmp sgt i32 %58, 3
br i1 %59, label %60, label %66
60: ; preds = %57
%61 = load i8*, i8** %6
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 3
%64 = load i8*, i8** %63
%65 = call i32 @actionPs(i8* %61, i8* %64)
br label %69
66: ; preds = %57
%67 = load i8*, i8** %6
%68 = call i32 @actionPs(i8* %67, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %69
69: ; preds = %66, %60
br label %101
70: ; preds = %51
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 1
%73 = load i8*, i8** %72
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %89
76: ; preds = %70
%77 = load i32, i32* %4
%78 = icmp sgt i32 %77, 3
br i1 %78, label %79, label %85
79: ; preds = %76
%80 = load i8*, i8** %6
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 3
%83 = load i8*, i8** %82
%84 = call i32 @actionPsext(i8* %80, i8* %83)
br label %88
85: ; preds = %76
%86 = load i8*, i8** %6
%87 = call i32 @actionPsext(i8* %86, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %88
88: ; preds = %85, %79
br label %100
89: ; preds = %70
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 1
%92 = load i8*, i8** %91
%93 = call i64 @strcmp(i8* %92, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%94 = icmp eq i64 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %89
%96 = call i32 (...) @actionForkTree()
br label %99
97: ; preds = %89
%98 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.9, i64 0, i64 0))
br label %99
99: ; preds = %97, %95
br label %100
100: ; preds = %99, %88
br label %101
101: ; preds = %100, %69
br label %102
102: ; preds = %101, %48
br label %103
103: ; preds = %102, %39
br label %104
104: ; preds = %103, %30
br label %105
105: ; preds = %104, %9
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"/proc\00"
@.str.2 = [4 x i8] c"sys\00"
@.str.3 = [5 x i8] c"pids\00"
@.str.4 = [6 x i8] c"names\00"
@.str.5 = [3 x i8] c"ps\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [6 x i8] c"psext\00"
@.str.8 = [9 x i8] c"forktree\00"
@str = [42 x i8] c"You did not provide the proper arguments.\00"
@str.10 = [23 x i8] c"No arguments provided.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
br label %66
6: ; preds = %2
%7 = tail call i64 @malloc(i32 257)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %0, 2
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @strcpy(i8* %8, i8* %13)
br label %15
15: ; preds = %11, %6
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @actionSys(i8* %8)
br label %66
22: ; preds = %15
%23 = load i8*, i8** %16
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = tail call i32 @actionPids(i8* %8)
br label %66
28: ; preds = %22
%29 = load i8*, i8** %16
%30 = tail call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = tail call i32 @actionNames(i8* %8)
br label %66
34: ; preds = %28
%35 = load i8*, i8** %16
%36 = tail call i64 @strcmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %34
%39 = icmp ugt i32 %0, 3
br i1 %39, label %40, label %44
40: ; preds = %38
%41 = getelementptr inbounds i8*, i8** %1, i64 3
%42 = load i8*, i8** %41
%43 = tail call i32 @actionPs(i8* %8, i8* %42)
br label %66
44: ; preds = %38
%45 = tail call i32 @actionPs(i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %66
46: ; preds = %34
%47 = load i8*, i8** %16
%48 = tail call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %46
%51 = icmp ugt i32 %0, 3
br i1 %51, label %52, label %56
52: ; preds = %50
%53 = getelementptr inbounds i8*, i8** %1, i64 3
%54 = load i8*, i8** %53
%55 = tail call i32 @actionPsext(i8* %8, i8* %54)
br label %66
56: ; preds = %50
%57 = tail call i32 @actionPsext(i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0))
br label %66
58: ; preds = %46
%59 = load i8*, i8** %16
%60 = tail call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = tail call i32 (...) @actionForkTree()
br label %66
64: ; preds = %58
%65 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %66
66: ; preds = %20, %32, %56, %52, %64, %62, %40, %44, %26, %4
ret i32 0
}