// File: /workspace/github_cpp_makefile_star2_O1/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 0x1af87(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
xorl %r15d, %r15d
movl $0x700, %esi            # imm = 0x700
xorl %edx, %edx
callq 0x5150
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x14080(%rip), %rdx     # 0x1a0f3
leaq 0x28(%rsp), %rdi
movq %rdx, %rsi
callq 0x16274
movq 0x681e1(%rip), %r13     # 0x6e268
subq 0x681d2(%rip), %r13     # 0x6e260
sarq $0x5, %r13
movslq 0x681e3(%rip), %rax     # 0x6e27c
movq %r13, %rcx
decq %rcx
cmpq %rax, %rcx
sete %dl
decl %r13d
leaq 0xa0(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
js 0x65f5
cmpq %rax, %rcx
sete 0x3(%rsp)
leaq 0x18(%rsp), %r14
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0x5, %ebx
movq $0x0, 0x48(%rsp)
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl %r15d, %ebp
cmpl $-0x1, %r15d
jne 0x611d
movl %r13d, %esi
shlq $0x5, %rsi
addq 0x6815a(%rip), %rsi     # 0x6e260
leaq 0x90(%rsp), %rdi
callq 0x5170
movl 0x98(%rsp), %ebp
movl %ebp, %r15d
movl $0x30, %r12d
subl 0x30(%rsp), %r12d
subl %r12d, %r15d
jge 0x6190
movslq %ebp, %rcx
leaq 0x70(%rsp), %r15
movq %r15, %rdi
leaq 0x90(%rsp), %rsi
xorl %edx, %edx
callq 0x5270
movq 0x78(%rsp), %rsi
movl $0x1, %ecx
movq %r15, %rdi
xorl %edx, %edx
movl $0x20, %r8d
callq 0x5400
leaq 0x60(%rsp), %r15
movq %r15, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6211
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x6218
cmpl $0x30, %ebp
jl 0x620a
movq %r13, 0xb0(%rsp)
movl %ebx, %r13d
movq %r14, %rbx
movslq %r15d, %rdx
movslq %r12d, %rcx
leaq 0x70(%rsp), %r14
movq %r14, %rdi
leaq 0x90(%rsp), %rsi
callq 0x5270
movq 0x78(%rsp), %rsi
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
movl $0x20, %r8d
callq 0x5400
leaq 0x60(%rsp), %rsi
movq %rsi, 0x50(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
movq %rbx, %r14
je 0x62d4
movq %rdx, 0x50(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x60(%rsp)
jmp 0x62da
xorl %eax, %eax
jmp 0x62cc
movups (%rcx), %xmm0
movups %xmm0, (%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
movq %r14, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6267
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x626e
movups (%rcx), %xmm0
movups %xmm0, (%r14)
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 %r14, %rdi
je 0x62a4
callq 0x5230
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x62b3
callq 0x5230
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x62ca
callq 0x5230
movb $0x1, %al
movl %ebp, %r15d
jmp 0x63a2
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movl %r13d, %ebx
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 0xb0(%rsp), %r13
movq %r14, 0x8(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x6334
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x633b
movups (%rcx), %xmm0
movups %xmm0, (%r14)
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 %r14, %rdi
je 0x6371
callq 0x5230
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6385
callq 0x5230
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x639c
callq 0x5230
testl %r15d, %r15d
sete %al
testb %al, %al
je 0x63e9
decl %r13d
movslq 0x67ecc(%rip), %rax     # 0x6e27c
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl %eax, %r13d
jne 0x63e9
movq 0x67ea6(%rip), %rcx     # 0x6e268
subq 0x67e97(%rip), %rcx     # 0x6e260
sarq $0x5, %rcx
decq %rcx
cmpq %rax, %rcx
je 0x63e9
movl 0x30(%rsp), %eax
movl %eax, 0x4(%rsp)
movb $0x1, %al
movq %rax, 0x48(%rsp)
movb $0x1, 0x3(%rsp)
cmpl %r12d, %ebp
jl 0x65d5
testb $0x1, 0x3(%rsp)
je 0x651c
movq 0x1abd4(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
testb $0x1, 0x48(%rsp)
je 0x657b
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq 0x1abb3(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
movslq 0x4(%rsp), %r12
cmpl $-0x1, %eax
je 0x647f
movq 0x1ab96(%rip), %rax     # 0x20fd8
movq (%rax), %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
cmpq %r14, %rdi
je 0x647f
callq 0x5230
movq 0x1ab52(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq 0x1ab3c(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl 0x30(%rsp), %edx
subl 0x4(%rsp), %edx
movl %ebx, %esi
callq 0x5280
cmpl $-0x1, %eax
je 0x64f8
movq 0x1ab1e(%rip), %rax     # 0x20fd8
movq (%rax), %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
cmpq %r14, %rdi
je 0x64f8
callq 0x5230
movq 0x1aad9(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movq $0x0, 0x48(%rsp)
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
jmp 0x65b8
movq 0x1aab5(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq 0x1aa9f(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x6563
movq 0x1aa87(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x1aa6e(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
jmp 0x65b8
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq 0x1aa4a(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x65b8
movq 0x1aa32(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x30(%rsp), %rdx
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
leaq 0x13b28(%rip), %rcx     # 0x1a0f3
xorl %r8d, %r8d
callq 0x5380
decl %ebx
testl %ebx, %ebx
js 0x65e2
testl %r13d, %r13d
jns 0x60ef
leaq 0xa0(%rsp), %r14
movb 0x3(%rsp), %dl
movq 0x48(%rsp), %r15
jmp 0x6602
movl $0x5, %ebx
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq 0x1a9cf(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
testb $0x1, %dl
je 0x6711
testb $0x1, %r15b
je 0x67b6
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq 0x1a9a6(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
movslq 0x4(%rsp), %r12
cmpl $-0x1, %eax
je 0x668f
movq 0x1a989(%rip), %rax     # 0x20fd8
movq (%rax), %r15
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 %r15, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x668f
callq 0x5230
movq 0x1a942(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq 0x1a92c(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl 0x30(%rsp), %edx
subl 0x4(%rsp), %edx
movl %ebx, %esi
callq 0x5280
cmpl $-0x1, %eax
je 0x674e
movq 0x1a90a(%rip), %rax     # 0x20fd8
movq (%rax), %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
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x674e
callq 0x5230
jmp 0x674e
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5150
movq 0x1a8b4(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x674e
movq 0x1a89c(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
movq 0x1a883(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
leaq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x1397f(%rip), %rcx     # 0x1a0f3
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x5380
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0x6790
callq 0x5230
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x67a4
callq 0x5230
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x200000, %esi         # imm = 0x200000
xorl %edx, %edx
callq 0x5310
movq 0x1a80f(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x5280
cmpl $-0x1, %eax
je 0x6764
movq 0x1a7f7(%rip), %rax     # 0x20fd8
movq (%rax), %rdi
movq 0x28(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x50d0
jmp 0x6764
jmp 0x67fc
jmp 0x686f
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x6863
jmp 0x686f
jmp 0x6810
jmp 0x686f
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
jne 0x6868
jmp 0x6872
jmp 0x686f
jmp 0x686f
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
jne 0x6851
jmp 0x6856
jmp 0x683d
jmp 0x686f
jmp 0x686f
movq %rax, %rbx
jmp 0x6856
jmp 0x686f
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x6856
callq 0x5230
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x6872
callq 0x5230
jmp 0x6872
movq %rax, %rbx
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x688c
callq 0x5230
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x68a0
callq 0x5230
movq %rbx, %rdi
callq 0x53d0