// File: /workspace/github_cpp_makefile_star2_O1/dmonaldo[P]simple-network-file-system/Shell.cpp
// Function: Shell::mountNFS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Shell::mountNFS(string fs_loc) {
  struct sockaddr_in server;

  // parse filesystem location into array with servername and port
  vector<string> fs_address;
  size_t pos = 0, found;
  while((found = fs_loc.find_first_of(':', pos)) != string::npos) {
    fs_address.push_back(fs_loc.substr(pos, found - pos));
    pos = found+1;
  }
  fs_address.push_back(fs_loc.substr(pos));

  // create the socket
  cs_sock = socket(AF_INET, SOCK_STREAM, 0);
  if (cs_sock < 0) {
    perror("ERROR creating socket");
    exit(0);
  }
  cout << "Socket created\n";

  // construct server address
  server.sin_addr.s_addr = inet_addr(fs_address[0].c_str());
  server.sin_family = AF_INET;
  server.sin_port = htons(stoi(fs_address[1]));

  // connect to remote server
  if (connect(cs_sock, (struct sockaddr *)&server, sizeof(server)) < 0) {
    perror("ERROR connection failed");
    exit(0);
  }

  cout << "Connected\n";
  is_mounted = true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
xorl %ebp, %ebp
movq %rsi, %rdi
movl $0x3a, %esi
xorl %edx, %edx
callq 0x3360
cmpq $-0x1, %rax
je 0x6064
movq %rax, %r15
leaq 0x10(%rsp), %rbx
xorl %ebp, %ebp
movq %rsp, %r12
leaq 0x20(%rsp), %r13
movq %r15, %rcx
subq %rbp, %rcx
movq %r12, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x32d0
movq %r13, %rdi
movq %r12, %rsi
callq 0x8cc4
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x6045
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32c0
movq %r15, %rbp
incq %rbp
movq %r14, %rdi
movl $0x3a, %esi
movq %rbp, %rdx
callq 0x3360
movq %rax, %r15
cmpq $-0x1, %rax
jne 0x6010
movq %rsp, %rdi
movq %r14, %rsi
movq %rbp, %rdx
movq $-0x1, %rcx
callq 0x32d0
leaq 0x20(%rsp), %rdi
movq %rsp, %rsi
callq 0x8cc4
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
movq 0x40(%rsp), %r13
je 0x60a6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32c0
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x30a0
movl %eax, (%r13)
testl %eax, %eax
js 0x6191
movq 0x6efe(%rip), %rdi      # 0xcfc8
leaq 0x43e7(%rip), %rsi      # 0xa4b8
movl $0xf, %edx
callq 0x3310
movq 0x20(%rsp), %rax
movq (%rax), %rdi
callq 0x32b0
movl %eax, 0x4c(%rsp)
movw $0x2, 0x48(%rsp)
movq 0x20(%rsp), %rax
movq 0x20(%rax), %r15
callq 0x3050
movq %rax, %r14
movl (%rax), %ebx
movl $0x0, (%rax)
movq %rsp, %r12
movq %r15, %rdi
movq %r12, %rsi
movl $0xa, %edx
callq 0x3380
cmpq %r15, (%r12)
je 0x6196
movslq %eax, %rcx
cmpq %rax, %rcx
jne 0x61a2
movl (%r14), %ecx
cmpl $0x22, %ecx
je 0x61a2
testl %ecx, %ecx
jne 0x613c
movl %ebx, (%r14)
rolw $0x8, %ax
leaq 0x48(%rsp), %rsi
movw %ax, 0x2(%rsi)
movl (%r13), %edi
movl $0x10, %edx
callq 0x3240
testl %eax, %eax
js 0x61ae
movq 0x6e66(%rip), %rdi      # 0xcfc8
leaq 0x4377(%rip), %rsi      # 0xa4e0
movl $0xa, %edx
callq 0x3310
movb $0x1, 0x4(%r13)
leaq 0x20(%rsp), %rdi
callq 0x8a8c
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3524
leaq 0x43a4(%rip), %rdi      # 0xa541
callq 0x31b0
leaq 0x4398(%rip), %rdi      # 0xa541
callq 0x33b0
callq 0x3510
movq %rax, %r15
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x61e9
jmp 0x61f6
jmp 0x61d8
movq %rax, %r15
cmpl $0x0, (%r14)
jne 0x61f6
movl %ebx, (%r14)
jmp 0x61f6
jmp 0x61d8
movq %rax, %r15
jmp 0x61f6
movq %rax, %r15
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x61f6
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32c0
leaq 0x20(%rsp), %rdi
callq 0x8a8c
movq %r15, %rdi
callq 0x3440