// File: iZhangHui[P]CppPrimer/CH04_Expressions/examples/oofe.cc
// Function: main
int main()
{
	int i = 0;
	cout << i << " " << ++i << endl;  // undefined

	string s("a string"), orig = s;
	cout << toupper(s) << endl;  // changes s to  uppercase
	cout << tolower(s) << endl;  // changes s to lowercase

	s = orig;
	// the calls to toupper and tolower change the value of s
	// << doesn't guarantee order of evaluation, 
	// so this expression is undefined
	cout << toupper(s) << " " << tolower(s) << endl; 

	string first = toupper(s);  // we control the order of evaluation
	string second = tolower(s); // by storing the results in the order in which we want

	cout << first << " " << second << endl;  // one possible evaluation
	cout << second << " " << first << endl;  // equally legal evaluation!
	cout << first << " " << first << endl;   // another legal evaluation!
	cout << second << " " << second << endl; // and a fourth!

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movl $0x0, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %esi
movq 0x2c35(%rip), %rdi      # 0x3fd8
callq 0x1100
movq %rax, %rdi
leaq 0xc52(%rip), %rsi       # 0x2004
callq 0x10a0
movq %rax, %rdi
movl -0x8(%rbp), %esi
incl %esi
movl %esi, -0x8(%rbp)
callq 0x1100
movq %rax, %rdi
movq 0x2bf7(%rip), %rsi      # 0x3fc8
callq 0x10b0
leaq -0x29(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x1120
movq -0xa8(%rbp), %rdx
leaq 0xc12(%rip), %rsi       # 0x2006
leaq -0x28(%rbp), %rdi
callq 0x10d0
jmp 0x13ff
leaq -0x29(%rbp), %rdi
callq 0x10c0
leaq -0x60(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1040
jmp 0x1417
leaq -0x28(%rbp), %rdi
callq 0x1300
movq %rax, %rsi
movq 0x2bae(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, -0xb0(%rbp)
jmp 0x1438
movq -0xb0(%rbp), %rdi
movq 0x2b82(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x144d
leaq -0x28(%rbp), %rdi
callq 0x1280
movq %rax, %rsi
movq 0x2b78(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, -0xb8(%rbp)
jmp 0x146e
movq -0xb8(%rbp), %rdi
movq 0x2b4c(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x1483
leaq -0x28(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1030
jmp 0x1492
leaq -0x28(%rbp), %rdi
callq 0x1300
movq %rax, %rsi
movq 0x2b33(%rip), %rdi      # 0x3fd8
callq 0x1090
movq %rax, -0xc0(%rbp)
jmp 0x14b3
movq -0xc0(%rbp), %rdi
leaq 0xb43(%rip), %rsi       # 0x2004
callq 0x10a0
movq %rax, -0xc8(%rbp)
jmp 0x14cf
leaq -0x28(%rbp), %rdi
callq 0x1280
movq -0xc8(%rbp), %rdi
movq %rax, %rsi
callq 0x1090
movq %rax, -0xd0(%rbp)
jmp 0x14f0
movq -0xd0(%rbp), %rdi
movq 0x2aca(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x1505
leaq -0x28(%rbp), %rdi
callq 0x1300
movq %rax, %rsi
leaq -0x80(%rbp), %rdi
callq 0x1040
jmp 0x151c
leaq -0x28(%rbp), %rdi
callq 0x1280
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x1040
jmp 0x1536
movq 0x2a9b(%rip), %rdi      # 0x3fd8
leaq -0x80(%rbp), %rsi
callq 0x1090
movq %rax, -0xd8(%rbp)
jmp 0x154f
movq -0xd8(%rbp), %rdi
leaq 0xaa7(%rip), %rsi       # 0x2004
callq 0x10a0
movq %rax, -0xe0(%rbp)
jmp 0x156b
movq -0xe0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1090
movq %rax, -0xe8(%rbp)
jmp 0x1587
movq -0xe8(%rbp), %rdi
movq 0x2a33(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x159c
movq 0x2a35(%rip), %rdi      # 0x3fd8
leaq -0xa0(%rbp), %rsi
callq 0x1090
movq %rax, -0xf0(%rbp)
jmp 0x15b8
movq -0xf0(%rbp), %rdi
leaq 0xa3e(%rip), %rsi       # 0x2004
callq 0x10a0
movq %rax, -0xf8(%rbp)
jmp 0x15d4
movq -0xf8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1090
movq %rax, -0x100(%rbp)
jmp 0x15ed
movq -0x100(%rbp), %rdi
movq 0x29cd(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x1602
movq 0x29cf(%rip), %rdi      # 0x3fd8
leaq -0x80(%rbp), %rsi
callq 0x1090
movq %rax, -0x108(%rbp)
jmp 0x161b
movq -0x108(%rbp), %rdi
leaq 0x9db(%rip), %rsi       # 0x2004
callq 0x10a0
movq %rax, -0x110(%rbp)
jmp 0x1637
movq -0x110(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1090
movq %rax, -0x118(%rbp)
jmp 0x1650
movq -0x118(%rbp), %rdi
movq 0x296a(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x1665
movq 0x296c(%rip), %rdi      # 0x3fd8
leaq -0xa0(%rbp), %rsi
callq 0x1090
movq %rax, -0x120(%rbp)
jmp 0x1681
movq -0x120(%rbp), %rdi
leaq 0x975(%rip), %rsi       # 0x2004
callq 0x10a0
movq %rax, -0x128(%rbp)
jmp 0x169d
movq -0x128(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1090
movq %rax, -0x130(%rbp)
jmp 0x16b9
movq -0x130(%rbp), %rdi
movq 0x2901(%rip), %rsi      # 0x3fc8
callq 0x10b0
jmp 0x16ce
movl $0x0, -0x4(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x1060
leaq -0x80(%rbp), %rdi
callq 0x1060
leaq -0x60(%rbp), %rdi
callq 0x1060
leaq -0x28(%rbp), %rdi
callq 0x1060
movl -0x4(%rbp), %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x10c0
jmp 0x177c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1773
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x176a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1761
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x1060
leaq -0x80(%rbp), %rdi
callq 0x1060
leaq -0x60(%rbp), %rdi
callq 0x1060
leaq -0x28(%rbp), %rdi
callq 0x1060
movq -0x38(%rbp), %rdi
callq 0x1110
nopw %cs:(%rax,%rax)
nop