#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char cmd;
  for (;;) {
    printf("/$ ");
    scanf(" %c", &cmd);
    if (cmd == 'q')
      exit(0);
    switch (cmd) {
    case 'h':
      printf("Ajuda prompt.... Comandos");
      break;
    case 'v':
      printf("Version 0.1");
      break;
    case 'e':
      printf("echo");
      break;
    default:
      printf("Syntax comand error!");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x71,%eax
jne    116f <main+0x3f>
xor    %edi,%edi
call   1050 <exit@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x65,%eax
je     11c8 <main+0x98>
jmp    1184 <main+0x54>
mov    -0xc(%rbp),%eax
sub    $0x68,%eax
je     11a6 <main+0x76>
jmp    1195 <main+0x65>
mov    -0xc(%rbp),%eax
sub    $0x76,%eax
je     11b7 <main+0x87>
jmp    11d9 <main+0xa9>
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
jmp    11e5 <main+0xb5>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    11e5 <main+0xb5>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    11e5 <main+0xb5>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0xf>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
cmp    $0x71,%al
jne    1177 <main+0x37>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe8a(%rip),%r12
lea    0xe7b(%rip),%r14
lea    0xe78(%rip),%r15
lea    0x7(%rsp),%rbx
lea    0xe8a(%rip),%rbp
lea    0xe94(%rip),%r13
jmp    11de <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movzbl 0x7(%rsp),%eax
cmp    $0x71,%al
je     1170 <main+0x30>
movsbl %al,%eax
cmp    $0x65,%eax
je     1200 <main+0xc0>
mov    %r12,%rdi
cmp    $0x68,%eax
je     11b3 <main+0x73>
cmp    $0x76,%eax
jne    11b0 <main+0x70>
mov    %rbp,%rdi
jmp    11b3 <main+0x73>
nopl   0x0(%rax,%rax,1)
lea    0xe27(%rip),%rdi
jmp    11b3 <main+0x73>

LLVM IR (-O0):
@.str = [4 x i8] c"/$ \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [26 x i8] c"Ajuda prompt.... Comandos\00"
@.str.3 = [12 x i8] c"Version 0.1\00"
@.str.4 = [5 x i8] c"echo\00"
@.str.5 = [21 x i8] c"Syntax comand error!\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %22, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = load i8, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 113
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %3
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
switch i32 %13, label %20 [
i32 104, label %14
i32 118, label %16
i32 101, label %18
]
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %22
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %22
18: ; preds = %11
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %22
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %18, %16, %14
%23 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %3
}

LLVM IR (-O2):
@.str = [4 x i8] c"/$ \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [26 x i8] c"Ajuda prompt.... Comandos\00"
@.str.3 = [12 x i8] c"Version 0.1\00"
@.str.4 = [5 x i8] c"echo\00"
@.str.5 = [21 x i8] c"Syntax comand error!\00"
define i32 @main() {
%1 = alloca i8
%2 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 113
br i1 %5, label %6, label %8
6: ; preds = %14, %0
%7 = call i32 @exit(i32 0)
unreachable
8: ; preds = %0, %14
%9 = phi i8 [ %20, %14 ], [ %4, %0 ]
%10 = sext i8 %9 to i32
switch i32 %10, label %13 [
i32 104, label %14
i32 118, label %11
i32 101, label %12
]
11: ; preds = %8
br label %14
12: ; preds = %8
br label %14
13: ; preds = %8
br label %14
14: ; preds = %8, %13, %12, %11
%15 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %8 ]
%16 = call i32 @printf(i8* dereferenceable(1) %15)
%17 = call i32 @putchar(i32 10)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%20 = load i8, i8* %1
%21 = icmp eq i8 %20, 113
br i1 %21, label %6, label %8
}