// File: 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
subq $0x260, %rsp            # imm = 0x260
movl $0x0, -0x4(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x218(%rbp)
callq 0x2190
movq -0x218(%rbp), %rdx
leaq 0x4ca0(%rip), %rsi      # 0x7040
leaq -0x58(%rbp), %rdi
callq 0x2130
jmp 0x23ab
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
movsd 0x4c4d(%rip), %xmm0     # 0x7008
callq 0x28f0
jmp 0x23c2
leaq -0x58(%rbp), %rdi
callq 0x2090
leaq -0x59(%rbp), %rdi
callq 0x2110
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x2190
movq -0x220(%rbp), %rdx
leaq 0x4c59(%rip), %rsi      # 0x704e
leaq -0xd0(%rbp), %rdi
callq 0x2130
jmp 0x2403
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
movsd 0x4bef(%rip), %xmm0     # 0x7008
movl $0xa, %edx
movsd 0x4bea(%rip), %xmm1     # 0x7010
callq 0x2940
jmp 0x242d
leaq -0xd0(%rbp), %rdi
callq 0x2090
leaq -0xd1(%rbp), %rdi
callq 0x2110
leaq -0xf0(%rbp), %rdi
callq 0x29a0
leaq -0x141(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x2190
movq -0x228(%rbp), %rdx
leaq 0x4bce(%rip), %rsi      # 0x7040
leaq -0x140(%rbp), %rdi
callq 0x2130
jmp 0x2480
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rsi
movsd 0x4b72(%rip), %xmm0     # 0x7008
callq 0x28f0
jmp 0x249d
leaq -0xf0(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x29c0
jmp 0x24b2
leaq -0x120(%rbp), %rdi
callq 0x29f0
leaq -0x140(%rbp), %rdi
callq 0x2090
leaq -0x141(%rbp), %rdi
callq 0x2110
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x2190
movq -0x230(%rbp), %rdx
leaq 0x4b57(%rip), %rsi      # 0x704e
leaq -0x1a8(%rbp), %rdi
callq 0x2130
jmp 0x2505
leaq -0x188(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
movsd 0x4aed(%rip), %xmm0     # 0x7008
movl $0xa, %edx
movsd 0x4ae8(%rip), %xmm1     # 0x7010
callq 0x2940
jmp 0x252f
leaq -0xf0(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x29c0
jmp 0x2544
leaq -0x188(%rbp), %rdi
callq 0x2a20
leaq -0x1a8(%rbp), %rdi
callq 0x2090
leaq -0x1a9(%rbp), %rdi
callq 0x2110
leaq -0xf0(%rbp), %rdi
callq 0x2a40
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
movl $0xf, %esi
callq *%rax
movsd %xmm0, -0x238(%rbp)
jmp 0x258f
movsd -0x238(%rbp), %xmm0
movq 0x9a3a(%rip), %rdi      # 0xbfd8
callq 0x21a0
movq %rax, -0x240(%rbp)
jmp 0x25ac
movq -0x240(%rbp), %rdi
movq 0x9a06(%rip), %rsi      # 0xbfc0
callq 0x2100
jmp 0x25c1
leaq -0x1c8(%rbp), %rdi
callq 0x2a80
movl $0x32, -0x1dc(%rbp)
leaq 0x4a62(%rip), %rsi      # 0x7040
leaq -0x1d8(%rbp), %rdi
leaq -0x1dc(%rbp), %rdx
callq 0x2ad0
jmp 0x25f3
leaq -0x1c8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x2aa0
jmp 0x2608
leaq -0x1d8(%rbp), %rdi
callq 0x2b50
movl $0x32, -0x204(%rbp)
movl $0xa, -0x208(%rbp)
movabsq $0x3fd0000000000000, %rax # imm = 0x3FD0000000000000
movq %rax, -0x210(%rbp)
leaq 0x4a0e(%rip), %rsi      # 0x704e
leaq -0x200(%rbp), %rdi
leaq -0x204(%rbp), %rdx
leaq -0x208(%rbp), %rcx
leaq -0x210(%rbp), %r8
callq 0x2b70
jmp 0x2663
leaq -0x1f0(%rbp), %rdi
movq %rdi, -0x248(%rbp)
leaq -0x200(%rbp), %rsi
callq 0x2c00
movq -0x248(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
callq 0x2aa0
jmp 0x2692
leaq -0x1f0(%rbp), %rdi
callq 0x2b50
leaq -0x200(%rbp), %rdi
callq 0x2c30
leaq -0x1c8(%rbp), %rdi
callq 0x2c50
movq %rax, %rdi
callq 0x2c90
movq %rax, %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
movl $0xf, %esi
callq *%rax
movsd %xmm0, -0x250(%rbp)
jmp 0x26d9
movsd -0x250(%rbp), %xmm0
movq 0x98f0(%rip), %rdi      # 0xbfd8
callq 0x21a0
movq %rax, -0x258(%rbp)
jmp 0x26f6
movq -0x258(%rbp), %rdi
movq 0x98bc(%rip), %rsi      # 0xbfc0
callq 0x2100
jmp 0x270b
movl $0x0, -0x4(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x2cb0
leaq -0xf0(%rbp), %rdi
callq 0x2d10
leaq -0xb0(%rbp), %rdi
callq 0x2a20
leaq -0x38(%rbp), %rdi
callq 0x29f0
movl -0x4(%rbp), %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x276e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x2090
leaq -0x59(%rbp), %rdi
callq 0x2110
jmp 0x28d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x27a2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x2090
leaq -0xd1(%rbp), %rdi
callq 0x2110
jmp 0x28d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x27f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x27e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x29f0
leaq -0x140(%rbp), %rdi
callq 0x2090
leaq -0x141(%rbp), %rdi
callq 0x2110
jmp 0x28b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2844
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x2838
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x2a20
leaq -0x1a8(%rbp), %rdi
callq 0x2090
leaq -0x1a9(%rbp), %rdi
callq 0x2110
jmp 0x28b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x28b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x28ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x2b50
jmp 0x28ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x2b50
leaq -0x200(%rbp), %rdi
callq 0x2c30
leaq -0x1c8(%rbp), %rdi
callq 0x2cb0
leaq -0xf0(%rbp), %rdi
callq 0x2d10
leaq -0xb0(%rbp), %rdi
callq 0x2a20
leaq -0x38(%rbp), %rdi
callq 0x29f0
movq -0x68(%rbp), %rdi
callq 0x2180
nopw %cs:(%rax,%rax)
nopl (%rax)