// File: iZhangHui[P]CppPrimer/CH07_Classes/examples/useScreen.cc
// Function: main
int main()
{
	Screen myScreen(5,3);
	// move the cursor to a given position, and set that character 
	myScreen.move(4,0).set('#');

	Screen nextScreen(5, 5, 'X');
	nextScreen.move(4,0).set('#').display(cout);
	cout << "\n";
	nextScreen.display(cout);
	cout << endl;

	const Screen blank(5, 3);
	myScreen.set('#').display(cout);  // calls nonconst version
	cout << endl;
	blank.display(cout);              // calls const version
	cout << endl;

	myScreen.clear('Z').display(cout); cout << endl;
	myScreen.move(4,0);
	myScreen.set('#');
	myScreen.display(cout); cout << endl;
	myScreen.clear('Z').display(cout); cout << endl;

	// if move returns Screen not Screen&
	Screen temp = myScreen.move(4,0); // the return value would be copied
	temp.set('#'); // the contents inside myScreen would be unchanged
	myScreen.display(cout);
	cout << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
leaq -0x38(%rbp), %rdi
movq %rdi, -0x100(%rbp)
movl $0x5, %esi
movl $0x3, %edx
callq 0x1630
movq -0x100(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x4, %esi
callq 0x16d0
movq %rax, -0xf8(%rbp)
jmp 0x1323
movq -0xf8(%rbp), %rdi
movl $0x23, %esi
callq 0x1700
jmp 0x1336
leaq -0x80(%rbp), %rdi
movl $0x5, %edx
movl $0x58, %ecx
movq %rdx, %rsi
callq 0x1750
jmp 0x134e
xorl %eax, %eax
movl %eax, %edx
leaq -0x80(%rbp), %rdi
movl $0x4, %esi
callq 0x16d0
movq %rax, -0x108(%rbp)
jmp 0x1369
movq -0x108(%rbp), %rdi
movl $0x23, %esi
callq 0x1700
movq %rax, -0x110(%rbp)
jmp 0x1383
movq -0x110(%rbp), %rdi
movq 0x2c47(%rip), %rsi      # 0x3fd8
callq 0x1800
jmp 0x1398
movq 0x2c39(%rip), %rdi      # 0x3fd8
leaq 0xc5e(%rip), %rsi       # 0x2004
callq 0x1080
jmp 0x13ad
movq 0x2c24(%rip), %rsi      # 0x3fd8
leaq -0x80(%rbp), %rdi
callq 0x1800
jmp 0x13bf
movq 0x2c12(%rip), %rdi      # 0x3fd8
movq 0x2bfb(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x13d4
leaq -0xb8(%rbp), %rdi
movl $0x5, %esi
movl $0x3, %edx
callq 0x1630
jmp 0x13ec
leaq -0x38(%rbp), %rdi
movl $0x23, %esi
callq 0x1700
movq %rax, -0x118(%rbp)
jmp 0x1403
movq -0x118(%rbp), %rdi
movq 0x2bc7(%rip), %rsi      # 0x3fd8
callq 0x1800
jmp 0x1418
movq 0x2bb9(%rip), %rdi      # 0x3fd8
movq 0x2ba2(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x142d
movq 0x2ba4(%rip), %rsi      # 0x3fd8
leaq -0xb8(%rbp), %rdi
callq 0x1830
jmp 0x1442
movq 0x2b8f(%rip), %rdi      # 0x3fd8
movq 0x2b78(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x1457
leaq -0x38(%rbp), %rdi
movl $0x5a, %esi
callq 0x1240
movq %rax, -0x120(%rbp)
jmp 0x146e
movq -0x120(%rbp), %rdi
movq 0x2b5c(%rip), %rsi      # 0x3fd8
callq 0x1800
jmp 0x1483
movq 0x2b4e(%rip), %rdi      # 0x3fd8
movq 0x2b37(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x1498
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x16d0
jmp 0x14ac
leaq -0x38(%rbp), %rdi
movl $0x23, %esi
callq 0x1700
jmp 0x14bc
movq 0x2b15(%rip), %rsi      # 0x3fd8
leaq -0x38(%rbp), %rdi
callq 0x1800
jmp 0x14ce
movq 0x2b03(%rip), %rdi      # 0x3fd8
movq 0x2aec(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x14e3
leaq -0x38(%rbp), %rdi
movl $0x5a, %esi
callq 0x1240
movq %rax, -0x128(%rbp)
jmp 0x14fa
movq -0x128(%rbp), %rdi
movq 0x2ad0(%rip), %rsi      # 0x3fd8
callq 0x1800
jmp 0x150f
movq 0x2ac2(%rip), %rdi      # 0x3fd8
movq 0x2aab(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x1524
xorl %eax, %eax
movl %eax, %edx
leaq -0x38(%rbp), %rdi
movl $0x4, %esi
callq 0x16d0
movq %rax, -0x130(%rbp)
jmp 0x153f
movq -0x130(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x1860
jmp 0x1554
leaq -0xf0(%rbp), %rdi
movl $0x23, %esi
callq 0x1700
jmp 0x1567
movq 0x2a6a(%rip), %rsi      # 0x3fd8
leaq -0x38(%rbp), %rdi
callq 0x1800
jmp 0x1579
movq 0x2a58(%rip), %rdi      # 0x3fd8
movq 0x2a41(%rip), %rsi      # 0x3fc8
callq 0x1090
jmp 0x158e
leaq -0xf0(%rbp), %rdi
callq 0x18b0
leaq -0xb8(%rbp), %rdi
callq 0x18b0
leaq -0x80(%rbp), %rdi
callq 0x18b0
leaq -0x38(%rbp), %rdi
callq 0x18b0
xorl %eax, %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x161a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1611
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1605
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x18b0
leaq -0xb8(%rbp), %rdi
callq 0x18b0
leaq -0x80(%rbp), %rdi
callq 0x18b0
leaq -0x38(%rbp), %rdi
callq 0x18b0
movq -0x40(%rbp), %rdi
callq 0x10d0
nopl (%rax)