// File: iZhangHui[P]CppPrimer/CH12_DynamicMemory/examples/TextQuery.cc
// Function: print(std::ostream&, QueryResult const&)
ostream &print(ostream& os, const QueryResult& qr)
{
    // if the word was found, print the count and all occurrences
    os << qr.sought << " occurs " << qr.lines->size() << " "
       << make_plural(qr.lines->size(), "time", "s") << endl;

    // print each line in which the word appeared
	for (auto num : *qr.lines) // for every element in the set
		// don't confound the user with text lines starting at 0
        os << "\t(line " << num + 1 << ") "
		   << *(qr.file->begin() + num) << endl;

	return os;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x3200
movq %rax, %rdi
leaq 0x3dae(%rip), %rsi      # 0xc188
callq 0x3220
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x4090
movq %rax, %rdi
callq 0x8c20
movq -0xe0(%rbp), %rdi
movq %rax, %rsi
callq 0x3070
movq %rax, %rdi
leaq 0x3d8d(%rip), %rsi      # 0xc1a1
callq 0x3220
movq %rax, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x4090
movq %rax, %rdi
callq 0x8c20
movq %rax, -0xd0(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x3380
movq -0xc8(%rbp), %rdx
leaq 0x3d37(%rip), %rsi      # 0xc191
leaq -0x50(%rbp), %rdi
callq 0x32d0
jmp 0x8465
leaq -0x89(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x3380
movq -0xe8(%rbp), %rdx
leaq 0x3d10(%rip), %rsi      # 0xc196
leaq -0x88(%rbp), %rdi
callq 0x32d0
jmp 0x8494
movq -0xd0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rdx
leaq -0x88(%rbp), %rcx
callq 0x8c40
jmp 0x84b1
movq -0xd8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3200
movq %rax, -0xf0(%rbp)
jmp 0x84ca
movq -0xf0(%rbp), %rdi
movq 0xaad0(%rip), %rsi      # 0x12fa8
callq 0x3260
jmp 0x84df
leaq -0x30(%rbp), %rdi
callq 0x3160
leaq -0x88(%rbp), %rdi
callq 0x3160
leaq -0x89(%rbp), %rdi
callq 0x3270
leaq -0x50(%rbp), %rdi
callq 0x3160
leaq -0x51(%rbp), %rdi
callq 0x3270
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
callq 0x4320
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x4350
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
callq 0x8ca0
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x4100
testb $0x1, %al
jne 0x8568
jmp 0x8693
leaq -0xa0(%rbp), %rdi
callq 0x4060
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x3c0f(%rip), %rsi      # 0xc198
callq 0x3220
movq %rax, %rdi
movq -0xb0(%rbp), %rsi
addq $0x1, %rsi
callq 0x3070
movq %rax, %rdi
leaq 0x3bf5(%rip), %rsi      # 0xc1a0
callq 0x3220
movq %rax, -0xf8(%rbp)
movq -0x10(%rbp), %rdi
addq $0x30, %rdi
callq 0x3fd0
movq %rax, %rdi
callq 0x8cd0
movq %rax, -0xc0(%rbp)
movq -0xb0(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x8d00
movq %rax, -0xb8(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x8d40
movq -0xf8(%rbp), %rdi
movq %rax, %rsi
callq 0x3200
movq %rax, %rdi
movq 0xa996(%rip), %rsi      # 0x12fa8
callq 0x3260
leaq -0xa0(%rbp), %rdi
callq 0x4130
jmp 0x854c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x8688
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x8673
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x8667
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3160
leaq -0x88(%rbp), %rdi
callq 0x3160
leaq -0x89(%rbp), %rdi
callq 0x3270
leaq -0x50(%rbp), %rdi
callq 0x3160
leaq -0x51(%rbp), %rdi
callq 0x3270
jmp 0x86a0
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x3370
nopl (%rax)