// File: iZhangHui[P]CppPrimer/CH17_SpecializedLibraryFacilities/examples/findbook.cc
// Function: reportResults(std::istream&, std::ostream&, std::vector<std::vector<Sales_data, std::allocator<Sales_data>>, std::allocator<std::vector<Sales_data, std::allocator<Sales_data>>>> const&)
void reportResults(istream &in, ostream &os,
                   const vector<vector<Sales_data>> &files)
{
	string s;   // book to look for
	while (in >> s) {
		auto trans = findBook(files, s);  // stores that sold this book
		if (trans.empty()) {
			cout << s << " not found in any stores" << endl;
			continue;  // get the next book to look for
		}
		for (const auto &store : trans)   // for every store with a sale
			// get<n> returns the specified member from the tuple in store
			os << "store " << get<0>(store) << " sales: "
			   << accumulate(get<1>(store), get<2>(store), 
			                 Sales_data(s))
			   << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x21e0
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x21b0
movq %rax, -0x100(%rbp)
jmp 0x27f6
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x21a0
movb %al, -0x101(%rbp)
jmp 0x2814
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x2823
jmp 0x2a78
movq -0x18(%rbp), %rsi
leaq -0x60(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x2470
jmp 0x2836
leaq -0x60(%rbp), %rdi
callq 0x32b0
testb $0x1, %al
jne 0x2845
jmp 0x28bd
movq 0xa78c(%rip), %rdi      # 0xcfd8
leaq -0x38(%rbp), %rsi
callq 0x2130
movq %rax, -0x110(%rbp)
jmp 0x285e
movq -0x110(%rbp), %rdi
leaq 0x5798(%rip), %rsi      # 0x8004
callq 0x2140
movq %rax, -0x118(%rbp)
jmp 0x287a
movq -0x118(%rbp), %rdi
movq 0xa740(%rip), %rsi      # 0xcfc8
callq 0x2170
jmp 0x288f
movl $0x2, -0x64(%rbp)
jmp 0x2a51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2a8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2a6d
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x32f0
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x3320
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x3350
testb $0x1, %al
jne 0x28f5
jmp 0x2a4a
leaq -0x78(%rbp), %rdi
callq 0x3390
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x570d(%rip), %rsi      # 0x801d
callq 0x2140
movq %rax, -0x120(%rbp)
jmp 0x291e
movq -0x88(%rbp), %rdi
callq 0x33b0
movq -0x120(%rbp), %rdi
movq (%rax), %rsi
callq 0x2050
movq %rax, -0x128(%rbp)
jmp 0x2942
movq -0x128(%rbp), %rdi
leaq 0x56d4(%rip), %rsi      # 0x8024
callq 0x2140
movq %rax, -0x130(%rbp)
jmp 0x295e
movq -0x88(%rbp), %rdi
callq 0x3460
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
movq -0x88(%rbp), %rdi
callq 0x3480
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
leaq -0xf8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x34a0
jmp 0x299c
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdx
leaq -0xb8(%rbp), %rdi
leaq -0xf8(%rbp), %rcx
callq 0x33d0
jmp 0x29bf
movq -0x130(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x7d10
movq %rax, -0x138(%rbp)
jmp 0x29db
movq -0x138(%rbp), %rdi
movq 0xa5df(%rip), %rsi      # 0xcfc8
callq 0x2170
jmp 0x29f0
leaq -0xb8(%rbp), %rdi
callq 0x3290
leaq -0xf8(%rbp), %rdi
callq 0x3290
leaq -0x78(%rbp), %rdi
callq 0x34e0
jmp 0x28df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2a3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x3290
leaq -0xf8(%rbp), %rdi
callq 0x3290
jmp 0x2a6d
movl $0x0, -0x64(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3050
movl -0x64(%rbp), %eax
testl %eax, %eax
je 0x2a68
jmp 0x2a63
jmp 0x27e0
jmp 0x27e0
leaq -0x60(%rbp), %rdi
callq 0x3050
jmp 0x2a8a
leaq -0x38(%rbp), %rdi
callq 0x20e0
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x20e0
movq -0x40(%rbp), %rdi
callq 0x2230
nopl (%rax)