// File: /workspace/github_cpp_makefile_star2_O2/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 $0xc8, %rsp
movq 0x18264(%rip), %rax     # 0x1dfd8
movq (%rax), %rdi
movq $0x0, 0x40(%rsp)
movl $0x700, %esi            # imm = 0x700
xorl %edx, %edx
callq 0x5150
leaq 0x10329(%rip), %rsi     # 0x160bc
leaq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x5110
movq 0x654af(%rip), %rax     # 0x6b258
subq 0x654a0(%rip), %rax     # 0x6b250
leaq 0x78(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
sarq $0x5, %rax
leal -0x1(%rax), %r12d
movb $0x0, (%rcx)
movslq 0x6549c(%rip), %rcx     # 0x6b26c
decq %rax
cmpq %rcx, %rax
sete 0x7(%rsp)
pushq $0x5
popq %rax
movl %eax, 0x8(%rsp)
pushq $-0x1
popq %rax
leaq 0xa8(%rsp), %rbp
leaq 0x48(%rsp), %r14
movl %eax, %r13d
movl %eax, 0xc(%rsp)
leal -0x1(%r12), %eax
movslq %eax, %rbx
cmpl $0x0, 0x8(%rsp)
js 0x6144
testl %r12d, %r12d
js 0x6144
movq %r12, 0x10(%rsp)
cmpl $-0x1, %r13d
jne 0x5e3e
movl 0x10(%rsp), %esi
shlq $0x5, %rsi
addq 0x65421(%rip), %rsi     # 0x6b250
leaq 0x68(%rsp), %rdi
callq 0x5170
movl 0x70(%rsp), %r13d
movl %r13d, %eax
pushq $0x30
popq %r13
subl 0x28(%rsp), %r13d
movl %eax, %r15d
subl %r13d, %r15d
movl %eax, 0x18(%rsp)
jge 0x5ebb
movslq %eax, %rcx
leaq 0x88(%rsp), %r15
movq %r15, %rdi
leaq 0x68(%rsp), %rsi
xorl %edx, %edx
callq 0x5250
movq %rbp, %rdi
movq %r15, %rsi
pushq $0x20
popq %rdx
callq 0x10d05
leaq 0x20(%rsp), %r15
movq %r14, %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x10ce6
movq %r15, %rdi
movq %r14, %rsi
callq 0x52e0
movq %r14, %rdi
callq 0x5418
movq %rbp, %rdi
callq 0x5418
leaq 0x88(%rsp), %rdi
callq 0x5418
jmp 0x5f38
cmpl $0x30, %eax
jl 0x5f9b
movq %rbp, %r14
movslq %r15d, %rdx
movslq %r13d, %rcx
leaq 0x88(%rsp), %rbp
movq %rbp, %rdi
leaq 0x68(%rsp), %rsi
callq 0x5250
movq %r14, %rdi
movq %rbp, %rsi
pushq $0x20
popq %rdx
callq 0x10d05
leaq 0x48(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rbp
movq %rbp, %rdx
callq 0x10ce6
movq %rbp, %rdi
movq %r12, %rsi
callq 0x52e0
movq %r12, %rdi
callq 0x5418
movq %r14, %rdi
callq 0x5418
leaq 0x88(%rsp), %rdi
callq 0x5418
testl %r15d, %r15d
movq %r14, %rbp
jne 0x5fac
cmpl 0x6532e(%rip), %ebx     # 0x6b26c
jne 0x5f75
movq 0x65311(%rip), %rax     # 0x6b258
subq 0x65302(%rip), %rax     # 0x6b250
sarq $0x5, %rax
decq %rax
cmpq %rax, %rbx
leaq 0x20(%rsp), %r15
je 0x5f7a
movl 0x28(%rsp), %eax
movl %eax, 0xc(%rsp)
movb $0x1, %al
movq %rax, 0x40(%rsp)
movb $0x1, 0x7(%rsp)
jmp 0x5f7a
leaq 0x20(%rsp), %r15
decq %rbx
movq 0x10(%rsp), %r12
decl %r12d
cmpl %r13d, 0x18(%rsp)
pushq $-0x1
popq %r13
leaq 0x48(%rsp), %r14
jl 0x5e01
jmp 0x5fbc
leaq 0x20(%rsp), %r15
movq 0x10(%rsp), %r12
movl 0x18(%rsp), %r13d
jmp 0x5fbc
movq %r12, %r14
movl %r15d, %r13d
leaq 0x20(%rsp), %r15
movq 0x10(%rsp), %r12
testb $0x1, 0x7(%rsp)
movq 0x18010(%rip), %rbx     # 0x1dfd8
je 0x60ba
movq (%rbx), %rdi
testb $0x1, 0x40(%rsp)
je 0x60fd
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
callq 0x5260
movslq 0xc(%rsp), %rcx
movq %rcx, 0x10(%rsp)
cmpl $-0x1, %eax
je 0x603e
movq (%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rcx
subq 0x10(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5250
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdi
pushq $-0x1
popq %rdx
callq 0x50d0
movq %r14, %rdi
callq 0x5418
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%rbx), %rdi
movl 0x28(%rsp), %edx
subl 0xc(%rsp), %edx
movl 0x8(%rsp), %esi
callq 0x5260
cmpl $-0x1, %eax
je 0x60a0
movq (%rbx), %rax
movq %rax, 0x18(%rsp)
movq 0x28(%rsp), %rdx
movq 0x10(%rsp), %rcx
subq %rcx, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x5250
movq 0x48(%rsp), %rsi
movq 0x18(%rsp), %rdi
pushq $-0x1
popq %rdx
callq 0x50d0
movq %r14, %rdi
callq 0x5418
movq (%rbx), %rdi
movq $0x0, 0x40(%rsp)
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
jmp 0x612c
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
callq 0x5260
cmpl $-0x1, %eax
je 0x60ec
movq (%rbx), %rdi
movq 0x20(%rsp), %rsi
pushq $-0x1
popq %rdx
callq 0x50d0
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
jmp 0x612c
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
callq 0x5260
cmpl $-0x1, %eax
je 0x612c
movq (%rbx), %rdi
movq 0x20(%rsp), %rsi
pushq $-0x1
popq %rdx
callq 0x50d0
decl 0x8(%rsp)
movq %r15, %rdi
leaq 0xff82(%rip), %rsi      # 0x160bc
callq 0x53f0
jmp 0x5df9
testb $0x1, 0x7(%rsp)
je 0x6224
movq 0x17e82(%rip), %rbx     # 0x1dfd8
movq (%rbx), %rdi
testb $0x1, 0x40(%rsp)
je 0x62a3
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
callq 0x5260
movslq 0xc(%rsp), %r14
cmpl $-0x1, %eax
je 0x61bd
movq (%rbx), %r15
leaq 0x20(%rsp), %rsi
movq 0x8(%rsi), %rcx
subq %r14, %rcx
leaq 0x48(%rsp), %rdi
xorl %edx, %edx
callq 0x5250
movq 0x48(%rsp), %rsi
pushq $-0x1
popq %rdx
movq %r15, %rdi
callq 0x50d0
leaq 0x48(%rsp), %rdi
callq 0x5418
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%rbx), %rdi
movl 0x28(%rsp), %edx
subl 0xc(%rsp), %edx
movl 0x8(%rsp), %esi
callq 0x5260
cmpl $-0x1, %eax
je 0x625d
movq (%rbx), %rbx
leaq 0x20(%rsp), %rsi
movq 0x8(%rsi), %rdx
subq %r14, %rdx
leaq 0x48(%rsp), %rdi
movq %r14, %rcx
callq 0x5250
movq 0x48(%rsp), %rsi
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x50d0
leaq 0x48(%rsp), %rdi
callq 0x5418
movq 0x17db6(%rip), %rbx     # 0x1dfd8
jmp 0x625d
movq 0x17dad(%rip), %rbx     # 0x1dfd8
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
callq 0x5260
cmpl $-0x1, %eax
je 0x625d
movq (%rbx), %rdi
movq 0x20(%rsp), %rsi
pushq $-0x1
popq %rdx
callq 0x50d0
movq (%rbx), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
leaq 0xfe49(%rip), %rsi      # 0x160bc
leaq 0x20(%rsp), %rdi
callq 0x53f0
leaq 0x68(%rsp), %rdi
callq 0x5418
leaq 0x20(%rsp), %rdi
callq 0x5418
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x52f0
movq (%rbx), %rdi
movl 0x8(%rsp), %esi
xorl %edx, %edx
callq 0x5260
cmpl $-0x1, %eax
je 0x626c
movq (%rbx), %rdi
movq 0x20(%rsp), %rsi
pushq $-0x1
popq %rdx
callq 0x50d0
jmp 0x626c
jmp 0x62e2
jmp 0x631c
jmp 0x62e2
jmp 0x631c
jmp 0x62e2
jmp 0x631c
jmp 0x631c
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0x6315
jmp 0x631c
jmp 0x631c
jmp 0x631c
jmp 0x62f8
jmp 0x631c
jmp 0x62fd
movq %rax, %rbx
jmp 0x630d
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x5418
leaq 0x88(%rsp), %rdi
callq 0x5418
jmp 0x631f
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x5418
leaq 0x20(%rsp), %rdi
callq 0x5418
movq %rbx, %rdi
callq 0x53c0