// File: craigbarstow[P]cmd-line-text-editor/text_editor.cc
// Function: save_file(text_ed&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool save_file(text_ed & T, string cl) { //take out couts
  string fn, new_name,CL=cl;
  int start,end;
  bool ok;
  string current_file = T.filename();
  if (cl.find_first_not_of(" ", 1)==string::npos) {  //if no filename given, save as current filename
    T.save_file(current_file); 
    cout << "Saved as \"" << current_file <<"\""<< endl;
    return true;
  } else { //if filename give after s in command line, save as given filename
    new_name = cl.substr(2,cl.length());
    ok = T.save_file(new_name);
    if (!ok) { //if it cant save to the given filename return an error message
      cout << "Can't save to file \"" << T.filename() << "\"." << endl;
    }
    return ok; //return the boolean value indicating whether the save was successful
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rsi, -0x140(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x32d0
leaq -0x58(%rbp), %rdi
callq 0x32d0
movq -0x140(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x30e0
jmp 0x38fe
movq -0x10(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x8290
jmp 0x3910
movq -0x140(%rbp), %rdi
leaq 0x5ab0(%rip), %rsi      # 0x93ce
movl $0x1, %edx
callq 0x3140
cmpq $-0x1, %rax
jne 0x3a4b
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x30e0
jmp 0x3952
movq -0x148(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x8560
jmp 0x3967
leaq -0xd0(%rbp), %rdi
callq 0x3160
movq 0x864e(%rip), %rdi      # 0xbfc8
leaq 0x59f8(%rip), %rsi      # 0x9379
callq 0x31f0
movq %rax, -0x150(%rbp)
jmp 0x398f
movq -0x150(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x31d0
movq %rax, -0x158(%rbp)
jmp 0x39ab
movq -0x158(%rbp), %rdi
leaq 0x5aad(%rip), %rsi      # 0x9466
callq 0x31f0
movq %rax, -0x160(%rbp)
jmp 0x39c7
movq -0x160(%rbp), %rdi
movq 0x85e3(%rip), %rsi      # 0xbfb8
callq 0x3210
jmp 0x39dc
movb $0x1, -0x1(%rbp)
movl $0x1, -0xd4(%rbp)
jmp 0x3bd8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3c22
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3c19
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3c0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x3160
jmp 0x3c0d
movq -0x140(%rbp), %rdi
callq 0x3310
movq -0x140(%rbp), %rsi
movq %rax, %rcx
leaq -0xf8(%rbp), %rdi
movl $0x2, %edx
callq 0x3200
jmp 0x3a74
leaq -0x58(%rbp), %rdi
movq %rdi, -0x170(%rbp)
leaq -0xf8(%rbp), %rsi
movq %rsi, -0x178(%rbp)
callq 0x3280
movq -0x178(%rbp), %rdi
callq 0x3160
movq -0x170(%rbp), %rsi
movq -0x10(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x30e0
jmp 0x3abe
movq -0x168(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x8560
movb %al, -0x179(%rbp)
jmp 0x3ad9
movb -0x179(%rbp), %al
andb $0x1, %al
movb %al, -0x8d(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3160
testb $0x1, -0x8d(%rbp)
jne 0x3bc3
movq 0x84c1(%rip), %rdi      # 0xbfc8
leaq 0x5876(%rip), %rsi      # 0x9384
callq 0x31f0
movq %rax, -0x188(%rbp)
jmp 0x3b1c
movq -0x10(%rbp), %rsi
leaq -0x138(%rbp), %rdi
callq 0x8290
jmp 0x3b2e
movq -0x188(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x31d0
movq %rax, -0x190(%rbp)
jmp 0x3b4a
movq -0x190(%rbp), %rdi
leaq 0x5841(%rip), %rsi      # 0x9399
callq 0x31f0
movq %rax, -0x198(%rbp)
jmp 0x3b66
movq -0x198(%rbp), %rdi
movq 0x8444(%rip), %rsi      # 0xbfb8
callq 0x3210
jmp 0x3b7b
leaq -0x138(%rbp), %rdi
callq 0x3160
jmp 0x3bc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x3160
jmp 0x3c0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x3160
jmp 0x3c0d
movb -0x8d(%rbp), %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movl $0x1, -0xd4(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3160
leaq -0x78(%rbp), %rdi
callq 0x3160
leaq -0x58(%rbp), %rdi
callq 0x3160
leaq -0x38(%rbp), %rdi
callq 0x3160
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
leaq -0xb0(%rbp), %rdi
callq 0x3160
leaq -0x78(%rbp), %rdi
callq 0x3160
leaq -0x58(%rbp), %rdi
callq 0x3160
leaq -0x38(%rbp), %rdi
callq 0x3160
movq -0x80(%rbp), %rdi
callq 0x3380
nopl (%rax)