// File: 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
subq $0x420, %rsp            # imm = 0x420
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2b70
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2ba0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x2bd0
testb $0x1, %al
jne 0x25a7
jmp 0x2923
leaq -0x20(%rbp), %rdi
callq 0x2c10
movq %rax, -0x30(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x2170
leaq -0x320(%rbp), %rdi
callq 0x2170
jmp 0x25ce
movq -0x30(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x338(%rbp)
movq -0x338(%rbp), %rdi
callq 0x2c30
movq %rax, -0x340(%rbp)
movq -0x338(%rbp), %rdi
callq 0x2c60
movq %rax, -0x348(%rbp)
leaq -0x340(%rbp), %rdi
leaq -0x348(%rbp), %rsi
callq 0x2c90
testb $0x1, %al
jne 0x261f
jmp 0x2730
leaq -0x340(%rbp), %rdi
callq 0x2cd0
movq %rax, -0x350(%rbp)
movq -0x350(%rbp), %rdi
callq 0x2360
testb $0x1, %al
jne 0x26a6
leaq 0x29db(%rip), %rsi      # 0x5024
leaq -0x320(%rbp), %rdi
callq 0x2100
movq %rax, -0x3d8(%rbp)
jmp 0x265e
movq -0x3d8(%rbp), %rdi
movq -0x350(%rbp), %rsi
callq 0x20f0
jmp 0x2673
jmp 0x271d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
jmp 0x2915
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
jmp 0x2909
leaq 0x2977(%rip), %rsi      # 0x5024
leaq -0x1a8(%rbp), %rdi
callq 0x2100
movq %rax, -0x3e0(%rbp)
jmp 0x26c2
movq -0x350(%rbp), %rsi
leaq -0x370(%rbp), %rdi
callq 0x2330
jmp 0x26d7
movq -0x3e0(%rbp), %rdi
leaq -0x370(%rbp), %rsi
callq 0x20f0
jmp 0x26ec
leaq -0x370(%rbp), %rdi
callq 0x20c0
jmp 0x271d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x20c0
jmp 0x2909
jmp 0x271f
leaq -0x340(%rbp), %rdi
callq 0x2cf0
jmp 0x2603
leaq -0x390(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x2130
jmp 0x2745
leaq -0x390(%rbp), %rdi
callq 0x21c0
movb %al, -0x3e1(%rbp)
leaq -0x390(%rbp), %rdi
callq 0x20c0
movb -0x3e1(%rbp), %al
testb $0x1, %al
jne 0x2772
jmp 0x281e
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x20f0
movq %rax, -0x3f0(%rbp)
jmp 0x2788
movq -0x3f0(%rbp), %rdi
leaq 0x288e(%rip), %rsi      # 0x5024
callq 0x2100
movq %rax, -0x3f8(%rbp)
jmp 0x27a4
leaq -0x3b0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x2130
jmp 0x27b9
movq -0x3f8(%rbp), %rdi
leaq -0x3b0(%rbp), %rsi
callq 0x20f0
movq %rax, -0x400(%rbp)
jmp 0x27d5
movq -0x400(%rbp), %rdi
movq 0x57d5(%rip), %rsi      # 0x7fb8
callq 0x2140
jmp 0x27ea
leaq -0x3b0(%rbp), %rdi
callq 0x20c0
jmp 0x28e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0x20c0
jmp 0x2909
movq 0x57cb(%rip), %rdi      # 0x7ff0
leaq 0x27d8(%rip), %rsi      # 0x5004
callq 0x2100
movq %rax, -0x408(%rbp)
jmp 0x283a
movq -0x408(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x20f0
movq %rax, -0x410(%rbp)
jmp 0x2853
movq -0x410(%rbp), %rdi
leaq 0x27b1(%rip), %rsi      # 0x5012
callq 0x2100
movq %rax, -0x418(%rbp)
jmp 0x286f
leaq -0x3d0(%rbp), %rdi
leaq -0x320(%rbp), %rsi
callq 0x2130
jmp 0x2884
movq -0x418(%rbp), %rdi
leaq -0x3d0(%rbp), %rsi
callq 0x20f0
movq %rax, -0x420(%rbp)
jmp 0x28a0
movq -0x420(%rbp), %rdi
movq 0x570a(%rip), %rsi      # 0x7fb8
callq 0x2140
jmp 0x28b5
leaq -0x3d0(%rbp), %rdi
callq 0x20c0
jmp 0x28e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x328(%rbp)
movl %eax, -0x32c(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x20c0
jmp 0x2909
leaq -0x320(%rbp), %rdi
callq 0x2040
leaq -0x1a8(%rbp), %rdi
callq 0x2040
leaq -0x20(%rbp), %rdi
callq 0x2d10
jmp 0x2591
leaq -0x320(%rbp), %rdi
callq 0x2040
leaq -0x1a8(%rbp), %rdi
callq 0x2040
jmp 0x2930
movq -0x8(%rbp), %rax
addq $0x420, %rsp            # imm = 0x420
popq %rbp
retq
movq -0x328(%rbp), %rdi
callq 0x21e0
nopl (%rax)