// File: dmonaldo[P]simple-network-file-system/Shell.cpp
// Function: Shell::print_response(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Shell::print_response(string command, string response)
{
  stringstream ss(response);
  string item;
  vector<string> splitResponse;

  // split response by line breaks into an array of strings
  while (getline(ss, item, '\n')) {
     splitResponse.push_back(item);
  }

  // check if response was successful
  if (stoi(response.substr(0,3)) == 200) {
    if (command == "ls" ||
        command == "head" ||
        command == "stat" ||
        command == "cat") {
      cout << splitResponse[3] << endl;
    }
  } else {
    cout << response << endl;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x240, %rsp            # imm = 0x240
movq %rsi, -0x218(%rbp)
movq %rdx, -0x210(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x10, %edi
movl $0x8, %esi
callq 0xa560
movq -0x210(%rbp), %rsi
movl %eax, %edx
leaq -0x1a0(%rbp), %rdi
callq 0x3500
leaq -0x1c0(%rbp), %rdi
callq 0x3470
leaq -0x1d8(%rbp), %rdi
callq 0xa020
leaq -0x1a0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
movl $0xa, %edx
callq 0x35b0
movq %rax, -0x220(%rbp)
jmp 0x78d2
movq -0x220(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x3430
movb %al, -0x221(%rbp)
jmp 0x78f0
movb -0x221(%rbp), %al
testb $0x1, %al
jne 0x78fc
jmp 0x792a
leaq -0x1d8(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0xa580
jmp 0x7911
jmp 0x78b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
jmp 0x7ae0
movq -0x210(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
leaq -0x208(%rbp), %rdi
movl $0x3, %ecx
callq 0x3380
jmp 0x7948
xorl %eax, %eax
movl %eax, %esi
leaq -0x208(%rbp), %rdi
movl $0xa, %edx
callq 0xa090
movl %eax, -0x228(%rbp)
jmp 0x7965
leaq -0x208(%rbp), %rdi
callq 0x3628
movl -0x228(%rbp), %eax
cmpl $0xc8, %eax
jne 0x7a80
movq -0x218(%rbp), %rdi
leaq 0x48d2(%rip), %rsi      # 0xc262
callq 0x6a60
movb %al, -0x229(%rbp)
jmp 0x799d
movb -0x229(%rbp), %al
testb $0x1, %al
jne 0x7a1e
jmp 0x79a9
movq -0x218(%rbp), %rdi
leaq 0x48c0(%rip), %rsi      # 0xc277
callq 0x6a60
movb %al, -0x22a(%rbp)
jmp 0x79c4
movb -0x22a(%rbp), %al
testb $0x1, %al
jne 0x7a1e
jmp 0x79d0
movq -0x218(%rbp), %rdi
leaq 0x48d8(%rip), %rsi      # 0xc2b6
callq 0x6a60
movb %al, -0x22b(%rbp)
jmp 0x79eb
movb -0x22b(%rbp), %al
testb $0x1, %al
jne 0x7a1e
jmp 0x79f7
movq -0x218(%rbp), %rdi
leaq 0x486e(%rip), %rsi      # 0xc273
callq 0x6a60
movb %al, -0x22c(%rbp)
jmp 0x7a12
movb -0x22c(%rbp), %al
testb $0x1, %al
jne 0x7a1e
jmp 0x7a7e
leaq -0x1d8(%rbp), %rdi
movl $0x3, %esi
callq 0xa070
movq %rax, %rsi
movq 0x8587(%rip), %rdi      # 0xffc0
callq 0x3310
movq %rax, -0x238(%rbp)
jmp 0x7a47
movq -0x238(%rbp), %rdi
movq 0x8553(%rip), %rsi      # 0xffa8
callq 0x3390
jmp 0x7a5c
jmp 0x7a7e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1e0(%rbp)
movl %eax, -0x1e4(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x3628
jmp 0x7ae0
jmp 0x7ab3
movq -0x210(%rbp), %rsi
movq 0x8532(%rip), %rdi      # 0xffc0
callq 0x3310
movq %rax, -0x240(%rbp)
jmp 0x7a9c
movq -0x240(%rbp), %rdi
movq 0x84fe(%rip), %rsi      # 0xffa8
callq 0x3390
jmp 0x7ab1
jmp 0x7ab3
leaq -0x1d8(%rbp), %rdi
callq 0xa0d0
leaq -0x1c0(%rbp), %rdi
callq 0x3628
leaq -0x1a0(%rbp), %rdi
callq 0x32a0
addq $0x240, %rsp            # imm = 0x240
popq %rbp
retq
leaq -0x1d8(%rbp), %rdi
callq 0xa0d0
leaq -0x1c0(%rbp), %rdi
callq 0x3628
leaq -0x1a0(%rbp), %rdi
callq 0x32a0
movq -0x1e0(%rbp), %rdi
callq 0x3560