// File: /workspace/github_cpp_makefile_star2_O2/craigbarstow[P]cmd-line-text-editor/text_editor.cc
// Function: move_line(text_ed&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool move_line (text_ed & T, string cl) {
  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 substring representing the first integer from the given string
    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 substring cant be converted to an integer, toggle error state to true
      error_state=true;
    } else {count++;} //if it can, increment count to show first integer is present
    if (cl.find_first_not_of(" ", m_end+2)!=string::npos){ //section to isolate the substring representing the second integer from the given string
      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 substring cant be converted to an integer, toggle error state to true
	error_state=true;
      } else {count++;} //if it can be, increment count to show second integer is present
      if (cl.find_first_not_of(" ", n_end+1)!=string::npos) { //section to isolate the substring representing the third integer from the given string
	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 third integer is present
	  count++;
	} 
      }
    }
    //SECTION TO MAKE SURE THE INTEGERS MAKE SENSE
    if (m<=0){ //if first integer is less than 1, toggle error state to true
      error_state=true;
    }
    if (count<=2){
      if (n>T.get_last_line()) { //if second int is greater than document length, reset it
	n=T.get_last_line();
      }
      if (n<=0) { //if second it is less than zero, 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 || o>T.get_last_line()) { //if the third integer is less than three, toggle error state to true
	error_state = true;
      }
    }
    if (!error_state) {
      if (count==3){ //if three integers are present, move the lines from the first to the second integer to after the position given by the third integer
	T.move_lines(m,n,o);
       } else if (count==2) { //if two integers are present, move the first line to after the position given by the second
	T.move_lines(m,m,n); //n+1
      }	else if (count==1) {
	return false;  //return false if only one integer is found
      }
      return true; //if error state is false, return true
    }
  }
  return false; //if error state is true or the first integer isnt found, return false
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rsi, %r14
movq %rdi, -0x40(%rbp)
leaq -0xb8(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x98(%rbp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
xorl %r15d, %r15d
movb %r15b, (%rax)
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq -0x78(%rbp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %r15b, (%rcx)
andl $0x0, -0x34(%rbp)
movb %r15b, (%rax)
andl $0x0, -0x30(%rbp)
movb %r15b, (%rdx)
andl $0x0, -0x38(%rbp)
leaq 0x2caf(%rip), %rsi      # 0x63ce
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x2120
cmpq $-0x1, %rax
je 0x3a47
leaq 0x2c93(%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 -0x248(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x21a0
leaq -0xa8(%rbp), %r12
leaq -0x248(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x20d0
leaq -0x248(%rbp), %rdi
pushq $0x8
popq %rdx
movq %r12, %rsi
callq 0x2220
leaq -0x248(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x2130
leaq -0x248(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl -0x228(%rbp,%rax), %r12d
xorl %ebx, %ebx
xorl %r13d, %r13d
testb $0x5, %r12b
setne -0x29(%rbp)
sete %r13b
callq 0x20e0
sarq $0x20, %r15
leaq 0x2bd0(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r15, %rdx
callq 0x2120
pushq $0x1
popq %rcx
cmpq $-0x1, %rax
je 0x39b1
movl %r13d, -0x44(%rbp)
leaq 0x2bad(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r15, %rdx
callq 0x2120
movslq %eax, %r13
movq %r14, %rdi
leaq 0x2b95(%rip), %rsi      # 0x63ce
movq %r13, %rdx
callq 0x2100
movq %rax, %r15
movslq %r15d, %rcx
leaq -0x248(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x21a0
leaq -0x68(%rbp), %rdi
leaq -0x248(%rbp), %r13
movq %r13, %rsi
callq 0x21c0
movq %r13, %rdi
callq 0x20d0
leaq -0x248(%rbp), %rdi
pushq $0x8
popq %rdx
leaq -0x68(%rbp), %rsi
callq 0x2220
leaq -0x248(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2130
movl -0x44(%rbp), %r13d
shlq $0x20, %r15
andl $0x5, %r12d
leaq -0x248(%rbp), %rdi
movq (%rdi), %rax
xorl %ecx, %ecx
cmpl $0x1, %r12d
adcl $0x1, %ecx
movq -0x18(%rax), %rax
testb $0x5, -0x228(%rbp,%rax)
movb -0x29(%rbp), %al
movb %al, %bl
pushq $0x1
popq %rax
cmovnel %eax, %ebx
cmovel %ecx, %r13d
callq 0x20e0
movabsq $0x100000000, %r12      # imm = 0x100000000
addq %r15, %r12
sarq $0x20, %r12
leaq 0x2ae0(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r12, %rdx
callq 0x2120
cmpq $-0x1, %rax
je 0x39ac
leaq 0x2ac4(%rip), %rsi      # 0x63ce
movq %r14, %rdi
movq %r12, %rdx
callq 0x2120
movslq %eax, %r15
leaq 0x2ab0(%rip), %rsi      # 0x63cf
movq %r14, %rdi
movq %r15, %rdx
callq 0x2100
movslq %eax, %rcx
leaq -0x248(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x21a0
leaq -0x88(%rbp), %r14
leaq -0x248(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x21c0
movq %r15, %rdi
callq 0x20d0
leaq -0x248(%rbp), %rdi
pushq $0x8
popq %rdx
movq %r14, %rsi
callq 0x2220
movl %ebx, %r14d
leaq -0x248(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2130
leaq -0x248(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl -0x228(%rbp,%rax), %ebx
andl $0x5, %ebx
callq 0x20e0
cmpl $0x1, %ebx
adcl $0x0, %r13d
movl %r14d, %ebx
pushq $0x1
popq %rcx
jmp 0x39b4
movb -0x29(%rbp), %bl
movl -0x34(%rbp), %r12d
testl %r12d, %r12d
movzbl %bl, %ebx
cmovlel %ecx, %ebx
movl -0x30(%rbp), %r14d
cmpl $0x2, %r13d
ja 0x39e7
movq -0x40(%rbp), %rdi
callq 0x5182
cmpl %eax, %r14d
jle 0x3a15
movq -0x40(%rbp), %rdi
callq 0x5182
movl %eax, -0x30(%rbp)
jmp 0x3a18
movl -0x38(%rbp), %r13d
testl %r13d, %r13d
jle 0x3a44
movq -0x40(%rbp), %rdi
callq 0x5182
xorl %r15d, %r15d
cmpl %eax, %r13d
jg 0x3a47
cmpl %r12d, %r14d
jl 0x3a47
testb %bl, %bl
jne 0x3a47
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
movl -0x38(%rbp), %eax
jmp 0x3a34
movl -0x30(%rbp), %eax
xorl %r15d, %r15d
testl %eax, %eax
jle 0x3a47
testb %bl, %bl
jne 0x3a47
cmpl $0x1, %r13d
je 0x3a44
cmpl $0x2, %r13d
jne 0x3a3f
movl -0x34(%rbp), %esi
movl %esi, %edx
movq -0x40(%rbp), %rdi
movl %eax, %ecx
callq 0x54be
movb $0x1, %r15b
jmp 0x3a47
xorl %r15d, %r15d
leaq -0x88(%rbp), %rdi
callq 0x20d0
leaq -0x68(%rbp), %rdi
callq 0x20d0
leaq -0xa8(%rbp), %rdi
callq 0x20d0
leaq -0xc8(%rbp), %rdi
callq 0x20d0
movl %r15d, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a95
jmp 0x3aaa
jmp 0x3aaa
jmp 0x3a95
jmp 0x3aaa
jmp 0x3aaa
movq %rax, %rbx
leaq -0x248(%rbp), %rdi
callq 0x20e0
jmp 0x3aad
jmp 0x3aaa
jmp 0x3aaa
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x20d0
leaq -0x68(%rbp), %rdi
callq 0x20d0
leaq -0xa8(%rbp), %rdi
callq 0x20d0
leaq -0xc8(%rbp), %rdi
callq 0x20d0
movq %rbx, %rdi
callq 0x2260