// File: /workspace/github_cpp_makefile_star2_O1/iZhangHui[P]CppPrimer/CH04_Expressions/examples/sizeof_pgm.cc
// Function: main
int main() 
{
	Sales_data data, *p;
	sizeof(Sales_data); // size required to hold an object of type Sales_data 
	sizeof data; // size of data's type, i.e., sizeof(Sales_data)
	sizeof p;    // size of a pointer
	sizeof *p;   // size of the type to which p points, i.e., sizeof(Sales_data)
	sizeof data.revenue; // size of the type of Sales_data's revenue member 
	sizeof Sales_data::revenue; // alternative way to get the size of revenue
	
	cout << "short: " << sizeof(short) << "\n"
	     << "short[3]: " << sizeof(short[3]) << "\n"
	     << "short*: " << sizeof(short*) << "\n"
	     << "short&: " << sizeof(short&) << endl;
	
	cout << endl; 
	
	cout << "int: " << sizeof(int) << "\n"
	     << "int[3]: " << sizeof(int[3]) << "\n"
	     << "int*: " << sizeof(int*) << "\n"
	     << "int&: " << sizeof(int&) << endl;
	
	cout << endl; 
	
	cout << "Sales_data: " << sizeof(Sales_data) << "\n"
	     << "Sales_data[3]: " << sizeof(Sales_data[3]) << "\n"
	     << "Sales_data*: " << sizeof(Sales_data*) << "\n"
	     << "Sales_data&: " << sizeof(Sales_data&) << endl;
	
	cout << "Sales_data::revenue: " << sizeof Sales_data::revenue << "\n"
	     << "data.revenue: " << sizeof data.revenue << endl;

	int x[10];   
	int *ip = x;

	// number of elements in x
	cout << sizeof(x)/sizeof(*x) << endl;

	// divides sizeof a pointer by sizeof an int
	cout << sizeof(ip)/sizeof(*ip) << endl;
	
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb $0x0, (%r15)
movl $0x0, 0x10(%r15)
movq %rax, 0x18(%r15)
movq 0x2daa(%rip), %rdi      # 0x3fd8
leaq 0xdcf(%rip), %rsi       # 0x2004
movl $0x7, %edx
callq 0x1090
movq 0x2d92(%rip), %rbx      # 0x3fd8
movl $0x2, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %r14
leaq 0xdaf(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xd9d(%rip), %rsi       # 0x200e
movl $0xa, %edx
movq %r14, %rdi
callq 0x1090
movl $0x6, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %r14
leaq 0xd77(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xd70(%rip), %rsi       # 0x2019
movl $0x8, %edx
movq %r14, %rdi
callq 0x1090
movl $0x8, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %r14
leaq 0xd3f(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xd41(%rip), %rsi       # 0x2022
movl $0x8, %edx
movq %r14, %rdi
callq 0x1090
movl $0x2, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq 0x2c95(%rip), %rdi      # 0x3fd8
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq 0x2c81(%rip), %rdi      # 0x3fd8
leaq 0xccd(%rip), %rsi       # 0x202b
movl $0x5, %edx
callq 0x1090
movq 0x2c69(%rip), %rbx      # 0x3fd8
movl $0x4, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %r14
leaq 0xc86(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xc97(%rip), %rsi       # 0x2031
movl $0x8, %edx
movq %r14, %rdi
callq 0x1090
movl $0xc, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %r14
leaq 0xc4e(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xc68(%rip), %rsi       # 0x203a
movl $0x6, %edx
movq %r14, %rdi
callq 0x1090
movl $0x8, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %r14
leaq 0xc16(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xc37(%rip), %rsi       # 0x2041
movl $0x6, %edx
movq %r14, %rdi
callq 0x1090
movl $0x4, %esi
movq %r14, %rdi
callq 0x1040
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq %r14, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq 0x2b6c(%rip), %rdi      # 0x3fd8
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq 0x2b58(%rip), %rdi      # 0x3fd8
leaq 0xbc1(%rip), %rsi       # 0x2048
movl $0xc, %edx
callq 0x1090
movq 0x2b40(%rip), %rdi      # 0x3fd8
movl $0x30, %esi
callq 0x1040
movq %rax, %rbx
leaq 0xb60(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xb95(%rip), %rsi       # 0x2055
movl $0xf, %edx
movq %rbx, %rdi
callq 0x1090
movl $0x90, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %rbx
leaq 0xb28(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xb6d(%rip), %rsi       # 0x2065
movl $0xd, %edx
movq %rbx, %rdi
callq 0x1090
movl $0x8, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %rbx
leaq 0xaf0(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xb43(%rip), %rsi       # 0x2073
movl $0xd, %edx
movq %rbx, %rdi
callq 0x1090
movl $0x30, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq 0x2a5d(%rip), %rdi      # 0x3fd8
leaq 0xaff(%rip), %rsi       # 0x2081
movl $0x15, %edx
callq 0x1090
movq 0x2a45(%rip), %rdi      # 0x3fd8
movl $0x8, %esi
callq 0x1040
movq %rax, %rbx
leaq 0xa65(%rip), %rsi       # 0x200c
movl $0x1, %edx
movq %rax, %rdi
callq 0x1090
leaq 0xadc(%rip), %rsi       # 0x2097
movl $0xe, %edx
movq %rbx, %rdi
callq 0x1090
movl $0x8, %esi
movq %rbx, %rdi
callq 0x1040
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq 0x29d2(%rip), %rdi      # 0x3fd8
movl $0xa, %esi
callq 0x1040
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq 0x2997(%rip), %rdi      # 0x3fd8
movl $0x2, %esi
callq 0x1040
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x1070
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1050
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x168a
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1080
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1699
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0x16b1
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x1080
movq %rbx, %rdi
callq 0x10b0