// File: Themaister[P]umusd/command.cpp
// Function: Command::parse_command(EventHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string Command::parse_command(EventHandler &event, const std::string &cmd)
{
   auto split = cmd.find(' ');
   auto first_arg = cmd.find('\"', split);
   auto last_arg = cmd.rfind('\"');

   auto name = cmd.substr(0, split);

   std::string arg;
   if (last_arg > first_arg)
      arg = cmd.substr(first_arg + 1, last_arg - first_arg - 1);

   auto &cb = command_map[name];
   if (cb)
      return cb(event, string_split(arg, "\n"));
   else
      throw std::runtime_error(stringify("Unrecognized command: \"", name, "\""));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x130(%rbp)
movq %rdi, %rax
movq %rax, -0x128(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x20(%rbp), %rdi
movl $0x20, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x5780
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rdx
movl $0x22, %esi
callq 0x5780
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movl $0x22, %esi
movq $-0x1, %rdx
callq 0x5570
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rcx
leaq -0x58(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0x5740
leaq -0x78(%rbp), %rdi
callq 0x5520
movq -0x38(%rbp), %rax
cmpq -0x30(%rbp), %rax
jbe 0xa11f
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
incq %rdx
movq -0x38(%rbp), %rax
notq %rcx
addq %rax, %rcx
leaq -0x98(%rbp), %rdi
callq 0x5740
jmp 0xa0ea
leaq -0x78(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x55b0
leaq -0x98(%rbp), %rdi
callq 0x5670
jmp 0xa11f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa347
movq -0x120(%rbp), %rdi
addq $0x20, %rdi
leaq -0x58(%rbp), %rsi
callq 0xffd0
movq %rax, -0x138(%rbp)
jmp 0xa13c
movq -0x138(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rdi
callq 0x100b0
testb $0x1, %al
jne 0xa15f
jmp 0xa28c
movq -0xb0(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0xe9(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x5370
movq -0x140(%rbp), %rdx
leaq 0x1c93a(%rip), %rsi     # 0x26ad3
leaq -0xe8(%rbp), %rdi
callq 0x67d0
jmp 0xa1a7
leaq -0xc8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0x10140
jmp 0xa1c0
movq -0x148(%rbp), %rdx
movq -0x150(%rbp), %rsi
movq -0x130(%rbp), %rdi
leaq -0xc8(%rbp), %rcx
callq 0x100e0
jmp 0xa1e3
leaq -0xc8(%rbp), %rdi
callq 0x102e0
leaq -0xe8(%rbp), %rdi
callq 0x5670
leaq -0xe9(%rbp), %rdi
callq 0x5040
leaq -0x78(%rbp), %rdi
callq 0x5670
leaq -0x58(%rbp), %rdi
callq 0x5670
movq -0x128(%rbp), %rax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa27b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa26f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x102e0
leaq -0xe8(%rbp), %rdi
callq 0x5670
leaq -0xe9(%rbp), %rdi
callq 0x5040
jmp 0xa347
movb $0x1, -0x111(%rbp)
movl $0x10, %edi
callq 0x5540
movq %rax, -0x158(%rbp)
leaq 0x1c26d(%rip), %rsi     # 0x26518
leaq 0x1c27c(%rip), %rcx     # 0x2652e
leaq -0x110(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x10340
jmp 0xa2c4
movq -0x158(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x5150
jmp 0xa2d9
movq -0x158(%rbp), %rdi
movb $0x0, -0x111(%rbp)
movq 0x30ca2(%rip), %rsi     # 0x3af90
movq 0x30ceb(%rip), %rdx     # 0x3afe0
callq 0x5260
jmp 0xa365
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
jmp 0xa32e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xa0(%rbp)
movl %eax, -0xa4(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x5670
testb $0x1, -0x111(%rbp)
jne 0xa339
jmp 0xa345
movq -0x158(%rbp), %rdi
callq 0x56d0
jmp 0xa347
leaq -0x78(%rbp), %rdi
callq 0x5670
leaq -0x58(%rbp), %rdi
callq 0x5670
movq -0xa0(%rbp), %rdi
callq 0x52a0
nopw %cs:(%rax,%rax)