// File: /workspace/github_cpp_makefile_star2_O3/iZhangHui[P]CppPrimer/CH08_TheIOLibrary/examples/sstream.cc
// Function: process(std::ostream&, std::vector<PersonInfo, std::allocator<PersonInfo>>)
ostream& process(ostream &os, vector<PersonInfo> people)
{
	for (const auto &entry : people) {    // for each entry in people
		ostringstream formatted, badNums; // objects created on each loop
		for (const auto &nums : entry.phones) {  // for each number 
			if (!valid(nums)) {           
				badNums << " " << nums;  // string in badNums
			} else                        
				// ``writes'' to formatted's string
				formatted << " " << format(nums); 
		}
		if (badNums.str().empty())      // there were no bad numbers
			os << entry.name << " "     // print the name 
			   << formatted.str() << endl; // and reformatted numbers 
		else                   // otherwise, print the name and bad numbers
			cerr << "input error: " << entry.name 
			     << " invalid number(s) " << badNums.str() << endl;
	}
	
	return os;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movq %rdi, -0x50(%rbp)
movq (%rsi), %r15
movq 0x8(%rsi), %rax
movq %rax, -0x58(%rbp)
cmpq %rax, %r15
je 0x27ea
leaq -0x38(%rbp), %r12
leaq -0x350(%rbp), %r13
leaq -0x1d8(%rbp), %rbx
leaq -0x48(%rbp), %r14
movq %r13, %rdi
callq 0x2140
movq %rbx, %rdi
callq 0x2140
movq 0x20(%r15), %rbx
movq %r15, -0x60(%rbp)
movq 0x28(%r15), %r15
cmpq %r15, %rbx
je 0x2655
movl $0x1, %edx
movq %r13, %rdi
leaq 0x1a31(%rip), %rsi      # 0x4040
callq 0x2120
movq %r12, -0x48(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x2a7a
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r13, %rdi
callq 0x2120
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x264f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2110
addq $0x20, %rbx
jmp 0x25fb
movq %r14, %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x2180
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rbx
cmpq %r12, %rdi
movq -0x60(%rbp), %r15
je 0x2681
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2110
testq %rbx, %rbx
je 0x2717
movl $0xd, %edx
movq 0x395a(%rip), %rdi      # 0x5ff0
leaq 0x1983(%rip), %rsi      # 0x4020
callq 0x2120
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq 0x3940(%rip), %rdi      # 0x5ff0
callq 0x2120
movq %rax, %rbx
movl $0x13, %edx
movq %rax, %rdi
leaq 0x1967(%rip), %rsi      # 0x402e
callq 0x2120
movq %r14, %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x2180
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x2120
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20a0
jmp 0x2787
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq -0x50(%rbp), %rdi
callq 0x2120
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1907(%rip), %rsi      # 0x4040
callq 0x2120
movq %r14, %rdi
leaq -0x348(%rbp), %rsi
callq 0x2180
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %rbx, %rdi
callq 0x2120
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20a0
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x279c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2110
leaq -0x1d8(%rbp), %rbx
movq %rbx, %rdi
movq 0x3813(%rip), %r14      # 0x5fc0
movq %r14, %rsi
callq 0x2090
leaq -0x168(%rbp), %rdi
callq 0x2050
movq %r13, %rdi
movq %r14, %rsi
callq 0x2090
leaq -0x2e0(%rbp), %rdi
callq 0x2050
addq $0x38, %r15
cmpq -0x58(%rbp), %r15
leaq -0x48(%rbp), %r14
jne 0x25df
movq -0x50(%rbp), %rax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x282d
jmp 0x282d
jmp 0x282d
movq %rax, %rbx
jmp 0x284f
jmp 0x2811
jmp 0x2811
jmp 0x282d
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0x2830
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2110
jmp 0x2830
jmp 0x282d
movq %rax, %rbx
movq 0x3789(%rip), %rsi      # 0x5fc0
leaq -0x1d8(%rbp), %rdi
callq 0x2090
leaq -0x168(%rbp), %rdi
callq 0x2050
movq 0x376a(%rip), %rsi      # 0x5fc0
leaq -0x350(%rbp), %rdi
callq 0x2090
leaq -0x2e0(%rbp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21b0