// File: /workspace/github_cpp_makefile_star2_O3/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 $0x480, %rsp            # imm = 0x480
movq %rdi, %rbx
leaq 0x70(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq 0x60(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x5ce8
movq %rsp, %rdi
movq %r14, %rdx
callq 0x4d76
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x4a7a
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32c0
movq %rsp, %rdi
movq 0x20(%rdi), %r14
leaq 0x56ae(%rip), %rsi      # 0xa136
callq 0x30d0
testl %eax, %eax
je 0x4ce2
leaq 0x57fe(%rip), %rsi      # 0xa29a
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4bb0
leaq 0x57ed(%rip), %rsi      # 0xa2a0
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4bc0
leaq 0x57d9(%rip), %rsi      # 0xa2a3
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4bd0
leaq 0x57c7(%rip), %rsi      # 0xa2a8
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4c0a
leaq 0x57b6(%rip), %rsi      # 0xa2ae
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4c1a
leaq 0x57a2(%rip), %rsi      # 0xa2b1
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4c27
leaq 0x5792(%rip), %rsi      # 0xa2b8
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4ce2
leaq 0x5782(%rip), %rsi      # 0xa2bf
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4c37
leaq 0x576f(%rip), %rsi      # 0xa2c3
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4c47
leaq 0x5794(%rip), %rsi      # 0xa2ff
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4cbd
leaq 0x5780(%rip), %rsi      # 0xa302
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
je 0x4cca
leaq 0x576e(%rip), %rsi      # 0xa307
movq %rsp, %rdi
callq 0x30d0
testl %eax, %eax
jne 0x4ce2
movb $0x1, %bl
jmp 0x4ce4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b2c
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3d4c
jmp 0x4ce2
movw $0x1, 0x4(%rbx)
movups 0x5592(%rip), %xmm0     # 0xa16f
leaq 0x80(%rsp), %rsi
movaps %xmm0, (%rsi)
movabsq $0xa0d0a0d30203a, %rax  # imm = 0xA0D0A0D30203A
movq %rax, 0xf(%rsi)
movl 0x8(%rbx), %edi
movl $0x400, %edx            # imm = 0x400
xorl %ecx, %ecx
callq 0x3180
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3f16
jmp 0x4ce2
movq %rbx, %rdi
callq 0x40f2
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4312
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x555e
jmp 0x4ce2
callq 0x3050
movq %rax, %r15
movl $0x0, (%rax)
movq 0x40(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3100
cmpl $0x0, (%r15)
je 0x4cd7
movq 0x8380(%rip), %rdi      # 0xcff0
leaq 0x5651(%rip), %rsi      # 0xa2c8
movl $0x16, %edx
callq 0x3310
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movq 0x835e(%rip), %rdi      # 0xcff0
callq 0x3310
movq 0x8352(%rip), %rdi      # 0xcff0
leaq 0x563a(%rip), %rsi      # 0xa2df
movl $0x1f, %edx
callq 0x3310
movq 0x833a(%rip), %rdi      # 0xcff0
callq 0x3170
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x450a
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x468c
jmp 0x4ce2
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5852
xorl %ebx, %ebx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4cff
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x32c0
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d1a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x32c0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d35
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32c0
movl %ebx, %eax
addq $0x480, %rsp            # imm = 0x480
popq %rbx
popq %r14
popq %r15
retq
jmp 0x4d46
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5b70
jmp 0x4d6d
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r15, %rdi
je 0x4d6d
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3440
nop