// File: /workspace/github_cpp_makefile_star2_O2/MatthewZMD[P]TetrisDual/textdisplay.cc
// Function: operator<<(std::ostream&, TextDisplay const&)
std::ostream& operator<<(std::ostream &out, const TextDisplay &td) {
	int cSpace = 6;
	int numberOfPlayers = (int)td.boardData.size();
	int numberOfRows = (int)td.boardData.at(0).size();
	int numberOfColumns = (int)td.boardData.at(0).at(0).size();

	// level
	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}
		out << "Level:" << std::setw(numberOfColumns - 6) << td.level.at(i);
	}
	out << std::endl;

	// score
	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}
		out << "Score:" << std::setw(numberOfColumns - 6) << td.score.at(i);
	}
	out << std::endl;

	// separator
	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}
		for (int j = 0; j < numberOfColumns; ++j) {
			out << "-";
		}
	}
	out << std::endl;

	// board data
	for (int r = 0; r < numberOfRows; ++r) {
		for (int i = 0; i < numberOfPlayers; ++i) {
			if (i > 0) {
				out << std::setw(cSpace) << "";
			}
			for (int c = 0; c < numberOfColumns; ++c) {
				out << td.boardData.at(i).at(r).at(c);
			}
		}
		out << std::endl;
	}

	// separator
	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}
		for (int j = 0; j < numberOfColumns; ++j) {
			out << "-";
		}
	}
	out << std::endl;

	// next block
	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}
		out << std::left << std::setw(numberOfColumns) << "Next:";
	}
	out << std::endl;

	// next type
	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}

		std::string str;
		if (td.nextType.at(i) == CellType::I) {
			str = "";
		}
		else if (td.nextType.at(i) == CellType::J) {
			str = "J";;
		}
		else if (td.nextType.at(i) == CellType::L) {
			str = "  L";
		}
		else if (td.nextType.at(i) == CellType::O) {
			str = "OO";
		}
		else if (td.nextType.at(i) == CellType::S) {
			str = " SS";
		}
		else if (td.nextType.at(i) == CellType::Z) {
			str = "ZZ";
		}
		else if (td.nextType.at(i) == CellType::T) {
			str = "TTT";
		}
		else if (td.nextType.at(i) == CellType::E) {
			str = "";
		}

		out << std::left << std::setw(numberOfColumns) << str;
	}
	out << std::endl;

	for (int i = 0; i < numberOfPlayers; ++i) {
		if (i > 0) {
			out << std::setw(cSpace) << "";
		}

		std::string str;
		if (td.nextType.at(i) == CellType::I) {
			str = "IIII";
		}
		else if (td.nextType.at(i) == CellType::J) {
			str = "JJJ";;
		}
		else if (td.nextType.at(i) == CellType::L) {
			str = "LLL";
		}
		else if (td.nextType.at(i) == CellType::O) {
			str = "OO";
		}
		else if (td.nextType.at(i) == CellType::S) {
			str = "SS";
		}
		else if (td.nextType.at(i) == CellType::Z) {
			str = " ZZ";
		}
		else if (td.nextType.at(i) == CellType::T) {
			str = " T";
		}
		else if (td.nextType.at(i) == CellType::E) {
			str = "";
		}

		out << std::left << std::setw(numberOfColumns) << str;
	}
	out << std::endl;

	return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x38(%rsi), %r15
movq 0x40(%rsi), %rax
subq 0x38(%rsi), %rax
pushq $0x18
popq %rbp
cqto
idivq %rbp
movq %rax, %r14
xorl %r13d, %r13d
movq %r15, %rdi
xorl %esi, %esi
callq 0xe6ea
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, %rax
cqto
idivq %rbp
movq %rax, 0x20(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0xe6ea
movq %rax, %rdi
xorl %esi, %esi
callq 0xe708
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, %rax
shlq $0x20, %rax
movabsq $-0x600000000, %rbp     # imm = 0xFFFFFFFA00000000
movq %rax, 0x18(%rsp)
addq %rax, %rbp
sarq $0x20, %rbp
movq %r12, (%rsp)
addq $0x8, %r12
testl %r14d, %r14d
movl $0x0, %eax
cmovgl %r14d, %eax
movq %rax, 0x8(%rsp)
cmpq %r13, 0x8(%rsp)
je 0xdf5a
testq %r13, %r13
je 0xdf22
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
leaq 0x3adc(%rip), %rsi      # 0x119f9
callq 0x5290
movq %rbx, %rdi
leaq 0x39ce(%rip), %rsi      # 0x118fa
callq 0x5290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rax
movq %rbp, 0x10(%r14,%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0xe726
movl (%rax), %esi
movq %r14, %rdi
callq 0x54a0
incq %r13
jmp 0xdef7
movq %rbx, %rdi
callq 0x5160
movq (%rsp), %rax
leaq 0x20(%rax), %r12
xorl %r13d, %r13d
cmpq %r13, 0x8(%rsp)
je 0xdfd0
testq %r13, %r13
je 0xdf98
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
leaq 0x3a66(%rip), %rsi      # 0x119f9
callq 0x5290
movq %rbx, %rdi
leaq 0x395f(%rip), %rsi      # 0x11901
callq 0x5290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rax
movq %rbp, 0x10(%r14,%rax)
movq %r12, %rdi
movq %r13, %rsi
callq 0xe726
movl (%rax), %esi
movq %r14, %rdi
callq 0x54a0
incq %r13
jmp 0xdf6d
movq %rbx, %rdi
callq 0x5160
xorl %ebp, %ebp
movq 0x10(%rsp), %rax
testl %eax, %eax
cmovlel %ebp, %eax
movq %rax, 0x10(%rsp)
leaq 0x3b46(%rip), %r12      # 0x11b36
leaq 0x3a02(%rip), %r13      # 0x119f9
cmpl 0x8(%rsp), %ebp
je 0xe03b
testl %ebp, %ebp
je 0xe01c
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5290
movq 0x10(%rsp), %rax
movl %eax, %r14d
subl $0x1, %r14d
jb 0xe037
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5290
jmp 0xe024
incl %ebp
jmp 0xdff7
movq %rbx, %rdi
callq 0x5160
xorl %r13d, %r13d
movq 0x20(%rsp), %rax
testl %eax, %eax
cmovlel %r13d, %eax
movq %rax, 0x20(%rsp)
movl 0x10(%rsp), %ebp
cmpq 0x20(%rsp), %r13
je 0xe0da
xorl %r12d, %r12d
cmpq 0x8(%rsp), %r12
je 0xe0cd
testq %r12, %r12
je 0xe08f
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
leaq 0x396f(%rip), %rsi      # 0x119f9
callq 0x5290
xorl %r14d, %r14d
cmpq %r14, %rbp
je 0xe0c8
movq %r15, %rdi
movq %r12, %rsi
callq 0xe6ea
movq %rax, %rdi
movq %r13, %rsi
callq 0xe708
movq %rax, %rdi
movq %r14, %rsi
callq 0xe748
movsbl (%rax), %esi
movq %rbx, %rdi
callq 0x5300
incq %r14
jmp 0xe092
incq %r12
jmp 0xe064
movq %rbx, %rdi
callq 0x5160
incq %r13
jmp 0xe05a
xorl %ebp, %ebp
leaq 0x3a53(%rip), %r15      # 0x11b36
leaq 0x390f(%rip), %r12      # 0x119f9
cmpl 0x8(%rsp), %ebp
je 0xe12e
testl %ebp, %ebp
je 0xe10f
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5290
movq 0x10(%rsp), %rax
movl %eax, %r14d
subl $0x1, %r14d
jb 0xe12a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5290
jmp 0xe117
incl %ebp
jmp 0xe0ea
movq %rbx, %rdi
callq 0x5160
sarq $0x20, 0x18(%rsp)
xorl %ebp, %ebp
movl $0xffffff4f, %r14d      # imm = 0xFFFFFF4F
leaq 0x37bd(%rip), %r12      # 0x11908
leaq 0x38a7(%rip), %r15      # 0x119f9
cmpl %ebp, 0x8(%rsp)
je 0xe1a9
testl %ebp, %ebp
je 0xe177
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5290
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r14d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5290
incl %ebp
jmp 0xe152
movq %rbx, %rdi
callq 0x5160
leaq 0x38(%rsp), %r14
addq $0x50, (%rsp)
xorl %r12d, %r12d
leaq 0x28(%rsp), %r13
movl $0xffffff4f, %ebp       # imm = 0xFFFFFF4F
cmpq %r12, 0x8(%rsp)
je 0xe308
testq %r12, %r12
je 0xe1f3
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5290
movq %r14, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x0, (%rax)
movq %r15, %rsi
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x1, (%rax)
leaq 0x36f3(%rip), %rsi      # 0x11924
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x2, (%rax)
leaq 0x36c1(%rip), %rsi      # 0x1190e
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x3, (%rax)
leaq 0x36ad(%rip), %rsi      # 0x11912
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x4, (%rax)
leaq 0x3698(%rip), %rsi      # 0x11915
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x5, (%rax)
leaq 0x3696(%rip), %rsi      # 0x1192b
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x6, (%rax)
leaq 0x366c(%rip), %rsi      # 0x11919
je 0xe2c3
movq (%rsp), %rdi
movq %r12, %rsi
callq 0xe766
cmpl $0x7, (%rax)
movq %r15, %rsi
jne 0xe2cb
movq %r13, %rdi
callq 0x5530
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %ebp, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x5270
movq %r13, %rdi
callq 0x5150
incq %r12
jmp 0xe1c8
movq %rbx, %rdi
callq 0x5160
xorl %r15d, %r15d
leaq 0x3603(%rip), %rbp      # 0x1191d
leaq 0x28(%rsp), %r12
movl $0xffffff4f, %r13d      # imm = 0xFFFFFF4F
cmpq %r15, 0x8(%rsp)
je 0xe46e
testq %r15, %r15
je 0xe354
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x6, 0x10(%rbx,%rax)
movq %rbx, %rdi
leaq 0x36aa(%rip), %rsi      # 0x119f9
callq 0x5290
movq %r14, 0x28(%rsp)
andq $0x0, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x0, (%rax)
movq %rbp, %rsi
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x1, (%rax)
leaq 0x3590(%rip), %rsi      # 0x11922
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x2, (%rax)
leaq 0x3578(%rip), %rsi      # 0x11926
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x3, (%rax)
leaq 0x354c(%rip), %rsi      # 0x11912
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x4, (%rax)
leaq 0x3538(%rip), %rsi      # 0x11916
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x5, (%rax)
leaq 0x3534(%rip), %rsi      # 0x1192a
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x6, (%rax)
leaq 0x3520(%rip), %rsi      # 0x1192e
je 0xe428
movq (%rsp), %rdi
movq %r15, %rsi
callq 0xe766
cmpl $0x7, (%rax)
leaq 0x35d3(%rip), %rsi      # 0x119f9
jne 0xe430
movq %r12, %rdi
callq 0x5530
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r13d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x10(%rbx,%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5270
movq %r12, %rdi
callq 0x5150
incq %r15
jmp 0xe325
movq %rbx, %rdi
callq 0x5160
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe48a
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5150
movq %rbx, %rdi
callq 0x54b0
nop