// File: /workspace/github_cpp_makefile_star2_O3/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: pretty_print_message_words()
void pretty_print_message_words()
{
	attron(COLOR_PAIR(COLOR_WHITE));
	int line_number = message_area_height-1;
	std::string line_so_far = "";
	int word_number = rlmessage_words.size()-1;
	int position = -1;
	std::string word;
	bool boundary_on_this_line = false;
	int boundary_position = -1;
	bool already_seen = (last_word_seen == rlmessage_words.size()-1);
	while(line_number >= 0 && word_number >= 0)
	{
		bool next_line = false;
		bool next_word = false;
		if(position == -1) // start a new word
		{
			word = rlmessage_words[word_number];
			position = word.length();
		}
		int line_chars_remaining = viewport_width - 1 - line_so_far.length();
		if(line_chars_remaining >= position+1) // whole remainder of word fits
		{
			line_so_far = word.substr(0,position) + ' ' + line_so_far;
			next_word = true;
		}
		else if(position >= viewport_width-1) // remainder of word couldn't possibly fit on an empty line, or exactly fits
		{
			line_so_far = word.substr(position-line_chars_remaining,line_chars_remaining) + ' ' + line_so_far;
			position -= line_chars_remaining;
			if(position == 0)
			{
				next_word = true;
			}
			next_line = true;
		}
		else // remainder of word would not fit on this line but would fit on an empty line
		{
			next_line = true;
		}
		if(next_word)
		{
			position = -1;
			word_number--;
			if(word_number == last_word_seen && last_word_seen != rlmessage_words.size()-1)
			{
				boundary_on_this_line = true;
				boundary_position = line_so_far.length();
				already_seen = true;
			}
		}


		if(next_line)
		{
			if(!already_seen)
			{
				attron(A_BOLD);
				mvaddstr(line_number,0,line_so_far.c_str());
				attroff(A_BOLD);
			}
			else
			{
				if(boundary_on_this_line)
				{
					attroff(A_BOLD);
					mvaddstr(line_number,0,line_so_far.substr(0,line_so_far.length()-boundary_position).c_str());
					attron(A_BOLD);
					mvaddstr(line_number,line_so_far.length()-boundary_position,line_so_far.substr(line_so_far.length()-boundary_position,boundary_position).c_str());
					attroff(A_BOLD);
					boundary_on_this_line = false;
				}
				else
				{
					attroff(A_BOLD);
					mvaddstr(line_number,0,line_so_far.c_str());
				}
			}
			line_number--;
			line_so_far = "";
		}
		
	}
	{
		if(!already_seen)
		{
			attron(A_BOLD);
			mvaddstr(line_number,0,line_so_far.c_str());
			attroff(A_BOLD);
		}
		else
		{
			if(boundary_on_this_line)
			{
				attroff(A_BOLD);
				mvaddstr(line_number,0,line_so_far.substr(0,line_so_far.length()-boundary_position).c_str());
				attron(A_BOLD);
				mvaddstr(line_number,line_so_far.length()-boundary_position,line_so_far.substr(line_so_far.length()-boundary_position,boundary_position).c_str());
				attroff(A_BOLD);
				boundary_on_this_line = false;
			}
			else
			{
				attroff(A_BOLD);
				mvaddstr(line_number,0,line_so_far.c_str());
			}
		}
		line_number--;
		line_so_far = "";
	}
	//last_word_seen  = rlmessage_words.size()-1;
	//if(last_word_seen < (int)rlmessage_words.size())
	//	attron(A_BOLD);
	//unsigned int colour_change_offset = 2*viewport_width;
	//int word_number = rlmessage_words.size()-1;
	//int word_position = -1;
	//for(int line = message_area_height-1; line >= 0; line--)
	//{
	//	std::string line_to_print;
	//	for(line_to_print = "";
	//		word_number >= 0 && (line_to_print.length() + rlmessage_words[word_number].length() < viewport_width
	//		                 || (word_position != -1));
	//		word_number--)
	//	{
	//		if(word_position == -1)
	//		{
	//			if((int)rlmessage_words[word_number].length() > viewport_width-1)
	//			{
	//				line_to_print = rlmessage_words[word_number].substr(rlmessage_words[word_number].length()-viewport_width+1+line_to_print.length(),viewport_width-line_to_print.length()-1)+' '+line_to_print;
	//				word_number++;
	//				word_position = rlmessage_words[word_number].length()-viewport_width+1+line_to_print.length();
	//			}
	//			else 
	//			{
	//				line_to_print = rlmessage_words[word_number] + ' ' + line_to_print;
	//				if(word_number == last_word_seen)
	//				{
	//					colour_change_offset = line_to_print.length();
	//				}
	//			}
	//		}
	//		else
	//		{
	//			if(word_position > viewport_width-1)
	//			{
	//				line_to_print = rlmessage_words[word_number].substr(word_position - viewport_width+1,viewport_width-1);
	//				word_number++;
	//				word_position = word_position - viewport_width+1;
	//			}
	//			else
	//			{
	//				line_to_print = rlmessage_words[word_number].substr(0,word_position);
	//				word_position = -1;
	//			}
	//		}
	//	}
	//	if(colour_change_offset != 2*viewport_width)
	//	{
	//		attroff(A_BOLD);
	//		mvaddstr(line,0,line_to_print.substr(0,line_to_print.length()-colour_change_offset).c_str());
	//		attron(A_BOLD);
	//		mvaddstr(line,line_to_print.length()-colour_change_offset,line_to_print.substr(line_to_print.length()-colour_change_offset).c_str());
	//		attroff(A_BOLD);
	//		colour_change_offset = 2*viewport_width;
	//	}
	//	else
	//	{
	//		mvaddstr(line,0,line_to_print.c_str());
	//	}
	//}
	////last_word_seen  = rlmessage_words.size();
	//attroff(A_BOLD);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq 0x1af3f(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl $0x700, %esi            # imm = 0x700
xorl %edx, %edx
callq 0x5150
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x140ab(%rip), %rdx     # 0x1a163
leaq 0x28(%rsp), %rdi
movq %rdx, %rsi
callq 0x15b1a
movq 0x6818c(%rip), %r15     # 0x6e258
subq 0x6817d(%rip), %r15     # 0x6e250
sarq $0x5, %r15
movq %r15, %rax
decq %rax
decl %r15d
leaq 0x80(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movslq 0x6816c(%rip), %rcx     # 0x6e26c
js 0x66fd
cmpq %rcx, %rax
sete 0x3(%rsp)
leaq 0x60(%rsp), %r12
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0x5, %ebx
movq $0x0, 0x48(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl %r13d, %ebp
cmpl $-0x1, %r13d
jne 0x6157
movl %r15d, %esi
shlq $0x5, %rsi
addq 0x6810a(%rip), %rsi     # 0x6e250
leaq 0x70(%rsp), %rdi
callq 0x5170
movl 0x78(%rsp), %ebp
movl %ebp, %r13d
movl $0x30, %r14d
subl 0x30(%rsp), %r14d
subl %r14d, %r13d
jge 0x61cd
movslq %ebp, %rcx
leaq 0x98(%rsp), %r13
movq %r13, %rdi
leaq 0x70(%rsp), %rsi
xorl %edx, %edx
callq 0x5270
movq 0xa0(%rsp), %rsi
movl $0x1, %ecx
movq %r13, %rdi
xorl %edx, %edx
movl $0x20, %r8d
callq 0x53f0
leaq 0x18(%rsp), %r13
movq %r12, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x624c
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x6254
cmpl $0x30, %ebp
jl 0x6244
movl %ebp, 0x94(%rsp)
movq %r15, %rbp
movl %ebx, %r15d
movslq %r13d, %rdx
movslq %r14d, %rcx
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
leaq 0x70(%rsp), %rsi
callq 0x5270
movq 0xa0(%rsp), %rsi
movl $0x1, %ecx
movq %rbx, %rdi
xorl %edx, %edx
movl $0x20, %r8d
callq 0x53f0
movq %r12, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movl %r15d, %ebx
je 0x6313
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x631b
movl %ebp, %r13d
jmp 0x643e
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x50(%rsp), %rdi
callq 0x50c0
movq %r13, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x62a3
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x62ab
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5300
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x62e1
callq 0x5230
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x62f0
callq 0x5230
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x63ea
callq 0x5230
jmp 0x63ea
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq %rbp, %r15
movq 0x8(%rax), %rdx
movq %rdx, 0x58(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x50(%rsp), %rdi
callq 0x50c0
movl 0x94(%rsp), %ebp
leaq 0x18(%rsp), %r12
movq %r12, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6379
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x6381
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5300
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x63b7
callq 0x5230
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %r12
cmpq %r12, %rdi
je 0x63cb
callq 0x5230
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x63e5
callq 0x5230
testl %r13d, %r13d
jne 0x643e
decl %r15d
cmpl 0x67e78(%rip), %r15d    # 0x6e26c
jne 0x6427
movq 0x67e5b(%rip), %rax     # 0x6e258
subq 0x67e4c(%rip), %rax     # 0x6e250
movslq %r15d, %rcx
sarq $0x5, %rax
decq %rax
cmpq %rcx, %rax
je 0x6427
movl 0x30(%rsp), %eax
movl %eax, 0x4(%rsp)
movb $0x1, %al
movq %rax, 0x48(%rsp)
movb $0x1, 0x3(%rsp)
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmpl %r14d, %ebp
jge 0x643e
movq 0x1ab9f(%rip), %r14     # 0x20fd8
jmp 0x65d9
testb $0x1, 0x3(%rsp)
movq 0x1ab8e(%rip), %r14     # 0x20fd8
je 0x6545
movq (%r14), %rdi
testb $0x1, 0x48(%rsp)
je 0x6588
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq (%r14), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
movslq 0x4(%rsp), %r12
cmpl $-0x1, %eax
je 0x64c2
movq (%r14), %rbp
movq 0x30(%rsp), %rcx
subq %r12, %rcx
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
xorl %edx, %edx
callq 0x5270
movq 0x8(%rsp), %rsi
movq %rbp, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x64c2
callq 0x5230
movq (%r14), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%r14), %rdi
movl 0x30(%rsp), %edx
subl 0x4(%rsp), %edx
movl %ebx, %esi
callq 0x5280
cmpl $-0x1, %eax
je 0x652b
movq (%r14), %rbp
movq 0x30(%rsp), %rdx
subq %r12, %rdx
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r12, %rcx
callq 0x5270
movq 0x8(%rsp), %rsi
movq %rbp, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x652b
callq 0x5230
movq (%r14), %rdi
movq $0x0, 0x48(%rsp)
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
jmp 0x65b7
movq (%r14), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%r14), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x6577
movq (%r14), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq (%r14), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
jmp 0x65b7
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq (%r14), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x65b7
movq (%r14), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
leaq 0x13b99(%rip), %rcx     # 0x1a163
xorl %r8d, %r8d
callq 0x5380
decl %ebx
leaq 0x60(%rsp), %r12
testl %ebx, %ebx
js 0x65e6
testl %r15d, %r15d
jns 0x612f
testb $0x1, 0x3(%rsp)
je 0x6709
testb $0x1, 0x48(%rsp)
leaq 0x80(%rsp), %r13
je 0x6760
movq (%r14), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
movq %r14, %r15
leaq 0x38(%rsp), %r14
callq 0x5310
movq (%r15), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
movslq 0x4(%rsp), %r12
cmpl $-0x1, %eax
je 0x6681
movq 0x1a9a0(%rip), %rax     # 0x20fd8
movq (%rax), %r13
leaq 0x28(%rsp), %rsi
movq 0x8(%rsi), %rcx
subq %r12, %rcx
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0x5270
movq 0x8(%rsp), %rsi
movq %r13, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
leaq 0x80(%rsp), %r13
je 0x6681
callq 0x5230
movq 0x1a950(%rip), %r15     # 0x20fd8
movq (%r15), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%r15), %rdi
movl 0x30(%rsp), %edx
subl 0x4(%rsp), %edx
movl %ebx, %esi
callq 0x5280
cmpl $-0x1, %eax
je 0x674f
movq (%r15), %rbx
leaq 0x28(%rsp), %rsi
movq 0x8(%rsi), %rdx
subq %r12, %rdx
leaq 0x8(%rsp), %rdi
movq %r12, %rcx
callq 0x5270
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x66f4
callq 0x5230
movq 0x1a8dd(%rip), %r15     # 0x20fd8
jmp 0x674f
movl $0x5, %ebx
cmpq %rcx, %rax
jne 0x6716
jmp 0x6765
leaq 0x38(%rsp), %r14
leaq 0x80(%rsp), %r13
movq 0x1a8bb(%rip), %r15     # 0x20fd8
movq (%r15), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%r15), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x674f
movq (%r15), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq (%r15), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
jmp 0x679e
leaq 0x38(%rsp), %r14
movq 0x1a86c(%rip), %r15     # 0x20fd8
movq (%r15), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq (%r15), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x679e
movq (%r15), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
leaq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x139b5(%rip), %rcx     # 0x1a163
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x5380
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x67c7
callq 0x5230
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x67d6
callq 0x5230
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x67f4
jmp 0x6859
jmp 0x67f4
jmp 0x6859
jmp 0x67f4
jmp 0x6859
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
jmp 0x684d
jmp 0x6859
movq %rax, %rbx
jmp 0x6869
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
jne 0x6838
jmp 0x683d
jmp 0x6824
jmp 0x6859
jmp 0x6859
movq %rax, %rbx
jmp 0x683d
jmp 0x6859
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r12, %rdi
je 0x683d
callq 0x5230
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x685c
callq 0x5230
jmp 0x685c
movq %rax, %rbx
leaq 0x38(%rsp), %r14
leaq 0x80(%rsp), %r13
movq 0x70(%rsp), %rdi
cmpq %r13, %rdi
je 0x6878
callq 0x5230
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x6887
callq 0x5230
movq %rbx, %rdi
callq 0x53d0