// File: iZhangHui[P]CppPrimer/CH14_OverloadedOperationsAndConversions/examples/add.cc
// Function: main
int main()
{
    Sales_item item1, item2;
    // read a pair of transactions
    cin >> item1 >> item2;
    // print the sum of two Sales_items
    cout << item1 + item2 << endl;

	Sales_data data1, data2;
    /**
     * read a pair of transactions
     * std::istream& read(std::istream&, Sales_data&)
     */
    read(read(cin, data1), data2);
    // print the sum of two Sales_datas
    print(cout, add(data1, data2));
 	cout << std::endl;

    // use input operator to read Sales_datas
	cin >> data1 >> data2;
    // use operators to print the sum of two Sales_datas
    cout << data1 + data2 << endl;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x1880
leaq -0x68(%rbp), %rdi
callq 0x1880
movq -0x178(%rbp), %rsi
movq 0x2a37(%rip), %rdi      # 0x3fe0
callq 0x1360
movq %rax, -0x170(%rbp)
jmp 0x15b7
movq -0x170(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x1360
jmp 0x15c9
leaq -0xa8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x1300
jmp 0x15df
movq 0x29ea(%rip), %rdi      # 0x3fd0
leaq -0xa8(%rbp), %rsi
callq 0x1410
movq %rax, -0x180(%rbp)
jmp 0x15fb
movq -0x180(%rbp), %rdi
movq 0x29b7(%rip), %rsi      # 0x3fc0
callq 0x10b0
jmp 0x1610
leaq -0xa8(%rbp), %rdi
callq 0x1860
leaq -0xd8(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x1930
leaq -0x108(%rbp), %rdi
callq 0x1930
movq -0x190(%rbp), %rsi
movq 0x2997(%rip), %rdi      # 0x3fe0
callq 0x1c90
movq %rax, -0x188(%rbp)
jmp 0x1657
movq -0x188(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x1c90
jmp 0x166c
leaq -0x138(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x1e00
jmp 0x1688
movq 0x2941(%rip), %rdi      # 0x3fd0
leaq -0x138(%rbp), %rsi
callq 0x1d00
jmp 0x169d
leaq -0x138(%rbp), %rdi
callq 0x1970
movq 0x2920(%rip), %rdi      # 0x3fd0
movq 0x2909(%rip), %rsi      # 0x3fc0
callq 0x10b0
jmp 0x16be
movq 0x291b(%rip), %rdi      # 0x3fe0
leaq -0xd8(%rbp), %rsi
callq 0x19f0
movq %rax, -0x198(%rbp)
jmp 0x16da
movq -0x198(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x19f0
jmp 0x16ef
leaq -0x168(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0x108(%rbp), %rdx
callq 0x1b30
jmp 0x170b
movq 0x28be(%rip), %rdi      # 0x3fd0
leaq -0x168(%rbp), %rsi
callq 0x1b90
movq %rax, -0x1a0(%rbp)
jmp 0x1727
movq -0x1a0(%rbp), %rdi
movq 0x288b(%rip), %rsi      # 0x3fc0
callq 0x10b0
jmp 0x173c
leaq -0x168(%rbp), %rdi
callq 0x1970
movl $0x0, -0x4(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x1970
leaq -0xd8(%rbp), %rdi
callq 0x1970
leaq -0x68(%rbp), %rdi
callq 0x1860
leaq -0x38(%rbp), %rdi
callq 0x1860
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x1805
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x1860
jmp 0x1805
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x17ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x1970
jmp 0x17ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x1970
leaq -0x108(%rbp), %rdi
callq 0x1970
leaq -0xd8(%rbp), %rdi
callq 0x1970
leaq -0x68(%rbp), %rdi
callq 0x1860
leaq -0x38(%rbp), %rdi
callq 0x1860
movq -0x70(%rbp), %rdi
callq 0x1120