// File: /workspace/github_cpp_makefile_star2_O1/craigbarstow[P]cmd-line-text-editor/text_editor.cc
// Function: copy_line(text_ed&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool copy_line (text_ed & T, string cl) { //Copy area between two given line numbers (inclusive) to after a third given line number if three numbers are given. If only two integers are given, move the line at the first position to after the position given by the second integer
  bool error_state=false;
  string aline,M_string,N_string,O_string;
  int i = 0,m=0,n=0,o=0,p=1,m_start, m_end, n_start, n_end, o_start, o_end, number, count=0;
  if (cl.find_first_not_of(" ",1)!=string::npos){ //section to isolate the first integer from the string entered into the command line
    m_start= cl.find_first_not_of(" ",1);
    m_end = cl.find_first_of(" ", m_start)-2;
    M_string=cl.substr(m_start,m_end);
    if (!(istringstream(M_string) >> m)) { //if the substring representing the first integer cannot be converted to an integer, toggle the error state to true
      error_state=true;
      m=1;
    } else {count++;} //increment count to show one integer is present
    if (cl.find_first_not_of(" ", m_end+2)!=string::npos){ //section to isolate the second integer from the string entered into the command line
      n_start = cl.find_first_not_of(" ", m_end+2);
      n_end = cl.find_first_of(" ",n_start);
      N_string=cl.substr(n_start,n_end);
      if (!(istringstream(N_string) >> n)){ //if the substring representing the second integer cannot be converted to an integer, toggle the error state to true
	error_state=true;
      } else {count++;} //increment count to show that two integers are present
      if (cl.find_first_not_of(" ", n_end+1)!=string::npos) { //section to isolate the third integer from the string entered into the command line
	  o_start = cl.find_first_not_of(" ", n_end+1);
	  o_end = cl.find_first_of("",o_start);
	  O_string=cl.substr(o_start,o_end);
	  if (istringstream(O_string) >> o){ //if substring can be converted to an integer, increment count to show a third integer is present
	    count++; 
	  } 
	}
    }
    //SECTION TO MAKE SURE INTEGERS MAKE SENSE
    if (m<1){ //if first integer is less than 1, toggle error state to true
      error_state=true;
    }
    if (n>T.get_last_line()) { //if second int is greater than document length, toggle error state
      error_state=true;
    }
    if (n<1) { //if second it is less than one, toggle error state to true
      error_state=true;
    }
    if (count==3) {
      if (n<m) { //if three integers are present and the first 
	error_state = true;
      }
      if (o<=0) { //if the third integer is less than three, toggle error state to true
	error_state = true;
      }
      if (o>T.get_last_line()) { //if third integer is greater than document length, reset it
	o=T.get_last_line();
      }
    }
    if (!error_state) { 
      if (count==3){ //if three integers are present, copy lines from the start position to the end position to after the given location
	T.copy_lines(m,n,o);
       }
      else if (count==2) { //if two integers are present, copy the line given by the first position to after the position denoted by the second integer
	T.copy_lines(m,m,n);
      }	
      return true; //return true if error state is false
    } else {
      return false; //return false if error state is true
    }
  }
  return false; //return false if nothing is found after the initial 'c' substring in the input string
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %r14
movq %rdi, %rbx
leaq -0xb0(%rbp), %r13
movq %r13, -0x10(%r13)
xorl %r15d, %r15d
movq %r15, -0x8(%r13)
movb %r15b, (%r13)
leaq -0x90(%rbp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
movq %r15, -0x8(%rax)
movb %r15b, (%rax)
movl %r15d, -0x30(%rbp)
movl %r15d, -0x34(%rbp)
movl %r15d, -0x38(%rbp)
leaq 0x386f(%rip), %rsi      # 0x73ce
movl $0x1, %edx
movl $0x1, %ecx
movq %r14, %rdi
callq 0x2210
cmpq $-0x1, %rax
je 0x3f51
movq %rbx, -0x40(%rbp)
leaq 0x3848(%rip), %r15      # 0x73ce
movl $0x1, %edx
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2210
movslq %eax, %r12
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x21e0
movq %rax, %r15
shlq $0x20, %r15
movabsq $-0x200000000, %rcx     # imm = 0xFFFFFFFE00000000
addq %r15, %rcx
sarq $0x20, %rcx
leaq -0x240(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x2160
leaq -0xa0(%rbp), %rdi
leaq -0x240(%rbp), %r12
movq %r12, %rsi
callq 0x2190
movq (%r12), %rdi
leaq -0x230(%rbp), %rax
cmpq %rax, %rdi
je 0x3c10
movq -0x230(%rbp), %rsi
incq %rsi
callq 0x2140
leaq -0x240(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
movl $0x8, %edx
callq 0x2200
movq -0x40(%rbp), %r12
leaq -0x240(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x20c0
leaq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movb -0x220(%rbp,%rax), %bl
movq 0x6368(%rip), %rsi      # 0x9fc0
callq 0x21c0
leaq -0x1c8(%rbp), %rdi
callq 0x2080
movl $0x0, -0x2c(%rbp)
testb $0x5, %bl
je 0x3c80
movl $0x1, -0x30(%rbp)
movb $0x1, %bl
jmp 0x3c89
movl $0x1, -0x2c(%rbp)
xorl %ebx, %ebx
sarq $0x20, %r15
leaq 0x373a(%rip), %rsi      # 0x73ce
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rdx
callq 0x2210
cmpq $-0x1, %rax
je 0x3eb7
leaq 0x3719(%rip), %r12      # 0x73ce
movl $0x1, %ecx
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2210
movslq %eax, %r13
movl $0x1, %ecx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x21e0
movq %rax, %r15
movslq %r15d, %rcx
leaq -0x240(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2160
leaq -0x80(%rbp), %rdi
leaq -0x240(%rbp), %r12
movq %r12, %rsi
callq 0x2190
movq (%r12), %rdi
leaq -0x230(%rbp), %rax
cmpq %rax, %rdi
je 0x3d28
movq -0x230(%rbp), %rsi
incq %rsi
callq 0x2140
leaq -0x240(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x8, %edx
callq 0x2200
leaq -0x240(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x20c0
shlq $0x20, %r15
leaq -0x1c8(%rbp), %r12
movq -0x78(%r12), %rax
movq -0x18(%rax), %rax
xorl %r13d, %r13d
testb $0x5, -0x220(%rbp,%rax)
sete %r13b
movq 0x6249(%rip), %rsi      # 0x9fc0
movzbl %bl, %eax
movl $0x1, %ebx
cmovel %eax, %ebx
leaq -0x240(%rbp), %rdi
callq 0x21c0
movq %r12, %rdi
callq 0x2080
addl %r13d, -0x2c(%rbp)
movabsq $0x100000000, %r12      # imm = 0x100000000
addq %r15, %r12
sarq $0x20, %r12
leaq 0x361c(%rip), %rsi      # 0x73ce
movl $0x1, %ecx
movq %r14, %rdi
movq %r12, %rdx
callq 0x2210
cmpq $-0x1, %rax
je 0x3eac
leaq 0x35fb(%rip), %rsi      # 0x73ce
movl $0x1, %ecx
movq %r14, %rdi
movq %r12, %rdx
callq 0x2210
movslq %eax, %r15
leaq 0x35e2(%rip), %rsi      # 0x73cf
movq %r14, %rdi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x21e0
movslq %eax, %rcx
leaq -0x240(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq -0xb0(%rbp), %r13
callq 0x2160
leaq -0x60(%rbp), %rdi
leaq -0x240(%rbp), %r14
movq %r14, %rsi
callq 0x2190
movq (%r14), %rdi
leaq -0x230(%rbp), %rax
cmpq %rax, %rdi
je 0x3e47
movq -0x230(%rbp), %rsi
incq %rsi
callq 0x2140
leaq -0x240(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movl $0x8, %edx
callq 0x2200
movq -0x40(%rbp), %r12
leaq -0x240(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x20c0
leaq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl -0x220(%rbp,%rax), %r14d
andl $0x5, %r14d
movq 0x612f(%rip), %rsi      # 0x9fc0
callq 0x21c0
leaq -0x1c8(%rbp), %rdi
callq 0x2080
cmpl $0x1, %r14d
adcl $0x0, -0x2c(%rbp)
jmp 0x3eb7
leaq -0xb0(%rbp), %r13
movq -0x40(%rbp), %r12
movl -0x30(%rbp), %r15d
movl -0x34(%rbp), %r14d
movq %r12, %rdi
callq 0x66b4
testl %r15d, %r15d
movzbl %bl, %ebx
movl $0x1, %ecx
cmovlel %ecx, %ebx
cmpl %eax, %r14d
movl -0x34(%rbp), %eax
cmovgl %ecx, %ebx
testl %eax, %eax
cmovlel %ecx, %ebx
movl -0x2c(%rbp), %edx
cmpl $0x3, %edx
jne 0x3f19
cmpl -0x30(%rbp), %eax
movzbl %bl, %ebx
cmovll %ecx, %ebx
movl -0x38(%rbp), %r14d
testl %r14d, %r14d
cmovlel %ecx, %ebx
movq %r12, %rdi
callq 0x66b4
cmpl %eax, %r14d
jle 0x3f16
movq %r12, %rdi
callq 0x66b4
movl %eax, -0x38(%rbp)
movl -0x2c(%rbp), %edx
testb %bl, %bl
je 0x3f22
xorl %r15d, %r15d
jmp 0x3f51
cmpl $0x3, %edx
jne 0x3f33
movl -0x30(%rbp), %esi
leaq -0x38(%rbp), %rax
movl -0x34(%rbp), %edx
jmp 0x3f44
movb $0x1, %r15b
cmpl $0x2, %edx
jne 0x3f51
leaq -0x34(%rbp), %rax
movl -0x30(%rbp), %esi
movl %esi, %edx
movl (%rax), %ecx
movb $0x1, %r15b
movq %r12, %rdi
callq 0x6ab6
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x3f6a
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2140
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x3f83
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2140
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x3fa5
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2140
movq -0xc0(%rbp), %rdi
cmpq %r13, %rdi
je 0x3fc0
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2140
movl %r15d, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3fe1
jmp 0x4009
jmp 0x4009
jmp 0x3fe1
jmp 0x4009
jmp 0x4009
movq %rax, %rbx
movq 0x5fd5(%rip), %rsi      # 0x9fc0
leaq -0x240(%rbp), %rdi
callq 0x21c0
leaq -0x1c8(%rbp), %rdi
callq 0x2080
jmp 0x400c
jmp 0x4009
jmp 0x4009
movq %rax, %rbx
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x4025
movq -0x50(%rbp), %rsi
incq %rsi
callq 0x2140
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x403e
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x2140
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x4060
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x2140
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x4082
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x2140
movq %rbx, %rdi
callq 0x2260