// File: iZhangHui[P]CppPrimer/CH07_Classes/examples/avg_price.cc
// Function: main
int main()
{
	Sales_data total;         // variable to hold the running sum
	if (read(cin, total))  {  // read the first transaction
		Sales_data trans;     // variable to hold data for the next transaction
		while(read(cin, trans)) {      // read the remaining transactions
			if (total.isbn() == trans.isbn())   // check the isbns
				total.combine(trans);  // update the running total
			else {
				print(cout, total) << endl;  // print the results
				total = trans;               // process the next book
			}
		}
		print(cout, total) << endl;          // print the last transaction
	} else {                                 // there was no input
		cerr << "No data?!" << endl;         // notify the user
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x1560
movq -0xc8(%rbp), %rsi
movq 0x2ca8(%rip), %rdi      # 0x3fd8
callq 0x1780
movq %rax, -0xc0(%rbp)
jmp 0x133e
movq -0xc0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x1100
movb %al, -0xc9(%rbp)
jmp 0x135c
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x136b
jmp 0x14f0
leaq -0x78(%rbp), %rdi
callq 0x1560
movq 0x2c5d(%rip), %rdi      # 0x3fd8
leaq -0x78(%rbp), %rsi
callq 0x1780
movq %rax, -0xd8(%rbp)
jmp 0x138d
movq -0xd8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x1100
movb %al, -0xd9(%rbp)
jmp 0x13ab
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x13ba
jmp 0x14ac
leaq -0x98(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1630
jmp 0x13cc
leaq -0xb8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1630
jmp 0x13de
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x15a0
movb %al, -0xda(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x1090
leaq -0x98(%rbp), %rdi
callq 0x1090
movb -0xda(%rbp), %al
testb $0x1, %al
jne 0x141b
jmp 0x1468
leaq -0x38(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1840
jmp 0x142a
jmp 0x14a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x153f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x14e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x1090
jmp 0x14e5
movq 0x2b59(%rip), %rdi      # 0x3fc8
leaq -0x38(%rbp), %rsi
callq 0x18e0
movq %rax, -0xe8(%rbp)
jmp 0x1481
movq -0xe8(%rbp), %rdi
movq 0x2b29(%rip), %rsi      # 0x3fb8
callq 0x10f0
jmp 0x1496
leaq -0x38(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x1660
jmp 0x14a5
jmp 0x14a7
jmp 0x1374
movq 0x2b15(%rip), %rdi      # 0x3fc8
leaq -0x38(%rbp), %rsi
callq 0x18e0
movq %rax, -0xf0(%rbp)
jmp 0x14c5
movq -0xf0(%rbp), %rdi
movq 0x2ae5(%rip), %rsi      # 0x3fb8
callq 0x10f0
jmp 0x14da
leaq -0x78(%rbp), %rdi
callq 0x16a0
jmp 0x1523
leaq -0x78(%rbp), %rdi
callq 0x16a0
jmp 0x153f
movq 0x2af9(%rip), %rdi      # 0x3ff0
leaq 0xb06(%rip), %rsi       # 0x2004
callq 0x10e0
movq %rax, -0xf8(%rbp)
jmp 0x150c
movq -0xf8(%rbp), %rdi
movq 0x2a9e(%rip), %rsi      # 0x3fb8
callq 0x10f0
jmp 0x1521
jmp 0x1523
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x16a0
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x16a0
movq -0x40(%rbp), %rdi
callq 0x1160
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)