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

  // copy the contents of the string to char array
  const char* command_name = command.name.c_str();
  const char* file_name = command.file_name.c_str();
  const char* append_data = command.append_data.c_str();

  // look for the matching command
  if (command.name == "") {
    return false;
  }
  else if (command.name == "mkdir") {
    mkdir(file_name);
  }
  else if (command.name == "cd") {
    cd(file_name);
  }
  else if (command.name == "home") {
    home();
  }
  else if (command.name == "rmdir") {
    rmdir(file_name);
  }
  else if (command.name == "ls") {
    ls();
  }
  else if (command.name == "create") {
    create(file_name);
  }
  else if (command.name == "append") {
    append(file_name, append_data);
  }
  else if (command.name == "cat") {
    cat(file_name);
  }
  else if (command.name == "head") {
    errno = 0;
    unsigned long n = strtoul(command.append_data.c_str(), NULL, 0);
    if (0 == errno) {
      head(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(file_name);
  }
  else if (command.name == "stat") {
    stat(file_name);
  }
  else if (command.name == "quit") {
    return true;
  }

  return false;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x80, %rsp
movq %rdi, %rbx
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rsp, %rdi
movq %r14, %rdx
callq 0x4a5a
leaq 0x60(%rsp), %rdi
callq 0x3498
movq %rsp, %rdi
movq 0x20(%rdi), %r14
leaq 0x38b1(%rip), %rsi      # 0x80ea
callq 0x52d1
testb %al, %al
jne 0x4a1d
leaq 0x3a01(%rip), %rsi      # 0x824e
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x4869
movq %rbx, %rdi
movq %r14, %rsi
callq 0x39dc
jmp 0x4a1d
leaq 0x39e4(%rip), %rsi      # 0x8254
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x488c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3bf4
jmp 0x4a1d
leaq 0x39c4(%rip), %rsi      # 0x8257
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x48ac
movq %rbx, %rdi
callq 0x3d44
jmp 0x4a1d
leaq 0x39a9(%rip), %rsi      # 0x825c
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x48cf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d84
jmp 0x4a1d
leaq 0x398c(%rip), %rsi      # 0x8262
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x48ef
movq %rbx, %rdi
callq 0x3f54
jmp 0x4a1d
leaq 0x396f(%rip), %rsi      # 0x8265
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x4912
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40fa
jmp 0x4a1d
leaq 0x3953(%rip), %rsi      # 0x826c
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
jne 0x4a1d
leaq 0x3943(%rip), %rsi      # 0x8273
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x494c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4ddc
jmp 0x4a1d
leaq 0x3924(%rip), %rsi      # 0x8277
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x49bb
callq 0x3040
movq %rax, %r15
andl $0x0, (%rax)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x30f0
cmpl $0x0, (%r15)
je 0x49fb
movq 0x666b(%rip), %rdi      # 0xaff0
leaq 0x38f0(%rip), %rsi      # 0x827c
callq 0x3270
leaq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x3250
movq 0x664b(%rip), %rdi      # 0xaff0
leaq 0x38e7(%rip), %rsi      # 0x8293
callq 0x3270
movq %rax, %rdi
callq 0x3160
jmp 0x4a1d
leaq 0x38f1(%rip), %rsi      # 0x82b3
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x49db
movq %rbx, %rdi
movq %r14, %rsi
callq 0x42fa
jmp 0x4a1d
leaq 0x38d4(%rip), %rsi      # 0x82b6
movq %rsp, %rdi
callq 0x52d1
testb %al, %al
je 0x4a08
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4490
jmp 0x4a1d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5032
jmp 0x4a1d
leaq 0x38ac(%rip), %rsi      # 0x82bb
movq %rsp, %rdi
callq 0x52d1
movb $0x1, %bl
testb %al, %al
jne 0x4a1f
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x52de
movl %ebx, %eax
addq $0x80, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x4a38
movq %rax, %rbx
movq %rsp, %rdi
callq 0x52de
jmp 0x4a52
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3498
movq %rbx, %rdi
callq 0x3410