// File: craigbarstow[P]cmd-line-text-editor/text_editor.cc
// Function: Do_Command(text_ed&, bool&)
bool Do_Command (text_ed & T, bool& toggle) { //
 char command;
 string command_line;
 bool success, filename_presence=false;
 cout << "File is \"" << T.filename() << "\"." << endl; //print out filename
 cout << "--> ";
 getline(cin,command_line);  //get input from command line
 command = command_line[0];
 switch (command) {
 case 'h':
 case 'H': Show_Commands(); break;
 case 'a':
 case 'A': success = add_lines(T,command_line); break;
 case 'q':
 case 'Q': return false;
 case 's':
 case 'S':
   if (command_line.find_first_not_of(" ",1)!=string::npos) { //if filename is present, toggle bool to true
     filename_presence = true;
   } 
   if (filename_presence) { //if filename is present, save file to filename and retrieve new filename
     success = save_file(T,command_line) && get_file(T,command_line);
   } else { //otherwise save the file under the current name
     success = save_file(T,command_line);
   }
   break;
 break;
 case 't':
 case 'T': success = type_lines(T,command_line, toggle); break;
 case 'x':
 case 'X': success = save_file(T,command_line);
	   return false;
	   break;
 case 'g':
 case 'G': success = get_file(T,command_line); break;
 case 'n':
 case 'N': if (!toggle) {
	    toggle=true;
	   } else {
	    toggle=false;
	   }
	   success = true; 
	   break;
 case 'd':
 case 'D': success = delete_line(T,command_line); break;
 case 'c':
 case 'C': success = copy_line(T,command_line); break;
 case 'm':
 case 'M': success = move_line(T,command_line); break;
 case 'f':
 case 'F': success = find_and_type(T,command_line, toggle); break;
 case 'r':
 case 'R': success = find_and_replace(T,command_line); break;
 default: if (command) {
              cout << "\"" << command << "\" is not a valid command." << endl;
      cout << "Type \"h\" for help." << endl;
      success = true;
          } else {
    success = true;
  }
 }
 if ( !success ) cout << "Error" << endl;
 return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x320, %rsp            # imm = 0x320
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x32d0
movb $0x0, -0x42(%rbp)
movq 0x5341(%rip), %rdi      # 0xbfc8
leaq 0x2782(%rip), %rsi      # 0x9410
callq 0x31f0
movq %rax, -0x210(%rbp)
jmp 0x6c9c
movq -0x10(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x8290
jmp 0x6cab
movq -0x210(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x31d0
movq %rax, -0x218(%rbp)
jmp 0x6cc4
movq -0x218(%rbp), %rdi
leaq 0x26c7(%rip), %rsi      # 0x9399
callq 0x31f0
movq %rax, -0x220(%rbp)
jmp 0x6ce0
movq -0x220(%rbp), %rdi
movq 0x52ca(%rip), %rsi      # 0xbfb8
callq 0x3210
jmp 0x6cf5
leaq -0x78(%rbp), %rdi
callq 0x3160
movq 0x52c3(%rip), %rdi      # 0xbfc8
leaq 0x270e(%rip), %rsi      # 0x941a
callq 0x31f0
jmp 0x6d13
movq 0x52be(%rip), %rdi      # 0xbfd8
leaq -0x40(%rbp), %rsi
callq 0x3070
jmp 0x6d25
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
callq 0x33e0
movq %rax, -0x228(%rbp)
jmp 0x6d3b
movq -0x228(%rbp), %rax
movb (%rax), %al
movb %al, -0x19(%rbp)
movsbl -0x19(%rbp), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x230(%rbp)
subl $0x37, %eax
ja 0x73b2
movq -0x230(%rbp), %rax
leaq 0x2296(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x74bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x3160
jmp 0x74bd
callq 0x3580
jmp 0x6da9
jmp 0x745f
movq -0x10(%rbp), %rax
movq %rax, -0x238(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x6dcb
movq -0x238(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x43f0
movb %al, -0x239(%rbp)
jmp 0x6de6
movb -0x239(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movb $0x0, -0x1(%rbp)
movl $0x1, -0x9c(%rbp)
jmp 0x74a6
leaq -0x40(%rbp), %rdi
leaq 0x2591(%rip), %rsi      # 0x93ce
movl $0x1, %edx
callq 0x3140
cmpq $-0x1, %rax
je 0x6e51
movb $0x1, -0x42(%rbp)
testb $0x1, -0x42(%rbp)
je 0x6f73
movq -0x10(%rbp), %rax
movq %rax, -0x248(%rbp)
movb $0x0, -0xe1(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x6e7f
movq -0x248(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x38c0
movb %al, -0x249(%rbp)
jmp 0x6e9a
movb -0x249(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x24a(%rbp)
jne 0x6eaf
jmp 0x6efc
movq -0x10(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq -0xe0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x6ecc
movq -0x258(%rbp), %rdi
movb $0x1, -0xe1(%rbp)
leaq -0xe0(%rbp), %rsi
callq 0x3740
movb %al, -0x259(%rbp)
jmp 0x6eee
movb -0x259(%rbp), %al
movb %al, -0x24a(%rbp)
jmp 0x6efc
movb -0x24a(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
testb $0x1, -0xe1(%rbp)
jne 0x6f12
jmp 0x6f1e
leaq -0xe0(%rbp), %rdi
callq 0x3160
leaq -0xc0(%rbp), %rdi
callq 0x3160
jmp 0x6fe1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x6f62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
testb $0x1, -0xe1(%rbp)
jne 0x6f54
jmp 0x6f60
leaq -0xe0(%rbp), %rdi
callq 0x3160
jmp 0x6f62
leaq -0xc0(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x268(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x6f90
movq -0x268(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x38c0
movb %al, -0x269(%rbp)
jmp 0x6fab
movb -0x269(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3160
jmp 0x6fe1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3160
jmp 0x74bd
jmp 0x745f
movq -0x10(%rbp), %rax
movq %rax, -0x278(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x7003
movq -0x278(%rbp), %rdi
movq -0x18(%rbp), %rax
movzbl (%rax), %edx
andl $0x1, %edx
leaq -0x128(%rbp), %rsi
callq 0x3c40
movb %al, -0x279(%rbp)
jmp 0x7028
movb -0x279(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x707e
movq -0x288(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x38c0
movb %al, -0x289(%rbp)
jmp 0x7099
movb -0x289(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3160
movb $0x0, -0x1(%rbp)
movl $0x1, -0x9c(%rbp)
jmp 0x74a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x298(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x70fd
movq -0x298(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x3740
movb %al, -0x299(%rbp)
jmp 0x7118
movb -0x299(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x18(%rbp), %rax
testb $0x1, (%rax)
jne 0x7163
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
jmp 0x716a
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movb $0x1, -0x41(%rbp)
jmp 0x745f
movq -0x10(%rbp), %rax
movq %rax, -0x2a8(%rbp)
leaq -0x188(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x7190
movq -0x2a8(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x48a0
movb %al, -0x2a9(%rbp)
jmp 0x71ab
movb -0x2a9(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x1a8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x7201
movq -0x2b8(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x4d00
movb %al, -0x2b9(%rbp)
jmp 0x721c
movb -0x2b9(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x2c8(%rbp)
leaq -0x1c8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x7272
movq -0x2c8(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x5370
movb %al, -0x2c9(%rbp)
jmp 0x728d
movb -0x2c9(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x2d8(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x72e3
movq -0x2d8(%rbp), %rdi
movq -0x18(%rbp), %rax
movzbl (%rax), %edx
andl $0x1, %edx
leaq -0x1e8(%rbp), %rsi
callq 0x59f0
movb %al, -0x2d9(%rbp)
jmp 0x7308
movb -0x2d9(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1e8(%rbp), %rdi
callq 0x3160
jmp 0x74bd
movq -0x10(%rbp), %rax
movq %rax, -0x2e8(%rbp)
leaq -0x208(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x30e0
jmp 0x735e
movq -0x2e8(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x63f0
movb %al, -0x2e9(%rbp)
jmp 0x7379
movb -0x2e9(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x3160
jmp 0x745f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x3160
jmp 0x74bd
cmpb $0x0, -0x19(%rbp)
je 0x7459
movq 0x4c05(%rip), %rdi      # 0xbfc8
leaq 0x209c(%rip), %rsi      # 0x9466
callq 0x31f0
movq %rax, -0x2f8(%rbp)
jmp 0x73d8
movq -0x2f8(%rbp), %rdi
movsbl -0x19(%rbp), %esi
callq 0x3270
movq %rax, -0x300(%rbp)
jmp 0x73f1
movq -0x300(%rbp), %rdi
leaq 0x2020(%rip), %rsi      # 0x941f
callq 0x31f0
movq %rax, -0x308(%rbp)
jmp 0x740d
movq -0x308(%rbp), %rdi
movq 0x4b9d(%rip), %rsi      # 0xbfb8
callq 0x3210
jmp 0x7422
movq 0x4b9f(%rip), %rdi      # 0xbfc8
leaq 0x2009(%rip), %rsi      # 0x9439
callq 0x31f0
movq %rax, -0x310(%rbp)
jmp 0x743e
movq -0x310(%rbp), %rdi
movq 0x4b6c(%rip), %rsi      # 0xbfb8
callq 0x3210
jmp 0x7453
movb $0x1, -0x41(%rbp)
jmp 0x745d
movb $0x1, -0x41(%rbp)
jmp 0x745f
testb $0x1, -0x41(%rbp)
jne 0x7498
movq 0x4b5c(%rip), %rdi      # 0xbfc8
leaq 0x1fd9(%rip), %rsi      # 0x944c
callq 0x31f0
movq %rax, -0x318(%rbp)
jmp 0x7481
movq -0x318(%rbp), %rdi
movq 0x4b29(%rip), %rsi      # 0xbfb8
callq 0x3210
jmp 0x7496
jmp 0x7498
movb $0x1, -0x1(%rbp)
movl $0x1, -0x9c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3160
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x320, %rsp            # imm = 0x320
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x3160
movq -0x50(%rbp), %rdi
callq 0x3380
nop