// File: 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
subq $0x1d0, %rsp            # imm = 0x1D0
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1740
movq 0x2dc6(%rip), %rdi      # 0x3fd8
leaq 0xdeb(%rip), %rsi       # 0x2004
callq 0x1060
movq %rax, -0x90(%rbp)
jmp 0x1227
movq -0x90(%rbp), %rdi
movl $0x2, %esi
callq 0x1030
movq %rax, -0x98(%rbp)
jmp 0x1241
movq -0x98(%rbp), %rdi
leaq 0xdbd(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0xa0(%rbp)
jmp 0x125d
movq -0xa0(%rbp), %rdi
leaq 0xda3(%rip), %rsi       # 0x200e
callq 0x1060
movq %rax, -0xa8(%rbp)
jmp 0x1279
movq -0xa8(%rbp), %rdi
movl $0x6, %esi
callq 0x1030
movq %rax, -0xb0(%rbp)
jmp 0x1293
movq -0xb0(%rbp), %rdi
leaq 0xd6b(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0xb8(%rbp)
jmp 0x12af
movq -0xb8(%rbp), %rdi
leaq 0xd5c(%rip), %rsi       # 0x2019
callq 0x1060
movq %rax, -0xc0(%rbp)
jmp 0x12cb
movq -0xc0(%rbp), %rdi
movl $0x8, %esi
callq 0x1030
movq %rax, -0xc8(%rbp)
jmp 0x12e5
movq -0xc8(%rbp), %rdi
leaq 0xd19(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0xd0(%rbp)
jmp 0x1301
movq -0xd0(%rbp), %rdi
leaq 0xd13(%rip), %rsi       # 0x2022
callq 0x1060
movq %rax, -0xd8(%rbp)
jmp 0x131d
movq -0xd8(%rbp), %rdi
movl $0x2, %esi
callq 0x1030
movq %rax, -0xe0(%rbp)
jmp 0x1337
movq -0xe0(%rbp), %rdi
movq 0x2c83(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x134c
movq 0x2c85(%rip), %rdi      # 0x3fd8
movq 0x2c6e(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x1361
movq 0x2c70(%rip), %rdi      # 0x3fd8
leaq 0xcbc(%rip), %rsi       # 0x202b
callq 0x1060
movq %rax, -0xe8(%rbp)
jmp 0x137d
movq -0xe8(%rbp), %rdi
movl $0x4, %esi
callq 0x1030
movq %rax, -0xf0(%rbp)
jmp 0x1397
movq -0xf0(%rbp), %rdi
leaq 0xc67(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0xf8(%rbp)
jmp 0x13b3
movq -0xf8(%rbp), %rdi
leaq 0xc70(%rip), %rsi       # 0x2031
callq 0x1060
movq %rax, -0x100(%rbp)
jmp 0x13cf
movq -0x100(%rbp), %rdi
movl $0xc, %esi
callq 0x1030
movq %rax, -0x108(%rbp)
jmp 0x13e9
movq -0x108(%rbp), %rdi
leaq 0xc15(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0x110(%rbp)
jmp 0x1405
movq -0x110(%rbp), %rdi
leaq 0xc27(%rip), %rsi       # 0x203a
callq 0x1060
movq %rax, -0x118(%rbp)
jmp 0x1421
movq -0x118(%rbp), %rdi
movl $0x8, %esi
callq 0x1030
movq %rax, -0x120(%rbp)
jmp 0x143b
movq -0x120(%rbp), %rdi
leaq 0xbc3(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0x128(%rbp)
jmp 0x1457
movq -0x128(%rbp), %rdi
leaq 0xbdc(%rip), %rsi       # 0x2041
callq 0x1060
movq %rax, -0x130(%rbp)
jmp 0x1473
movq -0x130(%rbp), %rdi
movl $0x4, %esi
callq 0x1030
movq %rax, -0x138(%rbp)
jmp 0x148d
movq -0x138(%rbp), %rdi
movq 0x2b2d(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x14a2
movq 0x2b2f(%rip), %rdi      # 0x3fd8
movq 0x2b18(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x14b7
movq 0x2b1a(%rip), %rdi      # 0x3fd8
leaq 0xb83(%rip), %rsi       # 0x2048
callq 0x1060
movq %rax, -0x140(%rbp)
jmp 0x14d3
movq -0x140(%rbp), %rdi
movl $0x30, %esi
callq 0x1030
movq %rax, -0x148(%rbp)
jmp 0x14ed
movq -0x148(%rbp), %rdi
leaq 0xb11(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0x150(%rbp)
jmp 0x1509
movq -0x150(%rbp), %rdi
leaq 0xb3e(%rip), %rsi       # 0x2055
callq 0x1060
movq %rax, -0x158(%rbp)
jmp 0x1525
movq -0x158(%rbp), %rdi
movl $0x90, %esi
callq 0x1030
movq %rax, -0x160(%rbp)
jmp 0x153f
movq -0x160(%rbp), %rdi
leaq 0xabf(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0x168(%rbp)
jmp 0x155b
movq -0x168(%rbp), %rdi
leaq 0xafc(%rip), %rsi       # 0x2065
callq 0x1060
movq %rax, -0x170(%rbp)
jmp 0x1577
movq -0x170(%rbp), %rdi
movl $0x8, %esi
callq 0x1030
movq %rax, -0x178(%rbp)
jmp 0x1591
movq -0x178(%rbp), %rdi
leaq 0xa6d(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0x180(%rbp)
jmp 0x15ad
movq -0x180(%rbp), %rdi
leaq 0xab8(%rip), %rsi       # 0x2073
callq 0x1060
movq %rax, -0x188(%rbp)
jmp 0x15c9
movq -0x188(%rbp), %rdi
movl $0x30, %esi
callq 0x1030
movq %rax, -0x190(%rbp)
jmp 0x15e3
movq -0x190(%rbp), %rdi
movq 0x29d7(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x15f8
movq 0x29d9(%rip), %rdi      # 0x3fd8
leaq 0xa7b(%rip), %rsi       # 0x2081
callq 0x1060
movq %rax, -0x198(%rbp)
jmp 0x1614
movq -0x198(%rbp), %rdi
movl $0x8, %esi
callq 0x1030
movq %rax, -0x1a0(%rbp)
jmp 0x162e
movq -0x1a0(%rbp), %rdi
leaq 0x9d0(%rip), %rsi       # 0x200c
callq 0x1060
movq %rax, -0x1a8(%rbp)
jmp 0x164a
movq -0x1a8(%rbp), %rdi
leaq 0xa3f(%rip), %rsi       # 0x2097
callq 0x1060
movq %rax, -0x1b0(%rbp)
jmp 0x1666
movq -0x1b0(%rbp), %rdi
movl $0x8, %esi
callq 0x1030
movq %rax, -0x1b8(%rbp)
jmp 0x1680
movq -0x1b8(%rbp), %rdi
movq 0x293a(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x1695
leaq -0x80(%rbp), %rax
movq %rax, -0x88(%rbp)
movq 0x2931(%rip), %rdi      # 0x3fd8
movl $0xa, %esi
callq 0x1030
movq %rax, -0x1c0(%rbp)
jmp 0x16ba
movq -0x1c0(%rbp), %rdi
movq 0x2900(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x16cf
movq 0x2902(%rip), %rdi      # 0x3fd8
movl $0x2, %esi
callq 0x1030
movq %rax, -0x1c8(%rbp)
jmp 0x16e9
movq -0x1c8(%rbp), %rdi
movq 0x28d1(%rip), %rsi      # 0x3fc8
callq 0x1070
jmp 0x16fe
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1780
movl -0x4(%rbp), %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x1780
movq -0x48(%rbp), %rdi
callq 0x10a0
nopl (%rax,%rax)