// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH02_VariablesAndBasicTypes/examples/decl-ex.cc
// Function: main
int main()
{
	int a = 0;
	decltype(a) c = a;   // c is an int
	decltype((a)) d = a; // d is a reference to a
	++c;                 // increments c, a (and d) unchanged
	cout << "a: " << a << " c: " << c << " d: " << d << endl;
	++d;                 // increments a through the reference d
	cout << "a: " << a << " c: " << c << " d: " << d << endl;
	
	int A = 0, B = 0;
	decltype((A)) C = A;   // C is a reference to A
	decltype(A = B) D = A; // D is also a reference to A
	++C;
	cout << "A: " << A << " C: " << C << " D: " << D << endl;
	++D;
	cout << "A: " << A << " C: " << C << " D: " << D << endl;
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x2de7(%rip), %rbx      # 0x3fd8
leaq 0xe0c(%rip), %r14       # 0x2004
movl $0x3, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1070
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1090
movq %rax, %r12
leaq 0xdec(%rip), %r15       # 0x2008
movl $0x4, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1070
movq %r12, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r13
leaq 0xdca(%rip), %r12       # 0x200d
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1070
movq %r13, %rdi
xorl %esi, %esi
callq 0x1090
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x1060
movsbl %al, %esi
movq %r13, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1040
movl $0x3, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1070
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1070
movq %r14, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r14
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1070
movq %r14, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x1060
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1040
leaq 0xcfd(%rip), %r14       # 0x2012
movl $0x3, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1070
movq %rbx, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r12
leaq 0xcda(%rip), %r15       # 0x2016
movl $0x4, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1070
movq %r12, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r13
leaq 0xcb8(%rip), %r12       # 0x201b
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1070
movq %r13, %rdi
movl $0x1, %esi
callq 0x1090
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x1060
movsbl %al, %esi
movq %r13, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1040
movl $0x3, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1070
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1090
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x1070
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1090
movq %rax, %rbx
movl $0x4, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x1070
movq %rbx, %rdi
movl $0x2, %esi
callq 0x1090
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1060
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1040
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq