#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*/ F_OK;
int /*<<< orphan*/ R_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ errou(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
void local(char *str) {
  char cmd[16];
  if ((str[0] == 'l') && (str[1] == 's')) {
    strcpy(cmd, str);
    system(cmd);
  } else if ((str[0] == 'c') && (str[1] == 'd')) {
    if (access(&str[3], F_OK) != -1) {
      if (access(&str[3], R_OK) != -1) {
        strcpy(cmd, &str[3]);
        chdir(cmd);
        system("pwd");
      } else
        errou(1);
    } else
      errou(0);
  } else if (!strcmp(str, "clear")) {
    system("clear");
  } else if ((str[0] == 'g') && (str[1] == 'e') && (str[2] == 't')) {
    if (access(&str[3], F_OK) != -1) {
      if (access(&str[3], R_OK) != -1) {
        strcpy(cmd, "cat ");
        strcat(cmd, &str[4]);
        system(cmd);
      } else
        errou(1);
    } else
      errou(0);
  } else if ((str[0] == 'p') && (str[1] == 'u') && (str[2] == 't')) {
    strcpy(cmd, "touch ");
    strcat(cmd, &str[4]);
    system(cmd);
  } else
    printf("Opcao invalida. Digite \"sair\" caso queira fechar o programa.\n");
}


x86 assembly (clang, -O0):
<local>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6c,%eax
jne    11c8 <local+0x48>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x73,%eax
jne    11c8 <local+0x48>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1050 <system@plt>
jmp    13d2 <local+0x252>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x63,%eax
jne    126d <local+0xed>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x64,%eax
jne    126d <local+0xed>
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     1261 <local+0xe1>
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    0x2dc9(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     1252 <local+0xd2>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x3,%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
call   1040 <chdir@plt>
lea    0xdb8(%rip),%rdi
call   1050 <system@plt>
jmp    125c <local+0xdc>
mov    $0x1,%edi
call   1080 <errou@plt>
jmp    1268 <local+0xe8>
xor    %edi,%edi
call   1080 <errou@plt>
jmp    13cd <local+0x24d>
mov    -0x8(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1297 <local+0x117>
lea    0xd77(%rip),%rdi
call   1050 <system@plt>
jmp    13c8 <local+0x248>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x67,%eax
jne    1351 <local+0x1d1>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x65,%eax
jne    1351 <local+0x1d1>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x74,%eax
jne    1351 <local+0x1d1>
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     1345 <local+0x1c5>
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    0x2ce9(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     1336 <local+0x1b6>
lea    -0x20(%rbp),%rdi
lea    0xcf8(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
call   10a0 <strcat@plt>
lea    -0x20(%rbp),%rdi
call   1050 <system@plt>
jmp    1340 <local+0x1c0>
mov    $0x1,%edi
call   1080 <errou@plt>
jmp    134c <local+0x1cc>
xor    %edi,%edi
call   1080 <errou@plt>
jmp    13c3 <local+0x243>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
jne    13b2 <local+0x232>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x75,%eax
jne    13b2 <local+0x232>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x74,%eax
jne    13b2 <local+0x232>
lea    -0x20(%rbp),%rdi
lea    0xc81(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x4,%rsi
call   10a0 <strcat@plt>
lea    -0x20(%rbp),%rdi
call   1050 <system@plt>
jmp    13be <local+0x23e>
lea    0xc5d(%rip),%rdi
call   1060 <printf@plt>
jmp    13c3 <local+0x243>
jmp    13c8 <local+0x248>
jmp    13cd <local+0x24d>
jmp    13d2 <local+0x252>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<local>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r15
mov    (%rdi),%bl
cmp    $0x63,%bl
je     11b2 <local+0x32>
cmp    $0x6c,%bl
jne    1213 <local+0x93>
cmpb   $0x73,0x1(%r15)
jne    1213 <local+0x93>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
jmp    12cb <local+0x14b>
cmpb   $0x64,0x1(%r15)
jne    1213 <local+0x93>
add    $0x3,%r15
mov    0x2e0c(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     12f2 <local+0x172>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     12f6 <local+0x176>
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1050 <chdir@plt>
lea    0xdf2(%rip),%rdi
jmp    12ce <local+0x14e>
lea    0xdea(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1287 <local+0x107>
cmp    $0x70,%bl
je     129c <local+0x11c>
cmp    $0x67,%bl
jne    12dd <local+0x15d>
cmpb   $0x65,0x1(%r15)
jne    12dd <local+0x15d>
cmpb   $0x74,0x2(%r15)
jne    12dd <local+0x15d>
lea    0x3(%r15),%r14
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     12f2 <local+0x172>
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1090 <access@plt>
cmp    $0xffffffff,%eax
je     12f6 <local+0x176>
lea    0xd85(%rip),%rsi
jmp    12b1 <local+0x131>
lea    0xd76(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <system@plt>
cmpb   $0x75,0x1(%r15)
jne    12dd <local+0x15d>
cmpb   $0x74,0x2(%r15)
jne    12dd <local+0x15d>
lea    0xd5e(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
add    $0x4,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
mov    %r14,%rdi
call   1060 <system@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd32(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>
xor    %edi,%edi
jmp    12fb <local+0x17b>
mov    $0x1,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <errou@plt>

LLVM IR (-O0):
@F_OK = global i32 0
@R_OK = global i32 0
@.str = [4 x i8] c"pwd\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [5 x i8] c"cat \00"
@.str.3 = [7 x i8] c"touch \00"
@.str.4 = [62 x i8] c"Opcao invalida. Digite \22sair\22 caso queira fechar o programa.\0A\00"
define void @local(i8* %0) {
%2 = alloca i8*
%3 = alloca [16 x i8]
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 108
br i1 %8, label %9, label %21
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 115
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32 @strcpy(i8* %16, i8* %17)
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%20 = call i32 @system(i8* %19)
br label %143
21: ; preds = %9, %1
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 99
br i1 %26, label %27, label %59
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 100
br i1 %32, label %33, label %59
33: ; preds = %27
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 3
%36 = load i32, i32* @F_OK
%37 = call i32 @access(i8* %35, i32 %36)
%38 = icmp ne i32 %37, -1
br i1 %38, label %39, label %56
39: ; preds = %33
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i64 3
%42 = load i32, i32* @R_OK
%43 = call i32 @access(i8* %41, i32 %42)
%44 = icmp ne i32 %43, -1
br i1 %44, label %45, label %53
45: ; preds = %39
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%47 = load i8*, i8** %2
%48 = getelementptr inbounds i8, i8* %47, i64 3
%49 = call i32 @strcpy(i8* %46, i8* %48)
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%51 = call i32 @chdir(i8* %50)
%52 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %55
53: ; preds = %39
%54 = call i32 @errou(i32 1)
br label %55
55: ; preds = %53, %45
br label %58
56: ; preds = %33
%57 = call i32 @errou(i32 0)
br label %58
58: ; preds = %56, %55
br label %142
59: ; preds = %27, %21
%60 = load i8*, i8** %2
%61 = call i32 @strcmp(i8* %60, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%62 = icmp ne i32 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %141
65: ; preds = %59
%66 = load i8*, i8** %2
%67 = getelementptr inbounds i8, i8* %66, i64 0
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 103
br i1 %70, label %71, label %110
71: ; preds = %65
%72 = load i8*, i8** %2
%73 = getelementptr inbounds i8, i8* %72, i64 1
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 101
br i1 %76, label %77, label %110
77: ; preds = %71
%78 = load i8*, i8** %2
%79 = getelementptr inbounds i8, i8* %78, i64 2
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp eq i32 %81, 116
br i1 %82, label %83, label %110
83: ; preds = %77
%84 = load i8*, i8** %2
%85 = getelementptr inbounds i8, i8* %84, i64 3
%86 = load i32, i32* @F_OK
%87 = call i32 @access(i8* %85, i32 %86)
%88 = icmp ne i32 %87, -1
br i1 %88, label %89, label %107
89: ; preds = %83
%90 = load i8*, i8** %2
%91 = getelementptr inbounds i8, i8* %90, i64 3
%92 = load i32, i32* @R_OK
%93 = call i32 @access(i8* %91, i32 %92)
%94 = icmp ne i32 %93, -1
br i1 %94, label %95, label %104
95: ; preds = %89
%96 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%97 = call i32 @strcpy(i8* %96, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%98 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%99 = load i8*, i8** %2
%100 = getelementptr inbounds i8, i8* %99, i64 4
%101 = call i32 @strcat(i8* %98, i8* %100)
%102 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%103 = call i32 @system(i8* %102)
br label %106
104: ; preds = %89
%105 = call i32 @errou(i32 1)
br label %106
106: ; preds = %104, %95
br label %109
107: ; preds = %83
%108 = call i32 @errou(i32 0)
br label %109
109: ; preds = %107, %106
br label %140
110: ; preds = %77, %71, %65
%111 = load i8*, i8** %2
%112 = getelementptr inbounds i8, i8* %111, i64 0
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 112
br i1 %115, label %116, label %137
116: ; preds = %110
%117 = load i8*, i8** %2
%118 = getelementptr inbounds i8, i8* %117, i64 1
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = icmp eq i32 %120, 117
br i1 %121, label %122, label %137
122: ; preds = %116
%123 = load i8*, i8** %2
%124 = getelementptr inbounds i8, i8* %123, i64 2
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = icmp eq i32 %126, 116
br i1 %127, label %128, label %137
128: ; preds = %122
%129 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%130 = call i32 @strcpy(i8* %129, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%131 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%132 = load i8*, i8** %2
%133 = getelementptr inbounds i8, i8* %132, i64 4
%134 = call i32 @strcat(i8* %131, i8* %133)
%135 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%136 = call i32 @system(i8* %135)
br label %139
137: ; preds = %122, %116, %110
%138 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0))
br label %139
139: ; preds = %137, %128
br label %140
140: ; preds = %139, %109
br label %141
141: ; preds = %140, %63
br label %142
142: ; preds = %141, %58
br label %143
143: ; preds = %142, %15
ret void
}

LLVM IR (-O2):
@F_OK = global i32 0
@R_OK = global i32 0
@.str = [4 x i8] c"pwd\00"
@.str.1 = [6 x i8] c"clear\00"
@.str.2 = [5 x i8] c"cat \00"
@.str.3 = [7 x i8] c"touch \00"
@str = [61 x i8] c"Opcao invalida. Digite \22sair\22 caso queira fechar o programa.\00"
define void @local(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
switch i8 %4, label %33 [
i8 108, label %5
i8 99, label %12
]
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 115
br i1 %8, label %9, label %33
9: ; preds = %5
%10 = call i32 @strcpy(i8* %3, i8* %0)
%11 = call i32 @system(i8* %3)
br label %80
12: ; preds = %1
%13 = getelementptr inbounds i8, i8* %0, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 100
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %0, i64 3
%18 = load i32, i32* @F_OK
%19 = tail call i32 @access(i8* %17, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %31, label %21
21: ; preds = %16
%22 = load i32, i32* @R_OK
%23 = tail call i32 @access(i8* %17, i32 %22)
%24 = icmp eq i32 %23, -1
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = call i32 @strcpy(i8* %3, i8* %17)
%27 = call i32 @chdir(i8* %3)
%28 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %80
29: ; preds = %21
%30 = tail call i32 @errou(i32 1)
br label %80
31: ; preds = %16
%32 = tail call i32 @errou(i32 0)
br label %80
33: ; preds = %1, %5, %12
%34 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %80
38: ; preds = %33
switch i8 %4, label %78 [
i8 103, label %39
i8 112, label %65
]
39: ; preds = %38
%40 = getelementptr inbounds i8, i8* %0, i64 1
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 101
br i1 %42, label %43, label %78
43: ; preds = %39
%44 = getelementptr inbounds i8, i8* %0, i64 2
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 116
br i1 %46, label %47, label %78
47: ; preds = %43
%48 = getelementptr inbounds i8, i8* %0, i64 3
%49 = load i32, i32* @F_OK
%50 = tail call i32 @access(i8* %48, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %63, label %52
52: ; preds = %47
%53 = load i32, i32* @R_OK
%54 = tail call i32 @access(i8* %48, i32 %53)
%55 = icmp eq i32 %54, -1
br i1 %55, label %61, label %56
56: ; preds = %52
%57 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%58 = getelementptr inbounds i8, i8* %0, i64 4
%59 = call i32 @strcat(i8* %3, i8* %58)
%60 = call i32 @system(i8* %3)
br label %80
61: ; preds = %52
%62 = tail call i32 @errou(i32 1)
br label %80
63: ; preds = %47
%64 = tail call i32 @errou(i32 0)
br label %80
65: ; preds = %38
%66 = getelementptr inbounds i8, i8* %0, i64 1
%67 = load i8, i8* %66
%68 = icmp eq i8 %67, 117
br i1 %68, label %69, label %78
69: ; preds = %65
%70 = getelementptr inbounds i8, i8* %0, i64 2
%71 = load i8, i8* %70
%72 = icmp eq i8 %71, 116
br i1 %72, label %73, label %78
73: ; preds = %69
%74 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%75 = getelementptr inbounds i8, i8* %0, i64 4
%76 = call i32 @strcat(i8* %3, i8* %75)
%77 = call i32 @system(i8* %3)
br label %80
78: ; preds = %38, %39, %43, %69, %65
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
br label %80
80: ; preds = %25, %29, %31, %56, %61, %63, %78, %73, %36, %9
ret void
}