#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*/ assemble();
int /*<<< orphan*/ display_header();
int /*<<< orphan*/ dump_memory();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
void parse_input(char *input) {
  char *args[8];
  int p = input[0];
  switch (p) {
  case 'q':
    exit(0);
    break;
  case 'a':
    assemble();
    break;
  case 'h':
    display_header();
    break;
  case 'l':
    printf("loading...\n");
    break;
  case 'd':
    dump_memory();
    break;
  default:
    printf("unknown command\n");
    break;
  }
  input = 0;
  return;
}


x86 assembly (clang, -O0):
<parse_input>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x60(%rbp)
sub    $0x10,%eax
ja     11cb <parse_input+0x7b>
mov    -0x60(%rbp),%rax
lea    0xe7a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1060 <assemble@plt>
jmp    11d7 <parse_input+0x87>
mov    $0x0,%al
call   1030 <display_header@plt>
jmp    11d7 <parse_input+0x87>
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
jmp    11d7 <parse_input+0x87>
mov    $0x0,%al
call   1040 <dump_memory@plt>
jmp    11d7 <parse_input+0x87>
lea    0xe7e(%rip),%rdi
call   1050 <printf@plt>
movq   $0x0,-0x8(%rbp)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_input>:
push   %rax
movsbl (%rdi),%eax
add    $0xffffff9f,%eax
cmp    $0x10,%eax
ja     1174 <parse_input+0x24>
lea    0xe9d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rcx
jmp    1060 <assemble@plt>
lea    0xed4(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <dump_memory@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <display_header@plt>
lea    0xeac(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"loading...\0A\00"
@.str.1 = [17 x i8] c"unknown command\0A\00"
define void @parse_input(i8* %0) {
%2 = alloca i8*
%3 = alloca [8 x i8*]
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
store i32 %8, i32* %4
%9 = load i32, i32* %4
switch i32 %9, label %20 [
i32 113, label %10
i32 97, label %12
i32 104, label %14
i32 108, label %16
i32 100, label %18
]
10: ; preds = %1
%11 = call i32 @exit(i32 0)
unreachable
12: ; preds = %1
%13 = call i32 (...) @assemble()
br label %22
14: ; preds = %1
%15 = call i32 (...) @display_header()
br label %22
16: ; preds = %1
%17 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %22
18: ; preds = %1
%19 = call i32 (...) @dump_memory()
br label %22
20: ; preds = %1
%21 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %18, %16, %14, %12
store i8* null, i8** %2
ret void
}

LLVM IR (-O2):
@str = [11 x i8] c"loading...\00"
@str.2 = [16 x i8] c"unknown command\00"
define void @parse_input(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %14 [
i32 113, label %4
i32 97, label %6
i32 104, label %8
i32 108, label %10
i32 100, label %12
]
4: ; preds = %1
%5 = tail call i32 @exit(i32 0)
unreachable
6: ; preds = %1
%7 = tail call i32 (...) @assemble()
br label %16
8: ; preds = %1
%9 = tail call i32 (...) @display_header()
br label %16
10: ; preds = %1
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %16
12: ; preds = %1
%13 = tail call i32 (...) @dump_memory()
br label %16
14: ; preds = %1
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %6
ret void
}