// File: /workspace/github_cpp_makefile_star2_O2/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), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x90(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %r15d, %r15d
movb %r15b, (%rax)
leaq -0x70(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x50(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %r15b, (%rcx)
andl $0x0, -0x2c(%rbp)
movb %r15b, (%rax)
andl $0x0, -0x34(%rbp)
movb %r15b, (%rdx)
andl $0x0, -0x30(%rbp)
leaq 0x30e4(%rip), %rsi      # 0x63ce
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x2120
cmpq $-0x1, %rax
je 0x3613
movq %rbx, -0x40(%rbp)
leaq 0x30c4(%rip), %r15      # 0x63ce
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2120
movslq %eax, %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2100
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 0x21a0
leaq -0xa0(%rbp), %r12
leaq -0x240(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x20d0
leaq -0x240(%rbp), %rdi
pushq $0x8
popq %rdx
movq %r12, %rsi
callq 0x2220
leaq -0x240(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2130
leaq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movb -0x220(%rbp,%rax), %bl
callq 0x20e0
xorl %r12d, %r12d
testb $0x5, %bl
movq -0x40(%rbp), %r13
je 0x33c7
movl $0x1, -0x2c(%rbp)
movb $0x1, %bl
jmp 0x33cd
pushq $0x1
popq %r12
xorl %ebx, %ebx
sarq $0x20, %r15
leaq 0x2ff6(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r15, %rdx
callq 0x2120
cmpq $-0x1, %rax
je 0x3580
movl %r12d, -0x38(%rbp)
leaq 0x2fd6(%rip), %r12      # 0x63ce
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2120
movslq %eax, %r13
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x2100
movq %rax, %r15
movslq %r15d, %rcx
leaq -0x240(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x21a0
leaq -0x80(%rbp), %r12
leaq -0x240(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x20d0
leaq -0x240(%rbp), %rdi
pushq $0x8
popq %rdx
movq %r12, %rsi
callq 0x2220
leaq -0x240(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x2130
movq -0x40(%rbp), %r13
shlq $0x20, %r15
leaq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
xorl %r12d, %r12d
testb $0x5, -0x220(%rbp,%rax)
sete %r12b
movzbl %bl, %eax
pushq $0x1
popq %rbx
cmovel %eax, %ebx
callq 0x20e0
addl %r12d, -0x38(%rbp)
movabsq $0x100000000, %r12      # imm = 0x100000000
addq %r15, %r12
sarq $0x20, %r12
leaq 0x2f10(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r12, %rdx
callq 0x2120
cmpq $-0x1, %rax
je 0x357c
leaq 0x2ef4(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r12, %rdx
callq 0x2120
movslq %eax, %r15
leaq 0x2ee0(%rip), %rsi      # 0x63cf
movq %r14, %rdi
movq %r15, %rdx
callq 0x2100
movslq %eax, %rcx
leaq -0x240(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21a0
leaq -0x60(%rbp), %r14
leaq -0x240(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r15, %rdi
callq 0x20d0
leaq -0x240(%rbp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x2220
movl -0x38(%rbp), %r12d
leaq -0x240(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2130
leaq -0x240(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl -0x220(%rbp,%rax), %r14d
andl $0x5, %r14d
callq 0x20e0
cmpl $0x1, %r14d
adcl $0x0, %r12d
jmp 0x3580
movl -0x38(%rbp), %r12d
movl -0x2c(%rbp), %r15d
movl -0x34(%rbp), %r14d
movq %r13, %rdi
callq 0x5182
testl %r15d, %r15d
movzbl %bl, %ebx
pushq $0x1
popq %rdx
cmovlel %edx, %ebx
cmpl %eax, %r14d
movl -0x34(%rbp), %ecx
cmovgl %edx, %ebx
testl %ecx, %ecx
cmovlel %edx, %ebx
cmpl $0x3, %r12d
jne 0x35f1
cmpl -0x2c(%rbp), %ecx
setl %r14b
movl -0x30(%rbp), %r12d
testl %r12d, %r12d
setle %r15b
movq %r13, %rdi
callq 0x5182
cmpl %eax, %r12d
jle 0x35da
movq %r13, %rdi
callq 0x5182
movl %eax, -0x30(%rbp)
orb %r14b, %r15b
orb %bl, %r15b
testb $0x1, %r15b
jne 0x35f5
movl -0x2c(%rbp), %esi
movl -0x34(%rbp), %edx
movl -0x30(%rbp), %ecx
jmp 0x3608
testb %bl, %bl
je 0x35fa
xorl %r15d, %r15d
jmp 0x3613
movb $0x1, %r15b
cmpl $0x2, %r12d
jne 0x3613
movl -0x2c(%rbp), %esi
movl %esi, %edx
movb $0x1, %r15b
movq %r13, %rdi
callq 0x5468
leaq -0x60(%rbp), %rdi
callq 0x20d0
leaq -0x80(%rbp), %rdi
callq 0x20d0
leaq -0xa0(%rbp), %rdi
callq 0x20d0
leaq -0xc0(%rbp), %rdi
callq 0x20d0
movl %r15d, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x365e
jmp 0x3673
jmp 0x3673
jmp 0x365e
jmp 0x3673
jmp 0x3673
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
callq 0x20e0
jmp 0x3676
jmp 0x3673
jmp 0x3673
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x20d0
leaq -0x80(%rbp), %rdi
callq 0x20d0
leaq -0xa0(%rbp), %rdi
callq 0x20d0
leaq -0xc0(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2260