// File: dmonaldo[P]simple-network-file-system/Shell.cpp
// Function: Shell::run_script(char*)
void Shell::run_script(char *file_name)
{
  // make sure that the file system is mounted
  if (!is_mounted)
  	return;
  // open script file
  ifstream infile;
  infile.open(file_name);
  if (infile.fail()) {
    cerr << "Could not open script file" << endl;
    return;
  }


  // execute each line in the script
  bool user_quit = false;
  string command_str;
  getline(infile, command_str, '\n');
  while (!infile.eof() && !user_quit) {
    cout << PROMPT_STRING << command_str << endl;
    user_quit = execute_command(command_str);
    getline(infile, command_str);
  }

  // clean up
  unmountNFS();
  infile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2c0, %rsp            # imm = 0x2C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x278(%rbp)
testb $0x1, 0x4(%rax)
jne 0x9519
jmp 0x9771
leaq -0x218(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x33f0
movq -0x280(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl $0x8, %edx
callq 0x3240
jmp 0x9543
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x3030
movb %al, -0x281(%rbp)
jmp 0x9563
movb -0x281(%rbp), %al
testb $0x1, %al
jne 0x956f
jmp 0x95c6
movq 0x6a7a(%rip), %rdi      # 0xfff0
leaq 0x2fa9(%rip), %rsi      # 0xc526
callq 0x3340
movq %rax, -0x290(%rbp)
jmp 0x958b
movq -0x290(%rbp), %rdi
movq 0x6a0f(%rip), %rsi      # 0xffa8
callq 0x3390
jmp 0x95a0
movl $0x1, -0x228(%rbp)
jmp 0x9765
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x9786
movb $0x0, -0x229(%rbp)
leaq -0x250(%rbp), %rdi
movq %rdi, -0x298(%rbp)
callq 0x3470
movq -0x298(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0xa, %edx
callq 0x35b0
jmp 0x95fa
jmp 0x95fc
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x35a0
movb %al, -0x299(%rbp)
jmp 0x961c
movb -0x299(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x29a(%rbp)
jne 0x963f
jmp 0x9631
movb -0x229(%rbp), %al
xorb $-0x1, %al
movb %al, -0x29a(%rbp)
movb -0x29a(%rbp), %al
testb $0x1, %al
jne 0x964e
jmp 0x9733
movq 0x696b(%rip), %rdi      # 0xffc0
leaq 0x6cdc(%rip), %rsi      # 0x10338
callq 0x3310
movq %rax, -0x2a8(%rbp)
jmp 0x966a
movq -0x2a8(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x3310
movq %rax, -0x2b0(%rbp)
jmp 0x9686
movq -0x2b0(%rbp), %rdi
movq 0x6914(%rip), %rsi      # 0xffa8
callq 0x3390
jmp 0x969b
leaq -0x270(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x31a0
jmp 0x96b0
movq -0x278(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x8de0
movb %al, -0x2b1(%rbp)
jmp 0x96cb
movb -0x2b1(%rbp), %al
andb $0x1, %al
movb %al, -0x229(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x3628
leaq -0x218(%rbp), %rdi
leaq -0x250(%rbp), %rsi
callq 0x30c0
jmp 0x96fa
jmp 0x95fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x977a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x3628
jmp 0x977a
movq -0x278(%rbp), %rdi
callq 0x7610
jmp 0x9741
leaq -0x218(%rbp), %rdi
callq 0x30d0
jmp 0x974f
leaq -0x250(%rbp), %rdi
callq 0x3628
movl $0x0, -0x228(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x30f0
addq $0x2c0, %rsp            # imm = 0x2C0
popq %rbp
retq
leaq -0x250(%rbp), %rdi
callq 0x3628
leaq -0x218(%rbp), %rdi
callq 0x30f0
movq -0x220(%rbp), %rdi
callq 0x3560
nop