#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 EXIT_SUCCESS;
int /*<<< orphan*/ do_cd(char *);
char *get_caminho_atual();
char *get_caminho_inicial();
char *get_maquina();
char *get_usuario();
char *input_malloc();
int /*<<< orphan*/ limpar_tela();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_string(char *);
scalar_t__ regexp_match(char *, char *);
int /*<<< orphan*/ strcasecmp(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ trim(char *);
int main(int argc, char *argv[]) {
  printf("::: S@mirforShell :::\n\n");
  printf(">>> Criado por Samir <samirfor@gmail.com>\n");
  printf("Este programa esta sob a GNU General Public License v3 "
         "<http://www.gnu.org/licenses/>\n");
  printf("Para finalizar o programa use o comando \"sair\"\n\n");
  char *input;
  char *usuario;
  char *caminho_atual;
  char *maquina;
  usuario = get_usuario();
  caminho_atual = get_caminho_inicial();
  maquina = get_maquina();
  input = input_malloc();
  do {
    printf("+%s em %s::%s$ ", usuario, maquina, caminho_atual);
    read_string(input);
    trim(input);
    if (regexp_match("^cd ", input)) {
      do_cd(input);
      caminho_atual = get_caminho_atual();
    } else if (!strcasecmp(input, "limpar")) {
      limpar_tela();
    } else {
      system(input);
    }
  } while (strcmp(input, "sair"));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1040 <get_usuario@plt>
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   10f0 <get_caminho_inicial@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   10d0 <get_maquina@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1060 <input_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1100 <read_string@plt>
mov    -0x18(%rbp),%rdi
call   1090 <trim@plt>
mov    -0x18(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1050 <regexp_match@plt>
cmp    $0x0,%rax
je     12b9 <main+0xd9>
mov    -0x18(%rbp),%rdi
call   10a0 <do_cd@plt>
mov    $0x0,%al
call   10e0 <get_caminho_atual@plt>
mov    %rax,-0x28(%rbp)
jmp    12ec <main+0x10c>
mov    -0x18(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%eax
jne    12de <main+0xfe>
mov    $0x0,%al
call   10c0 <limpar_tela@plt>
jmp    12e7 <main+0x107>
mov    -0x18(%rbp),%rdi
call   1070 <system@plt>
jmp    12ec <main+0x10c>
jmp    12f1 <main+0x111>
mov    -0x18(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    125a <main+0x7a>
mov    0x2cce(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe48(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <get_usuario@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1100 <get_caminho_inicial@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10e0 <get_maquina@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1070 <input_malloc@plt>
mov    %rax,%rbx
lea    0xdb6(%rip),%rbp
lea    0xdbb(%rip),%r13
jmp    128f <main+0x9f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   10b0 <do_cd@plt>
xor    %eax,%eax
call   10f0 <get_caminho_atual@plt>
mov    %rax,%r12
mov    %rbx,%rdi
mov    %r13,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     12ec <main+0xfc>
lea    0xd6a(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
call   1110 <read_string@plt>
mov    %rbx,%rdi
call   10a0 <trim@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <regexp_match@plt>
mov    %rbx,%rdi
test   %rax,%rax
jne    1270 <main+0x80>
lea    0xd45(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %eax,%eax
je     12e3 <main+0xf3>
mov    %rbx,%rdi
call   1080 <system@plt>
jmp    127f <main+0x8f>
xor    %eax,%eax
call   10d0 <limpar_tela@plt>
jmp    127f <main+0x8f>
mov    0x2ced(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"::: S@mirforShell :::\0A\0A\00"
@.str.1 = [43 x i8] c">>> Criado por Samir <samirfor@gmail.com>\0A\00"
@.str.2 = [87 x i8] c"Este programa esta sob a GNU General Public License v3 <http://www.gnu.org/licenses/>\0A\00"
@.str.3 = [49 x i8] c"Para finalizar o programa use o comando \22sair\22\0A\0A\00"
@.str.4 = [16 x i8] c"+%s em %s::%s$ \00"
@.str.5 = [5 x i8] c"^cd \00"
@.str.6 = [7 x i8] c"limpar\00"
@.str.7 = [5 x i8] c"sair\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0))
%14 = call i8* (...) @get_usuario()
store i8* %14, i8** %7
%15 = call i8* (...) @get_caminho_inicial()
store i8* %15, i8** %8
%16 = call i8* (...) @get_maquina()
store i8* %16, i8** %9
%17 = call i8* (...) @input_malloc()
store i8* %17, i8** %6
br label %18
18: ; preds = %45, %2
%19 = load i8*, i8** %7
%20 = load i8*, i8** %9
%21 = load i8*, i8** %8
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %19, i8* %20, i8* %21)
%23 = load i8*, i8** %6
%24 = call i32 @read_string(i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @trim(i8* %25)
%27 = load i8*, i8** %6
%28 = call i64 @regexp_match(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %18
%31 = load i8*, i8** %6
%32 = call i32 @do_cd(i8* %31)
%33 = call i8* (...) @get_caminho_atual()
store i8* %33, i8** %8
br label %44
34: ; preds = %18
%35 = load i8*, i8** %6
%36 = call i32 @strcasecmp(i8* %35, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %34
%39 = call i32 (...) @limpar_tela()
br label %43
40: ; preds = %34
%41 = load i8*, i8** %6
%42 = call i32 @system(i8* %41)
br label %43
43: ; preds = %40, %38
br label %44
44: ; preds = %43, %30
br label %45
45: ; preds = %44
%46 = load i8*, i8** %6
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %18, label %49
49: ; preds = %45
%50 = load i32, i32* @EXIT_SUCCESS
ret i32 %50
}

LLVM IR (-O2):
@.str.4 = [16 x i8] c"+%s em %s::%s$ \00"
@.str.5 = [5 x i8] c"^cd \00"
@.str.6 = [7 x i8] c"limpar\00"
@.str.7 = [5 x i8] c"sair\00"
@EXIT_SUCCESS = global i32 0
@str = [23 x i8] c"::: S@mirforShell :::\0A\00"
@str.8 = [42 x i8] c">>> Criado por Samir <samirfor@gmail.com>\00"
@str.9 = [86 x i8] c"Este programa esta sob a GNU General Public License v3 <http://www.gnu.org/licenses/>\00"
@str.10 = [48 x i8] c"Para finalizar o programa use o comando \22sair\22\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.8, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @str.9, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i8* (...) @get_usuario()
%8 = tail call i8* (...) @get_caminho_inicial()
%9 = tail call i8* (...) @get_maquina()
%10 = tail call i8* (...) @input_malloc()
br label %11
11: ; preds = %28, %2
%12 = phi i8* [ %8, %2 ], [ %29, %28 ]
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %7, i8* %9, i8* %12)
%14 = tail call i32 @read_string(i8* %10)
%15 = tail call i32 @trim(i8* %10)
%16 = tail call i64 @regexp_match(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %10)
%17 = icmp eq i64 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %11
%19 = tail call i32 @do_cd(i8* %10)
%20 = tail call i8* (...) @get_caminho_atual()
br label %28
21: ; preds = %11
%22 = tail call i32 @strcasecmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 (...) @limpar_tela()
br label %28
26: ; preds = %21
%27 = tail call i32 @system(i8* %10)
br label %28
28: ; preds = %18, %26, %24
%29 = phi i8* [ %20, %18 ], [ %12, %26 ], [ %12, %24 ]
%30 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %11
32: ; preds = %28
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}