// File: /workspace/github_cpp_makefile_star2_O2/dmonaldo[P]simple-network-file-system/Shell.cpp
// Function: Shell::execute_command(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool Shell::execute_command(string command_str)
{
  // parse the command line
  struct Command command = parse_command(command_str);

  // look for the matching command
  if (command.name == "") {
    return false;
  }
  else if (command.name == "mkdir") {
    mkdir_rpc(command.file_name);
  }
  else if (command.name == "cd") {
    cd_rpc(command.file_name);
  }
  else if (command.name == "home") {
    home_rpc();
  }
  else if (command.name == "rmdir") {
    rmdir_rpc(command.file_name);
  }
  else if (command.name == "ls") {
    ls_rpc();
  }
  else if (command.name == "create") {
    create_rpc(command.file_name);
  }
  else if (command.name == "append") {
    append_rpc(command.file_name, command.append_data);
  }
  else if (command.name == "cat") {
    cat_rpc(command.file_name);
  }
  else if (command.name == "head") {
    errno = 0;
    unsigned long n = strtoul(command.append_data.c_str(), NULL, 0);
    if (0 == errno) {
      head_rpc(command.file_name, n);
    } else {
      cerr << "Invalid command line: " << command.append_data;
      cerr << " is not a valid number of bytes" << endl;
      return false;
    }
  }
  else if (command.name == "rm") {
    rm_rpc(command.file_name);
  }
  else if (command.name == "stat") {
    stat_rpc(command.file_name);
  }
  else if (command.name == "quit") {
    return true;
  }

  return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, %rbx
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rsp, %rdi
movq %r14, %rdx
callq 0x6a7c
leaq 0x60(%rsp), %rdi
callq 0x3498
leaq 0x1b74(%rip), %rsi      # 0x80ea
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
jne 0x65f2
leaq 0x1cc5(%rip), %rsi      # 0x824e
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x65b7
leaq 0x20(%rsp), %rsi
leaq 0x1a0(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5808
jmp 0x65ea
leaq 0x1c96(%rip), %rsi      # 0x8254
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x660b
leaq 0x20(%rsp), %rsi
leaq 0x180(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5aac
movq %r14, %rdi
callq 0x3498
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x6f90
movl %ebx, %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbx
popq %r14
popq %r15
retq
leaq 0x1c45(%rip), %rsi      # 0x8257
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x6628
movq %rbx, %rdi
callq 0x5bcc
jmp 0x65f2
leaq 0x1c2d(%rip), %rsi      # 0x825c
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x665d
leaq 0x20(%rsp), %rsi
leaq 0x160(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5cc6
jmp 0x65ea
leaq 0x1bfe(%rip), %rsi      # 0x8262
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x667d
movq %rbx, %rdi
callq 0x5de6
jmp 0x65f2
leaq 0x1be1(%rip), %rsi      # 0x8265
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x66b5
leaq 0x20(%rsp), %rsi
leaq 0x140(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5ede
jmp 0x65ea
leaq 0x1bb0(%rip), %rsi      # 0x826c
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x6701
leaq 0x20(%rsp), %rsi
leaq 0x120(%rsp), %r14
movq %r14, %rdi
callq 0x3340
leaq 0x40(%rsp), %rsi
leaq 0x100(%rsp), %rdi
callq 0x3340
leaq 0x100(%rsp), %rdi
callq 0x3498
jmp 0x65ea
leaq 0x1b6b(%rip), %rsi      # 0x8273
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x6739
leaq 0x20(%rsp), %rsi
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6000
jmp 0x65ea
leaq 0x1b37(%rip), %rsi      # 0x8277
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x67af
callq 0x3040
movq %rax, %r14
andl $0x0, (%rax)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x30f0
cmpl $0x0, (%r14)
je 0x681f
movq 0x487a(%rip), %rdi      # 0xaff0
leaq 0x1aff(%rip), %rsi      # 0x827c
callq 0x3270
leaq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x3250
movq 0x485a(%rip), %rdi      # 0xaff0
leaq 0x1af6(%rip), %rsi      # 0x8293
callq 0x3270
movq %rax, %rdi
callq 0x3160
jmp 0x65f2
leaq 0x1afd(%rip), %rsi      # 0x82b3
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x67e7
leaq 0x20(%rsp), %rsi
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x62b0
jmp 0x65ea
leaq 0x1ac8(%rip), %rsi      # 0x82b6
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x684a
leaq 0x20(%rsp), %rsi
leaq 0x80(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
callq 0x63d0
jmp 0x65ea
movq %rax, %r15
leaq 0x20(%rsp), %rsi
leaq 0xc0(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
callq 0x6120
jmp 0x65ea
leaq 0x1a6a(%rip), %rsi      # 0x82bb
movq %rsp, %rdi
callq 0x52d1
movb $0x1, %bl
testb %al, %al
je 0x65f2
jmp 0x65f4
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x68dd
jmp 0x68e4
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
jmp 0x68dd
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
callq 0x3498
jmp 0x68e7
movq %rax, %rbx
movq %rsp, %rdi
callq 0x6f90
jmp 0x68fe
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3498
movq %rbx, %rdi
callq 0x3410