// File: /workspace/github_cpp_makefile_star2_O2/iZhangHui[P]CppPrimer/CH15_ObjectOrientedProgramming/examples/vecBasket.cc
// Function: main
int main ()
{
	Quote base("0-201-82470-1", 50);  
	Bulk_quote bulk("0-201-54848-8", 50, 10, .25); 

	// ok: but probably not what is wanted---
	//     the objects in basket have no derived members
	vector<Quote> basket;
	basket.push_back(Quote("0-201-82470-1", 50));

	// ok, but copies only the Quote part of the object into basket
	basket.push_back(Bulk_quote("0-201-54848-8", 50, 10, .25));  
	
	// calls version defined by Quote, prints 750, i.e., 15 * $50
	cout << basket.back().net_price(15) << endl;  
	
	// better approach---store shared_ptrs
	vector<shared_ptr<Quote>> basket2;
	
	basket2.push_back(make_shared<Quote>("0-201-82470-1", 50));  
	basket2.push_back(
		make_shared<Bulk_quote>("0-201-54848-8", 50, 10, .25));  
	
	// calls the version defined by Quote; 
	// prints 562.5, i.e., 15 * $50 less the discount
	cout << basket2.back()->net_price(15) << endl; 

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
leaq 0x1cfd(%rip), %rsi      # 0x4040
leaq -0x100(%rbp), %rdi
leaq -0x80(%rbp), %rdx
callq 0x2050
leaq -0x130(%rbp), %rdi
leaq -0x100(%rbp), %rsi
movsd 0x1c9f(%rip), %xmm0     # 0x4008
callq 0x2664
leaq -0x100(%rbp), %rdi
callq 0x2070
leaq 0x1ccd(%rip), %rsi      # 0x404e
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x2050
leaq -0x100(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movsd 0x1c67(%rip), %xmm0     # 0x4008
pushq $0xa
popq %rdx
movsd 0x1c64(%rip), %xmm1     # 0x4010
callq 0x2696
leaq -0x80(%rbp), %rdi
callq 0x2070
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
andq $0x0, -0xa0(%rbp)
leaq 0x1c6d(%rip), %rsi      # 0x4040
leaq -0x38(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x2050
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movsd 0x1c15(%rip), %xmm0     # 0x4008
callq 0x2664
leaq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x297e
leaq -0x80(%rbp), %rdi
callq 0x26ba
leaq -0x38(%rbp), %rdi
callq 0x2070
leaq 0x1c2d(%rip), %rsi      # 0x404e
leaq -0x38(%rbp), %rdi
leaq -0x90(%rbp), %rdx
callq 0x2050
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
movsd 0x1bc7(%rip), %xmm0     # 0x4008
pushq $0xa
popq %rdx
movsd 0x1bc4(%rip), %xmm1     # 0x4010
callq 0x2696
leaq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x297e
leaq -0x80(%rbp), %rdi
callq 0x26ba
leaq -0x38(%rbp), %rdi
callq 0x2070
movq -0xa8(%rbp), %rdi
movq -0x30(%rdi), %rax
addq $-0x30, %rdi
pushq $0xf
popq %rsi
callq *0x10(%rax)
movq 0x4b49(%rip), %rdi      # 0x6fd8
callq 0x2160
movq %rax, %rdi
callq 0x2080
andq $0x0, -0x70(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x80(%rbp)
leaq -0x90(%rbp), %rdx
movl $0x32, (%rdx)
leaq 0x1b84(%rip), %rsi      # 0x4040
leaq -0x38(%rbp), %rdi
callq 0x26d2
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2ea4
leaq -0x30(%rbp), %rdi
callq 0x2884
leaq -0xb8(%rbp), %rdx
movl $0x32, (%rdx)
leaq -0xb4(%rbp), %rcx
movl $0xa, (%rcx)
movabsq $0x3fd0000000000000, %rax # imm = 0x3FD0000000000000
leaq -0xc0(%rbp), %r8
movq %rax, (%r8)
leaq 0x1b3e(%rip), %rsi      # 0x404e
leaq -0x90(%rbp), %rdi
callq 0x26f4
leaq -0x88(%rbp), %r14
movups -0x8(%r14), %xmm0
leaq -0x30(%rbp), %r15
movups %xmm0, -0x8(%r15)
xorps %xmm0, %xmm0
movups %xmm0, -0x8(%r14)
leaq -0x80(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2ea4
movq %r15, %rdi
callq 0x2884
movq %r14, %rdi
callq 0x2884
movq -0x78(%rbp), %rax
movq -0x10(%rax), %rdi
movq (%rdi), %rax
pushq $0xf
popq %rsi
callq *0x10(%rax)
movq 0x4a6a(%rip), %rdi      # 0x6fd8
callq 0x2160
movq %rax, %rdi
callq 0x2080
leaq -0x80(%rbp), %rdi
callq 0x271c
leaq -0xb0(%rbp), %rdi
callq 0x2748
leaq -0x100(%rbp), %rdi
callq 0x26ba
leaq -0x130(%rbp), %rdi
callq 0x26ba
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x2884
movq %r14, %rdi
jmp 0x25d1
jmp 0x2627
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x2884
jmp 0x262a
jmp 0x2627
jmp 0x25e0
jmp 0x25ee
jmp 0x2635
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x26ba
jmp 0x25f1
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x2070
jmp 0x2638
jmp 0x2635
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x2070
jmp 0x2650
movq %rax, %rbx
jmp 0x2650
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
callq 0x2070
jmp 0x265c
movq %rax, %rbx
jmp 0x265c
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x271c
jmp 0x2638
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x2748
leaq -0x100(%rbp), %rdi
callq 0x26ba
leaq -0x130(%rbp), %rdi
callq 0x26ba
movq %rbx, %rdi
callq 0x2180