#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*/ dirs_chdir(char *);
char *dirs_get_cwd();
int /*<<< orphan*/ dirs_ls(char *);
int /*<<< orphan*/ dirs_mkdir(char *);
int /*<<< orphan*/ dirs_rm(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ utils_echo(char *);
int /*<<< orphan*/ utils_exit();
int utils_execute(char **tokens) {
  char *cmd = tokens[0];
  char *cwd = dirs_get_cwd();
  if (strcmp(cmd, "ls") == 0) {
    if (cmd) {
      dirs_ls(tokens[1]);
    }
  } else if (strcmp(cmd, "cd") == 0) {
    dirs_chdir(tokens[1]);
  } else if (strcmp(cmd, "echo") == 0) {
    utils_echo(tokens[1]);
  } else if (strcmp(cmd, "pwd") == 0) {
    printf("%s\n", cwd);
  } else if (strcmp(cmd, "exit") == 0) {
    utils_exit();
  } else if (strcmp(cmd, "mkdir") == 0) {
    dirs_mkdir(tokens[1]);
  } else if (strcmp(cmd, "rm") == 0) {
    dirs_rm(tokens[1]);
  } else {
    printf("Unrecognized command. To see available commands, write 'help'\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<utils_execute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   10a0 <dirs_get_cwd@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11e9 <utils_execute+0x59>
cmpq   $0x0,-0x10(%rbp)
je     11e4 <utils_execute+0x54>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <dirs_ls@plt>
jmp    131c <utils_execute+0x18c>
mov    -0x10(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1215 <utils_execute+0x85>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <dirs_chdir@plt>
jmp    1317 <utils_execute+0x187>
mov    -0x10(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1241 <utils_execute+0xb1>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <utils_echo@plt>
jmp    1312 <utils_execute+0x182>
mov    -0x10(%rbp),%rdi
lea    0xdbf(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1272 <utils_execute+0xe2>
mov    -0x18(%rbp),%rsi
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130d <utils_execute+0x17d>
mov    -0x10(%rbp),%rdi
lea    0xd96(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1298 <utils_execute+0x108>
mov    $0x0,%al
call   1060 <utils_exit@plt>
jmp    1308 <utils_execute+0x178>
mov    -0x10(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12c4 <utils_execute+0x134>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <dirs_mkdir@plt>
jmp    1303 <utils_execute+0x173>
mov    -0x10(%rbp),%rdi
lea    0xd4f(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12f0 <utils_execute+0x160>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <dirs_rm@plt>
jmp    12fe <utils_execute+0x16e>
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1303 <utils_execute+0x173>
jmp    1308 <utils_execute+0x178>
jmp    130d <utils_execute+0x17d>
jmp    1312 <utils_execute+0x182>
jmp    1317 <utils_execute+0x187>
jmp    131c <utils_execute+0x18c>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utils_execute>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%rbx
xor    %eax,%eax
call   10a0 <dirs_get_cwd@plt>
mov    %rax,%r15
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     123e <utils_execute+0xae>
lea    0xe3f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     124e <utils_execute+0xbe>
lea    0xe2e(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1259 <utils_execute+0xc9>
lea    0xe1f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1264 <utils_execute+0xd4>
lea    0xe0f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     126e <utils_execute+0xde>
lea    0xe00(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1277 <utils_execute+0xe7>
lea    0xdf2(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1282 <utils_execute+0xf2>
lea    0xde1(%rip),%rdi
jmp    1267 <utils_execute+0xd7>
test   %rbx,%rbx
je     128b <utils_execute+0xfb>
mov    0x8(%r14),%rdi
call   1090 <dirs_ls@plt>
jmp    128b <utils_execute+0xfb>
mov    0x8(%r14),%rdi
call   1080 <dirs_chdir@plt>
jmp    128b <utils_execute+0xfb>
mov    0x8(%r14),%rdi
call   1050 <utils_echo@plt>
jmp    128b <utils_execute+0xfb>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    128b <utils_execute+0xfb>
xor    %eax,%eax
call   1060 <utils_exit@plt>
jmp    128b <utils_execute+0xfb>
mov    0x8(%r14),%rdi
call   10b0 <dirs_mkdir@plt>
jmp    128b <utils_execute+0xfb>
mov    0x8(%r14),%rdi
call   1030 <dirs_rm@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ls\00"
@.str.1 = [3 x i8] c"cd\00"
@.str.2 = [5 x i8] c"echo\00"
@.str.3 = [4 x i8] c"pwd\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [5 x i8] c"exit\00"
@.str.6 = [6 x i8] c"mkdir\00"
@.str.7 = [3 x i8] c"rm\00"
@.str.8 = [63 x i8] c"Unrecognized command. To see available commands, write 'help'\0A\00"
define i32 @utils_execute(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8*
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = getelementptr inbounds i8*, i8** %5, i64 0
%7 = load i8*, i8** %6
store i8* %7, i8** %3
%8 = call i8* (...) @dirs_get_cwd()
store i8* %8, i8** %4
%9 = load i8*, i8** %3
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8**, i8*** %2
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @dirs_ls(i8* %18)
br label %20
20: ; preds = %15, %12
br label %78
21: ; preds = %1
%22 = load i8*, i8** %3
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8**, i8*** %2
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @dirs_chdir(i8* %28)
br label %77
30: ; preds = %21
%31 = load i8*, i8** %3
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i8**, i8*** %2
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 @utils_echo(i8* %37)
br label %76
39: ; preds = %30
%40 = load i8*, i8** %3
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %44)
br label %75
46: ; preds = %39
%47 = load i8*, i8** %3
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 (...) @utils_exit()
br label %74
52: ; preds = %46
%53 = load i8*, i8** %3
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i8**, i8*** %2
%58 = getelementptr inbounds i8*, i8** %57, i64 1
%59 = load i8*, i8** %58
%60 = call i32 @dirs_mkdir(i8* %59)
br label %73
61: ; preds = %52
%62 = load i8*, i8** %3
%63 = call i64 @strcmp(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %61
%66 = load i8**, i8*** %2
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = call i32 @dirs_rm(i8* %68)
br label %72
70: ; preds = %61
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.8, i64 0, i64 0))
br label %72
72: ; preds = %70, %65
br label %73
73: ; preds = %72, %56
br label %74
74: ; preds = %73, %50
br label %75
75: ; preds = %74, %43
br label %76
76: ; preds = %75, %34
br label %77
77: ; preds = %76, %25
br label %78
78: ; preds = %77, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"ls\00"
@.str.1 = [3 x i8] c"cd\00"
@.str.2 = [5 x i8] c"echo\00"
@.str.3 = [4 x i8] c"pwd\00"
@.str.5 = [5 x i8] c"exit\00"
@.str.6 = [6 x i8] c"mkdir\00"
@.str.7 = [3 x i8] c"rm\00"
@str = [62 x i8] c"Unrecognized command. To see available commands, write 'help'\00"
define i32 @utils_execute(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = tail call i8* (...) @dirs_get_cwd()
%4 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = icmp eq i8* %2, null
br i1 %7, label %52, label %8
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %0, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @dirs_ls(i8* %10)
br label %52
12: ; preds = %1
%13 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = getelementptr inbounds i8*, i8** %0, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @dirs_chdir(i8* %17)
br label %52
19: ; preds = %12
%20 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = getelementptr inbounds i8*, i8** %0, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @utils_echo(i8* %24)
br label %52
26: ; preds = %19
%27 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 @puts(i8* dereferenceable(1) %3)
br label %52
31: ; preds = %26
%32 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = tail call i32 (...) @utils_exit()
br label %52
36: ; preds = %31
%37 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = getelementptr inbounds i8*, i8** %0, i64 1
%41 = load i8*, i8** %40
%42 = tail call i32 @dirs_mkdir(i8* %41)
br label %52
43: ; preds = %36
%44 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = getelementptr inbounds i8*, i8** %0, i64 1
%48 = load i8*, i8** %47
%49 = tail call i32 @dirs_rm(i8* %48)
br label %52
50: ; preds = %43
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @str, i64 0, i64 0))
br label %52
52: ; preds = %15, %29, %39, %50, %46, %34, %22, %6, %8
ret i32 0
}