// File: iZhangHui[P]CppPrimer/CH05_Statements/examples/add_item2.cc
// Function: main
int main() 
{
	Sales_item item1, item2;
	
	while (cin >> item1 >> item2) {
	    try {
	        // execute code that will add the two Sales_items
	        // if the addition fails, the code throws a runtime_error exception
	        // first check that the data are for the same item 
	        if (item1.isbn() != item2.isbn())
	            throw runtime_error("Data must refer to same ISBN");
	
	        // if we're still here, the ISBNs are the same
	        cout << item1 + item2 << endl;
	    } catch (runtime_error err) {
	        // remind the user that the ISBNs must match 
			// and prompt for another pair
	        cout << err.what() 
	             << "\nTry Again?  Enter y or n" << endl;
	        char c;
	        cin >> c;
	        if (!cin || c == 'n')
	            break;      // break out of the while loop
	    }  // ends the catch clause
	}  // ends the while loop
	
	return 0;   // indicate success
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movl $0x0, -0x4(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2a10
leaq -0x68(%rbp), %rdi
callq 0x2a10
movq 0x298d(%rip), %rdi      # 0x4fd8
leaq -0x38(%rbp), %rsi
callq 0x2410
movq %rax, -0x108(%rbp)
jmp 0x265d
movq -0x108(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2410
movq %rax, -0x110(%rbp)
jmp 0x2676
movq -0x110(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x2170
movb %al, -0x111(%rbp)
jmp 0x2694
movb -0x111(%rbp), %al
testb $0x1, %al
jne 0x26a3
jmp 0x2955
leaq -0x98(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x2a90
jmp 0x26b5
leaq -0xb8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2a90
jmp 0x26c7
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x2ac0
movb %al, -0x112(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x20d0
leaq -0x98(%rbp), %rdi
callq 0x20d0
movb -0x112(%rbp), %al
testb $0x1, %al
jne 0x2707
jmp 0x27a4
movl $0x10, %edi
callq 0x20b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x120(%rbp)
leaq 0x8e1(%rip), %rsi       # 0x3006
callq 0x2050
jmp 0x272c
movq -0x120(%rbp), %rdi
movq 0x28b6(%rip), %rsi      # 0x4ff0
movq 0x287f(%rip), %rdx      # 0x4fc0
callq 0x2200
jmp 0x29a7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2984
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x2814
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x20d0
jmp 0x2814
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
callq 0x20f0
jmp 0x2814
leaq -0xe8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x68(%rbp), %rdx
callq 0x23b0
jmp 0x27ba
movq 0x2807(%rip), %rdi      # 0x4fc8
leaq -0xe8(%rbp), %rsi
callq 0x24c0
movq %rax, -0x128(%rbp)
jmp 0x27d6
movq -0x128(%rbp), %rdi
movq 0x27cc(%rip), %rsi      # 0x4fb0
callq 0x2140
jmp 0x27eb
leaq -0xe8(%rbp), %rdi
callq 0x29f0
jmp 0x294e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xe8(%rbp), %rdi
callq 0x29f0
movl -0x74(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x2984
movq -0x70(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x2160
movq %rax, %rsi
leaq -0xf8(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x2070
movq -0x140(%rbp), %rdi
callq 0x2060
movq -0x138(%rbp), %rdi
callq 0x21c0
movq %rax, %rsi
movq 0x275c(%rip), %rdi      # 0x4fc8
callq 0x2130
movq %rax, -0x130(%rbp)
jmp 0x287a
movq -0x130(%rbp), %rdi
leaq 0x79b(%rip), %rsi       # 0x3023
callq 0x2130
movq %rax, -0x148(%rbp)
jmp 0x2896
movq -0x148(%rbp), %rdi
movq 0x270c(%rip), %rsi      # 0x4fb0
callq 0x2140
jmp 0x28ab
movq 0x2726(%rip), %rdi      # 0x4fd8
leaq -0xf9(%rbp), %rsi
callq 0x21a0
jmp 0x28c0
movq 0x2711(%rip), %rdi      # 0x4fd8
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x20a0
movb %al, -0x149(%rbp)
jmp 0x28de
movb -0x149(%rbp), %al
testb $0x1, %al
jne 0x28f6
jmp 0x28ea
movsbl -0xf9(%rbp), %eax
cmpl $0x6e, %eax
jne 0x2921
movl $0x3, -0x100(%rbp)
jmp 0x292b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x2238
callq 0x21f0
jmp 0x2953
movl $0x0, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x2238
callq 0x21f0
jmp 0x293e
movl -0x100(%rbp), %eax
testl %eax, %eax
je 0x294c
jmp 0x294a
jmp 0x2955
jmp 0x294e
jmp 0x2644
jmp 0x2984
movl $0x0, -0x4(%rbp)
movl $0x1, -0x100(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x29f0
leaq -0x38(%rbp), %rdi
callq 0x29f0
movl -0x4(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x29f0
leaq -0x38(%rbp), %rdi
callq 0x29f0
movq -0x70(%rbp), %rdi
callq 0x2210
movq %rax, %rdi
callq 0x2af0
nopw (%rax,%rax)