#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*/ do_cd();
int /*<<< orphan*/ do_clear();
int /*<<< orphan*/ do_echo();
int /*<<< orphan*/ do_ls();
int /*<<< orphan*/ do_pwd();
int /*<<< orphan*/ edit_string();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ getuid();
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ print_user();
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ sudo_down();
int /*<<< orphan*/ sudo_up();
void exec_cmd(char *command) {
  if (strcmp(command, "echo") == 0) {
    do_echo();
  } else if (strcmp(command, "exit") == 0) {
    if (getuid() == 0)
      sudo_down();
    else
      exit(0);
  } else if (strcmp(command, "help") == 0) {
    print_help();
  } else if (strcmp(command, "ls") == 0) {
    do_ls();
  } else if (strcmp(command, "cd") == 0) {
    do_cd();
  } else if (strcmp(command, "pwd") == 0) {
    do_pwd();
  } else if (strcmp(command, "clear") == 0) {
    do_clear();
  } else if (strcmp(command, "editor") == 0) {
    edit_string();
  } else if (strcmp(command, "getuser") == 0) {
    print_user();
  } else if (strcmp(command, "sudo") == 0) {
    sudo_up();
  } else {
    printf("Command not found!\n");
  }
}


x86 assembly (clang, -O0):
<exec_cmd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1212 <exec_cmd+0x32>
mov    $0x0,%al
call   1050 <do_echo@plt>
jmp    13be <exec_cmd+0x1de>
mov    -0x8(%rbp),%rdi
lea    0xde8(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1255 <exec_cmd+0x75>
mov    $0x0,%al
call   1060 <getuid@plt>
cmp    $0x0,%rax
jne    1249 <exec_cmd+0x69>
mov    $0x0,%al
call   1070 <sudo_down@plt>
jmp    1250 <exec_cmd+0x70>
xor    %edi,%edi
call   10f0 <exit@plt>
jmp    13b9 <exec_cmd+0x1d9>
mov    -0x8(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <exec_cmd+0x9b>
mov    $0x0,%al
call   10d0 <print_help@plt>
jmp    13b4 <exec_cmd+0x1d4>
mov    -0x8(%rbp),%rdi
lea    0xd89(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12a1 <exec_cmd+0xc1>
mov    $0x0,%al
call   10c0 <do_ls@plt>
jmp    13af <exec_cmd+0x1cf>
mov    -0x8(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12c7 <exec_cmd+0xe7>
mov    $0x0,%al
call   1090 <do_cd@plt>
jmp    13aa <exec_cmd+0x1ca>
mov    -0x8(%rbp),%rdi
lea    0xd43(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    12ed <exec_cmd+0x10d>
mov    $0x0,%al
call   1030 <do_pwd@plt>
jmp    13a5 <exec_cmd+0x1c5>
mov    -0x8(%rbp),%rdi
lea    0xd21(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1313 <exec_cmd+0x133>
mov    $0x0,%al
call   1040 <do_clear@plt>
jmp    13a0 <exec_cmd+0x1c0>
mov    -0x8(%rbp),%rdi
lea    0xd01(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1339 <exec_cmd+0x159>
mov    $0x0,%al
call   10b0 <edit_string@plt>
jmp    139b <exec_cmd+0x1bb>
mov    -0x8(%rbp),%rdi
lea    0xce2(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    135f <exec_cmd+0x17f>
mov    $0x0,%al
call   10e0 <print_user@plt>
jmp    1396 <exec_cmd+0x1b6>
mov    -0x8(%rbp),%rdi
lea    0xcc4(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1385 <exec_cmd+0x1a5>
mov    $0x0,%al
call   1100 <sudo_up@plt>
jmp    1391 <exec_cmd+0x1b1>
lea    0xca7(%rip),%rdi
call   1080 <printf@plt>
jmp    1396 <exec_cmd+0x1b6>
jmp    139b <exec_cmd+0x1bb>
jmp    13a0 <exec_cmd+0x1c0>
jmp    13a5 <exec_cmd+0x1c5>
jmp    13aa <exec_cmd+0x1ca>
jmp    13af <exec_cmd+0x1cf>
jmp    13b4 <exec_cmd+0x1d4>
jmp    13b9 <exec_cmd+0x1d9>
jmp    13be <exec_cmd+0x1de>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exec_cmd>:
push   %rbx
mov    %rdi,%rbx
lea    0xe15(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12d2 <exec_cmd+0xf2>
lea    0xe05(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12da <exec_cmd+0xfa>
lea    0xdf2(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12ee <exec_cmd+0x10e>
lea    0xddf(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12f6 <exec_cmd+0x116>
lea    0xdca(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     12fe <exec_cmd+0x11e>
lea    0xdb5(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1306 <exec_cmd+0x126>
lea    0xda1(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     130e <exec_cmd+0x12e>
lea    0xd8f(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1316 <exec_cmd+0x136>
lea    0xd82(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     131e <exec_cmd+0x13e>
lea    0xd76(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1326 <exec_cmd+0x146>
lea    0xd67(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <do_echo@plt>
xor    %eax,%eax
call   1070 <getuid@plt>
test   %rax,%rax
jne    132e <exec_cmd+0x14e>
xor    %eax,%eax
pop    %rbx
jmp    1080 <sudo_down@plt>
xor    %eax,%eax
pop    %rbx
jmp    10d0 <print_help@plt>
xor    %eax,%eax
pop    %rbx
jmp    10c0 <do_ls@plt>
xor    %eax,%eax
pop    %rbx
jmp    1090 <do_cd@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <do_pwd@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <do_clear@plt>
xor    %eax,%eax
pop    %rbx
jmp    10b0 <edit_string@plt>
xor    %eax,%eax
pop    %rbx
jmp    10e0 <print_user@plt>
xor    %eax,%eax
pop    %rbx
jmp    1100 <sudo_up@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"echo\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [3 x i8] c"ls\00"
@.str.4 = [3 x i8] c"cd\00"
@.str.5 = [4 x i8] c"pwd\00"
@.str.6 = [6 x i8] c"clear\00"
@.str.7 = [7 x i8] c"editor\00"
@.str.8 = [8 x i8] c"getuser\00"
@.str.9 = [5 x i8] c"sudo\00"
@.str.10 = [20 x i8] c"Command not found!\0A\00"
define void @exec_cmd(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 (...) @do_echo()
br label %79
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %20
12: ; preds = %8
%13 = call i64 (...) @getuid()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (...) @sudo_down()
br label %19
17: ; preds = %12
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %15
br label %78
20: ; preds = %8
%21 = load i8*, i8** %2
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (...) @print_help()
br label %77
26: ; preds = %20
%27 = load i8*, i8** %2
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (...) @do_ls()
br label %76
32: ; preds = %26
%33 = load i8*, i8** %2
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (...) @do_cd()
br label %75
38: ; preds = %32
%39 = load i8*, i8** %2
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (...) @do_pwd()
br label %74
44: ; preds = %38
%45 = load i8*, i8** %2
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (...) @do_clear()
br label %73
50: ; preds = %44
%51 = load i8*, i8** %2
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 (...) @edit_string()
br label %72
56: ; preds = %50
%57 = load i8*, i8** %2
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 (...) @print_user()
br label %71
62: ; preds = %56
%63 = load i8*, i8** %2
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 (...) @sudo_up()
br label %70
68: ; preds = %62
%69 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0))
br label %70
70: ; preds = %68, %66
br label %71
71: ; preds = %70, %60
br label %72
72: ; preds = %71, %54
br label %73
73: ; preds = %72, %48
br label %74
74: ; preds = %73, %42
br label %75
75: ; preds = %74, %36
br label %76
76: ; preds = %75, %30
br label %77
77: ; preds = %76, %24
br label %78
78: ; preds = %77, %19
br label %79
79: ; preds = %78, %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"echo\00"
@.str.1 = [5 x i8] c"exit\00"
@.str.2 = [5 x i8] c"help\00"
@.str.3 = [3 x i8] c"ls\00"
@.str.4 = [3 x i8] c"cd\00"
@.str.5 = [4 x i8] c"pwd\00"
@.str.6 = [6 x i8] c"clear\00"
@.str.7 = [7 x i8] c"editor\00"
@.str.8 = [8 x i8] c"getuser\00"
@.str.9 = [5 x i8] c"sudo\00"
@str = [19 x i8] c"Command not found!\00"
define void @exec_cmd(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (...) @do_echo()
br label %58
6: ; preds = %1
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i64 (...) @getuid()
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 (...) @sudo_down()
br label %58
14: ; preds = %9
%15 = tail call i32 @exit(i32 0)
unreachable
16: ; preds = %6
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 (...) @print_help()
br label %58
21: ; preds = %16
%22 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 (...) @do_ls()
br label %58
26: ; preds = %21
%27 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 (...) @do_cd()
br label %58
31: ; preds = %26
%32 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 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 (...) @do_pwd()
br label %58
36: ; preds = %31
%37 = tail call i64 @strcmp(i8* %0, 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 %41
39: ; preds = %36
%40 = tail call i32 (...) @do_clear()
br label %58
41: ; preds = %36
%42 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = tail call i32 (...) @edit_string()
br label %58
46: ; preds = %41
%47 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = tail call i32 (...) @print_user()
br label %58
51: ; preds = %46
%52 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = tail call i32 (...) @sudo_up()
br label %58
56: ; preds = %51
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %58
58: ; preds = %12, %24, %34, %44, %54, %56, %49, %39, %29, %19, %4
ret void
}